mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-08 06:59:26 +08:00
Merge branch 'next' into develop
This commit is contained in:
commit
32de5ffea6
@ -45,15 +45,10 @@ export function AddButton(props: AddButtonProps) {
|
|||||||
const instructionList = Array.from(engine.instructions.getValues()) as Instruction[];
|
const instructionList = Array.from(engine.instructions.getValues()) as Instruction[];
|
||||||
const { styles } = useStyles();
|
const { styles } = useStyles();
|
||||||
const { onCreate, creating } = useAddNodeContext();
|
const { onCreate, creating } = useAddNodeContext();
|
||||||
|
const groupOptions = engine.useInstructionGroupOptions();
|
||||||
|
|
||||||
const groups = useMemo(() => {
|
const groups = useMemo(() => {
|
||||||
const result = [
|
return groupOptions
|
||||||
{ key: 'control', label: `{{t("Control", { ns: "${NAMESPACE}" })}}` },
|
|
||||||
{ key: 'calculation', label: `{{t("Calculation", { ns: "${NAMESPACE}" })}}` },
|
|
||||||
{ key: 'collection', label: `{{t("Collection operations", { ns: "${NAMESPACE}" })}}` },
|
|
||||||
{ key: 'manual', label: `{{t("Manual", { ns: "${NAMESPACE}" })}}` },
|
|
||||||
{ key: 'extended', label: `{{t("Extended types", { ns: "${NAMESPACE}" })}}` },
|
|
||||||
]
|
|
||||||
.map((group) => {
|
.map((group) => {
|
||||||
const groupInstructions = instructionList.filter(
|
const groupInstructions = instructionList.filter(
|
||||||
(item) =>
|
(item) =>
|
||||||
@ -68,15 +63,13 @@ export function AddButton(props: AddButtonProps) {
|
|||||||
role: 'button',
|
role: 'button',
|
||||||
'aria-label': item.type,
|
'aria-label': item.type,
|
||||||
key: item.type,
|
key: item.type,
|
||||||
label: item.title,
|
label: compile(item.title),
|
||||||
icon: item.icon,
|
icon: item.icon,
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.filter((group) => group.children.length);
|
.filter((group) => group.children.length);
|
||||||
|
}, [branchIndex, compile, engine, groupOptions, instructionList, upstream, workflow]);
|
||||||
return compile(result);
|
|
||||||
}, [branchIndex, compile, engine, instructionList, upstream, workflow]);
|
|
||||||
|
|
||||||
const onClick = useCallback(
|
const onClick = useCallback(
|
||||||
async ({ keyPath }) => {
|
async ({ keyPath }) => {
|
||||||
|
@ -39,9 +39,15 @@ const workflowConfigSettings = {
|
|||||||
Component: BindWorkflowConfig,
|
Component: BindWorkflowConfig,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type InstructionGroup = {
|
||||||
|
key?: string;
|
||||||
|
label: string;
|
||||||
|
};
|
||||||
|
|
||||||
export default class PluginWorkflowClient extends Plugin {
|
export default class PluginWorkflowClient extends Plugin {
|
||||||
triggers = new Registry<Trigger>();
|
triggers = new Registry<Trigger>();
|
||||||
instructions = new Registry<Instruction>();
|
instructions = new Registry<Instruction>();
|
||||||
|
instructionGroups = new Registry<InstructionGroup>();
|
||||||
systemVariables = new Registry<VariableOption>();
|
systemVariables = new Registry<VariableOption>();
|
||||||
|
|
||||||
taskTypes = new Registry<TaskTypeOptions>();
|
taskTypes = new Registry<TaskTypeOptions>();
|
||||||
@ -58,6 +64,16 @@ export default class PluginWorkflowClient extends Plugin {
|
|||||||
.sort((a, b) => a.label.localeCompare(b.label));
|
.sort((a, b) => a.label.localeCompare(b.label));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useInstructionGroupOptions = () => {
|
||||||
|
const compile = useCompile();
|
||||||
|
return Array.from(this.instructionGroups.getEntities())
|
||||||
|
.map(([key, { label }]) => ({
|
||||||
|
key,
|
||||||
|
label: compile(label),
|
||||||
|
}))
|
||||||
|
.sort((a, b) => a.label.localeCompare(b.label));
|
||||||
|
};
|
||||||
|
|
||||||
isWorkflowSync(workflow) {
|
isWorkflowSync(workflow) {
|
||||||
return this.triggers.get(workflow.type)?.sync ?? workflow.sync;
|
return this.triggers.get(workflow.type)?.sync ?? workflow.sync;
|
||||||
}
|
}
|
||||||
@ -82,6 +98,10 @@ export default class PluginWorkflowClient extends Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerInstructionGroup(key: string, group: InstructionGroup) {
|
||||||
|
this.instructionGroups.register(key, group);
|
||||||
|
}
|
||||||
|
|
||||||
registerSystemVariable(option: VariableOption) {
|
registerSystemVariable(option: VariableOption) {
|
||||||
this.systemVariables.register(option.key, option);
|
this.systemVariables.register(option.key, option);
|
||||||
}
|
}
|
||||||
@ -128,6 +148,21 @@ export default class PluginWorkflowClient extends Plugin {
|
|||||||
this.app.schemaSettingsManager.addItem('actionSettings:delete', 'workflowConfig', workflowConfigSettings);
|
this.app.schemaSettingsManager.addItem('actionSettings:delete', 'workflowConfig', workflowConfigSettings);
|
||||||
this.app.schemaSettingsManager.addItem('actionSettings:bulkEditSubmit', 'workflowConfig', workflowConfigSettings);
|
this.app.schemaSettingsManager.addItem('actionSettings:bulkEditSubmit', 'workflowConfig', workflowConfigSettings);
|
||||||
|
|
||||||
|
this.registerInstructionGroup('control', { key: 'control', label: `{{t("Control", { ns: "${NAMESPACE}" })}}` });
|
||||||
|
this.registerInstructionGroup('calculation', {
|
||||||
|
key: 'calculation',
|
||||||
|
label: `{{t("Calculation", { ns: "${NAMESPACE}" })}}`,
|
||||||
|
});
|
||||||
|
this.registerInstructionGroup('collection', {
|
||||||
|
key: 'collection',
|
||||||
|
label: `{{t("Collection operations", { ns: "${NAMESPACE}" })}}`,
|
||||||
|
});
|
||||||
|
this.registerInstructionGroup('manual', { key: 'manual', label: `{{t("Manual", { ns: "${NAMESPACE}" })}}` });
|
||||||
|
this.registerInstructionGroup('extended', {
|
||||||
|
key: 'extended',
|
||||||
|
label: `{{t("Extended types", { ns: "${NAMESPACE}" })}}`,
|
||||||
|
});
|
||||||
|
|
||||||
this.registerTrigger('collection', CollectionTrigger);
|
this.registerTrigger('collection', CollectionTrigger);
|
||||||
this.registerTrigger('schedule', ScheduleTrigger);
|
this.registerTrigger('schedule', ScheduleTrigger);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user