|
@@ -1,18 +1,21 @@
|
|
|
import React, { Component } from "react";
|
|
import React, { Component } from "react";
|
|
|
-import { Route, Redirect, Switch } from "react-router-dom";
|
|
|
|
|
|
|
+import { Redirect, Route, Switch } from "react-router-dom";
|
|
|
|
|
+
|
|
|
|
|
+import Loading from "components/Loading";
|
|
|
|
|
|
|
|
import api from "shared/api";
|
|
import api from "shared/api";
|
|
|
import { Context } from "shared/Context";
|
|
import { Context } from "shared/Context";
|
|
|
-import ResetPasswordInit from "./auth/ResetPasswordInit";
|
|
|
|
|
-import ResetPasswordFinalize from "./auth/ResetPasswordFinalize";
|
|
|
|
|
|
|
+import { PorterUrls, type PorterUrl } from "shared/routing";
|
|
|
|
|
+
|
|
|
import Login from "./auth/Login";
|
|
import Login from "./auth/Login";
|
|
|
import Register from "./auth/Register";
|
|
import Register from "./auth/Register";
|
|
|
-import VerifyEmail from "./auth/VerifyEmail";
|
|
|
|
|
|
|
+import ResetPasswordFinalize from "./auth/ResetPasswordFinalize";
|
|
|
|
|
+import ResetPasswordInit from "./auth/ResetPasswordInit";
|
|
|
import SetInfo from "./auth/SetInfo";
|
|
import SetInfo from "./auth/SetInfo";
|
|
|
|
|
+import VerifyEmail from "./auth/VerifyEmail";
|
|
|
import CurrentError from "./CurrentError";
|
|
import CurrentError from "./CurrentError";
|
|
|
import Home from "./home/Home";
|
|
import Home from "./home/Home";
|
|
|
-import Loading from "components/Loading";
|
|
|
|
|
-import { PorterUrl, PorterUrls } from "shared/routing";
|
|
|
|
|
|
|
+import StatusPage from "./status/StatusPage";
|
|
|
|
|
|
|
|
type PropsType = {};
|
|
type PropsType = {};
|
|
|
|
|
|
|
@@ -40,24 +43,26 @@ export default class Main extends Component<PropsType, StateType> {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
|
-
|
|
|
|
|
// Get capabilities to case on user info requirements
|
|
// Get capabilities to case on user info requirements
|
|
|
- api.getMetadata("", {}, {})
|
|
|
|
|
|
|
+ api
|
|
|
|
|
+ .getMetadata("", {}, {})
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
this.setState({
|
|
this.setState({
|
|
|
version: res.data?.version,
|
|
version: res.data?.version,
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
})
|
|
})
|
|
|
- .catch((err) => console.log(err));
|
|
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ console.log(err);
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- let { setUser, setCurrentError } = this.context;
|
|
|
|
|
- let urlParams = new URLSearchParams(window.location.search);
|
|
|
|
|
- let error = urlParams.get("error");
|
|
|
|
|
|
|
+ const { setUser, setCurrentError } = this.context;
|
|
|
|
|
+ const urlParams = new URLSearchParams(window.location.search);
|
|
|
|
|
+ const error = urlParams.get("error");
|
|
|
error && setCurrentError(error);
|
|
error && setCurrentError(error);
|
|
|
api
|
|
api
|
|
|
.checkAuth("", {}, {})
|
|
.checkAuth("", {}, {})
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
- if (res && res?.data) {
|
|
|
|
|
|
|
+ if (res?.data) {
|
|
|
setUser(res.data.id, res.data.email);
|
|
setUser(res.data.id, res.data.email);
|
|
|
this.setState({
|
|
this.setState({
|
|
|
isLoggedIn: true,
|
|
isLoggedIn: true,
|
|
@@ -71,16 +76,20 @@ export default class Main extends Component<PropsType, StateType> {
|
|
|
this.setState({ isLoggedIn: false, loading: false });
|
|
this.setState({ isLoggedIn: false, loading: false });
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
- .catch((err) => this.setState({ isLoggedIn: false, loading: false }));
|
|
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ this.setState({ isLoggedIn: false, loading: false });
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
api
|
|
api
|
|
|
.getMetadata("", {}, {})
|
|
.getMetadata("", {}, {})
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
this.context.setEdition(res.data?.version);
|
|
this.context.setEdition(res.data?.version);
|
|
|
this.setState({ local: !res.data?.provisioner });
|
|
this.setState({ local: !res.data?.provisioner });
|
|
|
- this.context.setEnableGitlab(res.data?.gitlab ? true : false);
|
|
|
|
|
|
|
+ this.context.setEnableGitlab(!!res.data?.gitlab);
|
|
|
})
|
|
})
|
|
|
- .catch((err) => console.log(err));
|
|
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ console.log(err);
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
initialize = () => {
|
|
initialize = () => {
|
|
@@ -92,7 +101,7 @@ export default class Main extends Component<PropsType, StateType> {
|
|
|
api
|
|
api
|
|
|
.checkAuth("", {}, {})
|
|
.checkAuth("", {}, {})
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
- if (res && res?.data) {
|
|
|
|
|
|
|
+ if (res?.data) {
|
|
|
this.context.setUser(res?.data?.id, res?.data?.email);
|
|
this.context.setUser(res?.data?.id, res?.data?.email);
|
|
|
this.setState({
|
|
this.setState({
|
|
|
isLoggedIn: true,
|
|
isLoggedIn: true,
|
|
@@ -106,7 +115,9 @@ export default class Main extends Component<PropsType, StateType> {
|
|
|
this.setState({ isLoggedIn: false, loading: false });
|
|
this.setState({ isLoggedIn: false, loading: false });
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
- .catch((err) => this.setState({ isLoggedIn: false, loading: false }));
|
|
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ this.setState({ isLoggedIn: false, loading: false });
|
|
|
|
|
+ });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
handleLogOut = () => {
|
|
handleLogOut = () => {
|
|
@@ -150,7 +161,7 @@ export default class Main extends Component<PropsType, StateType> {
|
|
|
// Handle case where new user signs up via OAuth and has not set name and company
|
|
// Handle case where new user signs up via OAuth and has not set name and company
|
|
|
if (
|
|
if (
|
|
|
this.state.version === "production" &&
|
|
this.state.version === "production" &&
|
|
|
- !this.state.hasInfo &&
|
|
|
|
|
|
|
+ !this.state.hasInfo &&
|
|
|
this.state.userId > 9312 &&
|
|
this.state.userId > 9312 &&
|
|
|
this.state.isLoggedIn
|
|
this.state.isLoggedIn
|
|
|
) {
|
|
) {
|
|
@@ -160,7 +171,7 @@ export default class Main extends Component<PropsType, StateType> {
|
|
|
path="/"
|
|
path="/"
|
|
|
render={() => {
|
|
render={() => {
|
|
|
return (
|
|
return (
|
|
|
- <SetInfo
|
|
|
|
|
|
|
+ <SetInfo
|
|
|
handleLogOut={this.handleLogOut}
|
|
handleLogOut={this.handleLogOut}
|
|
|
authenticate={this.authenticate}
|
|
authenticate={this.authenticate}
|
|
|
/>
|
|
/>
|
|
@@ -168,7 +179,7 @@ export default class Main extends Component<PropsType, StateType> {
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
</Switch>
|
|
</Switch>
|
|
|
- )
|
|
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
@@ -224,6 +235,17 @@ export default class Main extends Component<PropsType, StateType> {
|
|
|
}
|
|
}
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
|
|
+ <Route
|
|
|
|
|
+ path={`/:status/:projectId?/:clusterId?`}
|
|
|
|
|
+ render={() => {
|
|
|
|
|
+ if (!this.state.isLoggedIn) {
|
|
|
|
|
+ return <Redirect to="/login" />;
|
|
|
|
|
+ } else if (!this.context.user?.email?.includes("@porter.run")) {
|
|
|
|
|
+ return <Redirect to="/dashboard" />;
|
|
|
|
|
+ }
|
|
|
|
|
+ return <StatusPage />;
|
|
|
|
|
+ }}
|
|
|
|
|
+ />
|
|
|
<Route
|
|
<Route
|
|
|
path={`/:baseRoute/:cluster?/:namespace?`}
|
|
path={`/:baseRoute/:cluster?/:namespace?`}
|
|
|
render={(routeProps) => {
|
|
render={(routeProps) => {
|