From 4d1f28bf57a7b250566905689c85eeb0b475f8c7 Mon Sep 17 00:00:00 2001 From: Katherine Date: Mon, 10 Mar 2025 18:34:19 +0800 Subject: [PATCH] feat: compatible with historical button access control settings (#6376) * feat: compatible with historical button access control settings * fix: bug --- .../SchemaSettingAccessControl.tsx | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/core/client/src/schema-settings/SchemaSettingAccessControl.tsx b/packages/core/client/src/schema-settings/SchemaSettingAccessControl.tsx index e646d1ba74..da0822f644 100644 --- a/packages/core/client/src/schema-settings/SchemaSettingAccessControl.tsx +++ b/packages/core/client/src/schema-settings/SchemaSettingAccessControl.tsx @@ -8,11 +8,12 @@ */ import { useFieldSchema } from '@formily/react'; -import React from 'react'; +import React, { useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { App } from 'antd'; import { SchemaSettingsActionModalItem } from './SchemaSettings'; import { useAPIClient } from '../api-client/hooks/useAPIClient'; +import { useDesignable } from '../schema-component/hooks/useDesignable'; import { useRequest } from '../api-client'; import { useACLContext } from '../acl'; @@ -22,6 +23,7 @@ export function AccessControl() { const apiClient = useAPIClient(); const resource = apiClient.resource('uiSchemas.roles', fieldSchema['x-uid']); const { message } = App.useApp(); + const { dn } = useDesignable(); const { refresh, data }: any = useRequest( { url: `/uiSchemas/${fieldSchema['x-uid']}/roles:list`, @@ -31,6 +33,23 @@ export function AccessControl() { }, ); const { refresh: refreshRoleCheck } = useACLContext(); + + useEffect(() => { + if ( + fieldSchema['x-decorator'] !== 'ACLActionProvider' && + fieldSchema['x-decorator'] !== `CustomRequestAction.Decorator` && + fieldSchema['x-component'] !== 'WorkbenchAction' + ) { + dn.emit('patch', { + schema: { + ['x-uid']: fieldSchema['x-uid'], + 'x-decorator': 'ACLActionProvider', + }, + }); + dn.refresh(); + } + }, []); + const AccessControl = (