refactor: acl collection field provider (#2679)

This commit is contained in:
katherinehhh 2023-09-19 20:51:43 +08:00 committed by GitHub
parent 91095d8fe0
commit ebc1d1afb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 11 deletions

View File

@ -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;

View File

@ -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 (
<SchemaComponent
components={{ SnippetCheckboxGroup, FormItem }}
components={{ SnippetCheckboxGroup }}
schema={{
type: 'void',
name: 'form',

View File

@ -44,8 +44,6 @@ export const ImportActionInitializer = (props) => {
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': {