Merge branch 'main' into next

This commit is contained in:
nocobase[bot] 2024-11-11 02:10:07 +00:00
commit 0db386c704
2 changed files with 25 additions and 4 deletions

View File

@ -20,6 +20,7 @@ import {
SchemaSettingsModalItem, SchemaSettingsModalItem,
SchemaSettingsRemove, SchemaSettingsRemove,
SchemaSettingsSubMenu, SchemaSettingsSubMenu,
SchemaSettingsSwitchItem,
useAPIClient, useAPIClient,
useDesignable, useDesignable,
useURLAndHTMLSchema, useURLAndHTMLSchema,
@ -373,6 +374,20 @@ export const MenuDesigner = () => {
initialValues={initialValues} initialValues={initialValues}
onSubmit={onEditSubmit} onSubmit={onEditSubmit}
/> />
<SchemaSettingsSwitchItem
title={t('Hidden')}
checked={fieldSchema['x-component-props']?.hidden}
onChange={(v) => {
fieldSchema['x-component-props'].hidden = !!v;
field.componentProps.hidden = !!v;
dn.emit('patch', {
schema: {
'x-uid': fieldSchema['x-uid'],
'x-component-props': fieldSchema['x-component-props'],
},
});
}}
/>
<SchemaSettingsModalItem <SchemaSettingsModalItem
title={t('Move to')} title={t('Move to')}
eventKey="move-to" eventKey="move-to"

View File

@ -528,14 +528,16 @@ const menuItemTitleStyle = {
Menu.Item = observer( Menu.Item = observer(
(props) => { (props) => {
const { t } = useMenuTranslation(); const { t } = useMenuTranslation();
const { designable } = useDesignable();
const { pushMenuItem } = useCollectMenuItems(); const { pushMenuItem } = useCollectMenuItems();
const { icon, children, ...others } = props; const { icon, children, hidden, ...others } = props;
const schema = useFieldSchema(); const schema = useFieldSchema();
const field = useField(); const field = useField();
const Designer = useContext(MenuItemDesignerContext); const Designer = useContext(MenuItemDesignerContext);
const item = useMemo(() => { const item = useMemo(() => {
return { return {
...others, ...others,
hidden: designable ? false : hidden,
className: menuItemClass, className: menuItemClass,
key: schema.name, key: schema.name,
eventKey: schema.name, eventKey: schema.name,
@ -620,7 +622,8 @@ const MenuURLButton = ({ href, params, icon }) => {
Menu.URL = observer( Menu.URL = observer(
(props) => { (props) => {
const { pushMenuItem } = useCollectMenuItems(); const { pushMenuItem } = useCollectMenuItems();
const { icon, children, ...others } = props; const { designable } = useDesignable();
const { icon, children, hidden, ...others } = props;
const schema = useFieldSchema(); const schema = useFieldSchema();
const field = useField(); const field = useField();
const Designer = useContext(MenuItemDesignerContext); const Designer = useContext(MenuItemDesignerContext);
@ -633,6 +636,7 @@ Menu.URL = observer(
const item = useMemo(() => { const item = useMemo(() => {
return { return {
...others, ...others,
hidden: designable ? false : hidden,
className: menuItemClass, className: menuItemClass,
key: schema.name, key: schema.name,
eventKey: schema.name, eventKey: schema.name,
@ -646,7 +650,7 @@ Menu.URL = observer(
</SchemaContext.Provider> </SchemaContext.Provider>
), ),
}; };
}, [field.title, icon, props.href, schema, JSON.stringify(props.params)]); }, [field.title, designable, hidden, icon, props.href, schema, JSON.stringify(props.params)]);
pushMenuItem(item); pushMenuItem(item);
return null; return null;
@ -657,9 +661,10 @@ Menu.URL = observer(
Menu.SubMenu = observer( Menu.SubMenu = observer(
(props) => { (props) => {
const { t } = useMenuTranslation(); const { t } = useMenuTranslation();
const { designable } = useDesignable();
const { Component, getMenuItems } = useMenuItem(); const { Component, getMenuItems } = useMenuItem();
const { pushMenuItem } = useCollectMenuItems(); const { pushMenuItem } = useCollectMenuItems();
const { icon, children, ...others } = props; const { icon, children, hidden, ...others } = props;
const schema = useFieldSchema(); const schema = useFieldSchema();
const field = useField(); const field = useField();
const mode = useContext(MenuModeContext); const mode = useContext(MenuModeContext);
@ -667,6 +672,7 @@ Menu.SubMenu = observer(
const submenu = useMemo(() => { const submenu = useMemo(() => {
return { return {
...others, ...others,
hidden: designable ? false : hidden,
className: menuItemClass, className: menuItemClass,
key: schema.name, key: schema.name,
eventKey: schema.name, eventKey: schema.name,