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,
SchemaSettingsRemove,
SchemaSettingsSubMenu,
SchemaSettingsSwitchItem,
useAPIClient,
useDesignable,
useURLAndHTMLSchema,
@ -373,6 +374,20 @@ export const MenuDesigner = () => {
initialValues={initialValues}
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
title={t('Move to')}
eventKey="move-to"

View File

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