From 67235dcc54d6aa215687dde31e334dab152df326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Thu, 7 Mar 2024 19:49:39 +0100 Subject: [PATCH] Change design of Backups page a bit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- src/features/backups/index.tsx | 88 +++++++++++++++++++++++----------- src/locales/en.json | 1 + src/reducers/backups.tsx | 4 +- 3 files changed, 64 insertions(+), 29 deletions(-) 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}