Merge branch 'main' into next
Some checks are pending
Build Docker Image / build-and-push (push) Waiting to run
Build Pro Image / build-and-push (push) Waiting to run
E2E / Build (push) Waiting to run
E2E / Core and plugins (push) Blocked by required conditions
E2E / plugin-workflow (push) Blocked by required conditions
E2E / plugin-workflow-approval (push) Blocked by required conditions
E2E / plugin-data-source-main (push) Blocked by required conditions
E2E / Comment on PR (push) Blocked by required conditions
NocoBase FrontEnd Test / frontend-test (18) (push) Waiting to run

This commit is contained in:
GitHub Actions Bot 2024-08-12 07:10:02 +00:00
commit 6dac406f7e

View File

@ -15,6 +15,9 @@ import {
useFilterFieldOptions,
useFormBlockContext,
withDynamicSchemaProps,
useCollectionRecord,
Action,
useDestroyActionProps,
} from '@nocobase/client';
import React, { useContext, useEffect } from 'react';
import { RoleResourceCollectionContext } from '../RolesResourcesActions';
@ -51,6 +54,20 @@ const useFormBlockProps = () => {
};
};
const EditScopeActionComponent = (props) => {
const { data } = useCollectionRecord();
const { id } = data || ({} as any);
const actionProps = { ...props, disabled: [1, 2].includes(id) };
return <Action.Link {...actionProps} />;
};
const DestroyScopeActionComponent = (props) => {
const { data } = useCollectionRecord();
const { id } = data || ({} as any);
const actionProps = { ...props, ...useDestroyActionProps(), disabled: [1, 2].includes(id) };
return <Action.Link {...actionProps} />;
};
export const getScopesSchema = (dataSourceKey) => {
const collection = rolesResourcesScopesCollection(dataSourceKey);
return {
@ -247,7 +264,7 @@ export const getScopesSchema = (dataSourceKey) => {
title: '{{ t("Edit") }}',
'x-action': 'update',
'x-decorator': 'ACLActionProvider',
'x-component': 'Action.Link',
'x-component': EditScopeActionComponent,
'x-component-props': {
openMode: 'drawer',
icon: 'EditOutlined',
@ -341,8 +358,6 @@ export const getScopesSchema = (dataSourceKey) => {
title: '{{ t("Delete") }}',
'x-action': 'destroy',
'x-decorator': 'ACLActionProvider',
'x-component': 'Action.Link',
'x-use-component-props': 'useDestroyActionProps',
'x-component-props': {
icon: 'DeleteOutlined',
confirm: {
@ -350,6 +365,7 @@ export const getScopesSchema = (dataSourceKey) => {
content: "{{t('Are you sure you want to delete it?')}}",
},
},
'x-component': DestroyScopeActionComponent,
},
},
},