Skip to content

Commit 5f99e20

Browse files
committed
fix: always use the node displayname prop
It will fallback to basename anyways but will fix usage in public shares where the displayname is the real name but the basename is the share token. Also fixes end-to-end encryption ui. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent a61c93d commit 5f99e20

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

lib/components/ConflictPicker/ConflictPickerEntry.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ function validate() {
177177

178178
<template>
179179
<fieldset :class="$style.pickerEntry">
180-
<legend>{{ existing.basename }}</legend>
180+
<legend>{{ existing.displayname }}</legend>
181181

182182
<!-- Incoming file -->
183183
<NcCheckboxRadioSwitch

lib/components/FilePicker/FileListRow.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const node = new File({
5959
mime: 'text/plain',
6060
source: 'https://example.com/remote.php/dav/alice/a.txt',
6161
root: '/',
62-
attributes: { displayName: 'test' },
62+
attributes: { displayname: 'test' },
6363
})
6464

6565
const folder = new Folder({
@@ -69,7 +69,7 @@ const folder = new Folder({
6969
source: 'https://example.com/remote.php/dav/alice/b',
7070
root: '/',
7171
permissions: Permission.ALL,
72-
attributes: { displayName: 'test folder' },
72+
attributes: { displayname: 'test folder' },
7373
})
7474

7575
const folderNonReadable = new Folder({
@@ -79,7 +79,7 @@ const folderNonReadable = new Folder({
7979
source: 'https://example.com/remote.php/dav/alice/b',
8080
root: '/',
8181
permissions: Permission.ALL & ~Permission.READ,
82-
attributes: { displayName: 'test folder' },
82+
attributes: { displayname: 'test folder' },
8383
})
8484

8585
const defaultOptions = {

lib/components/FilePicker/FileListRow.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import type { INode } from '@nextcloud/files'
5050
5151
import { FileType, formatFileSize, Permission } from '@nextcloud/files'
52+
import { extname } from '@nextcloud/paths'
5253
import { computed } from 'vue'
5354
import NcCheckboxRadioSwitch from '@nextcloud/vue/components/NcCheckboxRadioSwitch'
5455
import NcDateTime from '@nextcloud/vue/components/NcDateTime'
@@ -80,14 +81,14 @@ const emit = defineEmits<{
8081
const timestamp = computed(() => props.node.mtime ?? 0)
8182
8283
/**
83-
* The displayname of the current node (excluding file extension)
84+
* The file extension of the file
8485
*/
85-
const displayName = computed(() => props.node.attributes?.displayName || props.node.basename.slice(0, props.node.extension ? -props.node.extension.length : undefined))
86+
const fileExtension = computed(() => extname(props.node.displayname))
8687
8788
/**
88-
* The file extension of the file
89+
* The displayname of the current node (excluding file extension)
8990
*/
90-
const fileExtension = computed(() => props.node.extension)
91+
const displayName = computed(() => props.node.displayname.slice(0, fileExtension.value ? -fileExtension.value.length : undefined))
9192
9293
/**
9394
* Check if the node is a directory

lib/filepicker-builder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ export class FilePickerBuilder<IsMultiSelect extends boolean> {
211211
public setType(type: FilePickerType) {
212212
this.buttons = (nodes, path) => {
213213
const buttons: IFilePickerButton[] = []
214-
const node = nodes?.[0]?.attributes?.displayName || nodes?.[0]?.basename
215-
const target = node || basename(path)
214+
const node = nodes[0]
215+
const target = node?.displayname || basename(path)
216216

217217
if (type === FilePickerType.Choose) {
218218
let label = t('Choose')
219219
if (nodes.length === 1) {
220-
label = t('Choose {file}', { file: node })
220+
label = t('Choose {file}', { file: target })
221221
} else if (this.multiSelect) {
222222
label = n('Choose %n file', 'Choose %n files', nodes.length)
223223
}

0 commit comments

Comments
 (0)