Fixed these 2 issues: (#741)

* fix order of alerts where the newest is on the top

* removed double loading indicator

* fixes showing old alerts again
This commit is contained in:
Erik Jan de Wit 2021-07-01 08:48:03 +02:00 committed by GitHub
parent dd07911a72
commit 1613331bba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 19 deletions

View file

@ -23,7 +23,6 @@ export function AlertPanel({ alerts, onCloseAlert }: AlertPanelProps) {
<AlertGroup isToast> <AlertGroup isToast>
{alerts.map(({ key, variant, message, description }) => ( {alerts.map(({ key, variant, message, description }) => (
<Alert <Alert
timeout={true}
key={key} key={key}
isLiveRegion isLiveRegion
variant={AlertVariant[variant]} variant={AlertVariant[variant]}

View file

@ -27,10 +27,12 @@ export const AlertProvider = ({ children }: { children: ReactNode }) => {
const addAlert = ( const addAlert = (
message: string, message: string,
variant: AlertVariant = AlertVariant.default, variant: AlertVariant = AlertVariant.success,
description?: string description?: string
) => { ) => {
setAlerts([...alerts, { key: createId(), message, variant, description }]); const key = createId();
setTimeout(() => hideAlert(key), 8000);
setAlerts([{ key, message, variant, description }, ...alerts]);
}; };
return ( return (

View file

@ -142,6 +142,7 @@ export type DataListProps<T> = Omit<
icon?: React.ComponentClass<SVGIconProps>; icon?: React.ComponentClass<SVGIconProps>;
isNotCompact?: boolean; isNotCompact?: boolean;
isRadio?: boolean; isRadio?: boolean;
isSearching?: boolean;
}; };
/** /**
@ -186,6 +187,7 @@ export function KeycloakDataTable<T>({
subToolbar, subToolbar,
emptyState, emptyState,
icon, icon,
isSearching = false,
...props ...props
}: DataListProps<T>) { }: DataListProps<T>) {
const { t } = useTranslation(); const { t } = useTranslation();
@ -256,7 +258,7 @@ export function KeycloakDataTable<T>({
? (node as TitleCell).title.props.children ? (node as TitleCell).title.props.children
: (node as TitleCell).title : (node as TitleCell).title
? (node as TitleCell).title ? (node as TitleCell).title
: (node as JSX.Element).props.children : (node as JSX.Element).props?.children
); );
} }
return ""; return "";
@ -375,8 +377,10 @@ export function KeycloakDataTable<T>({
return ( return (
<> <>
{!rows && loading && <Loading />} {((data && data.length > 0) ||
{((data && data.length > 0) || search !== "" || !emptyState) && ( search !== "" ||
isSearching ||
loading) && (
<PaginatingTableToolbar <PaginatingTableToolbar
count={data?.length || 0} count={data?.length || 0}
first={first} first={first}
@ -413,7 +417,7 @@ export function KeycloakDataTable<T>({
)} )}
{!loading && {!loading &&
(!data || data.length === 0) && (!data || data.length === 0) &&
(search !== "" || !emptyState) && (search !== "" || !isSearching) &&
searchPlaceholderKey && ( searchPlaceholderKey && (
<ListEmptyState <ListEmptyState
hasIcon={true} hasIcon={true}

View file

@ -272,19 +272,18 @@ export const KeysListTab = ({ realmComponents }: KeysListTabProps) => {
transforms: [cellWidth(20)], transforms: [cellWidth(20)],
}, },
]} ]}
isSearching={!!filterType}
emptyState={ emptyState={
filterType ? undefined : ( <ListEmptyState
<ListEmptyState hasIcon={true}
hasIcon={true} message={t("realm-settings:noKeys")}
message={t("realm-settings:noKeys")} instructions={
instructions={ t(`realm-settings:noKeysDescription`) +
t(`realm-settings:noKeysDescription`) + `${filterType.toLocaleLowerCase()}.`
`${filterType.toLocaleLowerCase()}.` }
} primaryActionText={t("createRole")}
primaryActionText={t("createRole")} onPrimaryAction={goToCreate}
onPrimaryAction={goToCreate} />
/>
)
} }
/> />
</PageSection> </PageSection>