Skip to content

Commit 34858f9

Browse files
committed
chore: clean up wrapped layout folder structure
1 parent 8d6179f commit 34858f9

20 files changed

Lines changed: 54 additions & 48 deletions

File tree

packages/ui/src/layouts/wrapped/hosting/manage/components/ServerManageStats.vue renamed to packages/ui/src/components/servers/ServerManageStats.vue

File renamed without changes.

packages/ui/src/components/servers/admonitions/ServerPanelAdmonitions.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import InstallingBanner, {
1212
type SyncProgress,
1313
} from '#ui/components/servers/InstallingBanner.vue'
1414
import { defineMessages, useVIntl } from '#ui/composables/i18n'
15-
import { useServerBackupsQueue } from '#ui/composables/server-backups-queue'
15+
import { useServerBackupsQueue } from '#ui/composables/servers/server-backups-queue.ts'
1616
import type { FileOperation } from '#ui/layouts/shared/files-tab/types'
1717
import { injectModrinthClient, injectModrinthServerContext } from '#ui/providers'
1818

packages/ui/src/layouts/wrapped/hosting/manage/components/WorldCard.vue renamed to packages/ui/src/components/servers/worlds/WorldCard.vue

File renamed without changes.

packages/ui/src/composables/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ export * from './i18n'
88
export * from './i18n-debug'
99
export * from './page-leave-safety'
1010
export * from './scroll-indicator'
11-
export * from './server-backup'
12-
export * from './server-backups-queue'
13-
export * from './server-console'
14-
export * from './server-manage-core-runtime'
11+
export * from './servers/server-backup'
12+
export * from './servers/server-backups-queue'
13+
export * from './servers/server-console'
14+
export * from './servers/server-manage-core-runtime'
15+
export * from './servers/use-server-image'
1516
export * from './sticky-observer'
1617
export * from './terminal'
1718
export * from './use-loading-bar-token'
1819
export * from './use-loading-state-core'
1920
export * from './use-ready-state'
20-
export * from './use-server-image'
2121
export * from './use-server-project'
2222
export * from './virtual-scroll'

packages/ui/src/layouts/wrapped/hosting/manage/backups-selection.ts renamed to packages/ui/src/composables/servers/backups-selection.ts

File renamed without changes.

packages/ui/src/composables/server-backup.ts renamed to packages/ui/src/composables/servers/server-backup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Archon } from '@modrinth/api-client'
22

3-
import { injectModrinthClient } from '../providers/api-client'
4-
import { injectNotificationManager } from '../providers/web-notifications'
3+
import { injectModrinthClient } from '../../providers/api-client'
4+
import { injectNotificationManager } from '../../providers/web-notifications'
55

66
export function useServerBackupDownload() {
77
const client = injectModrinthClient()

packages/ui/src/composables/server-backups-queue.ts renamed to packages/ui/src/composables/servers/server-backups-queue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { computed, reactive, type Ref } from 'vue'
44

55
import { type BusyReason, injectModrinthClient } from '#ui/providers'
66

7-
import { defineMessage } from './i18n'
7+
import { defineMessage } from '../i18n'
88

99
type ProgressKey = `${string}:${'create' | 'restore'}`
1010

packages/ui/src/composables/server-console.ts renamed to packages/ui/src/composables/servers/server-console.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { createGlobalState } from '@vueuse/core'
22
import { type Ref, ref, shallowRef, triggerRef } from 'vue'
33

4-
import { detectLogLevel } from '../layouts/shared/console/composables/log-level'
5-
import type { Log4jEvent, LogLevel, LogLine } from '../layouts/shared/console/types'
4+
import { detectLogLevel } from '../../layouts/shared/console/composables/log-level'
5+
import type { Log4jEvent, LogLevel, LogLine } from '../../layouts/shared/console/types'
66

77
// Flip to true during development to enable console perf logging.
88
// Uses a plain constant to avoid turbo env-var declarations.

packages/ui/src/composables/server-manage-core-runtime.ts renamed to packages/ui/src/composables/servers/server-manage-core-runtime.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import type { Stats } from '@modrinth/utils'
88
import type { ComputedRef, Ref } from 'vue'
99
import { computed, ref } from 'vue'
1010

11-
import type { FileOperation } from '../layouts/shared/files-tab/types'
12-
import { injectModrinthClient, provideModrinthServerContext } from '../providers'
13-
import type { BusyReason } from '../providers/server-context'
14-
import { defineMessage } from './i18n'
11+
import type { FileOperation } from '../../layouts/shared/files-tab/types'
12+
import { injectModrinthClient, provideModrinthServerContext } from '../../providers'
13+
import type { BusyReason } from '../../providers/server-context'
14+
import { defineMessage } from '../i18n'
1515
import { useModrinthServersConsole } from './server-console'
1616

1717
type ReadableRef<T> = Ref<T> | ComputedRef<T>

packages/ui/src/composables/use-server-image.ts renamed to packages/ui/src/composables/servers/use-server-image.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { computed, type ComputedRef, ref } from 'vue'
55
import { injectModrinthClient } from '#ui/providers'
66

77
type UpstreamRef = ComputedRef<Archon.Servers.v0.Server['upstream'] | null | undefined>
8+
type ServerIdSource = string | { readonly value: string }
89

910
type UseServerImageOptions = {
1011
enabled?: ComputedRef<boolean> | boolean
@@ -39,32 +40,35 @@ function isNotFound(error: unknown): boolean {
3940
}
4041

4142
export function useServerImage(
42-
serverId: string,
43+
serverId: ServerIdSource,
4344
upstream: UpstreamRef,
4445
options: UseServerImageOptions = {},
4546
) {
4647
const client = injectModrinthClient()
4748
const localImage = ref<string | null | undefined>(undefined)
4849
const iconSize = options.size ?? 512
4950
const includeProjectFallback = options.includeProjectFallback ?? false
51+
const resolvedServerId = computed(() => resolveServerId(serverId))
5052

5153
const queryKey = computed(
52-
() => ['servers', 'detail', serverId, 'icon', upstream.value?.project_id ?? null] as const,
54+
() =>
55+
['servers', 'detail', resolvedServerId.value, 'icon', upstream.value?.project_id ?? null] as const,
5356
)
5457

5558
const isEnabled = computed(() => {
5659
const explicitEnabled =
5760
typeof options.enabled === 'boolean' ? options.enabled : options.enabled?.value
58-
return !!serverId && (explicitEnabled ?? true)
61+
return !!resolvedServerId.value && (explicitEnabled ?? true)
5962
})
6063

6164
const { data: remoteImage, refetch } = useQuery({
6265
queryKey,
6366
queryFn: async (): Promise<string | null> => {
64-
if (!serverId) return null
67+
const id = resolvedServerId.value
68+
if (!id) return null
6569

6670
try {
67-
const fsAuth = await client.archon.servers_v0.getFilesystemAuth(serverId)
71+
const fsAuth = await client.archon.servers_v0.getFilesystemAuth(id)
6872

6973
try {
7074
const blob = await client.kyros.files_v0.downloadFileWithAuth(fsAuth, '/server-icon.png')
@@ -132,3 +136,7 @@ export function useServerImage(
132136
resetLocalOverride,
133137
}
134138
}
139+
140+
function resolveServerId(serverId: ServerIdSource): string {
141+
return typeof serverId === 'string' ? serverId : serverId.value
142+
}

0 commit comments

Comments
 (0)