This commit is contained in:
dream2023 2024-01-19 10:18:33 +08:00
parent 681b551697
commit 137d912802

View File

@ -52,10 +52,16 @@ export const actionDesignerCss = css`
}
`;
const actionAclCheck = function useAclCheck(actionPath) {
export function useAclCheck(actionPath) {
const aclCheck = useAclCheckFn();
return aclCheck(actionPath);
}
function useAclCheckFn() {
const { data, inResources, getResourceActionParams, getStrategyActionParams } = useACLRolesCheck();
const recordPkValue = useRecordPkValue();
const collection = useCollection();
function actionAclCheck(actionPath: string) {
const resource = collection.resource;
const parseAction = (actionPath: string, options: any = {}) => {
const [resourceName] = actionPath.split(':');
@ -81,7 +87,10 @@ const actionAclCheck = function useAclCheck(actionPath) {
return false;
}
return true;
};
}
return actionAclCheck;
}
export const CreateRecordAction = observer(
(props: any) => {
@ -95,7 +104,6 @@ export const CreateRecordAction = observer(
const ctx = useActionContext();
const variables = useVariables();
const localVariables = useLocalVariables({ currentForm: { values } as any });
useEffect(() => {
field.stateOfLinkageRules = {};
linkageRules
@ -153,6 +161,7 @@ export const CreateAction = observer(
const field: any = useField();
const form = useForm();
const variables = useVariables();
const aclCheck = useAclCheckFn();
const enableChildren = fieldSchema['x-enable-children'] || [];
const allowAddToCurrent = fieldSchema?.['x-allow-add-to-current'];
@ -177,7 +186,7 @@ export const CreateAction = observer(
};
})
.filter((v) => {
return v && actionAclCheck(`${v.name}:create`);
return v && aclCheck(`${v.name}:create`);
});
}, [enableChildren, totalChildCollections]);
const linkageRules: any[] = fieldSchema?.['x-linkage-rules'] || [];