From 86661e518a8de797a99d99803cb7f2895c798625 Mon Sep 17 00:00:00 2001 From: SevicheCC <91365763+Sevichecc@users.noreply.github.com> Date: Wed, 7 Jun 2023 22:33:48 +0800 Subject: [PATCH] feat: add admin read all and write all scopes --- components/scopes/ScopeItem.tsx | 24 ++++++++++++++++++++---- lib/scopes.ts | 2 ++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/components/scopes/ScopeItem.tsx b/components/scopes/ScopeItem.tsx index 1c7ac81..a1dc68e 100644 --- a/components/scopes/ScopeItem.tsx +++ b/components/scopes/ScopeItem.tsx @@ -10,12 +10,24 @@ interface ScopeCheckboxProps { } const ScopeItem: React.FC = ({ scope, method, field }) => { + const scopes = scope.split(":"); + const adminIsReadAll = + field.value?.includes("admin:read") && + method === "admin" && + scopes[1] === "read" && + scopes.length !== 2; + const adminIsWriteAll = + field.value?.includes("admin:write") && + method === "admin" && + scopes[1] === "write" && + scopes.length !== 2; + const isCovered = field.value?.includes(method); return (
{ @@ -37,10 +49,14 @@ const ScopeItem: React.FC = ({ scope, method, field }) => { : "hover:cursor-pointer" }`} > - {method == "admin" && ( - {scope.split(":")[1]} : + {method === "admin" && ( + {scopes[1]} : + )} + {scope === "admin:read" || scope === "admin:write" ? ( + All + ) : ( + scopes.slice(-1) )} - {scope.split(":").slice(-1)}
diff --git a/lib/scopes.ts b/lib/scopes.ts index d71ea79..da894cd 100644 --- a/lib/scopes.ts +++ b/lib/scopes.ts @@ -30,6 +30,7 @@ export const WRITE_SCOPES = [ ]; export const ADMIN_READ_SCOPES = [ + "admin:read", "admin:read:account", "admin:read:reports", "admin:read:domain_allows", @@ -40,6 +41,7 @@ export const ADMIN_READ_SCOPES = [ ]; export const ADMIN_WRITE_SCOPES = [ + "admin:write", "admin:write:account", "admin:write:reports", "admin:write:domain_allows",