Skip to content

Commit

Permalink
adapt checkboxes prop in data table
Browse files Browse the repository at this point in the history
  • Loading branch information
joshri committed Jul 7, 2023
1 parent 60db89e commit a1a8c6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ui/components/CheckboxActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const DefaultSuspend: React.FC<{
);
};

type Action = {
export type Action = {
element: React.ReactElement;
additionalProps?: { [key: string]: any };
};
Expand Down
13 changes: 9 additions & 4 deletions ui/components/DataTable/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useHistory, useLocation } from "react-router-dom";
import styled from "styled-components";
import { ThemeTypes } from "../../contexts/AppContext";
import { IconButton } from "../Button";
import CheckboxActions from "../CheckboxActions";
import CheckboxActions, { Action } from "../CheckboxActions";
import ChipGroup from "../ChipGroup";
import FilterDialog, {
FilterConfig,
Expand All @@ -37,7 +37,6 @@ import {
toPairs,
} from "./helpers";
import { Field, FilterState } from "./types";

/** DataTable Properties */
export interface Props {
/** The ID of the table. */
Expand All @@ -50,7 +49,7 @@ export interface Props {
rows?: any[];
filters?: FilterConfig;
dialogOpen?: boolean;
hasCheckboxes?: boolean;
hasCheckboxes?: Action[] | boolean;
hideSearchAndFilters?: boolean;
emptyMessagePlaceholder?: React.ReactNode;
onColumnHeaderClick?: (field: Field) => void;
Expand Down Expand Up @@ -252,7 +251,13 @@ function UnstyledDataTable({
return (
<Flex wide tall column className={className}>
<TopBar wide align end>
{checkboxes && <CheckboxActions checked={checked} rows={filtered} />}
{checkboxes && (
<CheckboxActions
checked={checked}
rows={filtered}
actions={typeof checkboxes !== "boolean" && checkboxes}
/>
)}
{filters && !hideSearchAndFilters && (
<>
<ChipGroup
Expand Down

0 comments on commit a1a8c6b

Please sign in to comment.