Skip to content

Commit f01848c

Browse files
committed
fix(files): Do not split filename into base and extension for folders
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 04788bb commit f01848c

File tree

4 files changed

+34
-16
lines changed

4 files changed

+34
-16
lines changed

apps/files/src/components/FileEntry.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
@click.native="execDefaultAction" />
3535

3636
<FileEntryName ref="name"
37-
:display-name="displayName"
37+
:basename="basename"
3838
:extension="extension"
3939
:files-list-width="filesListWidth"
4040
:nodes="nodes"

apps/files/src/components/FileEntry/FileEntryName.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
v-bind="linkTo.params">
3030
<!-- File name -->
3131
<span class="files-list__row-name-text">
32-
<!-- Keep the displayName stuck to the extension to avoid whitespace rendering issues-->
33-
<span class="files-list__row-name-" v-text="displayName" />
32+
<!-- Keep the filename stuck to the extension to avoid whitespace rendering issues-->
33+
<span class="files-list__row-name-" v-text="basename" />
3434
<span class="files-list__row-name-ext" v-text="extension" />
3535
</span>
3636
</component>
@@ -64,10 +64,16 @@ export default defineComponent({
6464
},
6565
6666
props: {
67-
displayName: {
67+
/**
68+
* The filename without extension
69+
*/
70+
basename: {
6871
type: String,
6972
required: true,
7073
},
74+
/**
75+
* The extension of the filename
76+
*/
7177
extension: {
7278
type: String,
7379
required: true,
@@ -155,7 +161,7 @@ export default defineComponent({
155161
params: {
156162
download: this.source.basename,
157163
href: this.source.source,
158-
title: t('files', 'Download file {name}', { name: this.displayName }),
164+
title: t('files', 'Download file {name}', { name: `${this.basename}${this.extension}` }),
159165
tabindex: '0',
160166
},
161167
}

apps/files/src/components/FileEntryGrid.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
@click.native="execDefaultAction" />
3737

3838
<FileEntryName ref="name"
39-
:display-name="displayName"
39+
:basename="basename"
4040
:extension="extension"
4141
:files-list-width="filesListWidth"
4242
:grid-mode="true"

apps/files/src/components/FileEntryMixin.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,31 @@ export default defineComponent({
7474
return this.source.status === NodeStatus.LOADING
7575
},
7676

77-
extension() {
78-
if (this.source.attributes?.displayname) {
79-
return extname(this.source.attributes.displayname)
77+
/**
78+
* The display name of the current node
79+
* Either the nodes filename or a custom display name (e.g. for shares)
80+
*/
81+
displayName() {
82+
return this.source.displayname
83+
},
84+
/**
85+
* The display name without extension
86+
*/
87+
basename() {
88+
if (this.extension === '') {
89+
return this.displayName
8090
}
81-
return this.source.extension || ''
91+
return this.displayName.slice(0, 0 - this.extension.length)
8292
},
83-
displayName() {
84-
const ext = this.extension
85-
const name = String(this.source.attributes.displayname
86-
|| this.source.basename)
93+
/**
94+
* The extension of the file
95+
*/
96+
extension() {
97+
if (this.source.type === FileType.Folder) {
98+
return ''
99+
}
87100

88-
// Strip extension from name if defined
89-
return !ext ? name : name.slice(0, 0 - ext.length)
101+
return extname(this.displayName)
90102
},
91103

92104
draggingFiles() {

0 commit comments

Comments
 (0)