Wire up media gallery empty state
This commit is contained in:
parent
4d01264c09
commit
fa45656e8e
3 changed files with 37 additions and 1 deletions
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue