Added hint when no user found (#2257)

This commit is contained in:
Erik Jan de Wit 2022-03-15 10:44:46 +01:00 committed by GitHub
parent 49c77c20cd
commit ceffcba321
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 6 deletions

View file

@ -7,7 +7,7 @@ import {
} from "@patternfly/react-core";
export type AlertType = {
key: number;
key: string;
message: string;
variant: AlertVariant;
description?: string;
@ -15,7 +15,7 @@ export type AlertType = {
type AlertPanelProps = {
alerts: AlertType[];
onCloseAlert: (key: number) => void;
onCloseAlert: (key: string) => void;
};
export function AlertPanel({ alerts, onCloseAlert }: AlertPanelProps) {

View file

@ -26,9 +26,9 @@ export const AlertProvider: FunctionComponent = ({ children }) => {
const [alerts, setAlerts] = useState<AlertType[]>([]);
const setTimeout = useSetTimeout();
const createId = () => new Date().getTime();
const createId = () => Math.random().toString(16);
const hideAlert = (key: number) => {
const hideAlert = (key: string) => {
setAlerts((alerts) => [...alerts.filter((el) => el.key !== key)]);
};

View file

@ -61,7 +61,7 @@ export default function UsersSection() {
const [selectedRows, setSelectedRows] = useState<UserRepresentation[]>([]);
const [key, setKey] = useState("");
const refresh = () => setKey(`${new Date().getTime()}`);
const refresh = () => setKey(key + 1);
useFetch(
async () => {
@ -129,7 +129,11 @@ export default function UsersSection() {
}
return users;
} catch (error) {
addError("users:noUsersFoundError", error);
if (userStorage?.length) {
addError("users:noUsersFoundErrorStorage", error);
} else {
addError("users:noUsersFoundError", error);
}
return [];
}
};

View file

@ -10,6 +10,8 @@ export default {
createNewUser: "Create new user",
noUsersFound: "No users found",
noUsersFoundError: "No users found due to {{error}}",
noUsersFoundErrorStorage:
"No users found, could be due to wrongly configured federated provider {{error}}",
noGroups: "No groups",
noGroupsText:
"You haven't added this user to any groups. Join a group to get started.",