mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
Merge branch 'v2' of https://github.com/notsidney/xtable into v2
This commit is contained in:
@@ -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";
|
||||
@@ -107,6 +108,7 @@ export default function App() {
|
||||
routes.userSettings,
|
||||
routes.userManagement,
|
||||
routes.impersonatorAuth,
|
||||
routes.rowyRunTest,
|
||||
]}
|
||||
render={() => (
|
||||
<ProjectContextProvider>
|
||||
@@ -116,6 +118,11 @@ export default function App() {
|
||||
path={routes.impersonatorAuth}
|
||||
render={() => <ImpersonatorAuthPage />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={routes.rowyRunTest}
|
||||
render={() => <RowyRunTestView />}
|
||||
/>
|
||||
<PrivateRoute
|
||||
exact
|
||||
path={routes.home}
|
||||
|
||||
@@ -128,7 +128,8 @@ export default function FieldSettings(props: IMenuModalProps) {
|
||||
rowyRun({
|
||||
route: RunRoutes.buildFunction,
|
||||
body: {
|
||||
configPath: tableState?.config.tableConfig.path,
|
||||
triggerPath: "demoAllFieldTypes/{docId}",
|
||||
// configPath: tableState?.config.tableConfig.path,
|
||||
},
|
||||
params: [],
|
||||
});
|
||||
|
||||
@@ -20,6 +20,7 @@ export enum routes {
|
||||
userSettings = "/settings/user",
|
||||
projectSettings = "/settings/project",
|
||||
userManagement = "/settings/userManagement",
|
||||
rowyRunTest = "/rrTest",
|
||||
}
|
||||
|
||||
export default routes;
|
||||
|
||||
@@ -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" },
|
||||
|
||||
@@ -72,7 +72,7 @@ interface ProjectContextProps {
|
||||
rowyRun: (args: {
|
||||
route: RunRoute;
|
||||
body?: any;
|
||||
params: string[];
|
||||
params?: string[];
|
||||
}) => Promise<any>;
|
||||
}
|
||||
|
||||
@@ -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, {
|
||||
|
||||
96
src/pages/RowyRunTest.tsx
Normal file
96
src/pages/RowyRunTest.tsx
Normal file
@@ -0,0 +1,96 @@
|
||||
import { useState } from "react";
|
||||
import { useSnackbar } from "notistack";
|
||||
|
||||
import Navigation from "components/Navigation";
|
||||
import {
|
||||
useTheme,
|
||||
Container,
|
||||
Button,
|
||||
TextField,
|
||||
Tabs,
|
||||
Tab,
|
||||
LinearProgress,
|
||||
Select,
|
||||
InputLabel,
|
||||
MenuItem,
|
||||
FormControl,
|
||||
} 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";
|
||||
|
||||
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<any>({});
|
||||
|
||||
const [method, setMethod] = useState<"GET" | "POST">("GET");
|
||||
const [path, setPath] = useState<string>("/");
|
||||
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;
|
||||
setLoading(true);
|
||||
const resp = await rowyRun({
|
||||
route: {
|
||||
method,
|
||||
path,
|
||||
},
|
||||
});
|
||||
setResult(resp);
|
||||
setLoading(false);
|
||||
};
|
||||
return (
|
||||
<Navigation title="Rowy Run Sandbox">
|
||||
{loading && <LinearProgress />}
|
||||
<Container style={{ margin: "24px 0 200px" }}>
|
||||
<FormControl style={{ minWidth: 240 }}>
|
||||
<InputLabel>Defined Route</InputLabel>
|
||||
<Select
|
||||
value={
|
||||
Object.values(RunRoutes).find((r) => r.path === path)?.path ?? ""
|
||||
}
|
||||
onChange={setDefinedRoute}
|
||||
>
|
||||
{Object.values(RunRoutes).map((route) => (
|
||||
<MenuItem key={route.path} value={route.path}>
|
||||
{route.path}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
</FormControl>
|
||||
<Tabs value={method} onChange={handleMethodChange}>
|
||||
<Tab label="GET" value="GET" />
|
||||
<Tab label="POST" value="POST" />
|
||||
<Tab label="PUT" value="PUT" />
|
||||
<Tab label="DELETE" value="DELETE" />
|
||||
</Tabs>
|
||||
<TextField
|
||||
value={path}
|
||||
onChange={(value) => {
|
||||
setPath(value.target.value);
|
||||
}}
|
||||
/>
|
||||
<Button onClick={handleRun}>Call</Button>
|
||||
<pre>{JSON.stringify(result, null, 2)}</pre>
|
||||
</Container>
|
||||
</Navigation>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user