Skip to content

Commit

Permalink
Fix parent folder rename
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Mar 21, 2022
1 parent df1e953 commit 0fb2479
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-rename-parent
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Rename parent folder

We fixed the rename option in the parent folder / breadcrumb context menu. It was broken due to malformed webdav paths.

https://github.com/owncloud/web/issues/6516
https://github.com/owncloud/web/pull/6631
5 changes: 4 additions & 1 deletion packages/web-app-files/src/mixins/actions/rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export default {
async $_rename_trigger({ resources }) {
let parentResources
if (isSameResource(resources[0], this.currentFolder)) {
const parentPaths = getParentPaths(resources[0].path, false)
const prefix = resources[0].webDavPath.slice(0, -resources[0].path.length)
const parentPaths = getParentPaths(resources[0].path, false).map((path) => {
return prefix + path
})
parentResources = await this.$client.files.list(parentPaths[0], 1)
parentResources = parentResources.map(buildResource)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ localVue.use(Vuex)

const currentFolder = {
id: 1,
path: '/folder'
path: '/folder',
webDavPath: '/files/admin/folder'
}

const Component = {
Expand All @@ -36,7 +37,7 @@ describe('rename', () => {
it('should trigger the rename modal window', async () => {
const wrapper = getWrapper()
const spyCreateModalStub = jest.spyOn(wrapper.vm, 'createModal')
const resources = [{ id: 1 }]
const resources = [currentFolder]
await wrapper.vm.$_rename_trigger({ resources })
expect(spyCreateModalStub).toHaveBeenCalledTimes(1)
})
Expand Down Expand Up @@ -91,7 +92,7 @@ describe('rename', () => {

const wrapper = getWrapper(promise)
const spyHideModalStub = jest.spyOn(wrapper.vm, 'hideModal')
const resource = { id: 2, path: 'folder' }
const resource = { id: 2, path: '/folder', webDavPath: '/files/admin/folder' }
wrapper.vm.$_rename_renameResource(resource, 'new name')
await wrapper.vm.$nextTick()

Expand Down

0 comments on commit 0fb2479

Please sign in to comment.