Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/components/menus/definitions/InspectorDefinitionMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -195,7 +194,6 @@ const InspectorDefinitionMenu = (props: InspectorDefinitionProps) => {
}
},
});
generateConfig();
}}
>
{(formikProps) => (
Expand Down
24 changes: 24 additions & 0 deletions src/state/DefinitionStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Action,
action,
ActionCreator,
Actions,
TargetResolver,
ThunkOn,
thunkOn,
Expand Down Expand Up @@ -473,6 +474,29 @@ export const createObservableThunks = <
};
};

export const generateLifeCycleMatrix = (actions: Actions<StoreActions>) => {
const lifeCycles = ['define', 'update', 'cleanup'];
const types: DefinitionType[] = [
'parameters',
'commands',
'jobs',
'executors',
'workflows',
];

const matrix: ActionCreator<any>[] = [];

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
Expand Down
38 changes: 23 additions & 15 deletions src/state/Store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
DefinitionStore,
DefinitionSubscriptions,
DefinitionType,
generateLifeCycleMatrix,
NamedGenerable,
} from './DefinitionStore';

Expand Down Expand Up @@ -167,11 +168,11 @@ export type StoreActions = AllDefinitionActions & {
updateConnecting: Action<
StoreModel,
| {
ref?: MutableRefObject<any>;
id: SetConnectionId;
pos?: XYPosition;
name?: string;
}
ref?: MutableRefObject<any>;
id: SetConnectionId;
pos?: XYPosition;
name?: string;
}
| undefined
>;

Expand Down Expand Up @@ -200,7 +201,7 @@ export type StoreActions = AllDefinitionActions & {
triggerToast: Action<StoreModel, ToastModel | undefined | void>;
triggerConfirmation: Action<StoreModel, ConfirmationModalModel | undefined>;
triggerConfigRefresh: ThunkOn<StoreActions, void>;

updateTooltip: Action<StoreModel, InfoToolTip | undefined>;
};

Expand Down Expand Up @@ -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,
},
},
},
};
}),

Expand Down Expand Up @@ -694,8 +695,8 @@ const Actions: StoreActions = {
const parameterList =
pipelineParameters.length > 0
? new parameters.CustomParametersList<PipelineParameterLiteral>(
pipelineParameters,
)
pipelineParameters,
)
: undefined;

const config = new Config(
Expand Down Expand Up @@ -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();
},
Expand Down