Skip to content

Commit

Permalink
Fix storageId in location picker
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Jun 3, 2022
1 parent f09fc09 commit 71b4923
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 25 deletions.
5 changes: 5 additions & 0 deletions packages/web-app-files/src/mixins/actions/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export default {
query.storageId = this.$route.params.storageId
}

if (isLocationSpacesActive(this.$router, 'files-spaces-personal')) {
context = 'personal'
query.storageId = this.$route.params.storageId
}

const item = this.currentFolder.path || this.homeFolder

return this.$router.push(
Expand Down
5 changes: 5 additions & 0 deletions packages/web-app-files/src/mixins/actions/move.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ export default {
query.storageId = this.$route.params.storageId
}

if (isLocationSpacesActive(this.$router, 'files-spaces-personal')) {
context = 'personal'
query.storageId = this.$route.params.storageId
}

const item = this.currentFolder.path || this.homeFolder

return this.$router.push(
Expand Down
70 changes: 50 additions & 20 deletions packages/web-app-files/src/views/LocationPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ export default {
item: itemPath
},
query: {
resource: this.resources
resource: this.resources,
...(this.$route.query.storageId && { storageId: this.$route.query.storageId })
}
}
}
Expand All @@ -364,21 +365,23 @@ export default {
leaveLocationPicker(target) {
switch (this.$route.params.context) {
case 'public':
this.$router.push(
return this.$router.push(
createLocationPublic('files-public-files', { params: { item: target } })
)
break
case 'space':
this.$router.push(
return this.$router.push(
createLocationSpaces('files-spaces-project', {
params: { storageId: this.$route.query.storageId, item: target || '/' }
})
)
break
default:
this.$router.push(
createLocationSpaces('files-spaces-personal', { params: { item: target || '/' } })
case 'personal':
return this.$router.push(
createLocationSpaces('files-spaces-personal', {
params: { storageId: this.$route.query.storageId, item: target || '/' }
})
)
default:
return this.$router.push(createLocationSpaces('files-spaces-personal'))
}
},
Expand Down Expand Up @@ -429,13 +432,26 @@ export default {
targetPath
)
break
case 'personal':
default:
targetPath = buildWebDavFilesPath(this.user.id, this.target || '/')
targetPath += `/${resourceName}`
promise = this.$client.files.move(
buildWebDavFilesPath(this.user.id, resource),
targetPath
)
if (this.hasShareJail) {
targetPath = buildWebDavSpacesPath(
this.$route.query.storageId,
this.target || '/'
)
targetPath += `/${resourceName}`
promise = this.$client.files.move(
buildWebDavSpacesPath(this.$route.query.storageId, resource),
targetPath
)
} else {
targetPath = buildWebDavFilesPath(this.user.id, this.target || '/')
targetPath += `/${resourceName}`
promise = this.$client.files.move(
buildWebDavFilesPath(this.user.id, resource),
targetPath
)
}
}
break
}
Expand All @@ -460,13 +476,27 @@ export default {
targetPath
)
break
case 'personal':
default:
targetPath = buildWebDavFilesPath(this.user.id, this.target || '/')
targetPath += `/${resourceName}`
promise = this.$client.files.copy(
buildWebDavFilesPath(this.user.id, resource),
targetPath
)
if (this.hasShareJail) {
targetPath = buildWebDavSpacesPath(
this.$route.query.storageId,
this.target || '/'
)
resourceName = basename(resource)
targetPath += `/${resourceName}`
promise = this.$client.files.copy(
buildWebDavSpacesPath(this.$route.query.storageId, resource),
targetPath
)
} else {
targetPath = buildWebDavFilesPath(this.user.id, this.target || '/')
targetPath += `/${resourceName}`
promise = this.$client.files.copy(
buildWebDavFilesPath(this.user.id, resource),
targetPath
)
}
}
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,7 @@ describe('LocationPicker', () => {
expect(spyLeaveLocationPicker).toHaveBeenCalledWith('/some/item')
expect(spyRouterPush).toHaveBeenCalledTimes(1)
expect(spyRouterPush).toHaveBeenCalledWith({
name: 'files-spaces-personal',
params: {
item: '/some/item',
storageId: 'home'
}
name: 'files-spaces-personal'
})
})
})
Expand Down
1 change: 1 addition & 0 deletions packages/web-app-files/tests/unit/views/Personal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const router = {
afterEach: jest.fn(),
currentRoute: {
...createLocationSpaces('files-spaces-personal'),
params: { storageId: '1234' },
query: {}
},
resolve: (r) => {
Expand Down
1 change: 1 addition & 0 deletions packages/web-app-files/tests/unit/views/views.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export const getStore = function ({
},
getters: {
configuration: () => ({
server: 'https://owncloud.test',
currentTheme: {
loginPage: {
backgroundImg: loginBackgroundImg
Expand Down

0 comments on commit 71b4923

Please sign in to comment.