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' ;
88import React , { useCallback , useMemo } from 'react' ;
99import { DropResult , DragDropContext } from 'react-beautiful-dnd' ;
1010import { useDispatch } from 'react-redux' ;
@@ -18,10 +18,13 @@ import { timelineSelectors } from '../../../timelines/store/timeline';
1818import { IdToDataProvider } from '../../store/drag_and_drop/model' ;
1919import { DataProvider } from '../../../timelines/components/timeline/data_providers/data_provider' ;
2020import { 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' ;
2225import { useAddToTimelineSensor } from '../../hooks/use_add_to_timeline' ;
2326import { displaySuccessToast , useStateToaster } from '../toasters' ;
24- import { TimelineId } from '../../../../common/types/timeline' ;
27+ import { TimelineId , TimelineType } from '../../../../common/types/timeline' ;
2528import {
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 (
0 commit comments