Skip to content

Commit

Permalink
fix(files): Do not split filename into base and extension for fol…
Browse files Browse the repository at this point in the history
…ders

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Jul 22, 2024
1 parent 04788bb commit f01848c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
2 changes: 1 addition & 1 deletion apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@click.native="execDefaultAction" />

<FileEntryName ref="name"
:display-name="displayName"
:basename="basename"
:extension="extension"
:files-list-width="filesListWidth"
:nodes="nodes"
Expand Down
14 changes: 10 additions & 4 deletions apps/files/src/components/FileEntry/FileEntryName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
v-bind="linkTo.params">
<!-- File name -->
<span class="files-list__row-name-text">
<!-- Keep the displayName stuck to the extension to avoid whitespace rendering issues-->
<span class="files-list__row-name-" v-text="displayName" />
<!-- Keep the filename stuck to the extension to avoid whitespace rendering issues-->
<span class="files-list__row-name-" v-text="basename" />
<span class="files-list__row-name-ext" v-text="extension" />
</span>
</component>
Expand Down Expand Up @@ -64,10 +64,16 @@ export default defineComponent({
},
props: {
displayName: {
/**
* The filename without extension
*/
basename: {
type: String,
required: true,
},
/**
* The extension of the filename
*/
extension: {
type: String,
required: true,
Expand Down Expand Up @@ -155,7 +161,7 @@ export default defineComponent({
params: {
download: this.source.basename,
href: this.source.source,
title: t('files', 'Download file {name}', { name: this.displayName }),
title: t('files', 'Download file {name}', { name: `${this.basename}${this.extension}` }),
tabindex: '0',
},
}
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/components/FileEntryGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@click.native="execDefaultAction" />

<FileEntryName ref="name"
:display-name="displayName"
:basename="basename"
:extension="extension"
:files-list-width="filesListWidth"
:grid-mode="true"
Expand Down
32 changes: 22 additions & 10 deletions apps/files/src/components/FileEntryMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,31 @@ export default defineComponent({
return this.source.status === NodeStatus.LOADING
},

extension() {
if (this.source.attributes?.displayname) {
return extname(this.source.attributes.displayname)
/**
* The display name of the current node
* Either the nodes filename or a custom display name (e.g. for shares)
*/
displayName() {
return this.source.displayname
},
/**
* The display name without extension
*/
basename() {
if (this.extension === '') {
return this.displayName
}
return this.source.extension || ''
return this.displayName.slice(0, 0 - this.extension.length)
},
displayName() {
const ext = this.extension
const name = String(this.source.attributes.displayname
|| this.source.basename)
/**
* The extension of the file
*/
extension() {
if (this.source.type === FileType.Folder) {
return ''
}

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

draggingFiles() {
Expand Down

0 comments on commit f01848c

Please sign in to comment.