diff --git a/src/components/menus/definitions/InspectorDefinitionMenu.tsx b/src/components/menus/definitions/InspectorDefinitionMenu.tsx index e46135e..fc6a85e 100644 --- a/src/components/menus/definitions/InspectorDefinitionMenu.tsx +++ b/src/components/menus/definitions/InspectorDefinitionMenu.tsx @@ -64,7 +64,6 @@ const getDependencies = ( */ const InspectorDefinitionMenu = (props: InspectorDefinitionProps) => { const definitions = useStoreState((state) => state.definitions); - const generateConfig = useStoreActions((actions) => actions.generateConfig); const navigateBack = useStoreActions((actions) => actions.navigateBack); const setGuideStep = useStoreActions((actions) => actions.setGuideStep); const guideStep = useStoreState((state) => state.guideStep); @@ -195,7 +194,6 @@ const InspectorDefinitionMenu = (props: InspectorDefinitionProps) => { } }, }); - generateConfig(); }} > {(formikProps) => ( diff --git a/src/state/DefinitionStore.tsx b/src/state/DefinitionStore.tsx index 76c7379..8cc7826 100644 --- a/src/state/DefinitionStore.tsx +++ b/src/state/DefinitionStore.tsx @@ -5,6 +5,7 @@ import { Action, action, ActionCreator, + Actions, TargetResolver, ThunkOn, thunkOn, @@ -473,6 +474,29 @@ export const createObservableThunks = < }; }; +export const generateLifeCycleMatrix = (actions: Actions) => { + const lifeCycles = ['define', 'update', 'cleanup']; + const types: DefinitionType[] = [ + 'parameters', + 'commands', + 'jobs', + 'executors', + 'workflows', + ]; + + const matrix: ActionCreator[] = []; + + lifeCycles.forEach((lifecycle) => { + matrix.push( + ...types.map( + (type) => actions[`${lifecycle}_${type}` as keyof AllDefinitionActions], + ), + ); + }); + + return matrix; +}; + export const createDefinitionStore = (): AllDefinitionActions => { return { // actions - lifecycle for each definition diff --git a/src/state/Store.tsx b/src/state/Store.tsx index 74fec7b..4a9108c 100644 --- a/src/state/Store.tsx +++ b/src/state/Store.tsx @@ -36,6 +36,7 @@ import { DefinitionStore, DefinitionSubscriptions, DefinitionType, + generateLifeCycleMatrix, NamedGenerable, } from './DefinitionStore'; @@ -167,11 +168,11 @@ export type StoreActions = AllDefinitionActions & { updateConnecting: Action< StoreModel, | { - ref?: MutableRefObject; - id: SetConnectionId; - pos?: XYPosition; - name?: string; - } + ref?: MutableRefObject; + id: SetConnectionId; + pos?: XYPosition; + name?: string; + } | undefined >; @@ -200,7 +201,7 @@ export type StoreActions = AllDefinitionActions & { triggerToast: Action; triggerConfirmation: Action; triggerConfigRefresh: ThunkOn; - + updateTooltip: Action; }; @@ -257,12 +258,12 @@ const Actions: StoreActions = { payload.origin && root ? root : { - ...curNav, - props: { - ...curNav.props, - values: payload.values, + ...curNav, + props: { + ...curNav.props, + values: payload.values, + }, }, - }, }; }), @@ -694,8 +695,8 @@ const Actions: StoreActions = { const parameterList = pipelineParameters.length > 0 ? new parameters.CustomParametersList( - pipelineParameters, - ) + pipelineParameters, + ) : undefined; const config = new Config( @@ -723,12 +724,19 @@ const Actions: StoreActions = { state.toast = payload ?? undefined; }), // this is just to trigger the set toast action - triggerToast: action((_, __) => { }), + triggerToast: action((_, __) => {}), triggerConfirmation: action((state, payload) => { state.confirm = payload; }), triggerConfigRefresh: thunkOn( - (actions) => actions.importOrb, + (actions) => [ + actions.importOrb, + ...generateLifeCycleMatrix(actions), + actions.addWorkflowElement, + actions.setWorkflowElements, + actions.removeWorkflowElement, + actions.updateWorkflowElement, + ], (actions) => { actions.generateConfig(); },