You've already forked AstralRinth
forked from didirus/AstralRinth
1cfbefff02
* fix: content filtering client only * fix: browse content bug Fixes #5570 * fix: Applying Mods & Updates filters at the same time doesn't work Fixes #5602 * fix: Browsing content: going back resets filters and installed state Fixes #5598 * fix: Mod tile background flickers when toggling enabled/disabled state Fixes #5600 * fix: Overhaul of "Content" tab on instances broke a lot Fixes #5567 * fix: Latest App update replacing all mods icons with a datapack/rescourcepack Fixes #5556 * fix: billing page api-client ditch useBaseFetch * fix: remove org icon from project card items * fix: lint
115 lines
3.5 KiB
TypeScript
115 lines
3.5 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 interface UploadState {
|
|
isUploading: boolean
|
|
currentFileName: string | null
|
|
currentFileProgress: number
|
|
uploadedBytes: number
|
|
totalBytes: number
|
|
completedFiles: number
|
|
totalFiles: number
|
|
}
|
|
|
|
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
|
|
|
|
// Identity & labelling
|
|
getItemId: (item: ContentItem) => string
|
|
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
|
|
|
|
// 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',
|
|
)
|