From ebc1d1afb4061ac33825af336a8acc24f5d2666f Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Tue, 19 Sep 2023 20:51:43 +0800 Subject: [PATCH] refactor: acl collection field provider (#2679) --- packages/core/client/src/acl/ACLProvider.tsx | 3 +-- .../core/client/src/acl/Configuration/RoleConfigure.tsx | 4 ++-- .../plugin-import/src/client/ImportActionInitializer.tsx | 9 ++------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/core/client/src/acl/ACLProvider.tsx b/packages/core/client/src/acl/ACLProvider.tsx index 9995c3cd6..6c1410299 100644 --- a/packages/core/client/src/acl/ACLProvider.tsx +++ b/packages/core/client/src/acl/ACLProvider.tsx @@ -261,8 +261,7 @@ export const ACLCollectionFieldProvider = (props) => { const { allowAll } = useACLRoleContext(); const { whitelist } = useACLFieldWhitelist(); const [name] = (fieldSchema.name as string).split('.'); - const allowed = whitelist.length > 0 ? whitelist.includes(name) : true; - + const allowed = !fieldSchema['x-acl-ignore'] && whitelist.length > 0 ? whitelist.includes(name) : true; useEffect(() => { if (!allowed) { field.required = false; diff --git a/packages/core/client/src/acl/Configuration/RoleConfigure.tsx b/packages/core/client/src/acl/Configuration/RoleConfigure.tsx index 923caba2c..011831243 100644 --- a/packages/core/client/src/acl/Configuration/RoleConfigure.tsx +++ b/packages/core/client/src/acl/Configuration/RoleConfigure.tsx @@ -5,7 +5,7 @@ import uniq from 'lodash/uniq'; import React, { useContext } from 'react'; import { useTranslation } from 'react-i18next'; import { useAPIClient, useRequest } from '../../api-client'; -import { SchemaComponent, FormItem } from '../../schema-component'; +import { SchemaComponent } from '../../schema-component'; import { PermissionContext } from './PermisionProvider'; const SnippetCheckboxGroup = connect((props) => { @@ -57,7 +57,7 @@ export const RoleConfigure = () => { const { t } = useTranslation(); return ( { const { exists, remove } = useCurrentSchema('importXlsx', 'x-action', item.find, item.remove); const { name } = useCollection(); const fields = useFields(name); - const { token } = useToken(); - const schema: ISchema = { type: 'void', title: '{{ t("Import") }}', @@ -77,16 +75,12 @@ export const ImportActionInitializer = (props) => { formLayout: { type: 'void', 'x-component': 'FormLayout', - 'x-component-props': { - labelCol: 6, - wrapperCol: 10, - layout: 'vertical', - }, properties: { download: { type: 'void', title: `{{ t("Step 1: Download template", {ns: "${NAMESPACE}" }) }}`, 'x-component': 'FormItem', + 'x-acl-ignore': true, properties: { tip: { type: 'void', @@ -120,6 +114,7 @@ export const ImportActionInitializer = (props) => { type: 'array', title: `{{ t("Step 2: Upload Excel", {ns: "${NAMESPACE}" }) }}`, 'x-decorator': 'FormItem', + 'x-acl-ignore': true, 'x-component': 'Upload.Dragger', 'x-validator': '{{ uploadValidator }}', 'x-component-props': {