diff --git a/src/components/alert/AlertPanel.tsx b/src/components/alert/AlertPanel.tsx index 6ff9791bcf..5367bd34bb 100644 --- a/src/components/alert/AlertPanel.tsx +++ b/src/components/alert/AlertPanel.tsx @@ -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) { diff --git a/src/components/alert/Alerts.tsx b/src/components/alert/Alerts.tsx index 793fb5ca7b..1fb35a0deb 100644 --- a/src/components/alert/Alerts.tsx +++ b/src/components/alert/Alerts.tsx @@ -26,9 +26,9 @@ export const AlertProvider: FunctionComponent = ({ children }) => { const [alerts, setAlerts] = useState([]); 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)]); }; diff --git a/src/user/UsersSection.tsx b/src/user/UsersSection.tsx index c3d9b07ab6..42cb5e1c4a 100644 --- a/src/user/UsersSection.tsx +++ b/src/user/UsersSection.tsx @@ -61,7 +61,7 @@ export default function UsersSection() { const [selectedRows, setSelectedRows] = useState([]); 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 []; } }; diff --git a/src/user/messages.ts b/src/user/messages.ts index 4432940fc1..a7005676a3 100644 --- a/src/user/messages.ts +++ b/src/user/messages.ts @@ -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.",