showEdit on Card

This make the Card consistent with the Datatable, and allow to hide the `edit` button on cards using the `showEdit` prop.
This commit is contained in:
Eric Burel 2018-01-26 17:57:15 +01:00 committed by GitHub
parent af4c44a2af
commit e85bbab894
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 canEdit = currentUser && collection.options.mutations.edit.check(currentUser, document);
const canEdit = showEdit && currentUser && collection.options.mutations.edit.check(currentUser, document);
return (
<div className={classNames(className, 'datacard', `datacard-${collection._name}`)}>
@ -146,10 +146,11 @@ Card.propTypes = {
document: PropTypes.object,
currentUser: PropTypes.object,
fields: PropTypes.array,
showEdit: PropTypes.bool
}
Card.contextTypes = {
intl: intlShape
}
registerComponent('Card', Card);
registerComponent('Card', Card);