Fix file creation in nested directory
This commit is contained in:
parent
a1a344bc48
commit
3e915e526b
2 changed files with 7 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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'}>
|
||||
|
|
Loading…
Reference in a new issue