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
This commit is contained in:
parent
630c6f2d79
commit
bc5ecc9b5f
@ -182,7 +182,7 @@ export const ACLCollectionProvider = (props) => {
|
|||||||
if (allowAll) {
|
if (allowAll) {
|
||||||
return props.children;
|
return props.children;
|
||||||
}
|
}
|
||||||
const actionPath = schema?.['x-acl-action'];
|
const actionPath = schema?.['x-acl-action'] || props.actionPath;
|
||||||
if (!actionPath) {
|
if (!actionPath) {
|
||||||
return props.children;
|
return props.children;
|
||||||
}
|
}
|
||||||
@ -190,6 +190,8 @@ export const ACLCollectionProvider = (props) => {
|
|||||||
if (!params) {
|
if (!params) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
const [_, actionName] = actionPath.split(':');
|
||||||
|
params.actionName = actionName;
|
||||||
return <ACLActionParamsContext.Provider value={params}>{props.children}</ACLActionParamsContext.Provider>;
|
return <ACLActionParamsContext.Provider value={params}>{props.children}</ACLActionParamsContext.Provider>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -258,7 +260,8 @@ export const ACLCollectionFieldProvider = (props) => {
|
|||||||
const field = useField<Field>();
|
const field = useField<Field>();
|
||||||
const { allowAll } = useACLRoleContext();
|
const { allowAll } = useACLRoleContext();
|
||||||
const { whitelist } = useACLFieldWhitelist();
|
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(() => {
|
useEffect(() => {
|
||||||
if (!allowed) {
|
if (!allowed) {
|
||||||
|
@ -4,6 +4,7 @@ import { RecursionField, useField, useFieldSchema, observer } from '@formily/rea
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { CollectionProvider } from '../../../collection-manager';
|
import { CollectionProvider } from '../../../collection-manager';
|
||||||
import { useAssociationFieldContext, useInsertSchema } from './hooks';
|
import { useAssociationFieldContext, useInsertSchema } from './hooks';
|
||||||
|
import { ACLCollectionProvider, useACLActionParamsContext } from '../../../acl';
|
||||||
import schema from './schema';
|
import schema from './schema';
|
||||||
|
|
||||||
export const InternalNester = observer(
|
export const InternalNester = observer(
|
||||||
@ -13,11 +14,13 @@ export const InternalNester = observer(
|
|||||||
const insertNester = useInsertSchema('Nester');
|
const insertNester = useInsertSchema('Nester');
|
||||||
const { options: collectionField } = useAssociationFieldContext();
|
const { options: collectionField } = useAssociationFieldContext();
|
||||||
const showTitle = fieldSchema['x-decorator-props']?.showTitle ?? true;
|
const showTitle = fieldSchema['x-decorator-props']?.showTitle ?? true;
|
||||||
|
const { actionName } = useACLActionParamsContext();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
insertNester(schema.Nester);
|
insertNester(schema.Nester);
|
||||||
}, []);
|
}, []);
|
||||||
return (
|
return (
|
||||||
<CollectionProvider name={collectionField.target}>
|
<CollectionProvider name={collectionField.target}>
|
||||||
|
<ACLCollectionProvider actionPath={`${collectionField.target}:${actionName}`}>
|
||||||
<FormLayout layout={'vertical'}>
|
<FormLayout layout={'vertical'}>
|
||||||
<div
|
<div
|
||||||
className={cx(
|
className={cx(
|
||||||
@ -54,6 +57,7 @@ export const InternalNester = observer(
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</FormLayout>
|
</FormLayout>
|
||||||
|
</ACLCollectionProvider>
|
||||||
</CollectionProvider>
|
</CollectionProvider>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -77,6 +77,11 @@ export const ImportActionInitializer = (props) => {
|
|||||||
formLayout: {
|
formLayout: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-component': 'FormLayout',
|
'x-component': 'FormLayout',
|
||||||
|
'x-component-props': {
|
||||||
|
labelCol: 6,
|
||||||
|
wrapperCol: 10,
|
||||||
|
layout: 'vertical',
|
||||||
|
},
|
||||||
properties: {
|
properties: {
|
||||||
download: {
|
download: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { SchemaComponentOptions } from '@nocobase/client';
|
import { SchemaComponentOptions } from '@nocobase/client';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
|
import { FormLayout, FormItem } from '@formily/antd-v5';
|
||||||
import { ImportActionInitializer, ImportDesigner, ImportInitializerProvider } from '.';
|
import { ImportActionInitializer, ImportDesigner, ImportInitializerProvider } from '.';
|
||||||
import { ImportContext } from './context';
|
import { ImportContext } from './context';
|
||||||
import { ImportModal, ImportStatus } from './ImportModal';
|
import { ImportModal, ImportStatus } from './ImportModal';
|
||||||
@ -11,7 +12,7 @@ export const ImportPluginProvider = (props: any) => {
|
|||||||
const { uploadValidator, beforeUploadHandler, validateUpload } = useShared();
|
const { uploadValidator, beforeUploadHandler, validateUpload } = useShared();
|
||||||
return (
|
return (
|
||||||
<SchemaComponentOptions
|
<SchemaComponentOptions
|
||||||
components={{ ImportActionInitializer, ImportDesigner }}
|
components={{ ImportActionInitializer, ImportDesigner, FormLayout, FormItem }}
|
||||||
scope={{
|
scope={{
|
||||||
uploadValidator,
|
uploadValidator,
|
||||||
validateUpload,
|
validateUpload,
|
||||||
|
Loading…
Reference in New Issue
Block a user