瀏覽代碼

Review fixes

Roman Zabaluev 1 年之前
父節點
當前提交
befee78ce7
共有 1 個文件被更改,包括 6 次插入9 次删除
  1. 6 9
      kafka-ui-react-app/src/lib/permissions.ts

+ 6 - 9
kafka-ui-react-app/src/lib/permissions.ts

@@ -47,6 +47,12 @@ interface IsPermittedConfig {
   rbacFlag: boolean;
 }
 
+const valueMatches = (regexp: string | undefined, val: string | undefined) => {
+  if (!val) return false;
+  if (!regexp) return true;
+  return new RegExp(regexp).test(val);
+};
+
 /**
  * @description it the logic behind depending on the roles whether a certain action
  * is permitted or not the philosophy is inspired from Headless UI libraries where
@@ -94,15 +100,6 @@ export function isPermitted({
   const resourcePermissions = clusterMap.get(resource);
   if (!resourcePermissions) return false;
 
-  const valueMatches = (
-    regexp: string | undefined,
-    val: string | undefined
-  ) => {
-    if (!val) return false;
-    if (!regexp) return true;
-    return new RegExp(regexp).test(val);
-  };
-
   const actions = Array.isArray(action) ? action : [action];
 
   return actions.every((a) => {