@@ -22,8 +22,10 @@ interface FormObjectType extends Omit<Correlation, 'correlation_id' | 'version'>
2222}
2323
2424const SaveCorrelationModal = ( ) => {
25- const [ { isSaveCorrelationModalOpen, selectedFields, fields, correlationCondition } , setCorrelationData ] =
26- useCorrelationStore ( ( store ) => store ) ;
25+ const [
26+ { isSaveCorrelationModalOpen, selectedFields, fields, correlationCondition, activeCorrelation } ,
27+ setCorrelationData ,
28+ ] = useCorrelationStore ( ( store ) => store ) ;
2729
2830 const [ formObject , setFormObject ] = useState < FormObjectType | null > ( null ) ;
2931 const [ timeRange ] = useAppStore ( ( store ) => store . timeRange ) ;
@@ -38,23 +40,44 @@ const SaveCorrelationModal = () => {
3840 useEffect ( ( ) => {
3941 const timeRangeOptions = makeTimeRangeOptions ( { selected : null , current : timeRange } ) ;
4042 const selectedTimeRangeOption = getDefaultTimeRangeOption ( timeRangeOptions ) ;
41- setFormObject ( {
42- version : 'v1' ,
43- title : '' ,
44- isNew : true ,
45- isError : false ,
46- timeRangeOptions,
47- selectedTimeRangeOption,
48- tableConfigs : [ ] ,
49- joinConfig : {
50- joinConditions : [ ] ,
51- } ,
52- id : '' ,
53- filter : null ,
54- startTime : '' ,
55- endTime : '' ,
56- } ) ;
57- } , [ timeRange ] ) ;
43+
44+ if ( activeCorrelation !== null ) {
45+ //Modify this after BE changes
46+ setFormObject ( {
47+ version : 'v1' ,
48+ title : activeCorrelation . title ,
49+ isNew : false ,
50+ isError : false ,
51+ timeRangeOptions,
52+ selectedTimeRangeOption,
53+ tableConfigs : [ ] ,
54+ joinConfig : {
55+ joinConditions : [ ] ,
56+ } ,
57+ id : '' ,
58+ filter : null ,
59+ startTime : '' ,
60+ endTime : '' ,
61+ } ) ;
62+ } else {
63+ setFormObject ( {
64+ version : 'v1' ,
65+ title : '' ,
66+ isNew : true ,
67+ isError : false ,
68+ timeRangeOptions,
69+ selectedTimeRangeOption,
70+ tableConfigs : [ ] ,
71+ joinConfig : {
72+ joinConditions : [ ] ,
73+ } ,
74+ id : '' ,
75+ filter : null ,
76+ startTime : '' ,
77+ endTime : '' ,
78+ } ) ;
79+ }
80+ } , [ timeRange , activeCorrelation ] ) ;
5881
5982 const closeModal = useCallback ( ( ) => {
6083 setCorrelationData ( ( store ) => toggleSaveCorrelationModal ( store , false ) ) ;
0 commit comments