fix(acl): add x-acl-action to action schema

This commit is contained in:
chenos 2022-12-03 13:51:55 +08:00
parent 6b253755a1
commit e5a9721674
7 changed files with 40 additions and 23 deletions

View File

@ -116,6 +116,7 @@ export const CalendarFormActionInitializers = {
title: '{{ t("Update record") }}',
'x-component': 'Action',
'x-designer': 'Action.Designer',
'x-acl-action': 'update',
'x-action': 'customize:update',
'x-action-settings': {
assignedValues: {},

View File

@ -108,6 +108,7 @@ export const ReadPrettyFormActionInitializers = {
'x-component': 'Action',
'x-designer': 'Action.Designer',
'x-action': 'customize:update',
'x-acl-action': 'update',
'x-action-settings': {
assignedValues: {},
onSuccess: {

View File

@ -135,6 +135,7 @@ export const TableActionColumnInitializers = (props: any) => {
title: '{{ t("Update record") }}',
'x-component': 'Action.Link',
'x-action': 'customize:update',
'x-acl-action': 'update',
'x-designer': 'Action.Designer',
'x-action-settings': {
assignedValues: {},

View File

@ -37,9 +37,6 @@ export const TableActionInitializers = {
schema: {
'x-align': 'right',
'x-decorator': 'ACLActionProvider',
'x-acl-action-props': {
skipScopeCheck: true,
},
},
},
{
@ -48,9 +45,6 @@ export const TableActionInitializers = {
component: 'RefreshActionInitializer',
schema: {
'x-align': 'right',
'x-acl-action-props': {
skipScopeCheck: true,
},
},
},
],
@ -71,6 +65,7 @@ export const TableActionInitializers = {
title: '{{ t("Bulk update") }}',
'x-component': 'Action',
'x-align': 'right',
'x-acl-action': 'update',
'x-decorator': 'ACLActionProvider',
'x-acl-action-props': {
skipScopeCheck: true,
@ -87,6 +82,7 @@ export const TableActionInitializers = {
},
},
'x-component-props': {
icon: 'EditOutlined',
useProps: '{{ useCustomizeBulkUpdateActionProps }}',
},
},
@ -98,6 +94,7 @@ export const TableActionInitializers = {
schema: {
'x-align': 'right',
'x-decorator': 'ACLActionProvider',
'x-acl-action': 'update',
'x-acl-action-props': {
skipScopeCheck: true,
},

View File

@ -1,21 +1,30 @@
import React from "react";
import React from 'react';
import { useCollection } from '../../collection-manager';
import { ActionInitializer } from "./ActionInitializer";
import { ActionInitializer } from './ActionInitializer';
export const BulkDestroyActionInitializer = (props) => {
const schema = {
title: '{{ t("Delete") }}',
'x-action': 'destroy',
'x-component': 'Action',
'x-designer': 'Action.Designer',
'x-component-props': {
icon: 'DeleteOutlined',
confirm: {
title: "{{t('Delete record')}}",
content: "{{t('Are you sure you want to delete it?')}}",
},
useProps: '{{ useBulkDestroyActionProps }}',
const collection = useCollection();
const schema = {
title: '{{ t("Delete") }}',
'x-action': 'destroy',
'x-component': 'Action',
'x-designer': 'Action.Designer',
'x-decorator': 'ACLActionProvider',
'x-acl-action-props': {
skipScopeCheck: true,
},
'x-component-props': {
icon: 'DeleteOutlined',
confirm: {
title: "{{t('Delete record')}}",
content: "{{t('Are you sure you want to delete it?')}}",
},
};
return <ActionInitializer {...props} schema={schema} />;
useProps: '{{ useBulkDestroyActionProps }}',
},
};
if (collection) {
schema['x-acl-action'] = `${collection.name}:destroy`;
}
return <ActionInitializer {...props} schema={schema} />;
};

View File

@ -1,7 +1,14 @@
import React from 'react';
import { BlockInitializer } from '.';
import { useCollection } from '../../collection-manager';
export const CustomizeActionInitializer = (props) => {
return <BlockInitializer {...props} />;
const collection = useCollection();
const schema = {};
if (collection && schema['x-acl-action']) {
schema['x-acl-action'] = `${collection.name}:${schema['x-acl-action']}`;
schema['x-decorator'] = 'ACLActionProvider';
}
return <BlockInitializer {...props} schema={schema} />;
};

View File

@ -13,6 +13,7 @@ export const CustomizeBulkEditActionInitializer = (props) => {
},
'x-component-props': {
openMode: 'drawer',
icon: 'EditOutlined',
},
properties: {
drawer: {