From 4f3aedb1f0792039ed61c875307947029b1597dd Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Mon, 4 Nov 2024 17:28:24 +0000 Subject: [PATCH 1/2] Make user confirm on first upload --- .../Context/CompileContextProvider.tsx | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/gui/src/app/Compilation/Context/CompileContextProvider.tsx b/gui/src/app/Compilation/Context/CompileContextProvider.tsx index 15a5ee8..935d804 100644 --- a/gui/src/app/Compilation/Context/CompileContextProvider.tsx +++ b/gui/src/app/Compilation/Context/CompileContextProvider.tsx @@ -46,6 +46,29 @@ const useIsConnected = (stanWasmServerUrl: string) => { const initialStanWasmServerUrl = localStorage.getItem("stanWasmServerUrl") || publicCompilationServerUrl; +const showOneTimeMessage = (url: string) => { + if (url !== publicCompilationServerUrl) { + // if the user opted in to a custom URL, we assume they are good with it... + return true; + } + + const alreadyConfirmed = "compileModelUploadMessage"; + if (localStorage.getItem(alreadyConfirmed) === "true") { + return true; + } + if ( + window.confirm( + "This will upload the main.stan file to the server " + + "for compilation. All other files remain local.\n" + + "Do you want to continue? (This message will not be shown again.)", + ) + ) { + localStorage.setItem(alreadyConfirmed, "true"); + return true; + } + return false; +}; + export const CompileContextProvider: FunctionComponent< PropsWithChildren > = ({ children }) => { @@ -86,6 +109,10 @@ export const CompileContextProvider: FunctionComponent< }, [stanWasmServerUrl]); const handleCompile = useCallback(async () => { + if (!showOneTimeMessage(stanWasmServerUrl)) { + return; + } + setCompileStatus("compiling"); await new Promise((resolve) => setTimeout(resolve, 500)); // for effect const onStatus = (msg: string) => { From 3d182c79432502d1e337f378833e1b62326dedc5 Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Mon, 4 Nov 2024 13:47:43 -0500 Subject: [PATCH 2/2] Update gui/src/app/Compilation/Context/CompileContextProvider.tsx Co-authored-by: Jeff Soules --- gui/src/app/Compilation/Context/CompileContextProvider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/app/Compilation/Context/CompileContextProvider.tsx b/gui/src/app/Compilation/Context/CompileContextProvider.tsx index 935d804..4458cdc 100644 --- a/gui/src/app/Compilation/Context/CompileContextProvider.tsx +++ b/gui/src/app/Compilation/Context/CompileContextProvider.tsx @@ -60,7 +60,7 @@ const showOneTimeMessage = (url: string) => { window.confirm( "This will upload the main.stan file to the server " + "for compilation. All other files remain local.\n" + - "Do you want to continue? (This message will not be shown again.)", + "Do you want to continue? (If you accept, this message will not be shown again.)", ) ) { localStorage.setItem(alreadyConfirmed, "true");