removed status row and use badge (#24683)

fixes: #24470

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
Erik Jan de Wit 2023-11-28 17:13:36 +01:00 committed by GitHub
parent 09c7c07670
commit cb4008e8d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -49,6 +49,51 @@ export type UserAttribute = {
value: string; value: string;
}; };
const UserDetailLink = (user: BruteUser) => {
const { realm } = useRealm();
return (
<Link to={toUser({ realm, id: user.id!, tab: "settings" })}>
{user.username} <StatusRow user={user} />
</Link>
);
};
type StatusRowProps = {
user: BruteUser;
};
const StatusRow = ({ user }: StatusRowProps) => {
const { t } = useTranslation();
return (
<>
{!user.enabled && (
<Label color="red" icon={<InfoCircleIcon />}>
{t("disabled")}
</Label>
)}
{user.bruteForceStatus?.disabled && (
<Label color="orange" icon={<WarningTriangleIcon />}>
{t("temporaryLocked")}
</Label>
)}
</>
);
};
const ValidatedEmail = (user: UserRepresentation) => {
const { t } = useTranslation();
return (
<>
{!user.emailVerified && (
<Tooltip content={t("notVerified")}>
<ExclamationCircleIcon className="keycloak__user-section__email-verified" />
</Tooltip>
)}{" "}
{emptyFormatter()(user.email)}
</>
);
};
export function UserDataTable() { export function UserDataTable() {
const { t } = useTranslation(); const { t } = useTranslation();
const { addAlert, addError } = useAlerts(); const { addAlert, addError } = useAlerts();
@ -96,15 +141,6 @@ export function UserDataTable() {
[], [],
); );
const UserDetailLink = (user: UserRepresentation) => (
<Link
key={user.username}
to={toUser({ realm: realmName, id: user.id!, tab: "settings" })}
>
{user.username}
</Link>
);
const loader = async (first?: number, max?: number, search?: string) => { const loader = async (first?: number, max?: number, search?: string) => {
const params: { [name: string]: string | number } = { const params: { [name: string]: string | number } = {
first: first!, first: first!,
@ -170,40 +206,6 @@ export function UserDataTable() {
}, },
}); });
const StatusRow = (user: BruteUser) => {
return (
<>
{!user.enabled && (
<Label key={user.id} color="red" icon={<InfoCircleIcon />}>
{t("disabled")}
</Label>
)}
{user.bruteForceStatus?.disabled && (
<Label key={user.id} color="orange" icon={<WarningTriangleIcon />}>
{t("temporaryLocked")}
</Label>
)}
{user.enabled && !user.bruteForceStatus?.disabled && "—"}
</>
);
};
const ValidatedEmail = (user: UserRepresentation) => {
return (
<>
{!user.emailVerified && (
<Tooltip
key={`email-verified-${user.id}`}
content={<>{t("notVerified")}</>}
>
<ExclamationCircleIcon className="keycloak__user-section__email-verified" />
</Tooltip>
)}{" "}
{emptyFormatter()(user.email)}
</>
);
};
const goToCreate = () => navigate(toAddUser({ realm: realmName })); const goToCreate = () => navigate(toAddUser({ realm: realmName }));
if (!userStorage || !realm) { if (!userStorage || !realm) {
@ -386,11 +388,6 @@ export function UserDataTable() {
displayKey: "firstName", displayKey: "firstName",
cellFormatters: [emptyFormatter()], cellFormatters: [emptyFormatter()],
}, },
{
name: "status",
displayKey: "status",
cellRenderer: StatusRow,
},
]} ]}
/> />
</> </>