mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-04 21:28:34 +08:00
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) {
|
||||
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 <ACLActionParamsContext.Provider value={params}>{props.children}</ACLActionParamsContext.Provider>;
|
||||
};
|
||||
|
||||
@ -258,7 +260,8 @@ export const ACLCollectionFieldProvider = (props) => {
|
||||
const field = useField<Field>();
|
||||
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) {
|
||||
|
@ -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 (
|
||||
<CollectionProvider name={collectionField.target}>
|
||||
<FormLayout layout={'vertical'}>
|
||||
<div
|
||||
className={cx(
|
||||
css`
|
||||
& .ant-formily-item-layout-vertical {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.ant-card-body {
|
||||
padding: 15px 20px 5px;
|
||||
}
|
||||
.ant-divider-horizontal {
|
||||
margin: 10px 0;
|
||||
}
|
||||
`,
|
||||
{
|
||||
[css`
|
||||
<ACLCollectionProvider actionPath={`${collectionField.target}:${actionName}`}>
|
||||
<FormLayout layout={'vertical'}>
|
||||
<div
|
||||
className={cx(
|
||||
css`
|
||||
& .ant-formily-item-layout-vertical {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.ant-card-body {
|
||||
padding: 0px 20px 20px 0px;
|
||||
padding: 15px 20px 5px;
|
||||
}
|
||||
> .ant-card-bordered {
|
||||
border: none;
|
||||
.ant-divider-horizontal {
|
||||
margin: 10px 0;
|
||||
}
|
||||
`]: showTitle === false,
|
||||
},
|
||||
)}
|
||||
>
|
||||
<RecursionField
|
||||
onlyRenderProperties
|
||||
basePath={field.address}
|
||||
schema={fieldSchema}
|
||||
filterProperties={(s) => {
|
||||
return s['x-component'] === 'AssociationField.Nester';
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</FormLayout>
|
||||
`,
|
||||
{
|
||||
[css`
|
||||
.ant-card-body {
|
||||
padding: 0px 20px 20px 0px;
|
||||
}
|
||||
> .ant-card-bordered {
|
||||
border: none;
|
||||
}
|
||||
`]: showTitle === false,
|
||||
},
|
||||
)}
|
||||
>
|
||||
<RecursionField
|
||||
onlyRenderProperties
|
||||
basePath={field.address}
|
||||
schema={fieldSchema}
|
||||
filterProperties={(s) => {
|
||||
return s['x-component'] === 'AssociationField.Nester';
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</FormLayout>
|
||||
</ACLCollectionProvider>
|
||||
</CollectionProvider>
|
||||
);
|
||||
},
|
||||
|
@ -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',
|
||||
|
@ -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 (
|
||||
<SchemaComponentOptions
|
||||
components={{ ImportActionInitializer, ImportDesigner }}
|
||||
components={{ ImportActionInitializer, ImportDesigner, FormLayout, FormItem }}
|
||||
scope={{
|
||||
uploadValidator,
|
||||
validateUpload,
|
||||
|
Loading…
Reference in New Issue
Block a user