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
This commit is contained in:
Junyi 2023-10-13 16:38:53 +08:00 committed by GitHub
parent 9044434930
commit 1f1e7e34f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View File

@ -927,7 +927,7 @@ export const ActionDesigner = (props) => {
{restProps.children}
{isChildCollectionAction && <SchemaSettings.EnableChildCollections collectionName={name} />}
{<RemoveButton {...removeButtonProps} />}
{fieldSchema?.['x-action-settings']?.removable !== false && <RemoveButton {...removeButtonProps} />}
</MenuGroup>
</GeneralSchemaDesigner>
);

View File

@ -609,7 +609,8 @@ SchemaInitializer.SwitchItem = (props) => {
return (
<SchemaInitializer.Item onClick={props.onClick}>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
{props.title} <Switch style={{ marginLeft: 20 }} size={'small'} checked={props.checked} />
<label>{props.title}</label>
<Switch disabled={props.disabled} style={{ marginLeft: 20 }} size={'small'} checked={props.checked} />
</div>
</SchemaInitializer.Item>
);

View File

@ -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 (
<SchemaInitializer.SwitchItem
checked={exists}
disabled={disabled}
title={item.title}
onClick={() => {
if (disabled) {
return;
}
if (exists) {
return remove();
}