Skip to content

Commit 9ed0bbd

Browse files
[Security Solution] Fix pop up message (#86973)
* fix wording * update wording * remove logic in translation Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent b66bf2b commit 9ed0bbd

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

x-pack/plugins/security_solution/public/common/components/drag_and_drop/drag_drop_context_wrapper.tsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { noop } from 'lodash/fp';
7+
import { noop, pick } from 'lodash/fp';
88
import React, { useCallback, useMemo } from 'react';
99
import { DropResult, DragDropContext } from 'react-beautiful-dnd';
1010
import { useDispatch } from 'react-redux';
@@ -18,10 +18,13 @@ import { timelineSelectors } from '../../../timelines/store/timeline';
1818
import { IdToDataProvider } from '../../store/drag_and_drop/model';
1919
import { DataProvider } from '../../../timelines/components/timeline/data_providers/data_provider';
2020
import { reArrangeProviders } from '../../../timelines/components/timeline/data_providers/helpers';
21-
import { ADDED_TO_TIMELINE_MESSAGE } from '../../hooks/translations';
21+
import {
22+
ADDED_TO_TIMELINE_MESSAGE,
23+
ADDED_TO_TIMELINE_TEMPLATE_MESSAGE,
24+
} from '../../hooks/translations';
2225
import { useAddToTimelineSensor } from '../../hooks/use_add_to_timeline';
2326
import { displaySuccessToast, useStateToaster } from '../toasters';
24-
import { TimelineId } from '../../../../common/types/timeline';
27+
import { TimelineId, TimelineType } from '../../../../common/types/timeline';
2528
import {
2629
addFieldToTimelineColumns,
2730
addProviderToTimeline,
@@ -98,17 +101,27 @@ export const DragDropContextWrapperComponent: React.FC<Props> = ({ browserFields
98101
const getTimeline = useMemo(() => timelineSelectors.getTimelineByIdSelector(), []);
99102
const getDataProviders = useMemo(() => dragAndDropSelectors.getDataProvidersSelector(), []);
100103

101-
const activeTimelineDataProviders = useDeepEqualSelector(
102-
(state) => (getTimeline(state, TimelineId.active) ?? timelineDefaults)?.dataProviders
104+
const {
105+
dataProviders: activeTimelineDataProviders,
106+
timelineType,
107+
} = useDeepEqualSelector((state) =>
108+
pick(
109+
['dataProviders', 'timelineType'],
110+
getTimeline(state, TimelineId.active) ?? timelineDefaults
111+
)
103112
);
104113
const dataProviders = useDeepEqualSelector(getDataProviders);
105114

106115
const [, dispatchToaster] = useStateToaster();
107116
const onAddedToTimeline = useCallback(
108117
(fieldOrValue: string) => {
109-
displaySuccessToast(ADDED_TO_TIMELINE_MESSAGE(fieldOrValue), dispatchToaster);
118+
const message =
119+
timelineType === TimelineType.template
120+
? ADDED_TO_TIMELINE_TEMPLATE_MESSAGE(fieldOrValue)
121+
: ADDED_TO_TIMELINE_MESSAGE(fieldOrValue);
122+
displaySuccessToast(message, dispatchToaster);
110123
},
111-
[dispatchToaster]
124+
[dispatchToaster, timelineType]
112125
);
113126

114127
const onDragEnd = useCallback(

x-pack/plugins/security_solution/public/common/hooks/translations.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ export const ADDED_TO_TIMELINE_MESSAGE = (fieldOrValue: string) =>
1212
defaultMessage: `Added {fieldOrValue} to timeline`,
1313
});
1414

15+
export const ADDED_TO_TIMELINE_TEMPLATE_MESSAGE = (fieldOrValue: string) =>
16+
i18n.translate('xpack.securitySolution.hooks.useAddToTimeline.template.addedFieldMessage', {
17+
values: { fieldOrValue },
18+
defaultMessage: `Added {fieldOrValue} to timeline template`,
19+
});
20+
1521
export const STATUS_CODE = i18n.translate(
1622
'xpack.securitySolution.components.ml.api.errors.statusCodeFailureTitle',
1723
{

0 commit comments

Comments
 (0)