From 26ec4bc0f0d5ecaaedb468993400632e2d5a58c0 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Wed, 23 Sep 2020 18:14:46 -0300 Subject: [PATCH] 16592: Restores 'Rename' action. Adds support for baseURL w/o trailing slash. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- src/common/webdav.ts | 14 ++++++++++++-- .../collection-files-item-action-set.ts | 19 +++++++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/common/webdav.ts b/src/common/webdav.ts index b2f43348..17032768 100644 --- a/src/common/webdav.ts +++ b/src/common/webdav.ts @@ -42,14 +42,24 @@ export class WebDAV { this.request({ ...config, url, method: 'COPY', - headers: { ...config.headers, Destination: this.defaults.baseURL + destination } + headers: { + ...config.headers, + Destination: this.defaults.baseURL + ? this.defaults.baseURL.replace(/\/+$/, '') + '/' + destination.replace(/^\/+/, '') + : destination + } }) move = (url: string, destination: string, config: WebDAVRequestConfig = {}) => this.request({ ...config, url, method: 'MOVE', - headers: { ...config.headers, Destination: this.defaults.baseURL + destination } + headers: { + ...config.headers, + Destination: this.defaults.baseURL + ? this.defaults.baseURL.replace(/\/+$/, '') + '/' + destination.replace(/^\/+/, '') + : destination + } }) delete = (url: string, config: WebDAVRequestConfig = {}) => diff --git a/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts b/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts index 2ded3736..b900d186 100644 --- a/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts +++ b/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts @@ -3,9 +3,9 @@ // SPDX-License-Identifier: AGPL-3.0 import { ContextMenuActionSet } from "../context-menu-action-set"; -import { RemoveIcon } from "~/components/icon/icon"; +import { RemoveIcon, RenameIcon } from "~/components/icon/icon"; import { DownloadCollectionFileAction } from "../actions/download-collection-file-action"; -import { openFileRemoveDialog } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions'; +import { openFileRemoveDialog, openRenameFileDialog } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions'; import { CollectionFileViewerAction } from '~/views-components/context-menu/actions/collection-file-viewer-action'; @@ -21,14 +21,13 @@ export const readOnlyCollectionFilesItemActionSet: ContextMenuActionSet = [[ ]]; export const collectionFilesItemActionSet: ContextMenuActionSet = readOnlyCollectionFilesItemActionSet.concat([[ - // FIXME: This isn't working. Maybe something related to WebDAV? - // { - // name: "Rename", - // icon: RenameIcon, - // execute: (dispatch, resource) => { - // dispatch(openRenameFileDialog({ name: resource.name, id: resource.uuid })); - // } - // }, + { + name: "Rename", + icon: RenameIcon, + execute: (dispatch, resource) => { + dispatch(openRenameFileDialog({ name: resource.name, id: resource.uuid })); + } + }, { name: "Remove", icon: RemoveIcon, -- 2.30.2