small refactor (#484)
This commit is contained in:
parent
6102770fbf
commit
f1a658da01
1 changed files with 5 additions and 20 deletions
|
@ -89,16 +89,9 @@ export const AssociatedRolesTab = ({
|
||||||
return _.sortBy(rolesList, (role) => role.name?.toUpperCase());
|
return _.sortBy(rolesList, (role) => role.name?.toUpperCase());
|
||||||
};
|
};
|
||||||
|
|
||||||
const loader = async (first?: number, max?: number, search?: string) => {
|
const loader = async () => {
|
||||||
if (isInheritedHidden) {
|
if (isInheritedHidden) {
|
||||||
const filteredRoles = additionalRoles.filter(
|
return alphabetize(additionalRoles);
|
||||||
(role) =>
|
|
||||||
!search ||
|
|
||||||
role.name?.toLowerCase().includes(search) ||
|
|
||||||
role.description?.toLowerCase().includes(search)
|
|
||||||
);
|
|
||||||
const roles = alphabetize(filteredRoles);
|
|
||||||
return roles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchedRoles: Promise<RoleRepresentation[]> = additionalRoles.reduce(
|
const fetchedRoles: Promise<RoleRepresentation[]> = additionalRoles.reduce(
|
||||||
|
@ -113,14 +106,7 @@ export const AssociatedRolesTab = ({
|
||||||
);
|
);
|
||||||
|
|
||||||
return fetchedRoles.then((results: RoleRepresentation[]) => {
|
return fetchedRoles.then((results: RoleRepresentation[]) => {
|
||||||
const filteredRoles = results.filter(
|
return alphabetize(results);
|
||||||
(role) =>
|
|
||||||
!search ||
|
|
||||||
role.name?.toLowerCase().includes(search) ||
|
|
||||||
role.description?.toLowerCase().includes(search)
|
|
||||||
);
|
|
||||||
const roles = alphabetize(filteredRoles);
|
|
||||||
return roles;
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -205,7 +191,6 @@ export const AssociatedRolesTab = ({
|
||||||
<KeycloakDataTable
|
<KeycloakDataTable
|
||||||
key={key}
|
key={key}
|
||||||
loader={loader}
|
loader={loader}
|
||||||
isPaginated
|
|
||||||
ariaLabelKey="roles:roleList"
|
ariaLabelKey="roles:roleList"
|
||||||
searchPlaceholderKey="roles:searchFor"
|
searchPlaceholderKey="roles:searchFor"
|
||||||
canSelectAll
|
canSelectAll
|
||||||
|
@ -280,8 +265,8 @@ export const AssociatedRolesTab = ({
|
||||||
emptyState={
|
emptyState={
|
||||||
<ListEmptyState
|
<ListEmptyState
|
||||||
hasIcon={true}
|
hasIcon={true}
|
||||||
message={t("noRolesInThisRealm")}
|
message={t("noRoles")}
|
||||||
instructions={t("noRolesInThisRealmInstructions")}
|
instructions={t("noRolesInstructions")}
|
||||||
primaryActionText={t("createRole")}
|
primaryActionText={t("createRole")}
|
||||||
onPrimaryAction={goToCreate}
|
onPrimaryAction={goToCreate}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue