From 3e915e526b464885c7a799fd7dd4adedff650b69 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 21 Dec 2019 17:43:50 -0800 Subject: [PATCH] Fix file creation in nested directory --- .../scripts/components/server/files/FileEditContainer.tsx | 2 +- .../scripts/components/server/files/FileNameModal.tsx | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/resources/scripts/components/server/files/FileEditContainer.tsx b/resources/scripts/components/server/files/FileEditContainer.tsx index 8c9b192b5..2d0de6576 100644 --- a/resources/scripts/components/server/files/FileEditContainer.tsx +++ b/resources/scripts/components/server/files/FileEditContainer.tsx @@ -46,7 +46,7 @@ export default () => { }) .then(() => { if (name) { - history.push(`/server/${id}/files/edit#${hash.replace(/^#/, '')}/${name}`); + history.push(`/server/${id}/files/edit#/${name}`); return; } diff --git a/resources/scripts/components/server/files/FileNameModal.tsx b/resources/scripts/components/server/files/FileNameModal.tsx index 16aafc0d0..98cdd49fa 100644 --- a/resources/scripts/components/server/files/FileNameModal.tsx +++ b/resources/scripts/components/server/files/FileNameModal.tsx @@ -3,6 +3,8 @@ import Modal, { RequiredModalProps } from '@/components/elements/Modal'; import { Form, Formik, FormikActions } from 'formik'; import { object, string } from 'yup'; import Field from '@/components/elements/Field'; +import { ServerContext } from '@/state/server'; +import { join } from 'path'; type Props = RequiredModalProps & { onFileNamed: (name: string) => void; @@ -13,8 +15,10 @@ interface Values { } export default ({ onFileNamed, onDismissed, ...props }: Props) => { + const directory = ServerContext.useStoreState(state => state.files.directory); + const submit = (values: Values, { setSubmitting }: FormikActions) => { - onFileNamed(values.fileName); + onFileNamed(join(directory, values.fileName)); setSubmitting(false); }; @@ -40,6 +44,7 @@ export default ({ onFileNamed, onDismissed, ...props }: Props) => { name={'fileName'} label={'File Name'} description={'Enter the name that this file should be saved as.'} + autoFocus={true} />