From 5f8325b27ce927054e7c3ed7cd162ca0e07565f2 Mon Sep 17 00:00:00 2001 From: shamsmosowi Date: Tue, 14 Sep 2021 00:38:01 +1000 Subject: [PATCH 1/2] rowy run tester --- src/App.tsx | 7 ++ .../Table/ColumnMenu/FieldSettings/index.tsx | 3 +- src/constants/routes.ts | 1 + src/contexts/ProjectContext.tsx | 8 +- src/pages/RowyRunTest.tsx | 84 +++++++++++++++++++ 5 files changed, 98 insertions(+), 5 deletions(-) create mode 100644 src/pages/RowyRunTest.tsx diff --git a/src/App.tsx b/src/App.tsx index a7d65ce3..9540442f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -25,6 +25,7 @@ import routes from "constants/routes"; import AuthView from "pages/Auth"; import SignOutView from "pages/Auth/SignOut"; import TestView from "pages/Test"; +import RowyRunTestView from "pages/RowyRunTest"; import Favicon from "assets/Favicon"; import "analytics"; @@ -100,6 +101,7 @@ export default function App() { routes.userSettings, routes.userManagement, routes.impersonatorAuth, + routes.rowyRunTest, ]} render={() => ( @@ -109,6 +111,11 @@ export default function App() { path={routes.impersonatorAuth} render={() => } /> + } + /> Promise; } @@ -181,7 +181,7 @@ export const ProjectContextProvider: React.FC = ({ children }) => { } ); }; - + console.log("tableState", tableState); // rowyRun access const rowyRun = async ({ route, @@ -190,11 +190,11 @@ export const ProjectContextProvider: React.FC = ({ children }) => { }: { route: RunRoute; body?: any; - params: string[]; + params?: string[]; }) => { const { method, path } = route; let url = - // 'http://localhost:8080' + //'http://localhost:8080' settings.doc.rowyRunUrl + path; if (params && params.length > 0) url = url + "/" + params.join("/"); const response = await fetch(url, { diff --git a/src/pages/RowyRunTest.tsx b/src/pages/RowyRunTest.tsx new file mode 100644 index 00000000..3f927130 --- /dev/null +++ b/src/pages/RowyRunTest.tsx @@ -0,0 +1,84 @@ +import { useState } from "react"; +import { useSnackbar } from "notistack"; + +import Navigation from "components/Navigation"; +import { + useTheme, + Container, + Button, + TextField, + Tabs, + Tab, + LinearProgress, +} 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"; + +const typographyVariants = [ + "h1", + "h2", + "h3", + "h4", + "h5", + "h6", + "subtitle1", + "subtitle2", + "body1", + "body2", + "button", + "caption", + "overline", +]; + +export default function TestView() { + const theme = useTheme(); + const { requestConfirmation } = useConfirmation(); + const { enqueueSnackbar, closeSnackbar } = useSnackbar(); + const [loading, setLoading] = useState(false); + const { rowyRun } = useProjectContext(); + const [result, setResult] = useState({}); + + const [method, setMethod] = useState<"GET" | "POST">("GET"); + const [path, setPath] = useState(""); + const handleMethodChange = (_, newMethod) => setMethod(newMethod); + + const handleRun = async () => { + console.log("run"); + if (!rowyRun) return; + setLoading(true); + const resp = await rowyRun({ + route: { + method, + path, + }, + }); + setResult(resp); + setLoading(false); + }; + return ( + + {loading && } + + + + + + + + { + setPath(value.target.value); + }} + /> + +
{JSON.stringify(result, null, 2)}
+
+
+ ); +} From 1b6274c22ea1ce562a5498ba261c30b6568ceb27 Mon Sep 17 00:00:00 2001 From: shamsmosowi Date: Tue, 14 Sep 2021 10:44:56 +1000 Subject: [PATCH 2/2] defined routes --- src/constants/runRoutes.ts | 1 + src/pages/RowyRunTest.tsx | 50 +++++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/constants/runRoutes.ts b/src/constants/runRoutes.ts index 88e1f006..1e6f0f81 100644 --- a/src/constants/runRoutes.ts +++ b/src/constants/runRoutes.ts @@ -32,6 +32,7 @@ type RunRoutes = actionScriptRequest | impersonateUserRequest; export const RunRoutes: { [key: string]: RunRoute } = { impersonateUser: { path: "/impersonateUser", method: "GET" }, version: { path: "/version", method: "GET" }, + region: { path: "/region", method: "GET" }, listCollections: { path: "/listCollections", method: "GET" }, actionScript: { path: "/actionScript", method: "POST" }, buildFunction: { path: "/buildFunction", method: "POST" }, diff --git a/src/pages/RowyRunTest.tsx b/src/pages/RowyRunTest.tsx index 3f927130..caa137b3 100644 --- a/src/pages/RowyRunTest.tsx +++ b/src/pages/RowyRunTest.tsx @@ -10,6 +10,10 @@ import { Tabs, Tab, LinearProgress, + Select, + InputLabel, + MenuItem, + FormControl, } from "@mui/material"; import SparkIcon from "@mui/icons-material/OfflineBoltOutlined"; import { useConfirmation } from "components/ConfirmationDialog"; @@ -18,22 +22,7 @@ import SnackbarProgress, { ISnackbarProgressRef, } from "components/SnackbarProgress"; import { useProjectContext } from "@src/contexts/ProjectContext"; - -const typographyVariants = [ - "h1", - "h2", - "h3", - "h4", - "h5", - "h6", - "subtitle1", - "subtitle2", - "body1", - "body2", - "button", - "caption", - "overline", -]; +import { RunRoutes } from "@src/constants/runRoutes"; export default function TestView() { const theme = useTheme(); @@ -44,9 +33,17 @@ export default function TestView() { const [result, setResult] = useState({}); const [method, setMethod] = useState<"GET" | "POST">("GET"); - const [path, setPath] = useState(""); + const [path, setPath] = useState("/"); const handleMethodChange = (_, newMethod) => setMethod(newMethod); - + const setDefinedRoute = (newPath) => { + setPath(newPath.target.value); + const _method = Object.values(RunRoutes).find( + (r) => r.path === path + )?.method; + if (_method) { + setMethod(_method); + } + }; const handleRun = async () => { console.log("run"); if (!rowyRun) return; @@ -64,6 +61,21 @@ export default function TestView() { {loading && } + + Defined Route + + @@ -71,7 +83,7 @@ export default function TestView() { { setPath(value.target.value); }}