Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #6050 - type definition for Datagrid rowClick property doesn't allow for functions that return Promise<string> #6060

Merged
merged 2 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions packages/ra-ui-materialui/src/list/datagrid/Datagrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import DatagridLoading from './DatagridLoading';
import DatagridBody, { PureDatagridBody } from './DatagridBody';
import useDatagridStyles from './useDatagridStyles';
import { ClassesOverride } from '../../types';
import { RowClickFunction } from './DatagridRow';

/**
* The Datagrid component renders a list of records as a table.
Expand Down Expand Up @@ -355,12 +356,6 @@ Datagrid.propTypes = {
isRowSelectable: PropTypes.func,
};

type RowClickFunction = (
id: Identifier,
basePath: string,
record: Record
) => string;

export interface DatagridProps extends Omit<TableProps, 'size' | 'classes'> {
body?: ReactElement;
classes?: ClassesOverride<typeof useDatagridStyles>;
Expand Down
8 changes: 1 addition & 7 deletions packages/ra-ui-materialui/src/list/datagrid/DatagridBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import classnames from 'classnames';
import { shallowEqual } from 'react-redux';
import { Identifier, Record, RecordMap } from 'ra-core';

import DatagridRow, { PureDatagridRow } from './DatagridRow';
import DatagridRow, { PureDatagridRow, RowClickFunction } from './DatagridRow';
import useDatagridStyles from './useDatagridStyles';

const DatagridBody: FC<DatagridBodyProps> = React.forwardRef(
Expand Down Expand Up @@ -98,12 +98,6 @@ DatagridBody.defaultProps = {
row: <DatagridRow />,
};

type RowClickFunction = (
id: Identifier,
basePath: string,
record: Record
) => string;

export interface DatagridBodyProps extends Omit<TableBodyProps, 'classes'> {
basePath?: string;
classes?: ReturnType<typeof useDatagridStyles>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export type RowClickFunction = (
id: Identifier,
basePath: string,
record: Record
) => string;
jvert marked this conversation as resolved.
Show resolved Hide resolved
) => string | Promise<string>;

const areEqual = (prevProps, nextProps) => {
const { children: _1, expand: _2, ...prevPropsWithoutChildren } = prevProps;
Expand Down
7 changes: 6 additions & 1 deletion packages/ra-ui-materialui/src/list/datagrid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import DatagridHeaderCell, {
DatagridHeaderCellProps,
} from './DatagridHeaderCell';
import DatagridLoading, { DatagridLoadingProps } from './DatagridLoading';
import DatagridRow, { DatagridRowProps, PureDatagridRow } from './DatagridRow';
import DatagridRow, {
DatagridRowProps,
PureDatagridRow,
RowClickFunction,
} from './DatagridRow';
import ExpandRowButton, { ExpandRowButtonProps } from './ExpandRowButton';
import useDatagridStyles from './useDatagridStyles';

Expand All @@ -33,4 +37,5 @@ export type {
DatagridLoadingProps,
DatagridRowProps,
ExpandRowButtonProps,
RowClickFunction,
};