Skip to content

Commit

Permalink
[Security Solution] Fix pop up message (#86973)
Browse files Browse the repository at this point in the history
* fix wording

* update wording

* remove logic in translation

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
angorayc and kibanamachine authored Jan 4, 2021
1 parent b66bf2b commit 9ed0bbd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { noop } from 'lodash/fp';
import { noop, pick } from 'lodash/fp';
import React, { useCallback, useMemo } from 'react';
import { DropResult, DragDropContext } from 'react-beautiful-dnd';
import { useDispatch } from 'react-redux';
Expand All @@ -18,10 +18,13 @@ import { timelineSelectors } from '../../../timelines/store/timeline';
import { IdToDataProvider } from '../../store/drag_and_drop/model';
import { DataProvider } from '../../../timelines/components/timeline/data_providers/data_provider';
import { reArrangeProviders } from '../../../timelines/components/timeline/data_providers/helpers';
import { ADDED_TO_TIMELINE_MESSAGE } from '../../hooks/translations';
import {
ADDED_TO_TIMELINE_MESSAGE,
ADDED_TO_TIMELINE_TEMPLATE_MESSAGE,
} from '../../hooks/translations';
import { useAddToTimelineSensor } from '../../hooks/use_add_to_timeline';
import { displaySuccessToast, useStateToaster } from '../toasters';
import { TimelineId } from '../../../../common/types/timeline';
import { TimelineId, TimelineType } from '../../../../common/types/timeline';
import {
addFieldToTimelineColumns,
addProviderToTimeline,
Expand Down Expand Up @@ -98,17 +101,27 @@ export const DragDropContextWrapperComponent: React.FC<Props> = ({ browserFields
const getTimeline = useMemo(() => timelineSelectors.getTimelineByIdSelector(), []);
const getDataProviders = useMemo(() => dragAndDropSelectors.getDataProvidersSelector(), []);

const activeTimelineDataProviders = useDeepEqualSelector(
(state) => (getTimeline(state, TimelineId.active) ?? timelineDefaults)?.dataProviders
const {
dataProviders: activeTimelineDataProviders,
timelineType,
} = useDeepEqualSelector((state) =>
pick(
['dataProviders', 'timelineType'],
getTimeline(state, TimelineId.active) ?? timelineDefaults
)
);
const dataProviders = useDeepEqualSelector(getDataProviders);

const [, dispatchToaster] = useStateToaster();
const onAddedToTimeline = useCallback(
(fieldOrValue: string) => {
displaySuccessToast(ADDED_TO_TIMELINE_MESSAGE(fieldOrValue), dispatchToaster);
const message =
timelineType === TimelineType.template
? ADDED_TO_TIMELINE_TEMPLATE_MESSAGE(fieldOrValue)
: ADDED_TO_TIMELINE_MESSAGE(fieldOrValue);
displaySuccessToast(message, dispatchToaster);
},
[dispatchToaster]
[dispatchToaster, timelineType]
);

const onDragEnd = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ export const ADDED_TO_TIMELINE_MESSAGE = (fieldOrValue: string) =>
defaultMessage: `Added {fieldOrValue} to timeline`,
});

export const ADDED_TO_TIMELINE_TEMPLATE_MESSAGE = (fieldOrValue: string) =>
i18n.translate('xpack.securitySolution.hooks.useAddToTimeline.template.addedFieldMessage', {
values: { fieldOrValue },
defaultMessage: `Added {fieldOrValue} to timeline template`,
});

export const STATUS_CODE = i18n.translate(
'xpack.securitySolution.components.ml.api.errors.statusCodeFailureTitle',
{
Expand Down

0 comments on commit 9ed0bbd

Please sign in to comment.