From 85b47ceb79922dd6c96049c84dea13a5d5bd1652 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Mon, 16 Dec 2019 19:55:02 -0800 Subject: [PATCH] Slightly more logical handling when moving things around --- .../components/server/files/RenameFileModal.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/resources/scripts/components/server/files/RenameFileModal.tsx b/resources/scripts/components/server/files/RenameFileModal.tsx index 7f50c8413..a94b91034 100644 --- a/resources/scripts/components/server/files/RenameFileModal.tsx +++ b/resources/scripts/components/server/files/RenameFileModal.tsx @@ -17,7 +17,7 @@ type Props = RequiredModalProps & { file: FileObject; useMoveTerminology?: boole export default ({ file, useMoveTerminology, ...props }: Props) => { const uuid = ServerContext.useStoreState(state => state.server.data!.uuid); const directory = ServerContext.useStoreState(state => state.files.directory); - const pushFile = ServerContext.useStoreActions(actions => actions.files.pushFile); + const { pushFile, removeFile } = ServerContext.useStoreActions(actions => actions.files); const submit = (values: FormikValues, { setSubmitting }: FormikActions) => { const renameFrom = join(directory, file.name); @@ -25,7 +25,14 @@ export default ({ file, useMoveTerminology, ...props }: Props) => { renameFile(uuid, { renameFrom, renameTo }) .then(() => { - pushFile({ ...file, name: values.name }); + if (!useMoveTerminology && values.name.split('/').length === 1) { + pushFile({ ...file, name: values.name }); + } + + if ((useMoveTerminology || values.name.split('/').length > 1) && file.uuid.length > 0) { + removeFile(file.uuid); + } + props.onDismissed(); }) .catch(error => {