hosting: Copy ID button for backups when developer mode is on (#5681)

* Copy ID button in backups tab

* Remove codex slop
This commit is contained in:
François-Xavier Talbot
2026-03-26 20:18:33 -04:00
committed by GitHub
parent c5a0c71424
commit b68aeddedc
3 changed files with 25 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ useHead({
<template> <template>
<ServersManageBackupsPage <ServersManageBackupsPage
:is-server-running="isServerRunning" :is-server-running="isServerRunning"
:show-copy-id-action="flags.developerMode"
:show-debug-info="flags.advancedDebugInfo" :show-debug-info="flags.advancedDebugInfo"
/> />
</template> </template>

View File

@@ -1,6 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { Archon } from '@modrinth/api-client' import type { Archon } from '@modrinth/api-client'
import { import {
ClipboardCopyIcon,
ClockIcon, ClockIcon,
DownloadIcon, DownloadIcon,
EditIcon, EditIcon,
@@ -35,6 +36,7 @@ const props = withDefaults(
preview?: boolean preview?: boolean
kyrosUrl?: string kyrosUrl?: string
jwt?: string jwt?: string
showCopyIdAction?: boolean
showDebugInfo?: boolean showDebugInfo?: boolean
restoreDisabled?: string restoreDisabled?: string
}>(), }>(),
@@ -42,6 +44,7 @@ const props = withDefaults(
preview: false, preview: false,
kyrosUrl: undefined, kyrosUrl: undefined,
jwt: undefined, jwt: undefined,
showCopyIdAction: false,
showDebugInfo: false, showDebugInfo: false,
restoreDisabled: undefined, restoreDisabled: undefined,
}, },
@@ -90,7 +93,18 @@ const backupIcon = computed(() => {
const overflowMenuOptions = computed<OverflowOption[]>(() => { const overflowMenuOptions = computed<OverflowOption[]>(() => {
const options: OverflowOption[] = [] const options: OverflowOption[] = []
if (props.showCopyIdAction) {
options.push({
id: 'copy-id',
action: () => copyId(),
})
}
if (!activeOperation.value) { if (!activeOperation.value) {
if (options.length > 0) {
options.push({ divider: true })
}
options.push({ options.push({
id: 'download', id: 'download',
action: () => emit('download'), action: () => emit('download'),
@@ -113,6 +127,10 @@ const overflowMenuOptions = computed<OverflowOption[]>(() => {
return options return options
}) })
async function copyId() {
await navigator.clipboard.writeText(props.backup.id)
}
// TODO: Uncomment when API supports size field // TODO: Uncomment when API supports size field
// const formatBytes = (bytes?: number) => { // const formatBytes = (bytes?: number) => {
// if (!bytes) return '' // if (!bytes) return ''
@@ -235,6 +253,10 @@ const messages = defineMessages({
<ButtonStyled circular type="transparent"> <ButtonStyled circular type="transparent">
<OverflowMenu :options="overflowMenuOptions"> <OverflowMenu :options="overflowMenuOptions">
<MoreVerticalIcon class="size-5" /> <MoreVerticalIcon class="size-5" />
<template #copy-id>
<ClipboardCopyIcon class="size-5" />
{{ formatMessage(commonMessages.copyIdButton) }}
</template>
<template #download> <template #download>
<DownloadIcon class="size-5" /> {{ formatMessage(commonMessages.downloadButton) }} <DownloadIcon class="size-5" /> {{ formatMessage(commonMessages.downloadButton) }}
</template> </template>

View File

@@ -100,6 +100,7 @@
:restore-disabled="backupRestoreDisabled" :restore-disabled="backupRestoreDisabled"
:kyros-url="server.node?.instance" :kyros-url="server.node?.instance"
:jwt="server.node?.token" :jwt="server.node?.token"
:show-copy-id-action="showCopyIdAction"
:show-debug-info="showDebugInfo" :show-debug-info="showDebugInfo"
@download="() => triggerDownloadAnimation()" @download="() => triggerDownloadAnimation()"
@rename="() => renameBackupModal?.show(backup)" @rename="() => renameBackupModal?.show(backup)"
@@ -171,6 +172,7 @@ const { server, worldId, backupsState, markBackupCancelled, busyReasons } =
const props = defineProps<{ const props = defineProps<{
isServerRunning: boolean isServerRunning: boolean
showCopyIdAction?: boolean
showDebugInfo?: boolean showDebugInfo?: boolean
}>() }>()