UNPKG

admin-on-rest-fr05t1k

Version:

A frontend Framework for building admin applications on top of REST services, using ES6, React and Material UI

35 lines (30 loc) 1.09 kB
import React, { PropTypes } from 'react'; import { Link } from 'react-router'; import shouldUpdate from 'recompose/shouldUpdate'; import compose from 'recompose/compose'; import FlatButton from 'material-ui/FlatButton'; import ContentCreate from 'material-ui/svg-icons/content/create'; import linkToRecord from '../../util/linkToRecord'; import translate from '../../i18n/translate'; const EditButton = ({ basePath = '', label = 'aor.action.edit', record = {}, translate }) => <FlatButton primary label={label && translate(label)} icon={<ContentCreate />} containerElement={<Link to={linkToRecord(basePath, record.id)} />} style={{ overflow: 'inherit' }} />; EditButton.propTypes = { basePath: PropTypes.string, label: PropTypes.string, record: PropTypes.object, translate: PropTypes.func.isRequired, }; const enhance = compose( shouldUpdate((props, nextProps) => props.record && props.record.id !== nextProps.record.id || props.basePath !== nextProps.basePath ), translate, ); export default enhance(EditButton);