Merge branch 'fix/backup-ui' into v2

This commit is contained in:
Matthew Penner 2021-08-04 17:29:57 -06:00
commit 0ab124f026
No known key found for this signature in database
GPG key ID: 5396CC4C3C1C9704
6 changed files with 23 additions and 10 deletions

View file

@ -65,12 +65,12 @@ const BackupContainer = () => {
}
<Can action={'backup.create'}>
<div css={tw`mt-6 sm:flex items-center justify-end`}>
{(backupLimit > 0 && backups.pagination.total > 0) &&
{(backupLimit > 0 && backups.usedBackupCount > 0) &&
<p css={tw`text-sm text-neutral-300 mb-4 sm:mr-6 sm:mb-0`}>
{backups.pagination.total} of {backupLimit} backups have been created for this server.
{backups.usedBackupCount} of {backupLimit} backups have been created for this server.
</p>
}
{backupLimit > 0 && backupLimit !== backups.pagination.total &&
{backupLimit > 0 && backupLimit > backups.usedBackupCount &&
<CreateBackupButton css={tw`w-full sm:w-auto`}/>
}
</div>

View file

@ -51,6 +51,7 @@ export default ({ backup }: Props) => {
.then(() => mutate(data => ({
...data!,
items: data!.items.filter(b => b.uuid !== backup.uuid),
usedBackupCount: data!.usedBackupCount - 1,
}), false))
.catch(error => {
console.error(error);

View file

@ -81,7 +81,7 @@ export default () => {
clearFlashes('backups:create');
createServerBackup(uuid, values)
.then(backup => {
mutate(data => ({ ...data!, items: data!.items.concat(backup) }), false);
mutate(data => ({ ...data!, items: data!.items.concat(backup), usedBackupCount: data!.usedBackupCount + 1 }), false);
setVisible(false);
})
.catch(error => {