fix: import action should not visible when view collection not editable (#2957)
* fix: import action should not visible when view collection not editable * refactor: action in view collection block
This commit is contained in:
parent
9da6606e86
commit
9ec2b50990
@ -212,11 +212,13 @@ export const useRecordPkValue = () => {
|
||||
};
|
||||
|
||||
export const ACLActionProvider = (props) => {
|
||||
const { template, writableView } = useCollection();
|
||||
const recordPkValue = useRecordPkValue();
|
||||
const resource = useResourceName();
|
||||
const { parseAction } = useACLRoleContext();
|
||||
const schema = useFieldSchema();
|
||||
let actionPath = schema['x-acl-action'];
|
||||
const editablePath = ['create', 'update', 'destroy', 'importXlsx'];
|
||||
if (!actionPath && resource && schema['x-action']) {
|
||||
actionPath = `${resource}:${schema['x-action']}`;
|
||||
}
|
||||
@ -230,6 +232,13 @@ export const ACLActionProvider = (props) => {
|
||||
if (!params) {
|
||||
return null;
|
||||
}
|
||||
//视图表无编辑权限时不显示
|
||||
if (editablePath.includes(actionPath) || editablePath.includes(actionPath?.split(':')[1])) {
|
||||
if (template !== 'view' || writableView) {
|
||||
return <ACLActionParamsContext.Provider value={params}>{props.children}</ACLActionParamsContext.Provider>;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return <ACLActionParamsContext.Provider value={params}>{props.children}</ACLActionParamsContext.Provider>;
|
||||
};
|
||||
|
||||
|
@ -50,6 +50,7 @@ export const GridCardActionInitializers = {
|
||||
component: 'ImportActionInitializer',
|
||||
schema: {
|
||||
'x-align': 'right',
|
||||
'x-acl-action': 'importXlsx',
|
||||
'x-decorator': 'ACLActionProvider',
|
||||
'x-acl-action-props': {
|
||||
skipScopeCheck: true,
|
||||
@ -57,7 +58,7 @@ export const GridCardActionInitializers = {
|
||||
},
|
||||
visible: function useVisible() {
|
||||
const collection = useCollection();
|
||||
return collection.template !== 'sql';
|
||||
return (collection.template !== 'view' || collection?.writableView) && collection.template !== 'sql';
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -54,6 +54,7 @@ export const ListActionInitializers = {
|
||||
component: 'ImportActionInitializer',
|
||||
schema: {
|
||||
'x-align': 'right',
|
||||
'x-acl-action': 'importXlsx',
|
||||
'x-decorator': 'ACLActionProvider',
|
||||
'x-acl-action-props': {
|
||||
skipScopeCheck: true,
|
||||
@ -61,7 +62,7 @@ export const ListActionInitializers = {
|
||||
},
|
||||
visible: function useVisible() {
|
||||
const collection = useCollection();
|
||||
return collection.template !== 'sql';
|
||||
return (collection.template !== 'view' || collection?.writableView) && collection.template !== 'sql';
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -14,6 +14,7 @@ export const ImportInitializerProvider = (props: any) => {
|
||||
schema: {
|
||||
'x-align': 'right',
|
||||
'x-decorator': 'ACLActionProvider',
|
||||
'x-acl-action': 'importXlsx',
|
||||
'x-acl-action-props': {
|
||||
skipScopeCheck: true,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user