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} {restProps.children}
{isChildCollectionAction && <SchemaSettings.EnableChildCollections collectionName={name} />} {isChildCollectionAction && <SchemaSettings.EnableChildCollections collectionName={name} />}
{<RemoveButton {...removeButtonProps} />} {fieldSchema?.['x-action-settings']?.removable !== false && <RemoveButton {...removeButtonProps} />}
</MenuGroup> </MenuGroup>
</GeneralSchemaDesigner> </GeneralSchemaDesigner>
); );

View File

@ -609,7 +609,8 @@ SchemaInitializer.SwitchItem = (props) => {
return ( return (
<SchemaInitializer.Item onClick={props.onClick}> <SchemaInitializer.Item onClick={props.onClick}>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}> <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> </div>
</SchemaInitializer.Item> </SchemaInitializer.Item>
); );

View File

@ -5,7 +5,7 @@ import { SchemaInitializer } from '..';
import { useCurrentSchema } from '../utils'; import { useCurrentSchema } from '../utils';
export const InitializerWithSwitch = (props) => { 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( const { exists, remove } = useCurrentSchema(
schema?.[type] || item?.schema?.[type], schema?.[type] || item?.schema?.[type],
type, type,
@ -16,8 +16,12 @@ export const InitializerWithSwitch = (props) => {
return ( return (
<SchemaInitializer.SwitchItem <SchemaInitializer.SwitchItem
checked={exists} checked={exists}
disabled={disabled}
title={item.title} title={item.title}
onClick={() => { onClick={() => {
if (disabled) {
return;
}
if (exists) { if (exists) {
return remove(); return remove();
} }