Files
modrinth/packages/ui/src/stories/servers/ServerPanelAdmonitions.stories.ts
T
Calum H.andGitHub 620894aecb feat: backups page cleanup before worlds (#5844)
* feat: card alignment + fix modals

* feat: change admon title in restore alert modal

* fix: lint

* feat: backups queue api into api-client

* feat: impl backup queue api endpoints into frontend

* feat: ack fix

* feat: bulk actions

* feat: bulk delete impl

* fix: lint

* fix: align error states

* fix: transition group

* feat: ready for qa

* fix: lint

* feat: qa

* feat: stacked admonitions component

* fix: issues with stacking

* feat: hook up admonition stacking + fix app csp for staging kyros nodes

* fix: logs.vue

* qa: close stack on admonitions click

* fix: all problems with stacked admonitions

* qa: admonition cleanup and copy overhaul draft

* fix: qa issues padding

* fix: padding bug

* feat: qa

* fix: intercom in app csp bug

* fix: positioning intercom

* feat: loading overlay on top of console + admon consistency changes

* feat: scroll indicator fade in backup delete modal + admon timestamp fix

* feat: move action bar behind modal

* fix: lint + i18n

* fix: server ping spam on filter (cache but clear on unmount)

* fix: 1 admon fade in flicker issue

* chore: temp staging undo

* qa: changes

* fix: lint

* chore: revert staging to use staging

* fix: scoping
2026-04-27 19:03:48 +00:00

117 lines
3.2 KiB
TypeScript

import type { Archon, UploadState } from '@modrinth/api-client'
import type { Stats } from '@modrinth/utils'
import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { computed, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import ServerPanelAdmonitions from '../../components/servers/admonitions/ServerPanelAdmonitions.vue'
import { defineMessage } from '../../composables/i18n'
import type { FileOperation } from '../../layouts/shared/files-tab/types'
import { provideModrinthServerContext } from '../../providers'
import type { ModrinthServerContext } from '../../providers/server-context'
const meta = {
title: 'Servers/ServerPanelAdmonitions',
component: ServerPanelAdmonitions,
parameters: {
layout: 'padded',
},
decorators: [
(story) => ({
components: { story },
setup() {
const router = useRouter()
onMounted(() => {
router.replace('/hosting/manage/demo-server/content')
})
const server = ref({
server_id: 'demo-server',
status: 'running',
upstream: null,
} as Archon.Servers.v0.Server)
const stats = ref<Stats>({
current: {
cpu_percent: 0,
ram_usage_bytes: 0,
ram_total_bytes: 1,
storage_usage_bytes: 0,
storage_total_bytes: 0,
},
past: {
cpu_percent: 0,
ram_usage_bytes: 0,
ram_total_bytes: 1,
storage_usage_bytes: 0,
storage_total_bytes: 0,
},
graph: { cpu: [], ram: [] },
})
const uploadState = ref<UploadState>({
isUploading: true,
currentFileName: 'resourcepack.zip',
currentFileProgress: 0.2,
uploadedBytes: 20_000,
totalBytes: 100_000,
completedFiles: 1,
totalFiles: 3,
})
const fileOp = ref<FileOperation[]>([
{
id: 'fs-op-1',
op: 'extract',
src: 'story-modpack.mrpack',
state: 'running',
progress: 0.35,
bytes_processed: 2_000_000,
},
])
const serverContext: ModrinthServerContext = {
get serverId() {
return 'demo-server'
},
worldId: ref(null),
server,
isConnected: ref(true),
isWsAuthIncorrect: ref(false),
powerState: ref('running'),
powerStateDetails: ref(undefined),
isServerRunning: computed(() => true),
stats,
uptimeSeconds: ref(0),
isSyncingContent: ref(false),
busyReasons: computed(() => [
{ reason: defineMessage({ id: 's.bg', defaultMessage: 'Background task running' }) },
]),
fsAuth: ref(null),
fsOps: ref<Archon.Websocket.v0.FilesystemOperation[]>([]),
fsQueuedOps: ref<Archon.Websocket.v0.QueuedFilesystemOp[]>([]),
refreshFsAuth: async () => {},
uploadState,
cancelUpload: ref(() => {
uploadState.value = { ...uploadState.value, isUploading: false }
}),
activeOperations: computed(() => fileOp.value),
dismissOperation: async (id) => {
fileOp.value = fileOp.value.filter((o) => o.id !== id)
},
}
provideModrinthServerContext(serverContext)
return {}
},
template: '<div style="max-width: 720px"><story /></div>',
}),
],
} satisfies Meta<typeof ServerPanelAdmonitions>
export default meta
type Story = StoryObj<typeof meta>
export const WithUploadFileOpAndBusy: Story = {}