Skip to content

Commit

Permalink
Merge pull request #462 from creative-commoners/pulls/4.0/show-placeh…
Browse files Browse the repository at this point in the history
…older

ENH Add placeholder when no summary content available
  • Loading branch information
robbieaverill committed Oct 19, 2018
2 parents 1c67e27 + 2cf7d6e commit 976fb1f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions client/src/components/ElementEditor/Summary.js
@@ -1,8 +1,21 @@
import React, { PureComponent, PropTypes } from 'react';
import i18n from 'i18n';

class Summary extends PureComponent {
/**
* Renders a preview of the Element's content, allowing for either a simple
* image, or a section of text content (or both). For an Element with only a
* file, we do NOT wish to render the "no preview available" filler content.
* Elements with content and/or a file should always show the text and/or
* the image.
* - if there is a file, show that.
* - if there is text, show that.
* - if there is a file and text show both.
* - if there is no file, and no text, substitute and show "no preview" text.
*/
render() {
const { fileUrl, fileTitle, content } = this.props;
const noContent = i18n._t('Summary.NO_PREVIEW', 'No preview available');

return (

Expand All @@ -16,7 +29,7 @@ class Summary extends PureComponent {
}
{(content || !fileUrl) &&
<p className="element-editor-summary__content">
{content}
{content || noContent}
</p>
}
</div>
Expand All @@ -34,4 +47,3 @@ Summary.propTypes = {
};

export default Summary;

0 comments on commit 976fb1f

Please sign in to comment.