Skip to content

Commit

Permalink
Solves infinite loading case
Browse files Browse the repository at this point in the history
  • Loading branch information
jvorcak committed Jan 2, 2025
1 parent c5dc922 commit 335be27
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
8 changes: 8 additions & 0 deletions frontend/src/components/pages/acls/Acl.List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,14 @@ const RolesTab = observer(() => {
data-testid="create-role-button"
variant="outline"
onClick={() => appGlobal.history.push('/security/roles/create')}
isDisabled={api.userData.canCreateRoles === false || !api.isAdminApiConfigured}
tooltip={[
api.userData?.canCreateRoles === false &&
'You need KafkaAclOperation.KAFKA_ACL_OPERATION_ALTER and RedpandaCapability.MANAGE_RBAC permissions.',
!api.isAdminApiConfigured && 'You need to enable Admin API.',
]
.filter(Boolean)
.join(' ')}
>
Create role
</Button>
Expand Down
9 changes: 1 addition & 8 deletions frontend/src/components/pages/acls/RoleCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,10 @@ class RoleCreatePage extends PageComponent {
}

async refreshData(force: boolean) {
if (api.userData != null && !api.userData.canListAcls) return;

await Promise.allSettled([
api.refreshAcls(AclRequestDefault, force),
api.refreshServiceAccounts(true),
rolesApi.refreshRoles(),
]);
await Promise.allSettled([api.refreshServiceAccounts(true), rolesApi.refreshRoles()]);
}

render() {
if (api.ACLs?.aclResources === undefined) return DefaultSkeleton;
if (!api.serviceAccounts || !api.serviceAccounts.users) return DefaultSkeleton;

return (
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/state/backendApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ export async function handleExpiredLicenseError(r: Response) {
canListAcls: true,
canListQuotas: true,
canPatchConfigs: true,
canCreateRoles: true,
canReassignPartitions: true,
canCreateSchemas: true,
canDeleteSchemas: true,
Expand Down Expand Up @@ -442,6 +443,9 @@ const apiStore = {
canReassignPartitions:
r.permissions?.kafkaClusterOperations.includes(KafkaAclOperation.ALTER_CONFIGS) &&
r.permissions?.kafkaClusterOperations.includes(KafkaAclOperation.DESCRIBE_CONFIGS),
canCreateRoles:
r.permissions?.kafkaClusterOperations.includes(KafkaAclOperation.ALTER) &&
r.permissions?.redpanda.includes(RedpandaCapability.MANAGE_RBAC),
canCreateSchemas: r.permissions?.schemaRegistry.includes(SchemaRegistryCapability.WRITE),
canDeleteSchemas: r.permissions?.schemaRegistry.includes(SchemaRegistryCapability.DELETE),
canManageSchemaRegistry: r.permissions?.schemaRegistry.includes(SchemaRegistryCapability.WRITE),
Expand Down
1 change: 1 addition & 0 deletions frontend/src/state/restInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ export interface UserData {
canListQuotas: boolean;
canReassignPartitions: boolean;
canPatchConfigs: boolean;
canCreateRoles: boolean;

canViewSchemas: boolean;
canCreateSchemas: boolean;
Expand Down

0 comments on commit 335be27

Please sign in to comment.