Skip to content

Commit ad9194a

Browse files
committed
Build out frontend for viewing server backups
1 parent 44ff99e commit ad9194a

File tree

2 files changed

+53
-7
lines changed

2 files changed

+53
-7
lines changed

resources/scripts/components/server/backups/BackupContainer.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { httpErrorToHuman } from '@/api/http';
77
import Can from '@/components/elements/Can';
88
import CreateBackupButton from '@/components/server/backups/CreateBackupButton';
99
import FlashMessageRender from '@/components/FlashMessageRender';
10+
import BackupRow from '@/components/server/backups/BackupRow';
1011

1112
export default () => {
1213
const { uuid } = useServer();
@@ -40,13 +41,11 @@ export default () => {
4041
</p>
4142
:
4243
<div>
43-
{
44-
backups.map(backup => (
45-
<div key={backup.uuid}>
46-
{backup.uuid}
47-
</div>
48-
))
49-
}
44+
{backups.map((backup, index) => <BackupRow
45+
key={backup.uuid}
46+
backup={backup}
47+
className={index !== (backups.length - 1) ? 'mb-2' : undefined}
48+
/>)}
5049
</div>
5150
}
5251
<Can action={'backup.create'}>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import React from 'react';
2+
import { ServerBackup } from '@/api/server/backups/getServerBackups';
3+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4+
import { faArchive } from '@fortawesome/free-solid-svg-icons/faArchive';
5+
import format from 'date-fns/format';
6+
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now'
7+
import Spinner from '@/components/elements/Spinner';
8+
import { faCloudDownloadAlt } from '@fortawesome/free-solid-svg-icons/faCloudDownloadAlt';
9+
10+
interface Props {
11+
backup: ServerBackup;
12+
className?: string;
13+
}
14+
15+
export default ({ backup, className }: Props) => {
16+
return (
17+
<div className={`grey-row-box flex items-center ${className}`}>
18+
<div className={'mr-4'}>
19+
<FontAwesomeIcon icon={faArchive} className={'text-neutral-300'}/>
20+
</div>
21+
<div className={'flex-1'}>
22+
<p className={'text-sm mb-1'}>{backup.name}</p>
23+
<p className={'text-xs text-neutral-400 font-mono'}>{backup.uuid}</p>
24+
</div>
25+
<div className={'ml-4 text-center'}>
26+
<p
27+
title={format(backup.createdAt, 'ddd, MMMM Do, YYYY HH:mm:ss Z')}
28+
className={'text-sm'}
29+
>
30+
{distanceInWordsToNow(backup.createdAt, { includeSeconds: true, addSuffix: true })}
31+
</p>
32+
<p className={'text-2xs text-neutral-500 uppercase mt-1'}>Created</p>
33+
</div>
34+
<div className={'ml-6'} style={{ marginRight: '-0.5rem' }}>
35+
{!backup.completedAt ?
36+
<div title={'Backup is in progress'} className={'p-2'}>
37+
<Spinner size={'tiny'}/>
38+
</div>
39+
:
40+
<a href={'#'} className={'text-sm text-neutral-300 p-2 transition-colors duration-250 hover:text-cyan-400'}>
41+
<FontAwesomeIcon icon={faCloudDownloadAlt}/>
42+
</a>
43+
}
44+
</div>
45+
</div>
46+
);
47+
};

0 commit comments

Comments
 (0)