|
|
|
|
@ -4,12 +4,13 @@ |
|
|
|
|
--> |
|
|
|
|
|
|
|
|
|
<script setup lang="ts"> |
|
|
|
|
import type { ISidebarTab, SidebarComponent } from '@nextcloud/files' |
|
|
|
|
import type { ISidebarTab } from '@nextcloud/files' |
|
|
|
|
|
|
|
|
|
import { NcIconSvgWrapper, NcLoadingIcon } from '@nextcloud/vue' |
|
|
|
|
import { ref, toRef, watch, watchEffect } from 'vue' |
|
|
|
|
import { ref, toRef, watch } from 'vue' |
|
|
|
|
import NcAppSidebarTab from '@nextcloud/vue/components/NcAppSidebarTab' |
|
|
|
|
import NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent' |
|
|
|
|
import logger from '../../logger.ts' |
|
|
|
|
import { useActiveStore } from '../../store/active.ts' |
|
|
|
|
import { useSidebarStore } from '../../store/sidebar.ts' |
|
|
|
|
|
|
|
|
|
@ -29,19 +30,31 @@ const sidebar = useSidebarStore() |
|
|
|
|
const activeStore = useActiveStore() |
|
|
|
|
|
|
|
|
|
const loading = ref(true) |
|
|
|
|
watch(toRef(props, 'tab'), async () => { |
|
|
|
|
watch(toRef(props, 'active'), async (active) => { |
|
|
|
|
if (!active) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
logger.debug('sidebar: activating files sidebar tab ' + props.tab.id, { tab: props.tab }) |
|
|
|
|
loading.value = true |
|
|
|
|
await window.customElements.whenDefined(props.tab.tagName) |
|
|
|
|
loading.value = false |
|
|
|
|
try { |
|
|
|
|
if (!initializedTabs.has(props.tab.tagName)) { |
|
|
|
|
initializedTabs.add(props.tab.tagName) |
|
|
|
|
logger.debug('sidebar: initializing ' + props.tab.id) |
|
|
|
|
await props.tab.onInit?.() |
|
|
|
|
} |
|
|
|
|
logger.debug('sidebar: waiting for sidebar tab component becoming defined ' + props.tab.id) |
|
|
|
|
await window.customElements.whenDefined(props.tab.tagName) |
|
|
|
|
logger.debug('sidebar: tab component defined and loaded ' + props.tab.id) |
|
|
|
|
loading.value = false |
|
|
|
|
} catch (error) { |
|
|
|
|
logger.error('Failed to get sidebar tab web component', { error }) |
|
|
|
|
} |
|
|
|
|
}, { immediate: true }) |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
const tabElement = ref<SidebarComponent>() |
|
|
|
|
watchEffect(async () => { |
|
|
|
|
if (tabElement.value) { |
|
|
|
|
// Mark as active |
|
|
|
|
await tabElement.value.setActive?.(props.active) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
<script lang="ts"> |
|
|
|
|
const initializedTabs = new Set<string>() |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
|
@ -61,7 +74,7 @@ watchEffect(async () => { |
|
|
|
|
<component |
|
|
|
|
:is="tab.tagName" |
|
|
|
|
v-else |
|
|
|
|
ref="tabElement" |
|
|
|
|
:active.prop="active" |
|
|
|
|
:node.prop="sidebar.currentNode" |
|
|
|
|
:folder.prop="activeStore.activeFolder" |
|
|
|
|
:view.prop="activeStore.activeView" /> |
|
|
|
|
|