parent
33a29d4735
commit
c45de338c0
2 changed files with 10 additions and 6 deletions
|
@ -16,13 +16,13 @@ import { Spinner } from "@patternfly/react-core";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
|
||||||
import { PaginatingTableToolbar } from "./PaginatingTableToolbar";
|
import { PaginatingTableToolbar } from "./PaginatingTableToolbar";
|
||||||
import { TableToolbar } from "./TableToolbar";
|
|
||||||
import { asyncStateFetch } from "../../context/auth/AdminClient";
|
import { asyncStateFetch } from "../../context/auth/AdminClient";
|
||||||
import { ListEmptyState } from "../list-empty-state/ListEmptyState";
|
import { ListEmptyState } from "../list-empty-state/ListEmptyState";
|
||||||
|
|
||||||
type Row<T> = {
|
type Row<T> = {
|
||||||
data: T;
|
data: T;
|
||||||
selected: boolean;
|
selected: boolean;
|
||||||
|
disableSelection: boolean;
|
||||||
cells: (keyof T | JSX.Element)[];
|
cells: (keyof T | JSX.Element)[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,6 +89,7 @@ export type DataListProps<T> = {
|
||||||
loader: (first?: number, max?: number, search?: string) => Promise<T[]>;
|
loader: (first?: number, max?: number, search?: string) => Promise<T[]>;
|
||||||
onSelect?: (value: T[]) => void;
|
onSelect?: (value: T[]) => void;
|
||||||
canSelectAll?: boolean;
|
canSelectAll?: boolean;
|
||||||
|
isRowDisabled?: (value: T) => boolean;
|
||||||
isPaginated?: boolean;
|
isPaginated?: boolean;
|
||||||
ariaLabelKey: string;
|
ariaLabelKey: string;
|
||||||
searchPlaceholderKey?: string;
|
searchPlaceholderKey?: string;
|
||||||
|
@ -128,6 +129,7 @@ export function KeycloakDataTable<T>({
|
||||||
isPaginated = false,
|
isPaginated = false,
|
||||||
onSelect,
|
onSelect,
|
||||||
canSelectAll = false,
|
canSelectAll = false,
|
||||||
|
isRowDisabled,
|
||||||
loader,
|
loader,
|
||||||
columns,
|
columns,
|
||||||
actions,
|
actions,
|
||||||
|
@ -191,6 +193,7 @@ export function KeycloakDataTable<T>({
|
||||||
return data!.map((value) => {
|
return data!.map((value) => {
|
||||||
return {
|
return {
|
||||||
data: value,
|
data: value,
|
||||||
|
disableSelection: isRowDisabled ? isRowDisabled(value) : false,
|
||||||
selected: !!selected.find((v) => (v as any).id === (value as any).id),
|
selected: !!selected.find((v) => (v as any).id === (value as any).id),
|
||||||
cells: columns.map((col) => {
|
cells: columns.map((col) => {
|
||||||
if (col.cellRenderer) {
|
if (col.cellRenderer) {
|
||||||
|
|
|
@ -59,19 +59,20 @@ export const PaginatingTableToolbar = ({
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
if (count === 0) {
|
|
||||||
<>{children}</>;
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<TableToolbar
|
<TableToolbar
|
||||||
searchTypeComponent={searchTypeComponent}
|
searchTypeComponent={searchTypeComponent}
|
||||||
toolbarItem={
|
toolbarItem={
|
||||||
<>
|
<>
|
||||||
{toolbarItem}
|
{toolbarItem}
|
||||||
<ToolbarItem variant="pagination">{pagination()}</ToolbarItem>
|
{count !== 0 && (
|
||||||
|
<ToolbarItem variant="pagination">{pagination()}</ToolbarItem>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
toolbarItemFooter={<ToolbarItem>{pagination("bottom")}</ToolbarItem>}
|
toolbarItemFooter={
|
||||||
|
count !== 0 ? <ToolbarItem>{pagination("bottom")}</ToolbarItem> : <></>
|
||||||
|
}
|
||||||
inputGroupName={inputGroupName}
|
inputGroupName={inputGroupName}
|
||||||
inputGroupPlaceholder={inputGroupPlaceholder}
|
inputGroupPlaceholder={inputGroupPlaceholder}
|
||||||
inputGroupOnChange={inputGroupOnChange}
|
inputGroupOnChange={inputGroupOnChange}
|
||||||
|
|
Loading…
Reference in a new issue