diff --git a/packages/core/client/src/acl/ACLProvider.tsx b/packages/core/client/src/acl/ACLProvider.tsx
index 2baf50e38..64f2318f8 100644
--- a/packages/core/client/src/acl/ACLProvider.tsx
+++ b/packages/core/client/src/acl/ACLProvider.tsx
@@ -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 {props.children};
+ }
+ return null;
+ }
return {props.children};
};
diff --git a/packages/core/client/src/schema-initializer/buttons/GridCardActionInitializers.tsx b/packages/core/client/src/schema-initializer/buttons/GridCardActionInitializers.tsx
index 701b2f1df..955d24f64 100644
--- a/packages/core/client/src/schema-initializer/buttons/GridCardActionInitializers.tsx
+++ b/packages/core/client/src/schema-initializer/buttons/GridCardActionInitializers.tsx
@@ -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';
},
},
{
diff --git a/packages/core/client/src/schema-initializer/buttons/ListActionInitializers.tsx b/packages/core/client/src/schema-initializer/buttons/ListActionInitializers.tsx
index 4be57a1b9..24d3071dc 100644
--- a/packages/core/client/src/schema-initializer/buttons/ListActionInitializers.tsx
+++ b/packages/core/client/src/schema-initializer/buttons/ListActionInitializers.tsx
@@ -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';
},
},
{
diff --git a/packages/plugins/@nocobase/plugin-import/src/client/ImportInitializerProvider.tsx b/packages/plugins/@nocobase/plugin-import/src/client/ImportInitializerProvider.tsx
index a2433711e..ea50357e3 100644
--- a/packages/plugins/@nocobase/plugin-import/src/client/ImportInitializerProvider.tsx
+++ b/packages/plugins/@nocobase/plugin-import/src/client/ImportInitializerProvider.tsx
@@ -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,
},