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") }}', title: '{{ t("Update record") }}',
'x-component': 'Action', 'x-component': 'Action',
'x-designer': 'Action.Designer', 'x-designer': 'Action.Designer',
'x-acl-action': 'update',
'x-action': 'customize:update', 'x-action': 'customize:update',
'x-action-settings': { 'x-action-settings': {
assignedValues: {}, assignedValues: {},

View File

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

View File

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

View File

@ -37,9 +37,6 @@ export const TableActionInitializers = {
schema: { schema: {
'x-align': 'right', 'x-align': 'right',
'x-decorator': 'ACLActionProvider', 'x-decorator': 'ACLActionProvider',
'x-acl-action-props': {
skipScopeCheck: true,
},
}, },
}, },
{ {
@ -48,9 +45,6 @@ export const TableActionInitializers = {
component: 'RefreshActionInitializer', component: 'RefreshActionInitializer',
schema: { schema: {
'x-align': 'right', 'x-align': 'right',
'x-acl-action-props': {
skipScopeCheck: true,
},
}, },
}, },
], ],
@ -71,6 +65,7 @@ export const TableActionInitializers = {
title: '{{ t("Bulk update") }}', title: '{{ t("Bulk update") }}',
'x-component': 'Action', 'x-component': 'Action',
'x-align': 'right', 'x-align': 'right',
'x-acl-action': 'update',
'x-decorator': 'ACLActionProvider', 'x-decorator': 'ACLActionProvider',
'x-acl-action-props': { 'x-acl-action-props': {
skipScopeCheck: true, skipScopeCheck: true,
@ -87,6 +82,7 @@ export const TableActionInitializers = {
}, },
}, },
'x-component-props': { 'x-component-props': {
icon: 'EditOutlined',
useProps: '{{ useCustomizeBulkUpdateActionProps }}', useProps: '{{ useCustomizeBulkUpdateActionProps }}',
}, },
}, },
@ -98,6 +94,7 @@ export const TableActionInitializers = {
schema: { schema: {
'x-align': 'right', 'x-align': 'right',
'x-decorator': 'ACLActionProvider', 'x-decorator': 'ACLActionProvider',
'x-acl-action': 'update',
'x-acl-action-props': { 'x-acl-action-props': {
skipScopeCheck: true, 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) => { export const BulkDestroyActionInitializer = (props) => {
const schema = { const collection = useCollection();
title: '{{ t("Delete") }}', const schema = {
'x-action': 'destroy', title: '{{ t("Delete") }}',
'x-component': 'Action', 'x-action': 'destroy',
'x-designer': 'Action.Designer', 'x-component': 'Action',
'x-component-props': { 'x-designer': 'Action.Designer',
icon: 'DeleteOutlined', 'x-decorator': 'ACLActionProvider',
confirm: { 'x-acl-action-props': {
title: "{{t('Delete record')}}", skipScopeCheck: true,
content: "{{t('Are you sure you want to delete it?')}}", },
}, 'x-component-props': {
useProps: '{{ useBulkDestroyActionProps }}', icon: 'DeleteOutlined',
confirm: {
title: "{{t('Delete record')}}",
content: "{{t('Are you sure you want to delete it?')}}",
}, },
}; useProps: '{{ useBulkDestroyActionProps }}',
return <ActionInitializer {...props} schema={schema} />; },
}; };
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 React from 'react';
import { BlockInitializer } from '.'; import { BlockInitializer } from '.';
import { useCollection } from '../../collection-manager';
export const CustomizeActionInitializer = (props) => { 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': { 'x-component-props': {
openMode: 'drawer', openMode: 'drawer',
icon: 'EditOutlined',
}, },
properties: { properties: {
drawer: { drawer: {