Skip to content

Commit a4fc840

Browse files
committed
fix(files): Add missing emptyView handling
The interface provides this option but it was never implemented. This feature of being able to render a custom empty view message is needed for public file drops to properly show the terms of service. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 4eaa440 commit a4fc840

1 file changed

Lines changed: 54 additions & 26 deletions

File tree

apps/files/src/views/FilesList.vue

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,32 +74,37 @@
7474
:name="t('files', 'Loading current folder')" />
7575

7676
<!-- Empty content placeholder -->
77-
<NcEmptyContent v-else-if="!loading && isEmptyDir"
78-
:name="currentView?.emptyTitle || t('files', 'No files in here')"
79-
:description="currentView?.emptyCaption || t('files', 'Upload some content or sync with your devices!')"
80-
data-cy-files-content-empty>
81-
<template v-if="directory !== '/'" #action>
82-
<!-- Uploader -->
83-
<UploadPicker v-if="currentFolder && canUpload && !isQuotaExceeded"
84-
allow-folders
85-
class="files-list__header-upload-button"
86-
:content="getContent"
87-
:destination="currentFolder"
88-
:forbidden-characters="forbiddenCharacters"
89-
multiple
90-
@failed="onUploadFail"
91-
@uploaded="onUpload" />
92-
<NcButton v-else
93-
:aria-label="t('files', 'Go to the previous folder')"
94-
:to="toPreviousDir"
95-
type="primary">
96-
{{ t('files', 'Go back') }}
97-
</NcButton>
98-
</template>
99-
<template #icon>
100-
<NcIconSvgWrapper :svg="currentView.icon" />
101-
</template>
102-
</NcEmptyContent>
77+
<template v-else-if="!loading && isEmptyDir">
78+
<div v-if="currentView?.emptyView" class="files-list__empty-view-wrapper">
79+
<div ref="customEmptyView" />
80+
</div>
81+
<NcEmptyContent v-else
82+
:name="currentView?.emptyTitle || t('files', 'No files in here')"
83+
:description="currentView?.emptyCaption || t('files', 'Upload some content or sync with your devices!')"
84+
data-cy-files-content-empty>
85+
<template v-if="directory !== '/'" #action>
86+
<!-- Uploader -->
87+
<UploadPicker v-if="currentFolder && canUpload && !isQuotaExceeded"
88+
allow-folders
89+
class="files-list__header-upload-button"
90+
:content="getContent"
91+
:destination="currentFolder"
92+
:forbidden-characters="forbiddenCharacters"
93+
multiple
94+
@failed="onUploadFail"
95+
@uploaded="onUpload" />
96+
<NcButton v-else
97+
:aria-label="t('files', 'Go to the previous folder')"
98+
:to="toPreviousDir"
99+
type="primary">
100+
{{ t('files', 'Go back') }}
101+
</NcButton>
102+
</template>
103+
<template #icon>
104+
<NcIconSvgWrapper :svg="currentView.icon" />
105+
</template>
106+
</NcEmptyContent>
107+
</template>
103108

104109
<!-- File list -->
105110
<FilesListVirtual v-else
@@ -398,9 +403,27 @@ export default defineComponent({
398403
filtersChanged() {
399404
return this.filtersStore.filtersChanged
400405
},
406+
407+
showCustomEmptyView() {
408+
return !this.loading && this.isEmptyDir && this.currentView?.emptyView !== undefined
409+
}
401410
},
402411
403412
watch: {
413+
/**
414+
* Handle rendering the custom empty view
415+
* @param show The current state if the custom empty view should be rendered
416+
*/
417+
showCustomEmptyView(show: boolean) {
418+
if (show) {
419+
this.$nextTick(() => {
420+
const el = this.$refs.customEmptyView as HTMLDivElement
421+
// We can cast here because "showCustomEmptyView" assets that current view is set
422+
this.currentView!.emptyView!(el)
423+
})
424+
}
425+
},
426+
404427
currentView(newView, oldView) {
405428
if (newView?.id === oldView?.id) {
406429
return
@@ -691,6 +714,11 @@ export default defineComponent({
691714
}
692715
}
693716
717+
&__empty-view-wrapper {
718+
display: flex;
719+
height: 100%;
720+
}
721+
694722
&__refresh-icon {
695723
flex: 0 0 44px;
696724
width: 44px;

0 commit comments

Comments
 (0)