Skip to content

Commit

Permalink
Deprecate Table component
Browse files Browse the repository at this point in the history
The `Table` component has been deprecated in favor of [MUI X Data Grid](https://mui.com/x/react-data-grid/) in combination with `useDataGridRemote`. See [docs](https://storybook.comet-dxp.com/?path=/story/docs-components-table-basics--page) for further information.
  • Loading branch information
johnnyomair committed Sep 28, 2023
1 parent 236c5ed commit 6d4ca5b
Show file tree
Hide file tree
Showing 50 changed files with 255 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changeset/mighty-lizards-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@comet/admin": minor
---

Deprecate `Table` component

The `Table` component has been deprecated in favor of [MUI X Data Grid](https://mui.com/x/react-data-grid/) in combination with `useDataGridRemote`. See [docs](https://storybook.comet-dxp.com/?path=/story/docs-components-table-basics--page) for further information.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Meta, Canvas, Story, Source } from "@storybook/addon-docs";
import { Alert, Link } from "@mui/material";

import dedent from "ts-dedent";

<Meta title="Docs/Components/Table/Basics" />

**The `Table` component has been deprecated in favor of [MUI X Data Grid](https://mui.com/x/react-data-grid/) in combination with `useDataGridRemote`. View [docs](?path=/story/docs-components-datagrid--page).**

# Table

> Tables display information in a way that's easy to scan, so that users can look for patterns and insights.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import dedent from "ts-dedent";

<Meta title="Docs/Components/Table/TableQuery" />

**The `Table` component has been deprecated in favor of [MUI X Data Grid](https://mui.com/x/react-data-grid/) in combination with `useDataGridRemote`. View [docs](?path=/story/docs-components-datagrid--page).**

# TableQuery

To fill a `Table` with API data, you can use the `useTableQuery()` hook in combination with the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import dedent from "ts-dedent";

<Meta title="Docs/Components/Table/Sorting" />

**The `Table` component has been deprecated in favor of [MUI X Data Grid](https://mui.com/x/react-data-grid/) in combination with `useDataGridRemote`. View [docs](?path=/story/docs-components-datagrid--page).**

# Sorting

The `Table` component has built-in support for sorting by column.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import dedent from "ts-dedent";

<Meta title="Docs/Components/Table/Pagination" />

**The `Table` component has been deprecated in favor of [MUI X Data Grid](https://mui.com/x/react-data-grid/) in combination with `useDataGridRemote`. View [docs](?path=/story/docs-components-datagrid--page).**

# Pagination

The `Table` has built-in support for pagination.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Meta, Canvas, Story, Source } from "@storybook/addon-docs";

import dedent from "ts-dedent";

**The `Table` component has been deprecated in favor of [MUI X Data Grid](https://mui.com/x/react-data-grid/) in combination with `useDataGridRemote`. View [docs](?path=/story/docs-components-datagrid--page).**

<Meta title="Docs/Components/Table/Filterbar" />

# Filterbar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Meta, Canvas, Story, Source } from "@storybook/addon-docs";

import dedent from "ts-dedent";

**The `Table` component has been deprecated in favor of [MUI X Data Grid](https://mui.com/x/react-data-grid/) in combination with `useDataGridRemote`. View [docs](?path=/story/docs-components-datagrid--page).**

<Meta title="Docs/Components/Table/Excel Export" />

# Excel Export
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import dedent from "ts-dedent";

<Meta title="Docs/Components/Table/TableDndOrder" />

**The `Table` component has been deprecated in favor of [MUI X Data Grid](https://mui.com/x/react-data-grid/) in combination with `useDataGridRemote`. View [docs](?path=/story/docs-components-datagrid--page).**

# TableDndOrder

`TableDndOrder` is a special version of the `Table`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import dedent from "ts-dedent";

<Meta title="Docs/Components/Table/Selection Table" />

**The `Table` component has been deprecated in favor of [MUI X Data Grid](https://mui.com/x/react-data-grid/) in combination with `useDataGridRemote`. View [docs](?path=/story/docs-components-datagrid--page).**

# Selection Table

The `Table` component has a built-in [selection](/story/docs-components-selection--page) functionality.
Expand Down
3 changes: 3 additions & 0 deletions packages/admin/admin/src/table/AddButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ interface IProps {
selectionApi: ISelectionApi;
}

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export class TableAddButton extends React.Component<IProps> {
public render() {
return (
Expand Down
3 changes: 3 additions & 0 deletions packages/admin/admin/src/table/DeleteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ interface IProps {

const DeleteMessage = () => <FormattedMessage {...messages.delete} />;

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export class TableDeleteButton extends React.Component<IProps> {
public render() {
const { selectedId, mutation, refetchQueries, icon = <DeleteIcon />, text = <DeleteMessage />, color } = this.props;
Expand Down
3 changes: 3 additions & 0 deletions packages/admin/admin/src/table/ExcelExportButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ interface IProps {
loadingComponent?: React.ReactNode;
}

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export const ExcelExportButton: React.FunctionComponent<IProps> = ({ onClick, children, exportApi, loadingComponent }) => {
const onClickButtonPressed = () => {
if (onClick != null) {
Expand Down
3 changes: 3 additions & 0 deletions packages/admin/admin/src/table/LocalChangesToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ interface Props {
loading: boolean;
}

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export const TableLocalChangesToolbar = ({ tableLocalChangesApi, localChangesCount, updateMutation, loading }: Props) => {
const handleSaveClick = () => {
tableLocalChangesApi.submitLocalDataChanges();
Expand Down
3 changes: 3 additions & 0 deletions packages/admin/admin/src/table/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ interface IProps {
rowName?: string | ((count: number) => string);
}

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export const TablePagination: React.FunctionComponent<IProps> = ({ totalCount, pagingInfo, rowName }) => {
if (typeof rowName === "function") {
rowName = rowName(totalCount);
Expand Down
36 changes: 36 additions & 0 deletions packages/admin/admin/src/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import { safeColumnGet } from "./safeColumnGet";
import { TableBodyRow, TableBodyRowProps } from "./TableBodyRow";
import { ISortApi, SortDirection } from "./useTableQuerySort";

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export type ITableHeadRowProps<TRow extends IRow> = ITableHeadColumnsProps<TRow>;
function DefaultHeadTableRow<TRow extends IRow>({ columns, sortApi }: ITableHeadRowProps<TRow>) {
return (
Expand All @@ -25,11 +28,17 @@ function DefaultHeadTableRow<TRow extends IRow>({ columns, sortApi }: ITableHead
);
}

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export interface ITableHeadColumnsProps<TRow extends IRow> {
columns: Array<ITableColumn<TRow>>;
sortApi?: ISortApi;
}
// render default TableCell fragments for given columns
/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export function TableHeadColumns<TRow extends IRow>({ columns, sortApi }: ITableHeadColumnsProps<TRow>) {
const handleSortClick = (name: string, ev: React.MouseEvent) => {
if (sortApi) sortApi.changeSort(name);
Expand Down Expand Up @@ -60,11 +69,17 @@ export function TableHeadColumns<TRow extends IRow>({ columns, sortApi }: ITable
);
}

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export interface ITableColumnsProps<TRow extends IRow> {
row: TRow;
columns: Array<ITableColumn<TRow>>;
}
// render default TableCell fragments for given columns
/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export function TableColumns<TRow extends IRow>({ row, columns }: ITableColumnsProps<TRow>) {
return (
<>
Expand All @@ -79,15 +94,27 @@ export function TableColumns<TRow extends IRow>({ row, columns }: ITableColumnsP
</>
);
}
/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export interface IRow {
id: string | number;
}

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export enum VisibleType {
Browser = "browser",
Export = "export",
}
/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export type Visible = boolean | { [key in VisibleType]?: boolean };
/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export interface ITableColumn<TRow extends IRow> {
name: string;
visible?: Visible;
Expand All @@ -101,12 +128,18 @@ export interface ITableColumn<TRow extends IRow> {
headerProps?: TableCellProps;
}

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export interface ITableRowProps<TRow extends IRow> extends ITableColumnsProps<TRow> {
index: number;
key: any;
rowProps: TableBodyRowProps;
}

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export interface ITableProps<TRow extends IRow> {
data: TRow[];
totalCount: number;
Expand Down Expand Up @@ -134,6 +167,9 @@ function DefaultTableRow<TRow extends IRow>({ columns, row, rowProps }: ITableRo
);
}

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export class Table<TRow extends IRow> extends React.Component<ITableProps<TRow>> {
private domRef: React.RefObject<HTMLTableElement>;
constructor(props: ITableProps<TRow>) {
Expand Down
9 changes: 9 additions & 0 deletions packages/admin/admin/src/table/TableBodyRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ import { TableRowProps } from "@mui/material/TableRow";
import { createStyles, WithStyles, withStyles } from "@mui/styles";
import * as React from "react";

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export type TableBodyRowClassKey = "root" | "even" | "odd";

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export interface TableBodyRowProps extends TableRowProps {
index?: number;
hideTableHead?: boolean;
Expand All @@ -25,6 +31,9 @@ const Row = React.forwardRef<HTMLTableRowElement, TableBodyRowProps & WithStyles
},
);

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export const TableBodyRow = withStyles(styles, { name: "CometAdminTableBodyRow" })(Row);

declare module "@mui/material/styles" {
Expand Down
3 changes: 3 additions & 0 deletions packages/admin/admin/src/table/TableDndOrder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ const styles = () =>
},
});

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
const TableDndOrderWithStyles = withStyles(styles, { name: "CometAdminTableDndOrder" })(TableDndOrder);
export { TableDndOrderWithStyles as TableDndOrder };

Expand Down
3 changes: 3 additions & 0 deletions packages/admin/admin/src/table/TableFilterFinalForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ type Props<FilterValues = AnyObject> = Omit<FormProps<FilterValues>, "onSubmit"
filterApi: IFilterApi<FilterValues>;
};

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export class TableFilterFinalForm<FilterValues = AnyObject> extends React.Component<Props<FilterValues>> {
public render() {
// remove render, children and component from forwardProps as we define render and those would interfere
Expand Down
9 changes: 9 additions & 0 deletions packages/admin/admin/src/table/TableLocalChanges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import * as React from "react";

import { DirtyHandlerApiContext } from "../DirtyHandlerApiContext";

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export async function submitChangesWithMutation(options: {
changes: { [id: string]: object };
variables?: object;
Expand All @@ -22,6 +25,9 @@ export async function submitChangesWithMutation(options: {
}
}

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export interface ITableLocalChangesApi {
setLocalDataChange: (id: string, column: string, value: any) => void;
moveRow: (dragIndex: number, hoverIndex: number) => void;
Expand All @@ -45,6 +51,9 @@ interface IState<TData> {
};
loading: boolean;
}
/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export class TableLocalChanges<TData extends { id: string; [key: string]: any }> extends React.Component<IProps<TData>, IState<TData>> {
public static contextType = DirtyHandlerApiContext;
protected static defaultProps = {
Expand Down
3 changes: 3 additions & 0 deletions packages/admin/admin/src/table/TableQuery.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { createStyles } from "@mui/styles";

import { IProps } from "./TableQuery";

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export type TableQueryClassKey = "root" | "loadingContainer" | "loadingPaper";

export const styles = ({ zIndex }: Theme) => {
Expand Down
9 changes: 9 additions & 0 deletions packages/admin/admin/src/table/TableQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ import { Loading } from "../common/Loading";
import { styles, TableQueryClassKey } from "./TableQuery.styles";
import { ITableQueryApi, TableQueryContext } from "./TableQueryContext";

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export const parseIdFromIri = (iri: string) => {
const m = iri.match(/\/(\d+)/);
if (!m) return null;
return m[1];
};

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface IDefaultVariables {}

Expand Down Expand Up @@ -57,6 +63,9 @@ export function Query({ classes, ...otherProps }: IProps & WithStyles<typeof sty
);
}

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export const TableQuery = withStyles(styles, { name: "CometAdminTableQuery" })(Query);

declare module "@mui/material/styles" {
Expand Down
9 changes: 9 additions & 0 deletions packages/admin/admin/src/table/TableQueryContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import * as React from "react";

import { ITableData } from "./useTableQuery";

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export interface ITableQueryApi {
getVariables: () => object;
getInnerOptions: () => object;
Expand All @@ -12,8 +15,14 @@ export interface ITableQueryApi {
onRowDeleted: () => void;
}

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export interface ITableQueryContext {
api: ITableQueryApi;
}

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export const TableQueryContext = React.createContext<ITableQueryContext | undefined>(undefined);
3 changes: 3 additions & 0 deletions packages/admin/admin/src/table/excelexport/IExportApi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { IRow, Table } from "../Table";

/**
* @deprecated Use MUI X Data Grid in combination with `useDataGridRemote` instead.
*/
export interface IExportApi<TRow extends IRow> {
loading: boolean;
progress?: number;
Expand Down
Loading

0 comments on commit 6d4ca5b

Please sign in to comment.