From e620e8e5fd995a836515f95a38258d023a82f0ae Mon Sep 17 00:00:00 2001 From: kunnu01 Date: Tue, 13 Aug 2019 14:59:35 +0530 Subject: [PATCH 1/6] remove bulkActions in V3 --- .../ra-ui-materialui/src/list/BulkActions.js | 202 ------------------ packages/ra-ui-materialui/src/list/index.js | 2 - 2 files changed, 204 deletions(-) delete mode 100644 packages/ra-ui-materialui/src/list/BulkActions.js diff --git a/packages/ra-ui-materialui/src/list/BulkActions.js b/packages/ra-ui-materialui/src/list/BulkActions.js deleted file mode 100644 index d6db1903602..00000000000 --- a/packages/ra-ui-materialui/src/list/BulkActions.js +++ /dev/null @@ -1,202 +0,0 @@ -import React, { - cloneElement, - Children, - Component, - isValidElement, -} from 'react'; -import PropTypes from 'prop-types'; -import { CSSTransition } from 'react-transition-group'; -import Menu from '@material-ui/core/Menu'; -import MenuItem from '@material-ui/core/MenuItem'; -import { withStyles, createStyles } from '@material-ui/core/styles'; -import FilterNoneIcon from '@material-ui/icons/FilterNone'; -import compose from 'recompose/compose'; -import classnames from 'classnames'; -import { translate } from 'ra-core'; - -import Button from '../button/Button'; -import BulkDeleteAction from './BulkDeleteAction'; - -const styles = theme => - createStyles({ - bulkActionsButton: { - opacity: 1, - transition: theme.transitions.create('opacity', { - easing: theme.transitions.easing.sharp, - duration: theme.transitions.duration.leavingScreen, - }), - '&.fade-enter': { - opacity: 0, - }, - '&.fade-enter-done': { - opacity: 1, - }, - '&.fade-exit': { - opacity: 0, - }, - '&.fade-exit-done': { - opacity: 0, - }, - }, - icon: { - marginRight: theme.spacing(1), - }, - }); - -const timeoutDurations = { - enter: 0, - exit: 300, -}; - -const sanitizeRestProps = ({ - basePath, - classes, - filterValues, - resource, - onUnselectItems, - ...rest -}) => rest; - -/** - * @deprecated pass a Fragment with button children as bulkActionButtons props instead - */ -class BulkActions extends Component { - state = { - isOpen: false, - activeAction: null, - }; - - componentDidMount() { - if (process.env.NODE_ENV !== 'production') { - // eslint-disable-next-line no-console - console.warn( - ' is deprecated. Use the bulkActionButtons prop instead.' - ); - } - } - - storeButtonRef = node => { - this.anchorElement = node; - }; - - handleClick = () => { - this.setState({ isOpen: true }); - }; - - handleClose = () => { - this.setState({ isOpen: false }); - }; - - handleLaunchAction = action => { - this.setState({ activeAction: action, isOpen: false }); - }; - - handleExitAction = () => { - this.setState({ activeAction: null }); - }; - - render() { - const { - basePath, - classes, - children, - className, - filterValues, - label, - resource, - selectedIds, - translate, - ...rest - } = this.props; - const { isOpen } = this.state; - - return ( - 0} - timeout={timeoutDurations} - mountOnEnter - unmountOnExit - classNames="fade" - > -
- - - {Children.map(children, (child, index) => - isValidElement(child) ? ( - - this.handleLaunchAction(index) - } - {...sanitizeRestProps(rest)} - > - {translate(child.props.label)} - - ) : null - )} - - {Children.map(children, (child, index) => - isValidElement(child) && - this.state.activeAction === index - ? cloneElement(child, { - basePath, - filterValues, - onExit: this.handleExitAction, - resource, - selectedIds, - }) - : null - )} -
-
- ); - } -} - -BulkActions.propTypes = { - basePath: PropTypes.string, - classes: PropTypes.object, - className: PropTypes.string, - children: PropTypes.node, - filterValues: PropTypes.object, // eslint-disable-line react/forbid-prop-types - label: PropTypes.string, - resource: PropTypes.string, - selectedIds: PropTypes.arrayOf(PropTypes.any), - translate: PropTypes.func.isRequired, -}; - -BulkActions.defaultProps = { - children: , - label: 'ra.action.bulk_actions', - selectedIds: [], -}; - -const EnhancedButton = compose( - withStyles(styles), - translate -)(BulkActions); - -export default EnhancedButton; diff --git a/packages/ra-ui-materialui/src/list/index.js b/packages/ra-ui-materialui/src/list/index.js index 6b6df1e9864..270a05acef8 100644 --- a/packages/ra-ui-materialui/src/list/index.js +++ b/packages/ra-ui-materialui/src/list/index.js @@ -1,4 +1,3 @@ -import BulkActions from './BulkActions'; import BulkActionsToolbar from './BulkActionsToolbar'; import BulkDeleteAction from './BulkDeleteAction'; import Datagrid from './Datagrid'; @@ -20,7 +19,6 @@ import SimpleList from './SimpleList'; import SingleFieldList from './SingleFieldList'; export { - BulkActions, BulkActionsToolbar, BulkDeleteAction, Datagrid, From f21345f26fa6952e8597cdd3217c2df5d3a497a6 Mon Sep 17 00:00:00 2001 From: kunnu01 Date: Tue, 13 Aug 2019 15:32:18 +0530 Subject: [PATCH 2/6] update Upgrade.md --- UPGRADE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/UPGRADE.md b/UPGRADE.md index 40d5b7e548b..3b37279ae42 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -173,6 +173,7 @@ Components deprecated in 2.X have been removed in 3.x. This includes: * `ViewTitle` (use `Title` instead) * `RecordTitle` (use `TitleForRecord` instead) * `TitleDeprecated` (use `Title` instead) +* `BulkActions` (use `BulkActionButtons` props instead) ## Replace papaparse with a lighter library From b55a852c46fbad3e5fa5f91ccc74828a26b734d0 Mon Sep 17 00:00:00 2001 From: kunnu01 Date: Tue, 13 Aug 2019 15:44:18 +0530 Subject: [PATCH 3/6] update Upgrade.md --- UPGRADE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index 3b37279ae42..8ece71b2420 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -173,7 +173,7 @@ Components deprecated in 2.X have been removed in 3.x. This includes: * `ViewTitle` (use `Title` instead) * `RecordTitle` (use `TitleForRecord` instead) * `TitleDeprecated` (use `Title` instead) -* `BulkActions` (use `BulkActionButtons` props instead) +* `BulkActions` (use the [`bulkActionButtons` prop](https://marmelab.com/react-admin/List.html#bulk-action-buttons) instead) ## Replace papaparse with a lighter library From f6b296cc1083b0134dad798b788655766908effb Mon Sep 17 00:00:00 2001 From: kunnu01 Date: Tue, 13 Aug 2019 17:27:54 +0530 Subject: [PATCH 4/6] remove bulkActions from List and ListToolbar --- packages/ra-ui-materialui/src/list/List.js | 22 +++++-------------- .../ra-ui-materialui/src/list/ListToolbar.js | 3 --- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/packages/ra-ui-materialui/src/list/List.js b/packages/ra-ui-materialui/src/list/List.js index 26b912752d3..f750892ad77 100644 --- a/packages/ra-ui-materialui/src/list/List.js +++ b/packages/ra-ui-materialui/src/list/List.js @@ -50,7 +50,6 @@ export const useStyles = makeStyles(theme => ({ const sanitizeRestProps = ({ actions, basePath, - bulkActions, changeListParams, children, classes, @@ -112,7 +111,6 @@ export const ListView = props => { aside, filter, filters, - bulkActions, bulkActionButtons, pagination, children, @@ -140,7 +138,6 @@ export const ListView = props => { filters={filters} {...controllerProps} actions={actions} - bulkActions={bulkActions} exporter={exporter} permanentFilter={filter} /> @@ -153,20 +150,15 @@ export const ListView = props => { })} key={version} > - {bulkActions !== false && - bulkActionButtons !== false && - bulkActionButtons && - !bulkActions && ( - - {bulkActionButtons} - - )} + {bulkActionButtons !== false && bulkActionButtons && ( + + {bulkActionButtons} + + )} {children && cloneElement(Children.only(children), { ...controllerProps, - hasBulkActions: - bulkActions !== false && - bulkActionButtons !== false, + hasBulkActions: bulkActionButtons !== false, })} {pagination && cloneElement(pagination, controllerProps)} @@ -180,7 +172,6 @@ ListView.propTypes = { actions: PropTypes.element, aside: PropTypes.element, basePath: PropTypes.string, - bulkActions: PropTypes.oneOfType([PropTypes.bool, PropTypes.element]), bulkActionButtons: PropTypes.oneOfType([PropTypes.bool, PropTypes.element]), children: PropTypes.element, className: PropTypes.string, @@ -275,7 +266,6 @@ List.propTypes = { // the props you can change actions: PropTypes.element, aside: PropTypes.element, - bulkActions: PropTypes.oneOfType([PropTypes.element, PropTypes.bool]), bulkActionButtons: PropTypes.oneOfType([PropTypes.element, PropTypes.bool]), children: PropTypes.node, classes: PropTypes.object, diff --git a/packages/ra-ui-materialui/src/list/ListToolbar.js b/packages/ra-ui-materialui/src/list/ListToolbar.js index a1be2c08d25..9f9feab7b80 100644 --- a/packages/ra-ui-materialui/src/list/ListToolbar.js +++ b/packages/ra-ui-materialui/src/list/ListToolbar.js @@ -34,7 +34,6 @@ const ListToolbar = ({ filterValues, // dynamically set via the UI by the user permanentFilter, // set in the List component by the developer actions, - bulkActions, exporter, ...rest }) => { @@ -52,7 +51,6 @@ const ListToolbar = ({ React.cloneElement(actions, { ...rest, className: styles.actions, - bulkActions, exporter, filters, filterValues, @@ -68,7 +66,6 @@ ListToolbar.propTypes = { filters: PropTypes.element, permanentFilter: PropTypes.object, actions: PropTypes.element, - bulkActions: PropTypes.oneOfType([PropTypes.element, PropTypes.bool]), exporter: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]), }; From 5fcae42d15a0f3ed8279258bd59429834fd1dc8e Mon Sep 17 00:00:00 2001 From: kunnu01 Date: Tue, 13 Aug 2019 17:42:21 +0530 Subject: [PATCH 5/6] remove bulkActions from ListActions --- packages/ra-ui-materialui/src/list/ListActions.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/packages/ra-ui-materialui/src/list/ListActions.js b/packages/ra-ui-materialui/src/list/ListActions.js index c41233e2fc9..cdf63ef0b60 100644 --- a/packages/ra-ui-materialui/src/list/ListActions.js +++ b/packages/ra-ui-materialui/src/list/ListActions.js @@ -6,7 +6,6 @@ import TopToolbar from '../layout/TopToolbar'; import { CreateButton, ExportButton } from '../button'; const ListActions = ({ - bulkActions, currentSort, className, resource, @@ -26,14 +25,6 @@ const ListActions = ({ useMemo( () => ( - {bulkActions && - cloneElement(bulkActions, { - basePath, - filterValues, - resource, - selectedIds, - onUnselectItems, - })} {filters && cloneElement(filters, { resource, @@ -58,7 +49,6 @@ const ListActions = ({ ); ListActions.propTypes = { - bulkActions: PropTypes.oneOfType([PropTypes.element, PropTypes.bool]), basePath: PropTypes.string, className: PropTypes.string, currentSort: PropTypes.object, From 26ff71f0e75dc00f98826dc3a8d0a09551310860 Mon Sep 17 00:00:00 2001 From: kunnu01 Date: Tue, 20 Aug 2019 08:41:51 +0530 Subject: [PATCH 6/6] add diff in Upgarde.md --- UPGRADE.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 8ece71b2420..9e6b12a4376 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -175,6 +175,32 @@ Components deprecated in 2.X have been removed in 3.x. This includes: * `TitleDeprecated` (use `Title` instead) * `BulkActions` (use the [`bulkActionButtons` prop](https://marmelab.com/react-admin/List.html#bulk-action-buttons) instead) +```diff +- const PostBulkActions = props => ( +- +- +- {/* Add the default bulk delete action */} +- +- +- ); ++ const PostBulkActionButtons = props => ( ++ ++ ++ {/* Add the default bulk delete action */} ++ ++ ++ ); + +export const PostList = (props) => ( + } ++ bulkActionButtons={}> + ... + +); +``` + ## Replace papaparse with a lighter library React-admin used to bundle the `papaparse` library for converting JSON to CSV. But 90% of the `papaparse` code is used to convert CSV to JSON.