diff --git a/apps/frontend/src/pages/hosting/manage/[id].vue b/apps/frontend/src/pages/hosting/manage/[id].vue index 40440193..580cc19a 100644 --- a/apps/frontend/src/pages/hosting/manage/[id].vue +++ b/apps/frontend/src/pages/hosting/manage/[id].vue @@ -790,7 +790,7 @@ const handleBackupProgress = (data: Archon.Websocket.v0.WSBackupProgressEvent) = 'list', serverId, ]) - const backup = backupData?.find((b) => b.id === backupId) + const backup = backupData?.find((b) => (b.physical_id ?? b.id) === backupId) if (backup?.ongoing && attempt < 3) { // retry 3 times max, archon is slow compared to ws state diff --git a/packages/api-client/src/modules/archon/backups/v0.ts b/packages/api-client/src/modules/archon/backups/v0.ts index 27e28f60..e1e402fa 100644 --- a/packages/api-client/src/modules/archon/backups/v0.ts +++ b/packages/api-client/src/modules/archon/backups/v0.ts @@ -52,24 +52,6 @@ export class ArchonBackupsV0Module extends AbstractModule { }) } - /** POST /modrinth/v0/servers/:server_id/backups/:backup_id/lock */ - public async lock(serverId: string, backupId: string): Promise { - await this.client.request(`/servers/${serverId}/backups/${backupId}/lock`, { - api: 'archon', - version: 'modrinth/v0', - method: 'POST', - }) - } - - /** POST /modrinth/v0/servers/:server_id/backups/:backup_id/unlock */ - public async unlock(serverId: string, backupId: string): Promise { - await this.client.request(`/servers/${serverId}/backups/${backupId}/unlock`, { - api: 'archon', - version: 'modrinth/v0', - method: 'POST', - }) - } - /** POST /modrinth/v0/servers/:server_id/backups/:backup_id/retry */ public async retry(serverId: string, backupId: string): Promise { await this.client.request(`/servers/${serverId}/backups/${backupId}/retry`, { diff --git a/packages/api-client/src/modules/archon/backups/v1.ts b/packages/api-client/src/modules/archon/backups/v1.ts index 62fa01f8..65537876 100644 --- a/packages/api-client/src/modules/archon/backups/v1.ts +++ b/packages/api-client/src/modules/archon/backups/v1.ts @@ -76,32 +76,6 @@ export class ArchonBackupsV1Module extends AbstractModule { }) } - /** POST /v1/:server_id/worlds/:world_id/backups/:backup_id/lock */ - public async lock( - serverId: string, - backupId: string, - worldId: string = DEFAULT_WORLD_ID, - ): Promise { - await this.client.request(`/${serverId}/worlds/${worldId}/backups/${backupId}/lock`, { - api: 'archon', - version: 1, - method: 'POST', - }) - } - - /** POST /v1/:server_id/worlds/:world_id/backups/:backup_id/unlock */ - public async unlock( - serverId: string, - backupId: string, - worldId: string = DEFAULT_WORLD_ID, - ): Promise { - await this.client.request(`/${serverId}/worlds/${worldId}/backups/${backupId}/unlock`, { - api: 'archon', - version: 1, - method: 'POST', - }) - } - /** POST /v1/:server_id/worlds/:world_id/backups/:backup_id/retry */ public async retry( serverId: string, diff --git a/packages/api-client/src/modules/archon/types.ts b/packages/api-client/src/modules/archon/types.ts index 777543ef..18b8d1cf 100644 --- a/packages/api-client/src/modules/archon/types.ts +++ b/packages/api-client/src/modules/archon/types.ts @@ -174,9 +174,9 @@ export namespace Archon { export type Backup = { id: string + physical_id?: string name: string created_at: string - locked: boolean automated: boolean interrupted: boolean ongoing: boolean diff --git a/packages/ui/src/components/servers/backups/BackupItem.vue b/packages/ui/src/components/servers/backups/BackupItem.vue index 51a46ca8..17caac9c 100644 --- a/packages/ui/src/components/servers/backups/BackupItem.vue +++ b/packages/ui/src/components/servers/backups/BackupItem.vue @@ -4,11 +4,8 @@ import { ClockIcon, DownloadIcon, EditIcon, - // LockIcon, - // LockOpenIcon, MoreVerticalIcon, RotateCounterClockwiseIcon, - // ShieldIcon, TrashIcon, UserRoundIcon, XIcon, @@ -25,7 +22,6 @@ import ProgressBar from '../../base/ProgressBar.vue' const { formatMessage } = useVIntl() const emit = defineEmits<{ - // TODO: Re-add 'lock' when lock functionality is implemented (e: 'download' | 'rename' | 'restore' | 'retry'): void (e: 'delete', skipConfirmation?: boolean): void }>() @@ -94,8 +90,6 @@ const failedToRestore = computed(() => props.backup.task?.restore?.state === 'fa const backupIcon = computed(() => { if (props.backup.automated) { - // TODO: Re-add locked icon when lock functionality is implemented - // return props.backup.locked ? ShieldIcon : ClockIcon return ClockIcon } return UserRoundIcon @@ -115,8 +109,6 @@ const overflowMenuOptions = computed(() => { } options.push({ id: 'rename', action: () => emit('rename') }) - // TODO: Re-add when lock functionality is implemented - // options.push({ id: 'lock', action: () => emit('lock') }) // Delete only available when not creating (has separate Cancel button) if (!creating.value) { @@ -139,19 +131,6 @@ const overflowMenuOptions = computed(() => { // } const messages = defineMessages({ - // TODO: Re-add when lock functionality is implemented - // locked: { - // id: 'servers.backups.item.locked', - // defaultMessage: 'Locked', - // }, - // lock: { - // id: 'servers.backups.item.lock', - // defaultMessage: 'Lock', - // }, - // unlock: { - // id: 'servers.backups.item.unlock', - // defaultMessage: 'Unlock', - // }, restore: { id: 'servers.backups.item.restore', defaultMessage: 'Restore', @@ -223,10 +202,6 @@ const messages = defineMessages({ > {{ formatMessage(messages.auto) }} - -
@@ -348,13 +316,6 @@ const messages = defineMessages({ - - diff --git a/packages/ui/src/components/servers/backups/BackupRestoreModal.vue b/packages/ui/src/components/servers/backups/BackupRestoreModal.vue index b4f15562..f75cd221 100644 --- a/packages/ui/src/components/servers/backups/BackupRestoreModal.vue +++ b/packages/ui/src/components/servers/backups/BackupRestoreModal.vue @@ -87,7 +87,7 @@ const restoreBackup = () => { restoreMutation.mutate(currentBackup.value.id, { onSuccess: () => { // Optimistically update backupsState to show restore in progress immediately - ctx.backupsState.set(currentBackup.value!.id, { + ctx.backupsState.set(currentBackup.value!.physical_id ?? currentBackup.value!.id, { restore: { progress: 0, state: 'ongoing' }, }) modal.value?.hide() diff --git a/packages/ui/src/pages/hosting/manage/backups.vue b/packages/ui/src/pages/hosting/manage/backups.vue index 96e8fcd3..a075617f 100644 --- a/packages/ui/src/pages/hosting/manage/backups.vue +++ b/packages/ui/src/pages/hosting/manage/backups.vue @@ -160,15 +160,6 @@ @download="() => triggerDownloadAnimation()" @rename="() => renameBackupModal?.show(backup)" @restore="() => restoreBackupModal?.show(backup)" - @lock=" - () => { - if (backup.locked) { - unlockBackup(backup.id) - } else { - lockBackup(backup.id) - } - } - " @delete=" (skipConfirmation?: boolean) => skipConfirmation ? deleteBackup(backup) : deleteBackupModal?.show(backup) @@ -251,24 +242,15 @@ const { }) const deleteMutation = useMutation({ - mutationFn: (backupId: string) => client.archon.backups_v0.delete(serverId, backupId), - onSuccess: (_data, backupId) => { - markBackupCancelled(backupId) - backupsState.delete(backupId) + mutationFn: ({ id }: { id: string; physicalId: string }) => + client.archon.backups_v0.delete(serverId, id), + onSuccess: (_data, { physicalId }) => { + markBackupCancelled(physicalId) + backupsState.delete(physicalId) queryClient.invalidateQueries({ queryKey: backupsQueryKey }) }, }) -const lockMutation = useMutation({ - mutationFn: (backupId: string) => client.archon.backups_v0.lock(serverId, backupId), - onSuccess: () => queryClient.invalidateQueries({ queryKey: backupsQueryKey }), -}) - -const unlockMutation = useMutation({ - mutationFn: (backupId: string) => client.archon.backups_v0.unlock(serverId, backupId), - onSuccess: () => queryClient.invalidateQueries({ queryKey: backupsQueryKey }), -}) - const retryMutation = useMutation({ mutationFn: (backupId: string) => client.archon.backups_v0.retry(serverId, backupId), onSuccess: () => queryClient.invalidateQueries({ queryKey: backupsQueryKey }), @@ -278,7 +260,7 @@ const backups = computed(() => { if (!backupsData.value) return [] const merged = backupsData.value.map((backup) => { - const progressState = backupsState.get(backup.id) + const progressState = backupsState.get(backup.physical_id ?? backup.id) if (progressState) { const hasOngoingTask = Object.values(progressState).some((task) => task?.state === 'ongoing') const hasCompletedTask = Object.values(progressState).some((task) => task?.state === 'done') @@ -404,22 +386,6 @@ function triggerDownloadAnimation() { setTimeout(() => (overTheTopDownloadAnimation.value = false), 500) } -const lockBackup = (backupId: string) => { - lockMutation.mutate(backupId, { - onError: (err) => { - console.error('Failed to lock backup:', err) - }, - }) -} - -const unlockBackup = (backupId: string) => { - unlockMutation.mutate(backupId, { - onError: (err) => { - console.error('Failed to unlock backup:', err) - }, - }) -} - const retryBackup = (backupId: string) => { retryMutation.mutate(backupId, { onError: (err) => { @@ -438,16 +404,19 @@ function deleteBackup(backup?: Archon.Backups.v1.Backup) { return } - deleteMutation.mutate(backup.id, { - onError: (err) => { - const message = err instanceof Error ? err.message : String(err) - addNotification({ - type: 'error', - title: 'Error deleting backup', - text: message, - }) + deleteMutation.mutate( + { id: backup.id, physicalId: backup.physical_id ?? backup.id }, + { + onError: (err) => { + const message = err instanceof Error ? err.message : String(err) + addNotification({ + type: 'error', + title: 'Error deleting backup', + text: message, + }) + }, }, - }) + ) } diff --git a/packages/utils/servers/types/backup.ts b/packages/utils/servers/types/backup.ts index 62f46d9c..7827df15 100644 --- a/packages/utils/servers/types/backup.ts +++ b/packages/utils/servers/types/backup.ts @@ -2,9 +2,9 @@ import type { WSBackupState, WSBackupTask } from './websocket' export interface Backup { id: string + physical_id?: string name: string created_at: string - locked: boolean automated: boolean interrupted: boolean ongoing: boolean