fix: save as template not shown (#6398)

* fix: save as template not shown

* fix: block template settings and route handling

* fix: incorrect l18n
This commit is contained in:
gchust 2025-03-10 21:40:51 +08:00 committed by GitHub
parent f70ff6da80
commit b73f170edd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 20 deletions

View File

@ -29,12 +29,13 @@ export class PMPlugin extends Plugin {
} }
addSettings() { addSettings() {
this.app.pluginSettingsManager.add('ui-schema-storage', { // hide old block template settings page
title: '{{t("Block templates")}}', // this.app.pluginSettingsManager.add('ui-schema-storage', {
icon: 'LayoutOutlined', // title: '{{t("Block templates")}}',
Component: BlockTemplatesPane, // icon: 'LayoutOutlined',
aclSnippet: 'pm.ui-schema-storage.block-templates', // Component: BlockTemplatesPane,
}); // aclSnippet: 'pm.ui-schema-storage.block-templates',
// });
this.app.pluginSettingsManager.add('system-settings', { this.app.pluginSettingsManager.add('system-settings', {
icon: 'SettingOutlined', icon: 'SettingOutlined',
title: '{{t("System settings")}}', title: '{{t("System settings")}}',

View File

@ -18,7 +18,7 @@ export const DeprecatedTemplateTitle = () => {
<Space> <Space>
{t('Deprecated')} {t('Deprecated')}
<Tooltip <Tooltip
title={t('The following old template features have been deprecated and will be removed in next versions.')} title={t('The following old template features have been deprecated and will be removed in next version.')}
> >
<QuestionCircleOutlined /> <QuestionCircleOutlined />
</Tooltip> </Tooltip>

View File

@ -8,27 +8,23 @@
*/ */
import { useMemo } from 'react'; import { useMemo } from 'react';
import { useLocation } from 'react-router-dom';
import { useFieldSchema } from '@formily/react'; import { useFieldSchema } from '@formily/react';
export const useIsPageBlock = () => { export const useIsPageBlock = () => {
const location = useLocation();
const fieldSchema = useFieldSchema(); const fieldSchema = useFieldSchema();
const isPageBlock = useMemo(() => { const isPageBlock = useMemo(() => {
if (!fieldSchema || fieldSchema['x-template-uid']) { if (!fieldSchema || fieldSchema['x-template-uid']) {
return false; return false;
} }
const isPage = location.pathname.includes('/admin/') || location.pathname.includes('/m/');
let schema = fieldSchema.parent; const notInPopup = !location.pathname.includes('/popups/');
while (schema) { const notInSetting = !location.pathname.includes('/admin/settings/');
if (['Page', 'MobilePage'].includes(schema['x-component'])) { const notInBlockTemplate = !location.pathname.includes('/m/block-templates/');
return true; return isPage && notInPopup && notInSetting && notInBlockTemplate;
} }, [location.pathname, fieldSchema]);
if (!['Grid', 'Grid.Row', 'Grid.Col'].includes(schema['x-component'])) {
return false;
}
schema = schema.parent;
}
return false;
}, [fieldSchema]);
return isPageBlock; return isPageBlock;
}; };