Wire up media gallery empty state

This commit is contained in:
Daniel Gasienica 2018-04-26 19:06:48 -04:00
parent 4d01264c09
commit fa45656e8e
3 changed files with 37 additions and 1 deletions

View file

@ -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
const DAY_MS = 24 * 60 * 60 * 1000;
const MONTH_MS = 30 * DAY_MS;

View file

@ -7,9 +7,11 @@ import moment from 'moment';
import { AttachmentSection } from './AttachmentSection';
import { AttachmentType } from './types/AttachmentType';
import { EmptyState } from './EmptyState';
import { groupMessagesByDate } from './groupMessagesByDate';
import { ItemClickEvent } from './types/ItemClickEvent';
import { Message } from './types/Message';
import { missingCaseError } from '../../../util/missingCaseError';
interface Props {
documents: Array<Message>;
@ -135,7 +137,19 @@ export class MediaGallery extends React.Component<Props, State> {
const type = selectedTab;
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();