Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/frontend/src/pages/hosting/manage/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,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
Expand Down
18 changes: 0 additions & 18 deletions packages/api-client/src/modules/archon/backups/v0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
await this.client.request<void>(`/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<void> {
await this.client.request<void>(`/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<void> {
await this.client.request<void>(`/servers/${serverId}/backups/${backupId}/retry`, {
Expand Down
26 changes: 0 additions & 26 deletions packages/api-client/src/modules/archon/backups/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
await this.client.request<void>(`/${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<void> {
await this.client.request<void>(`/${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,
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/modules/archon/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,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
Expand Down
39 changes: 0 additions & 39 deletions packages/ui/src/components/servers/backups/BackupItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import {
ClockIcon,
DownloadIcon,
EditIcon,
// LockIcon,
// LockOpenIcon,
MoreVerticalIcon,
RotateCounterClockwiseIcon,
// ShieldIcon,
TrashIcon,
UserRoundIcon,
XIcon,
Expand All @@ -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
}>()
Expand Down Expand Up @@ -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
Expand All @@ -115,8 +109,6 @@ const overflowMenuOptions = computed<OverflowOption[]>(() => {
}

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) {
Expand All @@ -139,19 +131,6 @@ const overflowMenuOptions = computed<OverflowOption[]>(() => {
// }

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',
Expand Down Expand Up @@ -223,10 +202,6 @@ const messages = defineMessages({
>
{{ formatMessage(messages.auto) }}
</span>
<!-- TODO: Re-add when lock functionality is implemented -->
<!-- <span v-if="backup.locked" class="flex items-center gap-1 text-sm text-secondary">
<LockIcon class="size-4" />
</span> -->
</div>
<div class="flex items-center gap-1.5 text-sm text-secondary">
<template v-if="failedToCreate || failedToRestore">
Expand Down Expand Up @@ -317,13 +292,6 @@ const messages = defineMessages({
<template #rename>
<EditIcon class="size-5" /> {{ formatMessage(messages.rename) }}
</template>
<!-- TODO: Re-add when lock functionality is implemented -->
<!-- <template v-if="backup.locked" #lock>
<LockOpenIcon class="size-5" /> {{ formatMessage(messages.unlock) }}
</template>
<template v-else #lock>
<LockIcon class="size-5" /> {{ formatMessage(messages.lock) }}
</template> -->
</OverflowMenu>
</ButtonStyled>
</template>
Expand All @@ -348,13 +316,6 @@ const messages = defineMessages({
<template #rename>
<EditIcon class="size-5" /> {{ formatMessage(messages.rename) }}
</template>
<!-- TODO: Re-add when lock functionality is implemented -->
<!-- <template v-if="backup.locked" #lock>
<LockOpenIcon class="size-5" /> {{ formatMessage(messages.unlock) }}
</template>
<template v-else #lock>
<LockIcon class="size-5" /> {{ formatMessage(messages.lock) }}
</template> -->
<template #delete>
<TrashIcon class="size-5" /> {{ formatMessage(commonMessages.deleteLabel) }}
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
67 changes: 18 additions & 49 deletions packages/ui/src/pages/hosting/manage/backups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 }),
Expand All @@ -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')
Expand Down Expand Up @@ -409,22 +391,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) => {
Expand All @@ -443,16 +409,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,
})
},
},
})
)
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion packages/utils/servers/types/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down