Browse Source

refactor Attachment component options

Yuki Takei 6 years ago
parent
commit
fe8c3c65ad
1 changed files with 8 additions and 4 deletions
  1. 8 4
      src/client/js/components/PageAttachment/Attachment.jsx

+ 8 - 4
src/client/js/components/PageAttachment/Attachment.jsx

@@ -20,7 +20,9 @@ export default class Attachment extends React.Component {
   }
   }
 
 
   _onAttachmentDeleteClicked(event) {
   _onAttachmentDeleteClicked(event) {
-    this.props.onAttachmentDeleteClicked(this.props.attachment);
+    if (this.props.onAttachmentDeleteClicked != null) {
+      this.props.onAttachmentDeleteClicked(this.props.attachment);
+    }
   }
   }
 
 
   render() {
   render() {
@@ -73,10 +75,12 @@ export default class Attachment extends React.Component {
 
 
 Attachment.propTypes = {
 Attachment.propTypes = {
   attachment: PropTypes.object.isRequired,
   attachment: PropTypes.object.isRequired,
-  inUse: PropTypes.bool.isRequired,
-  onAttachmentDeleteClicked: PropTypes.func.isRequired,
-  isUserLoggedIn: PropTypes.bool.isRequired,
+  inUse: PropTypes.bool,
+  onAttachmentDeleteClicked: PropTypes.func,
+  isUserLoggedIn: PropTypes.bool,
 };
 };
 
 
 Attachment.defaultProps = {
 Attachment.defaultProps = {
+  inUse: false,
+  isUserLoggedIn: false,
 };
 };