Skip to content

Commit

Permalink
Fix renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan committed Oct 6, 2022
1 parent 97c6d6c commit eb99f91
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
27 changes: 14 additions & 13 deletions packages/web-app-files/src/mixins/actions/rename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Resource } from 'web-client'
import { dirname, join } from 'path'
import { WebDAV } from 'web-client/src/webdav'
import { SpaceResource } from 'web-client/src/helpers'
import { SHARE_JAIL_ID } from 'files/src/services/folder'

export default {
computed: {
Expand Down Expand Up @@ -34,16 +35,6 @@ export default {
if (resources.length !== 1) {
return false
}
// FIXME: once renaming shares in share_jail has been sorted out backend side we can enable renaming shares again
if (
this.capabilities?.spaces?.share_jail === true &&
(isLocationSharesActive(this.$router, 'files-shares-with-me') ||
(isLocationSpacesActive(this.$router, 'files-spaces-generic') &&
this.space.driveType === 'share' &&
resources[0].path === '/'))
) {
return false
}

const renameDisabled = resources.some((resource) => {
return !resource.canRename()
Expand Down Expand Up @@ -184,11 +175,21 @@ export default {
this.toggleModalConfirmButton()

try {
const hasShareJail = this.capabilities?.spaces?.share_jail === true
space = space || this.space
const newPath = join(dirname(resource.path), newName)
await (this.$clientService.webdav as WebDAV).moveFiles(space, resource, space, {
path: newPath
})
await (this.$clientService.webdav as WebDAV).moveFiles(
space,
resource,
space,
{
path: newPath
},
{
hasShareJail,
shareJailId: SHARE_JAIL_ID
}
)
this.hideModal()

if (isSameResource(resource, this.currentFolder)) {
Expand Down
12 changes: 10 additions & 2 deletions packages/web-client/src/webdav/moveFiles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { urlJoin } from 'web-pkg/src/utils'
import { isPublicSpaceResource, SpaceResource } from '../helpers'
import { isPublicSpaceResource, isShareSpaceResource, SpaceResource } from '../helpers'
import { WebDavOptions } from './types'

export const MoveFilesFactory = ({ sdk }: WebDavOptions) => {
Expand All @@ -9,8 +9,16 @@ export const MoveFilesFactory = ({ sdk }: WebDavOptions) => {
{ path: sourcePath },
targetSpace: SpaceResource,
{ path: targetPath },
options?: { overwrite?: boolean }
options?: { overwrite?: boolean; hasShareJail?: boolean; shareJailId?: string }
): Promise<void> {
if (options?.hasShareJail && isShareSpaceResource(sourceSpace)) {
console.log('WOOP')
return sdk.files.move(
`${sourceSpace.webDavPath}/${sourcePath || ''}`,
`/spaces/${options?.shareJailId}!${options?.shareJailId}/${targetPath || ''}`,
options?.overwrite || false
)
}
if (isPublicSpaceResource(sourceSpace)) {
return sdk.publicFiles.move(
urlJoin(sourceSpace.webDavPath.replace(/^\/public-files/, ''), sourcePath),
Expand Down

0 comments on commit eb99f91

Please sign in to comment.