Skip to content

Commit 3e915e5

Browse files
committed
Fix file creation in nested directory
1 parent a1a344b commit 3e915e5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

resources/scripts/components/server/files/FileEditContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default () => {
4646
})
4747
.then(() => {
4848
if (name) {
49-
history.push(`/server/${id}/files/edit#${hash.replace(/^#/, '')}/${name}`);
49+
history.push(`/server/${id}/files/edit#/${name}`);
5050
return;
5151
}
5252

resources/scripts/components/server/files/FileNameModal.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import Modal, { RequiredModalProps } from '@/components/elements/Modal';
33
import { Form, Formik, FormikActions } from 'formik';
44
import { object, string } from 'yup';
55
import Field from '@/components/elements/Field';
6+
import { ServerContext } from '@/state/server';
7+
import { join } from 'path';
68

79
type Props = RequiredModalProps & {
810
onFileNamed: (name: string) => void;
@@ -13,8 +15,10 @@ interface Values {
1315
}
1416

1517
export default ({ onFileNamed, onDismissed, ...props }: Props) => {
18+
const directory = ServerContext.useStoreState(state => state.files.directory);
19+
1620
const submit = (values: Values, { setSubmitting }: FormikActions<Values>) => {
17-
onFileNamed(values.fileName);
21+
onFileNamed(join(directory, values.fileName));
1822
setSubmitting(false);
1923
};
2024

@@ -40,6 +44,7 @@ export default ({ onFileNamed, onDismissed, ...props }: Props) => {
4044
name={'fileName'}
4145
label={'File Name'}
4246
description={'Enter the name that this file should be saved as.'}
47+
autoFocus={true}
4348
/>
4449
<div className={'mt-6 text-right'}>
4550
<button className={'btn btn-primary btn-sm'}>

0 commit comments

Comments
 (0)