Skip to content

Commit 28ca002

Browse files
authored
Merge pull request #2182 from nextcloud-libraries/fix/always-use-displayname-6
[stable6] fix: always use the node displayname prop
2 parents ed642a8 + 02fa236 commit 28ca002

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

lib/components/FilePicker/FileListRow.spec.ts

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

6464
const folder = new Folder({
@@ -68,7 +68,7 @@ const folder = new Folder({
6868
source: 'https://example.com/remote.php/dav/alice/b',
6969
root: '/',
7070
permissions: Permission.ALL,
71-
attributes: { displayName: 'test folder' },
71+
attributes: { displayname: 'test folder' },
7272
})
7373

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

8484
const defaultOptions = {

lib/components/FilePicker/FileListRow.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@
4343
import type { INode } from '@nextcloud/files'
4444
4545
import { formatFileSize, FileType, Permission } from '@nextcloud/files'
46+
import { extname } from '@nextcloud/paths'
47+
import { computed } from 'vue'
4648
import NcCheckboxRadioSwitch from '@nextcloud/vue/components/NcCheckboxRadioSwitch'
4749
import NcDateTime from '@nextcloud/vue/components/NcDateTime'
48-
import { computed } from 'vue'
4950
import { t } from '../../utils/l10n'
5051
5152
import FilePreview from './FilePreview.vue'
@@ -73,14 +74,14 @@ const emit = defineEmits<{
7374
}>()
7475
7576
/**
76-
* The displayname of the current node (excluding file extension)
77+
* The file extension of the file
7778
*/
78-
const displayName = computed(() => props.node.attributes?.displayName || props.node.basename.slice(0, props.node.extension ? -props.node.extension.length : undefined))
79+
const fileExtension = computed(() => extname(props.node.displayname))
7980
8081
/**
81-
* The file extension of the file
82+
* The displayname of the current node (excluding file extension)
8283
*/
83-
const fileExtension = computed(() => props.node.extension)
84+
const displayName = computed(() => props.node.displayname.slice(0, fileExtension.value ? -fileExtension.value.length : undefined))
8485
8586
/**
8687
* 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
@@ -209,13 +209,13 @@ export class FilePickerBuilder<IsMultiSelect extends boolean> {
209209
public setType(type: FilePickerType) {
210210
this.buttons = (nodes, path) => {
211211
const buttons: IFilePickerButton[] = []
212-
const node = nodes?.[0]?.attributes?.displayName || nodes?.[0]?.basename
213-
const target = node || basename(path)
212+
const node = nodes[0]
213+
const target = node?.displayname || basename(path)
214214

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

0 commit comments

Comments
 (0)