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

View file

@ -26,9 +26,9 @@ export const AlertProvider: FunctionComponent = ({ children }) => {
const [alerts, setAlerts] = useState<AlertType[]>([]); const [alerts, setAlerts] = useState<AlertType[]>([]);
const setTimeout = useSetTimeout(); 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)]); setAlerts((alerts) => [...alerts.filter((el) => el.key !== key)]);
}; };

View file

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

View file

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