Browse Source

FE: Fix permissions check for cluster edit (#3862)

Roman Zabaluev 2 years ago
parent
commit
71a7a1ec84

+ 3 - 2
kafka-ui-react-app/src/components/Dashboard/ClusterTableActionsCell.tsx

@@ -11,7 +11,8 @@ const ClusterTableActionsCell: React.FC<Props> = ({ row }) => {
   const { name } = row.original;
   const { data } = useGetUserInfo();
 
-  const isApplicationConfig = useMemo(() => {
+  const hasPermissions = useMemo(() => {
+    if (!data?.rbacEnabled) return true;
     return !!data?.userInfo?.permissions.some(
       (permission) => permission.resource === ResourceType.APPLICATIONCONFIG
     );
@@ -22,7 +23,7 @@ const ClusterTableActionsCell: React.FC<Props> = ({ row }) => {
       buttonType="secondary"
       buttonSize="S"
       to={clusterConfigPath(name)}
-      canDoAction={isApplicationConfig}
+      canDoAction={hasPermissions}
     >
       Configure
     </ActionCanButton>

+ 3 - 2
kafka-ui-react-app/src/components/Dashboard/Dashboard.tsx

@@ -57,7 +57,8 @@ const Dashboard: React.FC = () => {
     return initialColumns;
   }, []);
 
-  const isApplicationConfig = useMemo(() => {
+  const hasPermissions = useMemo(() => {
+    if (!data?.rbacEnabled) return true;
     return !!data?.userInfo?.permissions.some(
       (permission) => permission.resource === ResourceType.APPLICATIONCONFIG
     );
@@ -91,7 +92,7 @@ const Dashboard: React.FC = () => {
             buttonType="primary"
             buttonSize="M"
             to={clusterNewConfigPath}
-            canDoAction={isApplicationConfig}
+            canDoAction={hasPermissions}
           >
             Configure new cluster
           </ActionCanButton>