Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/web-app-files/src/extensionPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ export const folderViewsSearchExtensionPoint: ExtensionPoint<FolderViewExtension
extensionType: 'folderView'
}

export const genericSpaceHeaderExtensionPoint: ExtensionPoint<CustomComponentExtension> = {
id: 'app.files.generic-space-header',
extensionType: 'customComponent'
}

export const fileSideBarFileDetailsTableExtensionPoint: ExtensionPoint<CustomComponentExtension> = {
id: 'app.files.sidebar.file-details.table',
extensionType: 'customComponent'
Expand Down Expand Up @@ -133,6 +138,7 @@ export const extensionPoints = () => {
folderViewsSharedViaLinkExtensionPoint,
folderViewsSharedWithOthersExtensionPoint,
folderViewsSearchExtensionPoint,
genericSpaceHeaderExtensionPoint,
floatingActionButtonExtension,
fileSideBarFileDetailsTableExtensionPoint,
fileSideBarSharesPanelSharedWithTopExtensionPoint,
Expand Down
28 changes: 25 additions & 3 deletions packages/web-app-files/src/views/spaces/GenericSpace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,23 @@
:class="{ 'h-[40vh]': isSpaceFrontpage }"
/>
<template v-else>
<space-header v-if="isSpaceFrontpage" :space="space" class="px-4" />
<custom-component-target
v-if="hasGenericSpaceHeaderExtension"
:extension-point="genericSpaceHeaderExtensionPoint"
>
<template #fallback>
<space-header
v-if="isSpaceFrontpage"
:space="space"
class="px-4"
/>
</template>
</custom-component-target>
<space-header
v-else-if="isSpaceFrontpage"
:space="space"
class="px-4"
/>
Comment on lines +46 to +50

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't hide this if a generic space header extension was found. There might be extensions were you actually want both.

We don't have a final solution for this yet, but for the time being, you could hide the space header in your custom extension via CSS.

<no-content-message
v-if="isCurrentFolderEmpty"
id="files-space-empty"
Expand Down Expand Up @@ -107,7 +123,7 @@
<script setup lang="ts">
import { omit, last } from 'lodash-es'
import { basename } from 'path'
import { computed, onBeforeUnmount, onMounted, unref, watch } from 'vue'
import { computed, onBeforeUnmount, onMounted, ref, unref, watch } from 'vue'
import { useGettext } from 'vue3-gettext'
import { Resource } from '@opencloud-eu/web-client'
import {
Expand Down Expand Up @@ -146,8 +162,10 @@ import {
useKeyboardActions,
useRoute,
useRouteQuery,
FolderLoaderOptions
FolderLoaderOptions,
CustomComponentTarget
} from '@opencloud-eu/web-pkg'
import { genericSpaceHeaderExtensionPoint } from '../../extensionPoints'
import CreateAndUpload from '../../components/AppBar/CreateAndUpload.vue'
import FilesViewWrapper from '../../components/FilesViewWrapper.vue'
import ListInfo from '../../components/FilesList/ListInfo.vue'
Expand Down Expand Up @@ -200,6 +218,10 @@ const canUpload = computed(() => {
})

const folderNotFound = computed(() => unref(currentFolder) === null)

const hasGenericSpaceHeaderExtension = computed(() => {
return extensionRegistry.requestExtensions(genericSpaceHeaderExtensionPoint).length > 0
})
const isCurrentFolderEmpty = computed(() => unref(paginatedResources).length < 1)

const titleSegments = computed(() => {
Expand Down
35 changes: 28 additions & 7 deletions packages/web-pkg/src/components/CustomComponentTarget.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<template>
<component
:is="extension.content"
v-for="extension in extensions"
:key="`custom-component-${extension.id}`"
v-bind="extension.componentProps ? extension.componentProps() : undefined"
/>
<template v-for="extension in extensions" :key="`custom-component-${extension.id}`">
<component
:is="extension.content"
v-bind="extension.componentProps ? extension.componentProps() : undefined"
@vue:mounted="onChildMounted"
@vue:unmounted="onChildUnmounted"
/>
</template>
<slot v-if="!hasRenderedContent" name="fallback" />
</template>

<script setup lang="ts">
import { computed, unref } from 'vue'
import { computed, ref, unref } from 'vue'
import {
CustomComponentExtension,
ExtensionPoint,
Expand All @@ -23,6 +26,24 @@ const props = defineProps<{
const extensionRegistry = useExtensionRegistry()
const extensionPreferences = useExtensionPreferencesStore()

// Track whether any extension component actually rendered visible content
const mountedCount = ref(0)
const hasRenderedContent = computed(() => mountedCount.value > 0)

function onChildMounted(e: any) {
// Check if the component rendered something visible (not just a comment node)
const el = e?.el
if (el && el.nodeType !== 8 /* Comment */) {
mountedCount.value++
}
}

function onChildUnmounted() {
if (mountedCount.value > 0) mountedCount.value--
}

defineExpose({ hasRenderedContent })

const allExtensions = computed(() => {
return extensionRegistry.requestExtensions(props.extensionPoint)
})
Expand Down