diff --git a/packages/core/client/src/schema-component/antd/input/ReadPretty.tsx b/packages/core/client/src/schema-component/antd/input/ReadPretty.tsx
index 25c0fb7ed..1a28b261d 100644
--- a/packages/core/client/src/schema-component/antd/input/ReadPretty.tsx
+++ b/packages/core/client/src/schema-component/antd/input/ReadPretty.tsx
@@ -123,6 +123,8 @@ ReadPretty.JSON = (props) => {
diff --git a/packages/plugins/workflow/src/client/AddButton.tsx b/packages/plugins/workflow/src/client/AddButton.tsx
index a15ce3531..6fa75ce58 100644
--- a/packages/plugins/workflow/src/client/AddButton.tsx
+++ b/packages/plugins/workflow/src/client/AddButton.tsx
@@ -20,7 +20,7 @@ interface AddButtonProps {
export function AddButton({ upstream, branchIndex = null }: AddButtonProps) {
const compile = useCompile();
const api = useAPIClient();
- const { workflow, onNodeAdded } = useFlowContext() ?? {};
+ const { workflow, refresh } = useFlowContext() ?? {};
if (!workflow) {
return null;
}
@@ -30,8 +30,9 @@ export function AddButton({ upstream, branchIndex = null }: AddButtonProps) {
const type = keyPath.pop();
const config = {};
const [optionKey] = keyPath;
+ const instruction = instructions.get(type);
if (optionKey) {
- const { value } = instructions.get(type)?.options?.find(item => item.key === optionKey) ?? {};
+ const { value } = instruction.options?.find(item => item.key === optionKey) ?? {};
Object.assign(config, value);
}
@@ -40,47 +41,46 @@ export function AddButton({ upstream, branchIndex = null }: AddButtonProps) {
type,
upstreamId: upstream?.id ?? null,
branchIndex,
+ title: compile(instruction.title),
config
}
});
- onNodeAdded(node);
+ refresh();
}
- const groups = [
- { value: 'control', name: `{{t("Control", { ns: "${NAMESPACE}" })}}` },
- { value: 'collection', name: `{{t("Collection operations", { ns: "${NAMESPACE}" })}}` },
- { value: 'manual', name: `{{t("Manual", { ns: "${NAMESPACE}" })}}` },
- { value: 'extended', name: `{{t("Extended types", { ns: "${NAMESPACE}" })}}` },
- ];
const instructionList = (Array.from(instructions.getValues()) as Instruction[]);
+ const groups = [
+ { key: 'control', label: `{{t("Control", { 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}" })}}` },
+ ]
+ .filter(group => instructionList.filter(item => item.group === group.key).length)
+ .map(group => {
+ const groupInstructions = instructionList.filter(item => item.group === group.key);
+
+ return {
+ ...group,
+ type: 'group',
+ children: groupInstructions.map(item => ({
+ key: item.type,
+ label: item.title,
+ type: item.options ? 'subMenu' : null,
+ children: item.options ? item.options.map(option => ({
+ key: option.key,
+ label: option.label,
+ })) : null
+ }))
+ };
+ });
+
return (
onCreate(ev)}>
- {groups.map(group => {
- const groupInstructions = instructionList.filter(item => item.group === group.value);
- return groupInstructions.length ? (
-
- {groupInstructions.map(item => item.options
- ? (
-
- {item.options.map(option => (
- {compile(option.label)}
- ))}
-
- )
- : (
- {compile(item.title)}
- ))}
-
- ) : null;
- })}
-
- }
+ overlay={