diff --git a/resources/assets/scripts/api/server/files/copyElement.ts b/resources/assets/scripts/api/server/files/copyElement.ts index 7b594974d..a65c50c29 100644 --- a/resources/assets/scripts/api/server/files/copyElement.ts +++ b/resources/assets/scripts/api/server/files/copyElement.ts @@ -1,15 +1,17 @@ import {withCredentials} from "@/api/http"; import {ServerApplicationCredentials} from "@/store/types"; +type PathChangeObject = { + currentPath: string, + newPath: string, +} /** * Creates a copy of the given file or directory on the Daemon. Expects a fully resolved path * to be passed through for both data arguments. */ -export function copyElement(server: string, credentials: ServerApplicationCredentials, data: { - currentPath: string, newPath: string -}): Promise { +export function copyElement(server: string, credentials: ServerApplicationCredentials, data: PathChangeObject, isMove = false): Promise { return new Promise((resolve, reject) => { - withCredentials(server, credentials).post('/v1/server/file/copy', { + withCredentials(server, credentials).post(`/v1/server/file/${isMove ? 'move' : 'copy'}`, { from: data.currentPath, to: data.newPath, }) @@ -17,3 +19,11 @@ export function copyElement(server: string, credentials: ServerApplicationCreden .catch(reject); }); } + +/** + * Moves a file or folder to a new location on the server. Works almost exactly the same as the copy + * file logic, so it really just passes an extra argument to copy to indicate that it is a move. + */ +export function moveElement(server: string, credentials: ServerApplicationCredentials, data: PathChangeObject): Promise { + return copyElement(server, credentials, data, true); +} diff --git a/resources/assets/scripts/components/server/components/filemanager/FileContextMenu.vue b/resources/assets/scripts/components/server/components/filemanager/FileContextMenu.vue index b8588a633..c37f8897a 100644 --- a/resources/assets/scripts/components/server/components/filemanager/FileContextMenu.vue +++ b/resources/assets/scripts/components/server/components/filemanager/FileContextMenu.vue @@ -7,7 +7,7 @@
Rename
-
+
diff --git a/resources/assets/scripts/components/server/components/filemanager/FileRow.vue b/resources/assets/scripts/components/server/components/filemanager/FileRow.vue index d2b0bbd37..d69d78b32 100644 --- a/resources/assets/scripts/components/server/components/filemanager/FileRow.vue +++ b/resources/assets/scripts/components/server/components/filemanager/FileRow.vue @@ -34,11 +34,13 @@ v-on:action:delete="showModal('delete')" v-on:action:rename="showModal('rename')" v-on:action:copy="showModal('copy')" + v-on:action:move="showModal('move')" ref="contextMenu" /> +
@@ -52,6 +54,7 @@ import DeleteFileModal from "@/components/server/components/filemanager/modals/DeleteFileModal.vue"; import RenameModal from "@/components/server/components/filemanager/modals/RenameModal.vue"; import CopyFileModal from "@/components/server/components/filemanager/modals/CopyFileModal.vue"; + import MoveFileModal from "@/components/server/components/filemanager/modals/MoveFileModal.vue"; type DataStructure = { currentDirectory: string, @@ -61,7 +64,7 @@ export default Vue.extend({ name: 'FileRow', - components: {CopyFileModal, DeleteFileModal, Icon, FileContextMenu, RenameModal}, + components: {CopyFileModal, DeleteFileModal, MoveFileModal, Icon, FileContextMenu, RenameModal}, props: { file: { @@ -83,6 +86,7 @@ rename: false, delete: false, copy: false, + move: false, }, }; }, diff --git a/resources/assets/scripts/components/server/components/filemanager/modals/MoveFileModal.vue b/resources/assets/scripts/components/server/components/filemanager/modals/MoveFileModal.vue new file mode 100644 index 000000000..e64f63345 --- /dev/null +++ b/resources/assets/scripts/components/server/components/filemanager/modals/MoveFileModal.vue @@ -0,0 +1,130 @@ + + + diff --git a/resources/assets/scripts/components/server/components/filemanager/modals/RenameModal.vue b/resources/assets/scripts/components/server/components/filemanager/modals/RenameModal.vue index dd666a032..288974ac3 100644 --- a/resources/assets/scripts/components/server/components/filemanager/modals/RenameModal.vue +++ b/resources/assets/scripts/components/server/components/filemanager/modals/RenameModal.vue @@ -16,8 +16,8 @@ :placeholder="object.name" ref="elementNameField" v-model="newName" - v-validate.disabled="'required'" - v-validate="'alpha_dash'" + :data-vv-as="object.directory ? 'folder name' : 'file name'" + v-validate="{ required: true, regex: /(^[\w\d.\-\/]+$)/}" v-on:keyup.enter="submit" />
@@ -34,8 +34,8 @@ -

- {{ errors.first('folder_name') }} +

+ {{ errors.first('element_name') }}