mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-07 14:39:25 +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 { styles } = useStyles();
|
||||
const { onCreate, creating } = useAddNodeContext();
|
||||
const groupOptions = engine.useInstructionGroupOptions();
|
||||
|
||||
const groups = useMemo(() => {
|
||||
const result = [
|
||||
{ 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}" })}}` },
|
||||
]
|
||||
return groupOptions
|
||||
.map((group) => {
|
||||
const groupInstructions = instructionList.filter(
|
||||
(item) =>
|
||||
@ -68,15 +63,13 @@ export function AddButton(props: AddButtonProps) {
|
||||
role: 'button',
|
||||
'aria-label': item.type,
|
||||
key: item.type,
|
||||
label: item.title,
|
||||
label: compile(item.title),
|
||||
icon: item.icon,
|
||||
})),
|
||||
};
|
||||
})
|
||||
.filter((group) => group.children.length);
|
||||
|
||||
return compile(result);
|
||||
}, [branchIndex, compile, engine, instructionList, upstream, workflow]);
|
||||
}, [branchIndex, compile, engine, groupOptions, instructionList, upstream, workflow]);
|
||||
|
||||
const onClick = useCallback(
|
||||
async ({ keyPath }) => {
|
||||
|
@ -39,9 +39,15 @@ const workflowConfigSettings = {
|
||||
Component: BindWorkflowConfig,
|
||||
};
|
||||
|
||||
type InstructionGroup = {
|
||||
key?: string;
|
||||
label: string;
|
||||
};
|
||||
|
||||
export default class PluginWorkflowClient extends Plugin {
|
||||
triggers = new Registry<Trigger>();
|
||||
instructions = new Registry<Instruction>();
|
||||
instructionGroups = new Registry<InstructionGroup>();
|
||||
systemVariables = new Registry<VariableOption>();
|
||||
|
||||
taskTypes = new Registry<TaskTypeOptions>();
|
||||
@ -58,6 +64,16 @@ export default class PluginWorkflowClient extends Plugin {
|
||||
.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) {
|
||||
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) {
|
||||
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: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('schedule', ScheduleTrigger);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user