From bc5ecc9b5f8562cd54e503101a3ecf595f877fa0 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Tue, 19 Sep 2023 17:26:29 +0800 Subject: [PATCH] fix(acl): association field acl check error (#2675) * fix: association field acl check * fix: association field acl check * fix: import action form field acl check error --- packages/core/client/src/acl/ACLProvider.tsx | 7 +- .../antd/association-field/InternalNester.tsx | 70 ++++++++++--------- .../src/client/ImportActionInitializer.tsx | 5 ++ .../src/client/ImportPluginProvider.tsx | 3 +- 4 files changed, 49 insertions(+), 36 deletions(-) diff --git a/packages/core/client/src/acl/ACLProvider.tsx b/packages/core/client/src/acl/ACLProvider.tsx index d505247a2..9995c3cd6 100644 --- a/packages/core/client/src/acl/ACLProvider.tsx +++ b/packages/core/client/src/acl/ACLProvider.tsx @@ -182,7 +182,7 @@ export const ACLCollectionProvider = (props) => { if (allowAll) { return props.children; } - const actionPath = schema?.['x-acl-action']; + const actionPath = schema?.['x-acl-action'] || props.actionPath; if (!actionPath) { return props.children; } @@ -190,6 +190,8 @@ export const ACLCollectionProvider = (props) => { if (!params) { return null; } + const [_, actionName] = actionPath.split(':'); + params.actionName = actionName; return {props.children}; }; @@ -258,7 +260,8 @@ export const ACLCollectionFieldProvider = (props) => { const field = useField(); const { allowAll } = useACLRoleContext(); const { whitelist } = useACLFieldWhitelist(); - const allowed = whitelist.length > 0 ? whitelist.includes(fieldSchema.name) : true; + const [name] = (fieldSchema.name as string).split('.'); + const allowed = whitelist.length > 0 ? whitelist.includes(name) : true; useEffect(() => { if (!allowed) { diff --git a/packages/core/client/src/schema-component/antd/association-field/InternalNester.tsx b/packages/core/client/src/schema-component/antd/association-field/InternalNester.tsx index bec008eb9..fabfead54 100644 --- a/packages/core/client/src/schema-component/antd/association-field/InternalNester.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/InternalNester.tsx @@ -4,6 +4,7 @@ import { RecursionField, useField, useFieldSchema, observer } from '@formily/rea import React, { useEffect } from 'react'; import { CollectionProvider } from '../../../collection-manager'; import { useAssociationFieldContext, useInsertSchema } from './hooks'; +import { ACLCollectionProvider, useACLActionParamsContext } from '../../../acl'; import schema from './schema'; export const InternalNester = observer( @@ -13,47 +14,50 @@ export const InternalNester = observer( const insertNester = useInsertSchema('Nester'); const { options: collectionField } = useAssociationFieldContext(); const showTitle = fieldSchema['x-decorator-props']?.showTitle ?? true; + const { actionName } = useACLActionParamsContext(); useEffect(() => { insertNester(schema.Nester); }, []); return ( - -
+ +
.ant-card-bordered { - border: none; + .ant-divider-horizontal { + margin: 10px 0; } - `]: showTitle === false, - }, - )} - > - { - return s['x-component'] === 'AssociationField.Nester'; - }} - /> -
-
+ `, + { + [css` + .ant-card-body { + padding: 0px 20px 20px 0px; + } + > .ant-card-bordered { + border: none; + } + `]: showTitle === false, + }, + )} + > + { + return s['x-component'] === 'AssociationField.Nester'; + }} + /> +
+
+
); }, diff --git a/packages/plugins/@nocobase/plugin-import/src/client/ImportActionInitializer.tsx b/packages/plugins/@nocobase/plugin-import/src/client/ImportActionInitializer.tsx index 9b91a6d26..d073635e1 100644 --- a/packages/plugins/@nocobase/plugin-import/src/client/ImportActionInitializer.tsx +++ b/packages/plugins/@nocobase/plugin-import/src/client/ImportActionInitializer.tsx @@ -77,6 +77,11 @@ export const ImportActionInitializer = (props) => { formLayout: { type: 'void', 'x-component': 'FormLayout', + 'x-component-props': { + labelCol: 6, + wrapperCol: 10, + layout: 'vertical', + }, properties: { download: { type: 'void', diff --git a/packages/plugins/@nocobase/plugin-import/src/client/ImportPluginProvider.tsx b/packages/plugins/@nocobase/plugin-import/src/client/ImportPluginProvider.tsx index b86836c07..cfc6142c7 100644 --- a/packages/plugins/@nocobase/plugin-import/src/client/ImportPluginProvider.tsx +++ b/packages/plugins/@nocobase/plugin-import/src/client/ImportPluginProvider.tsx @@ -1,6 +1,7 @@ import { SchemaComponentOptions } from '@nocobase/client'; import React, { useState } from 'react'; import { createPortal } from 'react-dom'; +import { FormLayout, FormItem } from '@formily/antd-v5'; import { ImportActionInitializer, ImportDesigner, ImportInitializerProvider } from '.'; import { ImportContext } from './context'; import { ImportModal, ImportStatus } from './ImportModal'; @@ -11,7 +12,7 @@ export const ImportPluginProvider = (props: any) => { const { uploadValidator, beforeUploadHandler, validateUpload } = useShared(); return (