diff --git a/src/features/backups/index.tsx b/src/features/backups/index.tsx index 5e1dd705f..9cac7cb13 100644 --- a/src/features/backups/index.tsx +++ b/src/features/backups/index.tsx @@ -1,19 +1,58 @@ import React, { useEffect, useState } from 'react'; -import { defineMessages, useIntl } from 'react-intl'; +import { FormattedDate, defineMessages, useIntl } from 'react-intl'; import { fetchBackups, createBackup } from 'soapbox/actions/backups'; -import ScrollableList from 'soapbox/components/scrollable-list'; -import { Button, Column, FormActions, Text } from 'soapbox/components/ui'; +import { Button, Card, Column, FormActions, HStack, Spinner, Stack, Text } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; +import type { Backup as BackupEntity } from 'soapbox/reducers/backups'; + const messages = defineMessages({ heading: { id: 'column.backups', defaultMessage: 'Backups' }, create: { id: 'backups.actions.create', defaultMessage: 'Create backup' }, emptyMessage: { id: 'backups.empty_message', defaultMessage: 'No backups found. {action}' }, emptyMessageAction: { id: 'backups.empty_message.action', defaultMessage: 'Create one now?' }, + download: { id: 'backups.download', defaultMessage: 'Download' }, pending: { id: 'backups.pending', defaultMessage: 'Pending' }, }); +interface IBackup { + backup: BackupEntity; +} + +const Backup: React.FC = ({ backup }) => { + const intl = useIntl(); + + const button = ( + + ); + + return ( +
+ + + + + + + + {backup.processed ? {button} : button} + + +
+ ); +}; + const Backups = () => { const intl = useIntl(); const dispatch = useAppDispatch(); @@ -35,34 +74,29 @@ const Backups = () => { const showLoading = isLoading && backups.count() === 0; - const emptyMessageAction = ( - - - {intl.formatMessage(messages.emptyMessageAction)} - - + const emptyMessage = ( + + {intl.formatMessage(messages.emptyMessage, { + action: ( + + + {intl.formatMessage(messages.emptyMessageAction)} + + + ), + })} + + ); + + const body = showLoading ? : backups.isEmpty() ? emptyMessage : ( +
+ {backups.map((backup) => )} +
); return ( - - {backups.map((backup) => ( -
- {backup.processed - ? {backup.inserted_at} - : {intl.formatMessage(messages.pending)}: {backup.inserted_at} - } -
- ))} -
+ {body}