From 78ccdf93b66a653dcf967cc28f3e4be1eb39e3a7 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 26 Oct 2019 13:16:27 -0700 Subject: [PATCH] Square away saving of existing files --- .../api/server/files/saveFileContents.ts | 18 ++++++ .../scripts/components/elements/AceEditor.tsx | 2 +- .../server/files/FileEditContainer.tsx | 59 +++++++++++++---- .../server/files/FileManagerBreadcrumbs.tsx | 64 +++++++++++++++++++ .../server/files/FileManagerContainer.tsx | 47 ++------------ 5 files changed, 135 insertions(+), 55 deletions(-) create mode 100644 resources/scripts/api/server/files/saveFileContents.ts create mode 100644 resources/scripts/components/server/files/FileManagerBreadcrumbs.tsx diff --git a/resources/scripts/api/server/files/saveFileContents.ts b/resources/scripts/api/server/files/saveFileContents.ts new file mode 100644 index 000000000..22f1766c3 --- /dev/null +++ b/resources/scripts/api/server/files/saveFileContents.ts @@ -0,0 +1,18 @@ +import http from '@/api/http'; + +export default (uuid: string, file: string, content: string): Promise => { + return new Promise((resolve, reject) => { + http.post( + `/api/client/servers/${uuid}/files/write`, + content, + { + params: { file }, + headers: { + 'Content-Type': 'text/plain', + }, + }, + ) + .then(() => resolve()) + .catch(reject); + }); +}; diff --git a/resources/scripts/components/elements/AceEditor.tsx b/resources/scripts/components/elements/AceEditor.tsx index 3afab6364..e62c24d95 100644 --- a/resources/scripts/components/elements/AceEditor.tsx +++ b/resources/scripts/components/elements/AceEditor.tsx @@ -113,7 +113,7 @@ export default ({ style, initialContent, initialModePath, fetchContent, onConten return (
-
+