Fix file creation in nested directory

This commit is contained in:
Dane Everitt 2019-12-21 17:43:50 -08:00
parent a1a344bc48
commit 3e915e526b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 7 additions and 2 deletions

View file

@ -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;
}

View file

@ -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<Values>) => {
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}
/>
<div className={'mt-6 text-right'}>
<button className={'btn btn-primary btn-sm'}>