refactor: move manager to code to documents manager

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-08-15 11:22:01 -04:00
parent 3c1a21a5c0
commit c32906bc12
5 changed files with 44 additions and 533 deletions
+30 -30
View File
@@ -2,7 +2,7 @@
import { ref, computed, onMounted, watch, nextTick, defineAsyncComponent } from 'vue'
import { useDisplay } from 'vuetify'
import { useModuleStore, useIntegrationStore } from '@KTXC'
import { useFileManager, useFileSelection, useFileUpload, useFileEditor } from '@/composables'
import { useDocumentManager, useDocumentSelection, useFileUpload, useFileEditor } from '@/composables'
import type { ViewMode, SortField, SortOrder, BreadcrumbItem } from '@/types'
import { CollectionObject } from '@DocumentsManager/models/collection'
import { EntityObject } from '@DocumentsManager/models/entity'
@@ -42,13 +42,13 @@ const activeProviderId = ref('default')
const activeServiceId = ref('personal')
// File manager composable
const fileManager = useFileManager({
const documentManager = useDocumentManager({
providerId: activeProviderId,
serviceId: activeServiceId,
})
// Selection composable
const selection = useFileSelection({ multiple: true })
const selection = useDocumentSelection({ multiple: true })
// Upload composable
const upload = useFileUpload({
@@ -57,11 +57,11 @@ const upload = useFileUpload({
})
// Keep upload collection in sync with current location
watch(() => fileManager.currentLocation.value, (newLocation) => {
watch(() => documentManager.currentLocation.value, (newLocation) => {
upload.setCollection(newLocation)
})
watch(() => fileManager.error.value, (message) => {
watch(() => documentManager.error.value, (message) => {
if (message) {
notify(message, 'error')
}
@@ -129,11 +129,11 @@ function entityToViewerItem(entity: EntityObject): ViewerItem {
}
function resolveViewerSource(item: ViewerItem): string {
return fileManager.getEntityUrl(item.id, (item.meta?.collection as string | null) ?? null)
return documentManager.getEntityUrl(item.id, (item.meta?.collection as string | null) ?? null)
}
function downloadViewerItem(item: ViewerItem): void {
fileManager.downloadEntity(item.id, (item.meta?.collection as string | null) ?? null)
documentManager.downloadEntity(item.id, (item.meta?.collection as string | null) ?? null)
}
// Editor state
@@ -241,10 +241,10 @@ function renameCurrentName(node: CollectionObject | EntityObject | null): string
// Computed
const breadcrumbs = computed<BreadcrumbItem[]>(() => {
const items: BreadcrumbItem[] = [
{ id: fileManager.ROOT_ID, label: 'Home', isRoot: true }
{ id: documentManager.ROOT_ID, label: 'Home', isRoot: true }
]
for (const node of fileManager.breadcrumbs.value) {
for (const node of documentManager.breadcrumbs.value) {
items.push({
id: nodeId(node),
label: nodeLabel(node),
@@ -256,8 +256,8 @@ const breadcrumbs = computed<BreadcrumbItem[]>(() => {
})
const sortedItems = computed(() => {
const collections = [...fileManager.currentCollections.value]
const entities = [...fileManager.currentEntities.value]
const collections = [...documentManager.currentCollections.value]
const entities = [...documentManager.currentEntities.value]
// Sort collections
collections.sort((a, b) => {
@@ -375,8 +375,8 @@ watch([activeProviderId, activeServiceId], async ([providerId, serviceId], [prev
}
selection.clear()
upload.setCollection(fileManager.rootId.value)
await fileManager.navigateToRoot()
upload.setCollection(documentManager.rootId.value)
await documentManager.navigateToRoot()
}, { flush: 'post' })
async function handleServiceSelect(service: ServiceObject) {
@@ -398,12 +398,12 @@ async function handleServiceSelect(service: ServiceObject) {
// Navigation methods
async function handleBreadcrumbNavigate(item: BreadcrumbItem) {
selection.clear()
await fileManager.navigateTo(item.isRoot ? null : item.id)
await documentManager.navigateTo(item.isRoot ? null : item.id)
}
async function handleFolderOpen(folder: CollectionObject) {
selection.clear()
await fileManager.navigateTo(nodeId(folder))
await documentManager.navigateTo(nodeId(folder))
}
// Item interaction methods
@@ -440,7 +440,7 @@ function handleShowDetails(item: CollectionObject | EntityObject) {
// Folder operations
async function handleCreateFolder(name: string) {
try {
await fileManager.createFolder(name)
await documentManager.createFolder(name)
showNewFolderDialog.value = false
notify(`Folder "${name}" created`, 'success')
} catch (error) {
@@ -460,7 +460,7 @@ async function handleRename(newName: string) {
const currentName = renameCurrentName(nodeToRename.value)
try {
await fileManager.renameNode(nodeId(nodeToRename.value), newName)
await documentManager.renameNode(nodeId(nodeToRename.value), newName)
showRenameDialog.value = false
nodeToRename.value = null
notify(`Renamed "${currentName}" to "${newName}"`, 'success')
@@ -481,7 +481,7 @@ async function handleDelete() {
try {
for (const node of nodesToDelete.value) {
await fileManager.deleteNode(nodeId(node))
await documentManager.deleteNode(nodeId(node))
}
selection.clear()
showDeleteDialog.value = false
@@ -500,11 +500,11 @@ async function handleDelete() {
function handleDownloadItem(item: CollectionObject | EntityObject) {
if (item instanceof EntityObject) {
// Download single file
fileManager.downloadEntity(nodeId(item), String(item.collection ?? fileManager.ROOT_ID))
documentManager.downloadEntity(nodeId(item), String(item.collection ?? documentManager.ROOT_ID))
notify(`Download started for "${nodeLabel(item)}"`, 'info')
} else if (item instanceof CollectionObject) {
// Download folder as ZIP
fileManager.downloadCollection(nodeId(item))
documentManager.downloadCollection(nodeId(item))
notify(`Archive download started for "${nodeLabel(item)}"`, 'info')
}
}
@@ -656,7 +656,7 @@ async function readEntriesRecursively(
async function handleUploadAll() {
try {
await upload.uploadAll()
await fileManager.refresh()
await documentManager.refresh()
notify('Uploads completed', 'success')
} catch (error) {
console.error('Failed to upload files:', error)
@@ -673,7 +673,7 @@ function handleUploadDialogClose() {
// Refresh
async function handleRefresh() {
try {
await fileManager.refresh()
await documentManager.refresh()
} catch (error) {
console.error('Failed to refresh files:', error)
notify(getErrorMessage(error, 'Failed to refresh files'), 'error')
@@ -683,10 +683,10 @@ async function handleRefresh() {
// Initialize
onMounted(async () => {
try {
await fileManager.initialize()
await documentManager.initialize()
await servicesStore.list()
syncActiveService(availableServices.value)
await fileManager.refresh()
await documentManager.refresh()
console.log('[Files] - Initialized with:', {
provider: activeProviderId.value,
service: activeServiceId.value,
@@ -723,7 +723,7 @@ onMounted(async () => {
<FilesToolbar
v-model:search-query="searchQuery"
v-model:view-mode="viewMode"
:is-loading="fileManager.isLoading.value"
:is-loading="documentManager.isLoading.value"
@toggle-sidebar="sidebarVisible = !sidebarVisible"
@refresh="handleRefresh"
@open-file-picker="openFilePicker"
@@ -747,7 +747,7 @@ onMounted(async () => {
:active-provider-id="activeProviderId"
:active-service-id="activeServiceId"
:services="availableServices"
@navigate-home="fileManager.navigateToRoot()"
@navigate-home="documentManager.navigateToRoot()"
@select-service="handleServiceSelect"
@new-folder="showNewFolderDialog = true"
@open-file-picker="openFilePicker"
@@ -766,7 +766,7 @@ onMounted(async () => {
<!-- Loading -->
<v-progress-linear
v-if="fileManager.isLoading.value"
v-if="documentManager.isLoading.value"
indeterminate
color="primary"
class="mx-4"
@@ -774,7 +774,7 @@ onMounted(async () => {
<div class="files-view-panel">
<!-- Empty state -->
<FilesEmptyState v-if="!hasItems && !fileManager.isLoading.value" />
<FilesEmptyState v-if="!hasItems && !documentManager.isLoading.value" />
<!-- Grid View -->
<FilesGridView
@@ -911,8 +911,8 @@ onMounted(async () => {
<FileEditorDialog
v-model="showEditor"
:entity="editorEntity"
:read-file="fileManager.readFile"
:write-file="fileManager.writeFile"
:read-file="documentManager.readFile"
:write-file="documentManager.writeFile"
/>
<v-snackbar