[INFRA-421] | Anoop | Remove unused links, add hidden json show page for debugging
This commit is contained in:
30
src/App.tsx
30
src/App.tsx
@@ -6,21 +6,13 @@ import { Route, Redirect } from "react-router";
|
||||
import { BrowserRouter as Router } from "react-router-dom";
|
||||
import Dashboard from "./components/Dashboard";
|
||||
import ProtectedRoute from "./components/ProtectedRoute";
|
||||
import AddLayout from "./components/admin/editform/AddLayout";
|
||||
import { CookiesProvider } from "react-cookie";
|
||||
import { getUser } from "./action/action";
|
||||
import { store } from "./store/store";
|
||||
import { withCookies } from "react-cookie";
|
||||
import { ToastContainer } from 'react-toastify';
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
|
||||
const config = {
|
||||
issuer: window.config.ISSUER,
|
||||
redirectUri: window.config.REDIRECT_URI,
|
||||
responseType: window.config.RESPONSE_TYPE,
|
||||
scope: window.config.SCOPE,
|
||||
clientId: window.config.CLIENT_ID,
|
||||
};
|
||||
import ShowJson from "./components/manifest/ShowJson";
|
||||
|
||||
function App() {
|
||||
const { state, dispatch } = React.useContext(store);
|
||||
@@ -42,10 +34,10 @@ function App() {
|
||||
<p>Healthy</p>
|
||||
</Route>
|
||||
<Route path="/" exact>
|
||||
<Dashboard />
|
||||
{isAuthenticated ? <Redirect to="/manifests" /> : <Dashboard />}
|
||||
</Route>
|
||||
<Route path="/dashboard" exact>
|
||||
<Dashboard />
|
||||
{isAuthenticated ? <Redirect to="/manifests" /> : <Dashboard />}
|
||||
</Route>
|
||||
<ProtectedRoute
|
||||
path="/manifests/create"
|
||||
@@ -61,14 +53,16 @@ function App() {
|
||||
/>
|
||||
<ProtectedRoute
|
||||
path={"/manifests"}
|
||||
exact
|
||||
loginRedirect={loginRedirect}
|
||||
>
|
||||
<ShowDeploymentManifest />
|
||||
</ProtectedRoute>
|
||||
<ProtectedRoute path={"/admin"} exact loginRedirect={loginRedirect}>
|
||||
<AddLayout />
|
||||
</ProtectedRoute>
|
||||
component={ShowDeploymentManifest}
|
||||
exact
|
||||
/>
|
||||
<ProtectedRoute
|
||||
path="/manifests/:manifestId/json"
|
||||
component={ShowJson}
|
||||
loginRedirect={loginRedirect}
|
||||
exact
|
||||
/>
|
||||
</Router>
|
||||
</CookiesProvider>
|
||||
<ToastContainer position="bottom-left"/>
|
||||
|
||||
@@ -138,27 +138,15 @@ function MenuAppBar(props: any) {
|
||||
}}
|
||||
keepMounted
|
||||
transformOrigin={{
|
||||
vertical: "top",
|
||||
horizontal: "right",
|
||||
vertical: "bottom",
|
||||
horizontal: "left",
|
||||
}}
|
||||
open={open}
|
||||
onClose={handleClose}
|
||||
>
|
||||
{isAuthenticated ? (
|
||||
<MenuItem onClick={handleClose}>Profile</MenuItem>
|
||||
) : null}
|
||||
{isAuthenticated ? (
|
||||
<MenuItem onClick={handleClose}>My account</MenuItem>
|
||||
) : null}
|
||||
{isAuthenticated ? (
|
||||
<MenuItem component={Link} onClick={handleClose} to="/admin">
|
||||
Admin
|
||||
</MenuItem>
|
||||
) : null}
|
||||
{isAuthenticated ? (
|
||||
<MenuItem onClick={handleLogout}>Logout</MenuItem>
|
||||
) : null}
|
||||
|
||||
{isAuthenticated ? null : (
|
||||
<MenuItem onClick={handleLogin}>Login</MenuItem>
|
||||
)}
|
||||
|
||||
32
src/components/manifest/ShowJson.tsx
Normal file
32
src/components/manifest/ShowJson.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { withCookies } from "react-cookie";
|
||||
import * as React from "react";
|
||||
|
||||
const ShowJson = (props: any) => {
|
||||
|
||||
const [jsonData, setJsonData] = React.useState({});
|
||||
|
||||
const getManifestData = async (manifestId: number): Promise<any> => {
|
||||
console.log(`Fetching manifest id ${manifestId}`);
|
||||
return fetch(`/api/manifest/${manifestId}`, {
|
||||
method: "GET",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"X-XSRF-TOKEN": props.csrfToken,
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}).then((res) => res.json());
|
||||
};
|
||||
|
||||
React.useEffect(() => {
|
||||
const manifestIdParam = props?.match?.params?.manifestId;
|
||||
getManifestData(manifestIdParam).then((res) => {
|
||||
setJsonData(res);
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (<pre>{JSON.stringify(jsonData, null, 2)}</pre>)
|
||||
|
||||
}
|
||||
|
||||
export default withCookies(ShowJson)
|
||||
Reference in New Issue
Block a user