diff --git a/apps/files/src/actions/moveOrCopyAction.ts b/apps/files/src/actions/moveOrCopyAction.ts index c77c88eb8c1..9afe4121286 100644 --- a/apps/files/src/actions/moveOrCopyAction.ts +++ b/apps/files/src/actions/moveOrCopyAction.ts @@ -30,7 +30,7 @@ import { AxiosError } from 'axios' import { basename, join } from 'path' import { emit } from '@nextcloud/event-bus' import { FilePickerClosed, getFilePickerBuilder, showError } from '@nextcloud/dialogs' -import { Permission, FileAction, FileType, NodeStatus, davGetClient, davRootPath, davResultToNode, davGetDefaultPropfind } from '@nextcloud/files' +import { FileAction, FileType, NodeStatus, davGetClient, davRootPath, davResultToNode, davGetDefaultPropfind, getUniqueName } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' import { openConflictPicker, hasConflict } from '@nextcloud/upload' import Vue from 'vue' @@ -41,7 +41,6 @@ import FolderMoveSvg from '@mdi/svg/svg/folder-move.svg?raw' import { MoveCopyAction, canCopy, canMove, getQueue } from './moveOrCopyActionUtils' import { getContents } from '../services/Files' import logger from '../logger' -import { getUniqueName } from '../utils/fileUtils' /** * Return the action that is possible for the given nodes diff --git a/apps/files/src/actions/openFolderAction.ts b/apps/files/src/actions/openFolderAction.ts index 791b328b3ed..f575bdde7e8 100644 --- a/apps/files/src/actions/openFolderAction.ts +++ b/apps/files/src/actions/openFolderAction.ts @@ -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].attributes.displayname || files[0].basename return t('files', 'Open folder {displayName}', { displayName }) }, iconSvgInline: () => FolderSvg, diff --git a/apps/files/src/components/BreadCrumbs.vue b/apps/files/src/components/BreadCrumbs.vue index e979405b599..823c9554d8c 100644 --- a/apps/files/src/components/BreadCrumbs.vue +++ b/apps/files/src/components/BreadCrumbs.vue @@ -177,7 +177,7 @@ export default defineComponent({ const source: FileSource | undefined = this.getFileSourceFromPath(path) const node: Node | undefined = source ? this.getNodeFromSource(source) : undefined - return node?.attributes?.displayName || basename(path) + return node?.attributes?.displayname || basename(path) }, onClick(to) { diff --git a/apps/files/src/components/DragAndDropPreview.vue b/apps/files/src/components/DragAndDropPreview.vue index 1284eed2566..dd4e2d036bc 100644 --- a/apps/files/src/components/DragAndDropPreview.vue +++ b/apps/files/src/components/DragAndDropPreview.vue @@ -79,7 +79,7 @@ export default Vue.extend({ summary(): string { if (this.isSingleNode) { const node = this.nodes[0] - return node.attributes?.displayName || node.basename + return node.attributes?.displayname || node.basename } return getSummaryFor(this.nodes) diff --git a/apps/files/src/components/FileEntryMixin.ts b/apps/files/src/components/FileEntryMixin.ts index 94d7610bc07..d54b20fc757 100644 --- a/apps/files/src/components/FileEntryMixin.ts +++ b/apps/files/src/components/FileEntryMixin.ts @@ -88,15 +88,14 @@ export default defineComponent({ }, extension() { - if (this.source.attributes?.displayName) { - return extname(this.source.attributes.displayName) + if (this.source.attributes?.displayname) { + return extname(this.source.attributes.displayname) } return this.source.extension || '' }, displayName() { const ext = this.extension - const name = (this.source.attributes.displayName - || this.source.basename) + const name = String(this.source.attributes.displayname || this.source.basename) // Strip extension from name if defined return !ext ? name : name.slice(0, 0 - ext.length) diff --git a/apps/files/src/components/NewNodeDialog.vue b/apps/files/src/components/NewNodeDialog.vue index 5947334f11b..4087b58c607 100644 --- a/apps/files/src/components/NewNodeDialog.vue +++ b/apps/files/src/components/NewNodeDialog.vue @@ -47,7 +47,7 @@ import type { PropType } from 'vue' import { defineComponent } from 'vue' import { translate as t } from '@nextcloud/l10n' -import { getUniqueName } from '../utils/fileUtils' +import { getUniqueName } from '@nextcloud/files' import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' import NcDialog from '@nextcloud/vue/dist/Components/NcDialog.js' diff --git a/apps/files/src/utils/davUtils.js b/apps/files/src/utils/davUtils.js index 22367d09a1a..d86b69eaabd 100644 --- a/apps/files/src/utils/davUtils.js +++ b/apps/files/src/utils/davUtils.js @@ -20,17 +20,8 @@ * */ -import { generateRemoteUrl } from '@nextcloud/router' import { getCurrentUser } from '@nextcloud/auth' -export const getRootPath = function() { - if (getCurrentUser()) { - return generateRemoteUrl(`dav/files/${getCurrentUser().uid}`) - } else { - return generateRemoteUrl('webdav').replace('/remote.php', '/public.php') - } -} - export const isPublic = function() { return !getCurrentUser() } diff --git a/apps/files/src/utils/fileUtils.ts b/apps/files/src/utils/fileUtils.ts index fe94fc9fb43..f874c316076 100644 --- a/apps/files/src/utils/fileUtils.ts +++ b/apps/files/src/utils/fileUtils.ts @@ -19,44 +19,9 @@ * along with this program. If not, see . * */ -import { basename, extname } from 'path' import { FileType, type Node } from '@nextcloud/files' import { translate as t, translatePlural as n } from '@nextcloud/l10n' -// TODO: move to @nextcloud/files -/** - * Create an unique file name - * @param name The initial name to use - * @param otherNames Other names that are already used - * @param options Optional parameters for tuning the behavior - * @param options.suffix A function that takes an index and returns a suffix to add to the file name, defaults to '(index)' - * @param options.ignoreFileExtension Set to true to ignore the file extension when adding the suffix (when getting a unique directory name) - * @return Either the initial name, if unique, or the name with the suffix so that the name is unique - */ -export const getUniqueName = ( - name: string, - otherNames: string[], - options: { - suffix?: (i: number) => string, - ignoreFileExtension?: boolean, - } = {}, -): string => { - const opts = { - suffix: (n: number) => `(${n})`, - ignoreFileExtension: false, - ...options, - } - - let newName = name - let i = 1 - while (otherNames.includes(newName)) { - const ext = opts.ignoreFileExtension ? '' : extname(name) - const base = basename(name, ext) - newName = `${base} ${opts.suffix(i++)}${ext}` - } - return newName -} - /** * Extract dir and name from file path * diff --git a/apps/files/src/views/FilesList.vue b/apps/files/src/views/FilesList.vue index a9c7dacc1ae..7fa7aff9a01 100644 --- a/apps/files/src/views/FilesList.vue +++ b/apps/files/src/views/FilesList.vue @@ -280,8 +280,8 @@ export default defineComponent({ ...(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, + // 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, ] diff --git a/package-lock.json b/package-lock.json index 701f031d428..e13429606d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "@nextcloud/capabilities": "^1.2.0", "@nextcloud/dialogs": "^5.3.5", "@nextcloud/event-bus": "^3.3.1", - "@nextcloud/files": "^3.4.1", + "@nextcloud/files": "^3.5.1", "@nextcloud/initial-state": "^2.0.0", "@nextcloud/l10n": "^2.1.0", "@nextcloud/logger": "^2.5.0", diff --git a/package.json b/package.json index 134e19da2d2..9c204884634 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@nextcloud/capabilities": "^1.2.0", "@nextcloud/dialogs": "^5.3.5", "@nextcloud/event-bus": "^3.3.1", - "@nextcloud/files": "^3.4.1", + "@nextcloud/files": "^3.5.1", "@nextcloud/initial-state": "^2.0.0", "@nextcloud/l10n": "^2.1.0", "@nextcloud/logger": "^2.5.0",