Added empty state for assign roles (#3563)

This commit is contained in:
Erik Jan de Wit 2022-10-17 12:21:03 +02:00 committed by GitHub
parent 799442060f
commit c5af1e143c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 6 deletions

View file

@ -207,5 +207,6 @@
"temporaryPassword": "Temporary", "temporaryPassword": "Temporary",
"temporaryPasswordHelpText": "If enabled, the user must change the password on next login", "temporaryPasswordHelpText": "If enabled, the user must change the password on next login",
"forbidden_one": "Forbidden, permission needed:", "forbidden_one": "Forbidden, permission needed:",
"forbidden_other": "Forbidden, permissions needed:" "forbidden_other": "Forbidden, permissions needed:",
"noRealmRolesToAssign": "There are no realm roles to assign"
} }

View file

@ -17,6 +17,7 @@ import useLocaleSort from "../../utils/useLocaleSort";
import { ResourcesKey, Row, ServiceRole } from "./RoleMapping"; import { ResourcesKey, Row, ServiceRole } from "./RoleMapping";
import { getAvailableRoles } from "./queries"; import { getAvailableRoles } from "./queries";
import { getAvailableClientRoles } from "./resource"; import { getAvailableClientRoles } from "./resource";
import { ListEmptyState } from "../list-empty-state/ListEmptyState";
type AddRoleMappingModalProps = { type AddRoleMappingModalProps = {
id: string; id: string;
@ -39,7 +40,7 @@ export const AddRoleMappingModal = ({
onAssign, onAssign,
onClose, onClose,
}: AddRoleMappingModalProps) => { }: AddRoleMappingModalProps) => {
const { t } = useTranslation("common"); const { t } = useTranslation(type);
const { adminClient } = useAdminClient(); const { adminClient } = useAdminClient();
const [searchToggle, setSearchToggle] = useState(false); const [searchToggle, setSearchToggle] = useState(false);
@ -104,9 +105,11 @@ export const AddRoleMappingModal = ({
<Modal <Modal
variant={ModalVariant.large} variant={ModalVariant.large}
title={ title={
isLDAPmapper ? t("assignRole") : t("assignRolesTo", { client: name }) isLDAPmapper
? t("common:assignRole")
: t("common:assignRolesTo", { client: name })
} }
isOpen={true} isOpen
onClose={onClose} onClose={onClose}
actions={[ actions={[
<Button <Button
@ -119,7 +122,7 @@ export const AddRoleMappingModal = ({
onClose(); onClose();
}} }}
> >
{t("assign")} {t("common:assign")}
</Button>, </Button>,
<Button <Button
data-testid="cancel" data-testid="cancel"
@ -177,9 +180,24 @@ export const AddRoleMappingModal = ({
}, },
{ {
name: "role.description", name: "role.description",
displayKey: t("description"), displayKey: "common:description",
}, },
]} ]}
emptyState={
<ListEmptyState
message={t("noRoles")}
instructions={t("common:noRealmRolesToAssign")}
secondaryActions={[
{
text: t("common:filterByClients"),
onClick: () => {
setFilterType("clients");
refresh();
},
},
]}
/>
}
/> />
</Modal> </Modal>
); );