Przeglądaj źródła

render message when attachments is empty

Yuki Takei 6 lat temu
rodzic
commit
95646bc91d

+ 27 - 0
packages/growi-plugin-attachment-refs/src/client/js/components/AttachmentList.jsx

@@ -121,6 +121,28 @@ export default class AttachmentList extends React.Component {
 
 
   }
   }
 
 
+  renderNoAttachmentsMessage() {
+    const { refsContext } = this.props;
+
+    let message;
+
+    if (refsContext.prefix != null) {
+      message = `${refsContext.prefix} and descendant pages have no attachments`;
+    }
+    else {
+      message = `${refsContext.pagePath} has no attachments`;
+    }
+
+    return (
+      <div className="text-muted">
+        <small>
+          <i className="fa fa-fw fa-info-circle" aria-hidden="true"></i>
+          {message}
+        </small>
+      </div>
+    );
+  }
+
   renderContents() {
   renderContents() {
     const { refsContext } = this.props;
     const { refsContext } = this.props;
 
 
@@ -144,6 +166,11 @@ export default class AttachmentList extends React.Component {
     if (this.state.isLoaded) {
     if (this.state.isLoaded) {
       const { attachments } = this.state;
       const { attachments } = this.state;
 
 
+      // no attachments
+      if (attachments.length === 0) {
+        return this.renderNoAttachmentsMessage();
+      }
+
       return (refsContext.isExtractImg)
       return (refsContext.isExtractImg)
         ? <ExtractedAttachments attachments={attachments} refsContext={refsContext} />
         ? <ExtractedAttachments attachments={attachments} refsContext={refsContext} />
         : attachments.map((attachment) => {
         : attachments.map((attachment) => {