changed id of dropdown (#17512)
fixes: https://github.com/keycloak/keycloak-ui/issues/4483
This commit is contained in:
parent
f71acc1d1f
commit
d7388c479b
4 changed files with 31 additions and 18 deletions
|
@ -407,6 +407,7 @@ export function KeycloakDataTable<T>({
|
||||||
<>
|
<>
|
||||||
{(loading || !noData || searching) && (
|
{(loading || !noData || searching) && (
|
||||||
<PaginatingTableToolbar
|
<PaginatingTableToolbar
|
||||||
|
id={ariaLabelKey}
|
||||||
count={rowLength}
|
count={rowLength}
|
||||||
first={first}
|
first={first}
|
||||||
max={max}
|
max={max}
|
||||||
|
|
|
@ -7,13 +7,18 @@ import { PropsWithChildren, ReactNode } from "react";
|
||||||
|
|
||||||
import { TableToolbar } from "./TableToolbar";
|
import { TableToolbar } from "./TableToolbar";
|
||||||
|
|
||||||
type TableToolbarProps = {
|
type KeycloakPaginationProps = {
|
||||||
|
id?: string;
|
||||||
count: number;
|
count: number;
|
||||||
first: number;
|
first: number;
|
||||||
max: number;
|
max: number;
|
||||||
onNextClick: (page: number) => void;
|
onNextClick: (page: number) => void;
|
||||||
onPreviousClick: (page: number) => void;
|
onPreviousClick: (page: number) => void;
|
||||||
onPerPageSelect: (max: number, first: number) => void;
|
onPerPageSelect: (max: number, first: number) => void;
|
||||||
|
variant?: "top" | "bottom";
|
||||||
|
};
|
||||||
|
|
||||||
|
type TableToolbarProps = KeycloakPaginationProps & {
|
||||||
searchTypeComponent?: ReactNode;
|
searchTypeComponent?: ReactNode;
|
||||||
toolbarItem?: ReactNode;
|
toolbarItem?: ReactNode;
|
||||||
subToolbar?: ReactNode;
|
subToolbar?: ReactNode;
|
||||||
|
@ -22,28 +27,20 @@ type TableToolbarProps = {
|
||||||
inputGroupOnEnter?: (value: string) => void;
|
inputGroupOnEnter?: (value: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PaginatingTableToolbar = ({
|
const KeycloakPagination = ({
|
||||||
|
id,
|
||||||
|
variant = "top",
|
||||||
count,
|
count,
|
||||||
first,
|
first,
|
||||||
max,
|
max,
|
||||||
onNextClick,
|
onNextClick,
|
||||||
onPreviousClick,
|
onPreviousClick,
|
||||||
onPerPageSelect,
|
onPerPageSelect,
|
||||||
searchTypeComponent,
|
}: KeycloakPaginationProps) => {
|
||||||
toolbarItem,
|
|
||||||
subToolbar,
|
|
||||||
children,
|
|
||||||
inputGroupName,
|
|
||||||
inputGroupPlaceholder,
|
|
||||||
inputGroupOnEnter,
|
|
||||||
}: PropsWithChildren<TableToolbarProps>) => {
|
|
||||||
const page = Math.round(first / max);
|
const page = Math.round(first / max);
|
||||||
const KeycloakPagination = ({
|
return (
|
||||||
variant = "top",
|
|
||||||
}: {
|
|
||||||
variant?: "top" | "bottom";
|
|
||||||
}) => (
|
|
||||||
<Pagination
|
<Pagination
|
||||||
|
widgetId={id}
|
||||||
isCompact
|
isCompact
|
||||||
toggleTemplate={({ firstIndex, lastIndex }: ToggleTemplateProps) => (
|
toggleTemplate={({ firstIndex, lastIndex }: ToggleTemplateProps) => (
|
||||||
<b>
|
<b>
|
||||||
|
@ -59,7 +56,19 @@ export const PaginatingTableToolbar = ({
|
||||||
variant={variant}
|
variant={variant}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const PaginatingTableToolbar = ({
|
||||||
|
count,
|
||||||
|
searchTypeComponent,
|
||||||
|
toolbarItem,
|
||||||
|
subToolbar,
|
||||||
|
children,
|
||||||
|
inputGroupName,
|
||||||
|
inputGroupPlaceholder,
|
||||||
|
inputGroupOnEnter,
|
||||||
|
...rest
|
||||||
|
}: PropsWithChildren<TableToolbarProps>) => {
|
||||||
return (
|
return (
|
||||||
<TableToolbar
|
<TableToolbar
|
||||||
searchTypeComponent={searchTypeComponent}
|
searchTypeComponent={searchTypeComponent}
|
||||||
|
@ -67,7 +76,7 @@ export const PaginatingTableToolbar = ({
|
||||||
<>
|
<>
|
||||||
{toolbarItem}
|
{toolbarItem}
|
||||||
<ToolbarItem variant="pagination">
|
<ToolbarItem variant="pagination">
|
||||||
<KeycloakPagination />
|
<KeycloakPagination count={count} {...rest} />
|
||||||
</ToolbarItem>
|
</ToolbarItem>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
@ -75,7 +84,7 @@ export const PaginatingTableToolbar = ({
|
||||||
toolbarItemFooter={
|
toolbarItemFooter={
|
||||||
count !== 0 ? (
|
count !== 0 ? (
|
||||||
<ToolbarItem>
|
<ToolbarItem>
|
||||||
<KeycloakPagination variant="bottom" />
|
<KeycloakPagination count={count} variant="bottom" {...rest} />
|
||||||
</ToolbarItem>
|
</ToolbarItem>
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ export const AddEventTypesDialog = ({
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<EventsTypeTable
|
<EventsTypeTable
|
||||||
|
ariaLabelKey="addTypes"
|
||||||
onSelect={(selected) => setSelectedTypes(selected)}
|
onSelect={(selected) => setSelectedTypes(selected)}
|
||||||
eventTypes={enums!["eventType"].filter(
|
eventTypes={enums!["eventType"].filter(
|
||||||
(type) => !configured.includes(type)
|
(type) => !configured.includes(type)
|
||||||
|
|
|
@ -9,6 +9,7 @@ export type EventType = {
|
||||||
};
|
};
|
||||||
|
|
||||||
type EventsTypeTableProps = {
|
type EventsTypeTableProps = {
|
||||||
|
ariaLabelKey?: string;
|
||||||
eventTypes: string[];
|
eventTypes: string[];
|
||||||
addTypes?: () => void;
|
addTypes?: () => void;
|
||||||
onSelect?: (value: EventType[]) => void;
|
onSelect?: (value: EventType[]) => void;
|
||||||
|
@ -16,6 +17,7 @@ type EventsTypeTableProps = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function EventsTypeTable({
|
export function EventsTypeTable({
|
||||||
|
ariaLabelKey = "userEventsRegistered",
|
||||||
eventTypes,
|
eventTypes,
|
||||||
addTypes,
|
addTypes,
|
||||||
onSelect,
|
onSelect,
|
||||||
|
@ -29,7 +31,7 @@ export function EventsTypeTable({
|
||||||
}));
|
}));
|
||||||
return (
|
return (
|
||||||
<KeycloakDataTable
|
<KeycloakDataTable
|
||||||
ariaLabelKey="userEventsRegistered"
|
ariaLabelKey={ariaLabelKey}
|
||||||
searchPlaceholderKey="realm-settings:searchEventType"
|
searchPlaceholderKey="realm-settings:searchEventType"
|
||||||
loader={data}
|
loader={data}
|
||||||
onSelect={onSelect ? onSelect : undefined}
|
onSelect={onSelect ? onSelect : undefined}
|
||||||
|
|
Loading…
Reference in a new issue