Wire up media gallery empty state
This commit is contained in:
parent
4d01264c09
commit
fa45656e8e
3 changed files with 37 additions and 1 deletions
|
@ -326,10 +326,18 @@
|
||||||
"message": "Media",
|
"message": "Media",
|
||||||
"description": "Header of the default pane in the media gallery, showing images and videos"
|
"description": "Header of the default pane in the media gallery, showing images and videos"
|
||||||
},
|
},
|
||||||
|
"mediaEmptyState": {
|
||||||
|
"message": "You don’t have any media in this conversation",
|
||||||
|
"description": "Message shown to user in the media gallery when there are no messages with media attachments (images or video)"
|
||||||
|
},
|
||||||
"documents": {
|
"documents": {
|
||||||
"message": "Documents",
|
"message": "Documents",
|
||||||
"description": "Header of the secondary pane in the media gallery, showing every non-media attachment"
|
"description": "Header of the secondary pane in the media gallery, showing every non-media attachment"
|
||||||
},
|
},
|
||||||
|
"documentsEmptyState": {
|
||||||
|
"message": "You don’t have any documents in this conversation",
|
||||||
|
"description": "Message shown to user in the media gallery when there are no messages with document attachments (anything other than images or video)"
|
||||||
|
},
|
||||||
"messageCaption": {
|
"messageCaption": {
|
||||||
"message": "Message caption",
|
"message": "Message caption",
|
||||||
"description": "Prefix of attachment alt tags in the media gallery"
|
"description": "Prefix of attachment alt tags in the media gallery"
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
### Empty states for missing media and documents
|
||||||
|
|
||||||
|
```
|
||||||
|
<div style={{width: '100%', height: 300}}>
|
||||||
|
<MediaGallery
|
||||||
|
i18n={window.i18n}
|
||||||
|
media={[]}
|
||||||
|
documents={[]}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Media gallery with media and documents
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
const DAY_MS = 24 * 60 * 60 * 1000;
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
||||||
const MONTH_MS = 30 * DAY_MS;
|
const MONTH_MS = 30 * DAY_MS;
|
||||||
|
|
|
@ -7,9 +7,11 @@ import moment from 'moment';
|
||||||
|
|
||||||
import { AttachmentSection } from './AttachmentSection';
|
import { AttachmentSection } from './AttachmentSection';
|
||||||
import { AttachmentType } from './types/AttachmentType';
|
import { AttachmentType } from './types/AttachmentType';
|
||||||
|
import { EmptyState } from './EmptyState';
|
||||||
import { groupMessagesByDate } from './groupMessagesByDate';
|
import { groupMessagesByDate } from './groupMessagesByDate';
|
||||||
import { ItemClickEvent } from './types/ItemClickEvent';
|
import { ItemClickEvent } from './types/ItemClickEvent';
|
||||||
import { Message } from './types/Message';
|
import { Message } from './types/Message';
|
||||||
|
import { missingCaseError } from '../../../util/missingCaseError';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
documents: Array<Message>;
|
documents: Array<Message>;
|
||||||
|
@ -135,7 +137,19 @@ export class MediaGallery extends React.Component<Props, State> {
|
||||||
const type = selectedTab;
|
const type = selectedTab;
|
||||||
|
|
||||||
if (!messages || messages.length === 0) {
|
if (!messages || messages.length === 0) {
|
||||||
return null;
|
const label = (() => {
|
||||||
|
switch (type) {
|
||||||
|
case 'media':
|
||||||
|
return i18n('mediaEmptyState');
|
||||||
|
|
||||||
|
case 'documents':
|
||||||
|
return i18n('documentsEmptyState');
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw missingCaseError(type);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
return <EmptyState data-test="EmptyState" label={label} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue