From 6a42e3be1f424a9a0e8fbc87a0308aa327a09b37 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Sat, 28 Apr 2018 23:38:05 -0500 Subject: [PATCH] Reuse default TableHeadingCellContainer for local plugin --- .../components/TableHeadingCellContainer.js | 75 +------------------ src/plugins/local/components/index.js | 2 +- 2 files changed, 4 insertions(+), 73 deletions(-) diff --git a/src/plugins/local/components/TableHeadingCellContainer.js b/src/plugins/local/components/TableHeadingCellContainer.js index 815b0e87..cf3847c7 100644 --- a/src/plugins/local/components/TableHeadingCellContainer.js +++ b/src/plugins/local/components/TableHeadingCellContainer.js @@ -1,75 +1,6 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { connect } from '../../../utils/griddleConnect'; -import compose from 'recompose/compose'; -import mapProps from 'recompose/mapProps'; -import getContext from 'recompose/getContext'; -import withHandlers from 'recompose/withHandlers'; -import { sortPropertyByIdSelector, iconsForComponentSelector, customHeadingComponentSelector, stylesForComponentSelector, classNamesForComponentSelector, cellPropertiesSelector } from '../../../selectors/dataSelectors'; -import { setSortColumn } from '../../../actions'; -import { combineHandlers } from '../../../utils/compositionUtils'; -import { getSortIconProps, setSortProperties } from '../../../utils/sortUtils'; -import { valueOrResult } from '../../../utils/valueUtils'; +import TableHeadingCellContainer from '../../../components/TableHeadingCellContainer'; -const DefaultTableHeadingCellContent = ({title, icon, iconClassName}) => ( - - { title } - { icon && {icon} } - -) - -const EnhancedHeadingCell = OriginalComponent => compose( - getContext({ - events: PropTypes.object, - selectors: PropTypes.object, - }), - connect( - (state, props) => ({ - sortProperty: sortPropertyByIdSelector(state, props), - customHeadingComponent: customHeadingComponentSelector(state, props), - cellProperties: cellPropertiesSelector(state, props), - className: classNamesForComponentSelector(state, 'TableHeadingCell'), - sortAscendingClassName: classNamesForComponentSelector(state, 'TableHeadingCellAscending'), - sortDescendingClassName: classNamesForComponentSelector(state, 'TableHeadingCellDescending'), - style: stylesForComponentSelector(state, 'TableHeadingCell'), - ...iconsForComponentSelector(state, 'TableHeadingCell'), - }), - (dispatch, { events: { onSort } }) => ({ - setSortColumn: combineHandlers([ - onSort, - compose(dispatch, setSortColumn), - ]), - }) - ), - withHandlers(props => ({ - onClick: props.cellProperties.sortable === false ? (() => () => {}) : - props.events.setSortProperties || setSortProperties, - })), - //TODO: use with props on change or something more performant here - mapProps(props => { - const iconProps = getSortIconProps(props); - const title = props.customHeadingComponent ? - : - ; - const className = valueOrResult(props.cellProperties.headerCssClassName, props) || props.className; - const style = { - ...(props.cellProperties.sortable === false || { cursor: 'pointer' }), - ...props.style, - }; - - return { - ...props.cellProperties.extraData, - ...props, - ...iconProps, - title, - style, - className - }; - }) -)(props => - -); +// Obsolete +const EnhancedHeadingCell = TableHeadingCellContainer; export default EnhancedHeadingCell; diff --git a/src/plugins/local/components/index.js b/src/plugins/local/components/index.js index fdfe2a65..36a253d7 100644 --- a/src/plugins/local/components/index.js +++ b/src/plugins/local/components/index.js @@ -13,5 +13,5 @@ export default { PreviousButtonContainer, PageDropdownContainer, TableContainer, - TableHeadingCellContainer, + TableHeadingCellContainer, // TODO: Obsolete; remove };