ui(server): fix used backup count (#3526)
* ui(server): fix used backup count * ui(server): refactor backup count code
This commit is contained in:
parent
7e91a33a67
commit
10b357b71e
7 changed files with 41 additions and 32 deletions
|
@ -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.backupCount > 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.backupCount} of {backupLimit} backups have been created for this server.
|
||||
</p>
|
||||
}
|
||||
{backupLimit > 0 && backupLimit !== backups.pagination.total &&
|
||||
{backupLimit > 0 && backupLimit > backups.backupCount &&
|
||||
<CreateBackupButton css={tw`w-full sm:w-auto`}/>
|
||||
}
|
||||
</div>
|
||||
|
|
|
@ -58,6 +58,7 @@ export default ({ backup }: Props) => {
|
|||
.then(() => mutate(data => ({
|
||||
...data,
|
||||
items: data.items.filter(b => b.uuid !== backup.uuid),
|
||||
backupCount: data.backupCount - 1,
|
||||
}), false))
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
|
|
|
@ -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), backupCount: data.backupCount + 1 }), false);
|
||||
setVisible(false);
|
||||
})
|
||||
.catch(error => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue