Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/files/src/actions/openFolderAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const action = new FileAction({
id: 'open-folder',
displayName(files: Node[]) {
// Only works on single node
const displayName = files[0].attributes.displayname || files[0].basename
const displayName = files[0].displayname
return t('files', 'Open folder {displayName}', { displayName })
},
iconSvgInline: () => FolderSvg,
Expand Down
6 changes: 3 additions & 3 deletions apps/files/src/components/BreadCrumbs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ export default defineComponent({
return this.$navigation?.active?.name || t('files', 'Home')
}

const source: FileSource | null = this.getFileSourceFromPath(path)
const node: Node | undefined = source ? this.getNodeFromSource(source) : undefined
return node?.attributes?.displayname || basename(path)
const source = this.getFileSourceFromPath(path)
const node = source ? this.getNodeFromSource(source) : undefined
return node?.displayname || basename(path)
},

onClick(to) {
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,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 @@ -46,8 +46,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 @@ -81,10 +81,16 @@ export default Vue.extend({
},

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 @@ -172,7 +178,7 @@ export default Vue.extend({
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 @@ -53,7 +53,7 @@
@click.native="execDefaultAction" />

<FileEntryName ref="name"
:display-name="displayName"
:basename="basename"
:extension="extension"
:files-list-width="filesListWidth"
:grid-mode="true"
Expand Down
31 changes: 22 additions & 9 deletions apps/files/src/components/FileEntryMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,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
6 changes: 6 additions & 0 deletions apps/files/src/services/Files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ export const resultToNode = function(node: FileStat): File | Folder {
? hashCode(source)
: props?.fileid as number || 0

// TODO remove this hack with nextcloud-files v3.7
// just needed because of a bug in the webdav client
if (node.props?.displayname !== undefined) {
node.props.displayname = String(node.props.displayname)
}

const nodeData = {
id,
source,
Expand Down
100 changes: 0 additions & 100 deletions apps/files/src/services/SortingService.spec.ts

This file was deleted.

59 changes: 0 additions & 59 deletions apps/files/src/services/SortingService.ts

This file was deleted.

49 changes: 8 additions & 41 deletions apps/files/src/views/FilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ import type { UserConfig } from '../types.ts'
import { getCapabilities } from '@nextcloud/capabilities'
import { showError } from '@nextcloud/dialogs'
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
import { Folder, Node, Permission } from '@nextcloud/files'
import { Folder, Node, Permission, sortNodes } from '@nextcloud/files'
import { loadState } from '@nextcloud/initial-state'
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
import { ShareType } from '@nextcloud/sharing'
Expand Down Expand Up @@ -154,7 +154,6 @@ import { useSelectionStore } from '../store/selection.ts'
import { useUploaderStore } from '../store/uploader.ts'
import { useUserConfigStore } from '../store/userconfig.ts'
import { useViewConfigStore } from '../store/viewConfig.ts'
import { orderBy } from '../services/SortingService.ts'
import BreadCrumbs from '../components/BreadCrumbs.vue'
import FilesListVirtual from '../components/FilesListVirtual.vue'
import filesListWidthMixin from '../mixins/filesListWidth.ts'
Expand Down Expand Up @@ -273,44 +272,10 @@ export default defineComponent({
return this.filesStore.getNode(source) as Folder
},

/**
* Directory content sorting parameters
* Provided by an extra computed property for caching
*/
sortingParameters() {
const identifiers = [
// 1: Sort favorites first if enabled
...(this.userConfig.sort_favorites_first ? [v => v.attributes?.favorite !== 1] : []),
// 2: Sort folders first if sorting by name
...(this.userConfig.sort_folders_first ? [v => v.type !== 'folder'] : []),
// 3: Use sorting mode if NOT basename (to be able to use displayName too)
...(this.sortingMode !== 'basename' ? [v => v[this.sortingMode]] : []),
// 4: Use displayname if available, fallback to name
v => v.attributes?.displayname || v.basename,
// 5: Finally, use basename if all previous sorting methods failed
v => v.basename,
]
const orders = [
// (for 1): always sort favorites before normal files
...(this.userConfig.sort_favorites_first ? ['asc'] : []),
// (for 2): always sort folders before files
...(this.userConfig.sort_folders_first ? ['asc'] : []),
// (for 3): Reverse if sorting by mtime as mtime higher means edited more recent -> lower
...(this.sortingMode === 'mtime' ? [this.isAscSorting ? 'desc' : 'asc'] : []),
// (also for 3 so make sure not to conflict with 2 and 3)
...(this.sortingMode !== 'mtime' && this.sortingMode !== 'basename' ? [this.isAscSorting ? 'asc' : 'desc'] : []),
// for 4: use configured sorting direction
this.isAscSorting ? 'asc' : 'desc',
// for 5: use configured sorting direction
this.isAscSorting ? 'asc' : 'desc',
]
return [identifiers, orders] as const
},

/**
* The current directory contents.
*/
dirContentsSorted(): Node[] {
dirContentsSorted() {
if (!this.currentView) {
return []
}
Expand All @@ -333,10 +298,12 @@ export default defineComponent({
return this.isAscSorting ? results : results.reverse()
}

return orderBy(
filteredDirContent,
...this.sortingParameters,
)
return sortNodes(filteredDirContent, {
sortFavoritesFirst: this.userConfig.sort_favorites_first,
sortFoldersFirst: this.userConfig.sort_folders_first,
sortingMode: this.sortingMode,
sortingOrder: this.isAscSorting ? 'asc' : 'desc',
})
},

dirContents(): Node[] {
Expand Down
Loading