From 1f1e7e34f5f67f8c33c3972bdb2d271a85de677b Mon Sep 17 00:00:00 2001 From: Junyi Date: Fri, 13 Oct 2023 16:38:53 +0800 Subject: [PATCH] feat(client): add disabled for initializer switch and undeletable for action settings (#2820) * feat(client): add disabled for initializer switch and undeletable for action settings * refactor(client): adjust api --- .../src/schema-component/antd/action/Action.Designer.tsx | 2 +- .../client/src/schema-initializer/SchemaInitializer.tsx | 3 ++- .../src/schema-initializer/items/InitializerWithSwitch.tsx | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx index eab4803ba5..3aa6f932db 100644 --- a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx +++ b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx @@ -927,7 +927,7 @@ export const ActionDesigner = (props) => { {restProps.children} {isChildCollectionAction && } - {} + {fieldSchema?.['x-action-settings']?.removable !== false && } ); diff --git a/packages/core/client/src/schema-initializer/SchemaInitializer.tsx b/packages/core/client/src/schema-initializer/SchemaInitializer.tsx index dfcbc546ce..e400e4a37f 100644 --- a/packages/core/client/src/schema-initializer/SchemaInitializer.tsx +++ b/packages/core/client/src/schema-initializer/SchemaInitializer.tsx @@ -609,7 +609,8 @@ SchemaInitializer.SwitchItem = (props) => { return (
- {props.title} + +
); diff --git a/packages/core/client/src/schema-initializer/items/InitializerWithSwitch.tsx b/packages/core/client/src/schema-initializer/items/InitializerWithSwitch.tsx index e5ea105451..17878f4040 100644 --- a/packages/core/client/src/schema-initializer/items/InitializerWithSwitch.tsx +++ b/packages/core/client/src/schema-initializer/items/InitializerWithSwitch.tsx @@ -5,7 +5,7 @@ import { SchemaInitializer } from '..'; import { useCurrentSchema } from '../utils'; export const InitializerWithSwitch = (props) => { - const { type, schema, item, insert, remove: passInRemove } = props; + const { type, schema, item, insert, remove: passInRemove, disabled } = props; const { exists, remove } = useCurrentSchema( schema?.[type] || item?.schema?.[type], type, @@ -16,8 +16,12 @@ export const InitializerWithSwitch = (props) => { return ( { + if (disabled) { + return; + } if (exists) { return remove(); }