Skip to content

Commit a5770a5

Browse files
authored
Merge pull request #46917 from nextcloud/fix/add-missing-empty-content
fix(files): Add missing `emptyView` handling
2 parents c8c84e6 + f570507 commit a5770a5

3 files changed

Lines changed: 57 additions & 29 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
@@ -391,9 +396,27 @@ export default defineComponent({
391396
filtersChanged() {
392397
return this.filtersStore.filtersChanged
393398
},
399+
400+
showCustomEmptyView() {
401+
return !this.loading && this.isEmptyDir && this.currentView?.emptyView !== undefined
402+
}
394403
},
395404
396405
watch: {
406+
/**
407+
* Handle rendering the custom empty view
408+
* @param show The current state if the custom empty view should be rendered
409+
*/
410+
showCustomEmptyView(show: boolean) {
411+
if (show) {
412+
this.$nextTick(() => {
413+
const el = this.$refs.customEmptyView as HTMLDivElement
414+
// We can cast here because "showCustomEmptyView" assets that current view is set
415+
this.currentView!.emptyView!(el)
416+
})
417+
}
418+
},
419+
397420
currentView(newView, oldView) {
398421
if (newView?.id === oldView?.id) {
399422
return
@@ -679,6 +702,11 @@ export default defineComponent({
679702
}
680703
}
681704
705+
&__empty-view-wrapper {
706+
display: flex;
707+
height: 100%;
708+
}
709+
682710
&__refresh-icon {
683711
flex: 0 0 44px;
684712
width: 44px;

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)