Skip to content

Commit

Permalink
Merge pull request #46374 from nextcloud/fix/29-nextcloud-libraries
Browse files Browse the repository at this point in the history
[stable29] fix: Update Nextcloud libraries
  • Loading branch information
susnux authored Jul 10, 2024
2 parents 2071f4d + e1a76f1 commit 27a8e5f
Show file tree
Hide file tree
Showing 173 changed files with 732 additions and 1,688 deletions.
3 changes: 1 addition & 2 deletions apps/files/src/actions/moveOrCopyAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
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].attributes.displayname || files[0].basename
return t('files', 'Open folder {displayName}', { displayName })
},
iconSvgInline: () => FolderSvg,
Expand Down
22 changes: 13 additions & 9 deletions apps/files/src/components/BreadCrumbs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

<script lang="ts">
import type { Node } from '@nextcloud/files'
import type { FileSource } from '../types.ts'

import { basename } from 'path'
import { defineComponent } from 'vue'
Expand All @@ -62,6 +63,7 @@ import NcBreadcrumb from '@nextcloud/vue/dist/Components/NcBreadcrumb.js'
import NcBreadcrumbs from '@nextcloud/vue/dist/Components/NcBreadcrumbs.js'
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'

import { useNavigation } from '../composables/useNavigation'
import { onDropInternalFiles, dataTransferToFileTree, onDropExternalFiles } from '../services/DropService'
import { showError } from '@nextcloud/dialogs'
import { useDragAndDropStore } from '../store/dragging.ts'
Expand All @@ -71,7 +73,6 @@ import { useSelectionStore } from '../store/selection.ts'
import { useUploaderStore } from '../store/uploader.ts'
import filesListWidthMixin from '../mixins/filesListWidth.ts'
import logger from '../logger'
import type { FileSource } from '../types.ts'

export default defineComponent({
name: 'BreadCrumbs',
Expand Down Expand Up @@ -99,21 +100,20 @@ export default defineComponent({
const pathsStore = usePathsStore()
const selectionStore = useSelectionStore()
const uploaderStore = useUploaderStore()
const { currentView } = useNavigation()

return {
draggingStore,
filesStore,
pathsStore,
selectionStore,
uploaderStore,

currentView,
}
},

computed: {
currentView() {
return this.$navigation.active
},

dirs(): string[] {
const cumulativePath = (acc: string) => (value: string) => (acc += `${value}/`)
// Generate a cumulative path for each path segment: ['/', '/foo', '/foo/bar', ...] etc
Expand Down Expand Up @@ -167,17 +167,17 @@ export default defineComponent({
getNodeFromSource(source: FileSource): Node | undefined {
return this.filesStore.getNode(source)
},
getFileSourceFromPath(path: string): FileSource | undefined {
return this.pathsStore.getPath(this.currentView?.id, path)
getFileSourceFromPath(path: string): FileSource | null {
return (this.currentView && this.pathsStore.getPath(this.currentView.id, path)) ?? null
},
getDirDisplayName(path: string): string {
if (path === '/') {
return this.$navigation?.active?.name || t('files', 'Home')
}

const source: FileSource | undefined = this.getFileSourceFromPath(path)
const source: FileSource | null = 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) {
Expand All @@ -187,6 +187,10 @@ export default defineComponent({
},

onDragOver(event: DragEvent, path: string) {
if (!event.dataTransfer) {
return
}

// Cannot drop on the current directory
if (path === this.dirs[this.dirs.length - 1]) {
event.dataTransfer.dropEffect = 'none'
Expand Down
22 changes: 14 additions & 8 deletions apps/files/src/components/DragAndDropNotice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { Folder, Permission } from '@nextcloud/files'
import type { Folder } from '@nextcloud/files'
import { Permission } from '@nextcloud/files'
import { showError } from '@nextcloud/dialogs'
import { translate as t } from '@nextcloud/l10n'
import { UploadStatus } from '@nextcloud/upload'
import { defineComponent, type PropType } from 'vue'

import TrayArrowDownIcon from 'vue-material-design-icons/TrayArrowDown.vue'

import logger from '../logger.js'
import { useNavigation } from '../composables/useNavigation'
import { dataTransferToFileTree, onDropExternalFiles } from '../services/DropService'
import logger from '../logger.js'

export default defineComponent({
name: 'DragAndDropNotice',
Expand All @@ -64,22 +66,26 @@ export default defineComponent({

props: {
currentFolder: {
type: Folder,
type: Object as PropType<Folder>,
required: true,
},
},

setup() {
const { currentView } = useNavigation()

return {
currentView,
}
},

data() {
return {
dragover: false,
}
},

computed: {
currentView() {
return this.$navigation.active
},

/**
* Check if the current folder has create permissions
*/
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/components/DragAndDropPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 11 additions & 5 deletions apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@

<script lang="ts">
import { defineComponent } from 'vue'
import { Permission, formatFileSize } from '@nextcloud/files'
import { formatFileSize } from '@nextcloud/files'
import moment from '@nextcloud/moment'

import { useNavigation } from '../composables/useNavigation'
import { useActionsMenuStore } from '../store/actionsmenu.ts'
import { useDragAndDropStore } from '../store/dragging.ts'
import { useFilesStore } from '../store/files.ts'
Expand Down Expand Up @@ -157,12 +158,16 @@ export default defineComponent({
const filesStore = useFilesStore()
const renamingStore = useRenamingStore()
const selectionStore = useSelectionStore()
const { currentView } = useNavigation()

return {
actionsMenuStore,
draggingStore,
filesStore,
renamingStore,
selectionStore,

currentView,
}
},

Expand Down Expand Up @@ -196,21 +201,22 @@ export default defineComponent({
},

size() {
const size = parseInt(this.source.size, 10)
if (typeof size !== 'number' || isNaN(size) || size < 0) {
const size = this.source.size
if (!size || size < 0) {
return this.t('files', 'Pending')
}
return formatFileSize(size, true)
},

sizeOpacity() {
const maxOpacitySize = 10 * 1024 * 1024

const size = parseInt(this.source.size, 10)
const size = this.source.size
if (!size || isNaN(size) || size < 0) {
return {}
}

const ratio = Math.round(Math.min(100, 100 * Math.pow((this.source.size / maxOpacitySize), 2)))
const ratio = Math.round(Math.min(100, 100 * Math.pow((size / maxOpacitySize), 2)))
return {
color: `color-mix(in srgb, var(--color-main-text) ${ratio}%, var(--color-text-maxcontrast))`,
}
Expand Down
24 changes: 16 additions & 8 deletions apps/files/src/components/FileEntry/FileEntryActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,22 @@
</template>

<script lang="ts">
import type { PropType } from 'vue'
import type { PropType, ShallowRef } from 'vue'
import type { FileAction, Node, View } from '@nextcloud/files'

import { DefaultType, FileAction, Node, NodeStatus, View, getFileActions } from '@nextcloud/files'
import { DefaultType, NodeStatus, getFileActions } from '@nextcloud/files'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { translate as t } from '@nextcloud/l10n'
import { defineComponent } from 'vue'

import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
import NcActionSeparator from '@nextcloud/vue/dist/Components/NcActionSeparator.js'
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import ArrowLeftIcon from 'vue-material-design-icons/ArrowLeft.vue'
import Vue, { defineComponent } from 'vue'

import { useNavigation } from '../../composables/useNavigation'
import CustomElementRender from '../CustomElementRender.vue'
import logger from '../../logger.js'

Expand Down Expand Up @@ -149,6 +151,15 @@ export default defineComponent({
},
},

setup() {
const { currentView } = useNavigation()

return {
// The file list is guaranteed to be only shown with active view
currentView: currentView as ShallowRef<View>,
}
},

data() {
return {
openedSubmenu: null as FileAction | null,
Expand All @@ -160,9 +171,6 @@ export default defineComponent({
// Remove any trailing slash but leave root slash
return (this.$route?.query?.dir?.toString() || '/').replace(/^(.+)\/$/, '$1')
},
currentView(): View {
return this.$navigation.active as View
},
isLoading() {
return this.source.status === NodeStatus.LOADING
},
Expand Down Expand Up @@ -286,7 +294,7 @@ export default defineComponent({
try {
// Set the loading marker
this.$emit('update:loading', action.id)
Vue.set(this.source, 'status', NodeStatus.LOADING)
this.$set(this.source, 'status', NodeStatus.LOADING)

const success = await action.exec(this.source, this.currentView, this.currentDir)

Expand All @@ -306,7 +314,7 @@ export default defineComponent({
} finally {
// Reset the loading marker
this.$emit('update:loading', '')
Vue.set(this.source, 'status', undefined)
this.$set(this.source, 'status', undefined)

// If that was a submenu, we just go back after the action
if (isSubmenu) {
Expand Down
6 changes: 6 additions & 0 deletions apps/files/src/components/FileEntry/FileEntryName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
</template>

<script lang="ts">
import type { Node } from '@nextcloud/files'
import type { PropType } from 'vue'

import { emit } from '@nextcloud/event-bus'
Expand All @@ -66,6 +67,7 @@ import Vue from 'vue'

import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'

import { useNavigation } from '../../composables/useNavigation'
import { useRenamingStore } from '../../store/renaming.ts'
import logger from '../../logger.js'

Expand Down Expand Up @@ -106,8 +108,12 @@ export default Vue.extend({
},

setup() {
const { currentView } = useNavigation()
const renamingStore = useRenamingStore()

return {
currentView,

renamingStore,
}
},
Expand Down
5 changes: 5 additions & 0 deletions apps/files/src/components/FileEntryGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<script lang="ts">
import { defineComponent } from 'vue'

import { useNavigation } from '../composables/useNavigation'
import { useActionsMenuStore } from '../store/actionsmenu.ts'
import { useDragAndDropStore } from '../store/dragging.ts'
import { useFilesStore } from '../store/files.ts'
Expand Down Expand Up @@ -110,12 +111,16 @@ export default defineComponent({
const filesStore = useFilesStore()
const renamingStore = useRenamingStore()
const selectionStore = useSelectionStore()
const { currentView } = useNavigation()

return {
actionsMenuStore,
draggingStore,
filesStore,
renamingStore,
selectionStore,

currentView,
}
},

Expand Down
11 changes: 3 additions & 8 deletions apps/files/src/components/FileEntryMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ export default defineComponent({
},

computed: {
currentView(): View {
return this.$navigation.active as View
},

currentDir() {
// Remove any trailing slash but leave root slash
return (this.$route?.query?.dir?.toString() || '/').replace(/^(.+)\/$/, '$1')
Expand All @@ -88,15 +84,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)
Expand Down
Loading

0 comments on commit 27a8e5f

Please sign in to comment.