Skip to content

Commit

Permalink
Merge pull request #6060 from jvert/master
Browse files Browse the repository at this point in the history
fix #6050 - type definition for Datagrid rowClick property doesn't allow for functions that return Promise<string>
  • Loading branch information
djhi committed Mar 23, 2021
2 parents 9140b41 + 31a9076 commit 3e48fa5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
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;
) => 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,
};

0 comments on commit 3e48fa5

Please sign in to comment.