Files
AstralRinth/packages/ui/src/layouts/shared/content-tab/providers/content-manager.ts
T
Calum H. 381ea51cce refactor: align files tab with content tab design (#5621)
* fix: files.vue bugs before styling changes

* feat: move files tab to shared layout structure

* fix: qa

* fix: qa

* fix: bugs

* fix: lint

* fix: admonition cleanup with progress + actions

* fix: cleanup

* fix: modals

* fix: admon title

* fix: i18n standard

* fix: lint + i18n pass

* fix: remove transition

* fix: type errors

* feat: files tab in app

* fix: qa

* fix: backup item minmax

* fix: use ContentPageHeader for server panel

* fix: lint

* fix: lint

* fix: lint

* feat: page leave safety

* fix: lint

* fix: cargo fmt fix

* fix: blank in prod

* fix: content card table stuff

* Revert "fix: blank in prod"

This reverts commit 74758fe185cf85a4a20355857f889cb091b97ace.

* fix: import

* feat: browse worlds/servers flow

* fix: worlds tab parity with content tab

* fix: perf bug + shader filter pill copy

* feat: singleplayer filter

* fix: ordering

* fix: breadcrumbs

* fix: lint

* fix: qa

* feat: store server proj id when adding to a non-linked instance

* fix: lint

* fix: i18n + qa

* fix: conflict

* qa: already installed modal + placeholders not server-specific

* fix: qa

* fix: add + edit server modals

* fix: qa

* fix: security

* fix: devin flags

* fix: lint

* chore: change file to break build cache

* fix: admon

* fix: import path stuff

* feat: qa

* fix: fmt fmt idiot

---------

Signed-off-by: Calum H. <calum@modrinth.com>
2026-03-26 18:55:15 +00:00

109 lines
3.4 KiB
TypeScript

import type { ComputedRef, Ref } from 'vue'
import type { RouteLocationRaw } from 'vue-router'
import type { Option as OverflowMenuOption } from '#ui/components/base/OverflowMenu.vue'
import { createContext } from '#ui/providers/create-context'
import type {
ContentCardTableItem,
ContentItem,
ContentModpackCardCategory,
ContentModpackCardProject,
ContentModpackCardVersion,
ContentOwner,
} from '../types'
export interface ContentModpackData {
project: ContentModpackCardProject
projectLink?: string | RouteLocationRaw
version?: ContentModpackCardVersion
versionLink?: string | RouteLocationRaw
owner?: ContentOwner
categories: ContentModpackCardCategory[]
hasUpdate: boolean
disabled?: boolean
disabledText?: string
}
export type { UploadState } from '@modrinth/api-client'
export interface ContentManagerContext {
// Data
items: Ref<ContentItem[]> | ComputedRef<ContentItem[]>
loading: Ref<boolean>
error: Ref<Error | null>
// Modpack
modpack: Ref<ContentModpackData | null> | ComputedRef<ContentModpackData | null>
isPackLocked: Ref<boolean> | ComputedRef<boolean>
// Guards
isBusy: Ref<boolean> | ComputedRef<boolean>
busyMessage?: Ref<string | null> | ComputedRef<string | null>
disableAddContent?: Ref<boolean> | ComputedRef<boolean>
disableAddContentTooltip?: string
// Labelling
contentTypeLabel: Ref<string> | ComputedRef<string>
// Core actions
toggleEnabled: (item: ContentItem) => Promise<void>
deleteItem: (item: ContentItem) => Promise<void>
refresh: () => Promise<void>
browse: () => void
uploadFiles: () => void
// Bulk actions (optional — when provided, used instead of one-by-one loops)
bulkDeleteItems?: (items: ContentItem[]) => Promise<void>
bulkEnableItems?: (items: ContentItem[]) => Promise<void>
bulkDisableItems?: (items: ContentItem[]) => Promise<void>
// Update support (optional per-platform)
hasUpdateSupport: boolean
updateItem?: (id: string) => void
bulkUpdateItem?: (item: ContentItem) => Promise<void>
bulkUpdateItems?: (items: ContentItem[]) => Promise<void>
// Modpack actions (optional)
updateModpack?: () => void
viewModpackContent?: () => void
unlinkModpack?: () => void
openSettings?: () => void
// Switch version (optional)
switchVersion?: (item: ContentItem) => void
// Per-item overflow menu (optional)
getOverflowOptions?: (item: ContentItem) => OverflowMenuOption[]
// Share support (optional — when undefined, share button becomes hidden entirely)
shareItems?: (items: ContentItem[], format: 'names' | 'file-names' | 'urls' | 'markdown') => void
// Upload progress (optional)
uploadState?: Ref<UploadState> | ComputedRef<UploadState>
// Show client-only environment filter pill
showClientOnlyFilter?: boolean
// Bulk operation guard — set by layout, checked by providers to suppress refreshes
isBulkOperating?: Ref<boolean>
// Deletion context (controls modal variant)
deletionContext?: 'instance' | 'server'
// One-time content hint (optional — shows tooltip on modpack content button)
showContentHint?: Ref<boolean>
dismissContentHint?: () => void
// Table item mapping (link generation differs per platform)
mapToTableItem: (item: ContentItem) => ContentCardTableItem
// Filter persistence key — when set, selected filters are saved/restored via sessionStorage
filterPersistKey?: string
}
export const [injectContentManager, provideContentManager] = createContext<ContentManagerContext>(
'ContentPageLayout',
'contentManagerContext',
)