refactor: acl collection field provider (#2679)
This commit is contained in:
parent
91095d8fe0
commit
ebc1d1afb4
@ -261,8 +261,7 @@ export const ACLCollectionFieldProvider = (props) => {
|
|||||||
const { allowAll } = useACLRoleContext();
|
const { allowAll } = useACLRoleContext();
|
||||||
const { whitelist } = useACLFieldWhitelist();
|
const { whitelist } = useACLFieldWhitelist();
|
||||||
const [name] = (fieldSchema.name as string).split('.');
|
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(() => {
|
useEffect(() => {
|
||||||
if (!allowed) {
|
if (!allowed) {
|
||||||
field.required = false;
|
field.required = false;
|
||||||
|
@ -5,7 +5,7 @@ import uniq from 'lodash/uniq';
|
|||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useAPIClient, useRequest } from '../../api-client';
|
import { useAPIClient, useRequest } from '../../api-client';
|
||||||
import { SchemaComponent, FormItem } from '../../schema-component';
|
import { SchemaComponent } from '../../schema-component';
|
||||||
import { PermissionContext } from './PermisionProvider';
|
import { PermissionContext } from './PermisionProvider';
|
||||||
|
|
||||||
const SnippetCheckboxGroup = connect((props) => {
|
const SnippetCheckboxGroup = connect((props) => {
|
||||||
@ -57,7 +57,7 @@ export const RoleConfigure = () => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<SchemaComponent
|
<SchemaComponent
|
||||||
components={{ SnippetCheckboxGroup, FormItem }}
|
components={{ SnippetCheckboxGroup }}
|
||||||
schema={{
|
schema={{
|
||||||
type: 'void',
|
type: 'void',
|
||||||
name: 'form',
|
name: 'form',
|
||||||
|
@ -44,8 +44,6 @@ export const ImportActionInitializer = (props) => {
|
|||||||
const { exists, remove } = useCurrentSchema('importXlsx', 'x-action', item.find, item.remove);
|
const { exists, remove } = useCurrentSchema('importXlsx', 'x-action', item.find, item.remove);
|
||||||
const { name } = useCollection();
|
const { name } = useCollection();
|
||||||
const fields = useFields(name);
|
const fields = useFields(name);
|
||||||
const { token } = useToken();
|
|
||||||
|
|
||||||
const schema: ISchema = {
|
const schema: ISchema = {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
title: '{{ t("Import") }}',
|
title: '{{ t("Import") }}',
|
||||||
@ -77,16 +75,12 @@ 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',
|
||||||
title: `{{ t("Step 1: Download template", {ns: "${NAMESPACE}" }) }}`,
|
title: `{{ t("Step 1: Download template", {ns: "${NAMESPACE}" }) }}`,
|
||||||
'x-component': 'FormItem',
|
'x-component': 'FormItem',
|
||||||
|
'x-acl-ignore': true,
|
||||||
properties: {
|
properties: {
|
||||||
tip: {
|
tip: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
@ -120,6 +114,7 @@ export const ImportActionInitializer = (props) => {
|
|||||||
type: 'array',
|
type: 'array',
|
||||||
title: `{{ t("Step 2: Upload Excel", {ns: "${NAMESPACE}" }) }}`,
|
title: `{{ t("Step 2: Upload Excel", {ns: "${NAMESPACE}" }) }}`,
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
|
'x-acl-ignore': true,
|
||||||
'x-component': 'Upload.Dragger',
|
'x-component': 'Upload.Dragger',
|
||||||
'x-validator': '{{ uploadValidator }}',
|
'x-validator': '{{ uploadValidator }}',
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
|
Loading…
Reference in New Issue
Block a user