Skip to content

Commit

Permalink
Revert changes related to ListActions and updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
asvarcas committed Jun 7, 2021
1 parent c859fc1 commit dd8f78a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
20 changes: 13 additions & 7 deletions docs/List.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,29 @@ You can add extra actions to a `<List>` by using the `actions` prop:

```jsx
import * as React from 'react';
import { cloneElement } from 'react';
import { List, ListActions, Button } from 'react-admin';
import IconEvent from '@material-ui/icons/Event';

const CustomListActions = (props) => (
<ListActions {...props}>
const ListActions = (props) => (
<TopToolbar>
{cloneElement(props.filters, { context: 'button' })}
<CreateButton/>
<ExportButton/>
{/* Add your custom actions */}
<Button
onClick={() => { alert('Your custom action'); }}
label="Show calendar"
>
<IconEvent />
<IconEvent/>
</Button>
</ListActions>
</TopToolbar>
);

export const PostList = (props) => (
<List {...props} actions={<CustomListActions />}>
...
</List>
<List {...props} actions={<ListActions/>}>
...
</List>
);
```

Expand All @@ -130,12 +134,14 @@ import {
ExportButton,
Button,
sanitizeListRestProps,
useListContext
} from 'react-admin';
import IconEvent from '@material-ui/icons/Event';

const ListActions = (props) => {
const {
className,
filters,
maxResults,
...rest
} = props;
Expand Down
9 changes: 3 additions & 6 deletions packages/ra-ui-materialui/src/list/ListActions.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { cloneElement, useMemo, FC, ReactElement, ReactNode } from 'react';
import { cloneElement, useMemo, FC, ReactElement } from 'react';
import PropTypes from 'prop-types';
import {
sanitizeListRestProps,
Expand Down Expand Up @@ -36,7 +36,7 @@ import { CreateButton, ExportButton } from '../button';
* total,
* } = useListContext();
*
* const PostCreateActions = ({ basePath }) => (
* const PostListActions = ({ basePath }) => (
* <TopToolbar>
* <CreateButton basePath={basePath} />
* <ExportButton
Expand All @@ -57,7 +57,7 @@ import { CreateButton, ExportButton } from '../button';
* );
*/
const ListActions: FC<ListActionsProps> = props => {
const { className, exporter, filters, children, ...rest } = props;
const { className, exporter, filters, ...rest } = props;
const {
currentSort,
displayedFilters,
Expand Down Expand Up @@ -89,7 +89,6 @@ const ListActions: FC<ListActionsProps> = props => {
filterValues={filterValues}
/>
)}
{children}
</TopToolbar>
),
[resource, displayedFilters, filterValues, selectedIds, filters, total] // eslint-disable-line react-hooks/exhaustive-deps
Expand All @@ -98,7 +97,6 @@ const ListActions: FC<ListActionsProps> = props => {

ListActions.propTypes = {
basePath: PropTypes.string,
children: PropTypes.node,
className: PropTypes.string,
currentSort: PropTypes.any,
displayedFilters: PropTypes.object,
Expand All @@ -119,7 +117,6 @@ ListActions.defaultProps = {
};

export interface ListActionsProps extends ToolbarProps {
children?: ReactNode;
currentSort?: SortPayload;
className?: string;
resource?: string;
Expand Down

0 comments on commit dd8f78a

Please sign in to comment.