Merge pull request #45728 from nextcloud/backport/45611/stable29

This commit is contained in:
Benjamin Gaussorgues 2024-06-10 11:11:54 +02:00 committed by GitHub
commit f993d52c2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 48 additions and 22 deletions

View file

@ -76,7 +76,7 @@ describe('Open in files action execute tests', () => {
// Silent action
expect(exec).toBe(null)
expect(goToRouteMock).toBeCalledTimes(1)
expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/Foo' })
expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/Foo', openfile: 'true' })
})
test('Open in files with folder', async () => {
@ -96,6 +96,6 @@ describe('Open in files action execute tests', () => {
// Silent action
expect(exec).toBe(null)
expect(goToRouteMock).toBeCalledTimes(1)
expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/Foo/Bar' })
expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/Foo/Bar', openfile: 'true' })
})
})

View file

@ -42,7 +42,7 @@ export const action = new FileAction({
window.OCP.Files.Router.goToRoute(
null, // use default route
{ view: 'files', fileid: node.fileid },
{ dir },
{ dir, openfile: 'true' },
)
return null
},

View file

@ -60,7 +60,7 @@ export const action = new FileAction({
window.OCP.Files.Router.goToRoute(
null,
{ view: view.id, fileid: node.fileid },
{ dir },
{ ...window.OCP.Files.Router.query, dir },
true,
)

View file

@ -228,12 +228,12 @@ export default defineComponent({
return this.enabledActions
.filter(action => action.parent)
.reduce((arr, action) => {
if (!arr[action.parent]) {
arr[action.parent] = []
if (!arr[action.parent!]) {
arr[action.parent!] = []
}
arr[action.parent].push(action)
arr[action.parent!].push(action)
return arr
}, {} as Record<string, FileAction>)
}, {} as Record<string, FileAction[]>)
},
openedMenu: {
@ -255,7 +255,7 @@ export default defineComponent({
},
mountType() {
return this.source._attributes['mount-type']
return this.source.attributes['mount-type']
},
},

View file

@ -20,7 +20,7 @@
*
*/
import type { PropType } from 'vue'
import type { ComponentPublicInstance, PropType } from 'vue'
import { showError } from '@nextcloud/dialogs'
import { FileType, Permission, Folder, File as NcFile, NodeStatus, Node, View } from '@nextcloud/files'
@ -35,6 +35,7 @@ import { getDragAndDropPreview } from '../utils/dragUtils.ts'
import { hashCode } from '../utils/hashUtils.ts'
import { dataTransferToFileTree, onDropExternalFiles, onDropInternalFiles } from '../services/DropService.ts'
import logger from '../logger.js'
import FileEntryActions from '../components/FileEntry/FileEntryActions.vue'
Vue.directive('onClickOutside', vOnClickOutside)
@ -233,7 +234,8 @@ export default defineComponent({
return false
}
this.$refs.actions.execDefaultAction(event)
const actions = this.$refs.actions as ComponentPublicInstance<typeof FileEntryActions>
actions.execDefaultAction(event)
},
openDetailsIfAvailable(event) {

View file

@ -142,9 +142,17 @@ export default Vue.extend({
return Math.floor(this.filesListWidth / this.itemWidth)
},
/**
* Index of the first item to be rendered
*/
startIndex() {
return Math.max(0, this.index - this.bufferItems)
},
/**
* Number of items to be rendered at the same time
* For list view this is the same as `rowCount`, for grid view this is `rowCount` * `columnCount`
*/
shownItems() {
// If in grid mode, we need to multiply the number of rows by the number of columns
if (this.gridMode) {
@ -153,6 +161,7 @@ export default Vue.extend({
return this.rowCount
},
renderedItems(): RecycledPoolItem[] {
if (!this.isReady) {
return []
@ -181,6 +190,13 @@ export default Vue.extend({
})
},
/**
* The total number of rows that are available
*/
totalRowCount() {
return Math.floor(this.dataSources.length / this.columnCount)
},
tbodyStyle() {
const isOverScrolled = this.startIndex + this.rowCount > this.dataSources.length
const lastIndex = this.dataSources.length - this.startIndex - this.shownItems
@ -188,6 +204,7 @@ export default Vue.extend({
return {
paddingTop: `${Math.floor(this.startIndex / this.columnCount) * this.itemHeight}px`,
paddingBottom: isOverScrolled ? 0 : `${hiddenAfterItems * this.itemHeight}px`,
minHeight: `${this.totalRowCount * this.itemHeight + this.beforeHeight}px`,
}
},
},
@ -195,6 +212,13 @@ export default Vue.extend({
scrollToIndex(index) {
this.scrollTo(index)
},
totalRowCount() {
if (this.scrollToIndex) {
this.$nextTick(() => this.scrollTo(this.scrollToIndex))
}
},
columnCount(columnCount, oldColumnCount) {
if (oldColumnCount === 0) {
// We're initializing, the scroll position

View file

@ -89,6 +89,6 @@ describe('Open in files action execute tests', () => {
// Silent action
expect(exec).toBe(null)
expect(goToRouteMock).toBeCalledTimes(1)
expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/Foo' })
expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/Foo', openfile: 'true' })
})
})

View file

@ -44,7 +44,7 @@ export const action = new FileAction({
window.OCP.Files.Router.goToRoute(
null, // use default route
{ view: 'files', fileid: node.fileid },
{ dir: node.dirname },
{ dir: node.dirname, openfile: 'true' },
)
return null
},

4
dist/files-init.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
dist/files-main.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long