Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from "react";
import React, { useState, useEffect, useMemo } from "react";
import RenderMultiField from "../wizard/RenderMultiField";
import {
Acl,
Expand Down Expand Up @@ -434,6 +434,12 @@ export const AccessPolicyTable = <T extends AccessPolicyTabFormikProps>({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const dropdownOptions = useMemo(() => {
return roles.length > 0
? formatAclRolesForDropdown(rolesFilteredbyPolicies)
: [];
}, [roles, rolesFilteredbyPolicies]);

const createPolicy = (role: string, withUser: boolean): TransformedAcl => {
const user = withUser ? { username: "", name: "", email: "" } : undefined;

Expand Down Expand Up @@ -537,11 +543,7 @@ export const AccessPolicyTable = <T extends AccessPolicyTabFormikProps>({
<DropDown
value={policy.role}
text={createPolicyLabel(policy)}
options={
roles.length > 0
? formatAclRolesForDropdown(rolesFilteredbyPolicies)
: []
}
options={dropdownOptions}
required={true}
creatable={true}
handleChange={element => {
Expand Down
Loading