Merge pull request #1836 from eric-burel/patch-1

showEdit on Card
This commit is contained in:
Michel Herszak 2018-01-26 16:22:55 -07:00 committed by GitHub
commit a5a560eb21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -119,10 +119,10 @@ const CardEditForm = ({ collection, document, closeModal }) =>
}} }}
/> />
const Card = ({className, collection, document, currentUser, fields}, {intl}) => { const Card = ({className, collection, document, currentUser, fields, showEdit = true}, {intl}) => {
const fieldNames = fields ? fields : _.without(_.keys(document), '__typename'); const fieldNames = fields ? fields : _.without(_.keys(document), '__typename');
const canEdit = currentUser && collection.options.mutations.edit.check(currentUser, document); const canEdit = showEdit && currentUser && collection.options.mutations.edit.check(currentUser, document);
return ( return (
<div className={classNames(className, 'datacard', `datacard-${collection._name}`)}> <div className={classNames(className, 'datacard', `datacard-${collection._name}`)}>
@ -146,10 +146,11 @@ Card.propTypes = {
document: PropTypes.object, document: PropTypes.object,
currentUser: PropTypes.object, currentUser: PropTypes.object,
fields: PropTypes.array, fields: PropTypes.array,
showEdit: PropTypes.bool
} }
Card.contextTypes = { Card.contextTypes = {
intl: intlShape intl: intlShape
} }
registerComponent('Card', Card); registerComponent('Card', Card);