From 08210825888bd3eb3a3d3cad9d9b30fba5fbd76a Mon Sep 17 00:00:00 2001 From: shamsmosowi Date: Tue, 14 Sep 2021 12:51:34 +1000 Subject: [PATCH] rowyRun localhost option --- src/contexts/ProjectContext.tsx | 9 ++++++--- src/pages/RowyRunTest.tsx | 20 +++++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/contexts/ProjectContext.tsx b/src/contexts/ProjectContext.tsx index 30634fa0..e7b1b7ba 100644 --- a/src/contexts/ProjectContext.tsx +++ b/src/contexts/ProjectContext.tsx @@ -73,6 +73,7 @@ interface ProjectContextProps { route: RunRoute; body?: any; params?: string[]; + localhost?: boolean; }) => Promise; } @@ -187,15 +188,17 @@ export const ProjectContextProvider: React.FC = ({ children }) => { route, body, params, + localhost = false, }: { route: RunRoute; body?: any; params?: string[]; + localhost?: boolean; }) => { const { method, path } = route; - let url = - //'http://localhost:8080' - settings.doc.rowyRunUrl + path; + let url = `${ + localhost ? "http://localhost:8080" : settings.doc.rowyRunUrl + }${path}`; if (params && params.length > 0) url = url + "/" + params.join("/"); const response = await fetch(url, { method: method, // *GET, POST, PUT, DELETE, etc. diff --git a/src/pages/RowyRunTest.tsx b/src/pages/RowyRunTest.tsx index a2fe94b6..d3133f5d 100644 --- a/src/pages/RowyRunTest.tsx +++ b/src/pages/RowyRunTest.tsx @@ -11,13 +11,10 @@ import { Tab, LinearProgress, MenuItem, + Switch, + FormControlLabel, } from "@mui/material"; -import SparkIcon from "@mui/icons-material/OfflineBoltOutlined"; import { useConfirmation } from "components/ConfirmationDialog"; - -import SnackbarProgress, { - ISnackbarProgressRef, -} from "components/SnackbarProgress"; import { useProjectContext } from "@src/contexts/ProjectContext"; import { RunRoutes } from "@src/constants/runRoutes"; @@ -26,6 +23,7 @@ export default function TestView() { const { requestConfirmation } = useConfirmation(); const { enqueueSnackbar, closeSnackbar } = useSnackbar(); const [loading, setLoading] = useState(false); + const [localhost, setLocalhost] = useState(false); const { rowyRun } = useProjectContext(); const [result, setResult] = useState({}); @@ -50,6 +48,7 @@ export default function TestView() { method, path, }, + localhost, }); setResult(resp); setLoading(false); @@ -63,6 +62,17 @@ export default function TestView() { )} + { + setLocalhost(!localhost); + }} + /> + } + label="Localhost?" + />