From 94b2e8d58ff2ffe5d322eddd77d4d4004d0fc407 Mon Sep 17 00:00:00 2001 From: "Jingwei.Zhang" Date: Fri, 1 Sep 2023 17:30:51 +0800 Subject: [PATCH] feat: update Action component update Action component to check allowed by other func first Change-Id: I656d853417dd5969fd5c4f226689111f9043b993 --- src/components/Tables/Base/Action/index.jsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/components/Tables/Base/Action/index.jsx b/src/components/Tables/Base/Action/index.jsx index 9bea6103..34a4f7f5 100644 --- a/src/components/Tables/Base/Action/index.jsx +++ b/src/components/Tables/Base/Action/index.jsx @@ -19,6 +19,7 @@ export async function checkAllowed({ policy, aliasPolicy, allowed, + allowedExtra, containerProps, actionName, extra, @@ -38,6 +39,16 @@ export async function checkAllowed({ return false; } let result = false; + let allowedExtraResult = true; + if (allowedExtra) { + allowedExtraResult = allowedExtra({ item, containerProps, extra, action }); + if (allowedExtraResult instanceof Promise) { + allowedExtraResult = await allowedExtraResult; + } + } + if (!allowedExtraResult) { + return false; + } if (allowed) { result = allowed(item, containerProps, extra); if (result instanceof Promise) { @@ -61,6 +72,7 @@ export async function getAllowedResults({ policy: key ? it[key].policy : it.policy, aliasPolicy: key ? it[key].aliasPolicy : it.aliasPolicy, allowed: key ? it[key].allowed : it.allowed, + allowedExtra: key ? it[key].allowedExtra : it.allowedExtra, containerProps, actionName: key ? it[key].title : it.title, extra,