|
|
@@ -1,5 +1,5 @@
|
|
|
import React, { Component } from "react";
|
|
|
-import { RouteComponentProps, withRouter } from "react-router";
|
|
|
+import { RouteComponentProps, Switch, withRouter } from "react-router";
|
|
|
import styled from "styled-components";
|
|
|
|
|
|
import api from "shared/api";
|
|
|
@@ -15,24 +15,18 @@ import Dashboard from "./dashboard/Dashboard";
|
|
|
import WelcomeForm from "./WelcomeForm";
|
|
|
import Integrations from "./integrations/Integrations";
|
|
|
import Templates from "./launch/Launch";
|
|
|
-import ClusterInstructionsModal from "./modals/ClusterInstructionsModal";
|
|
|
-import IntegrationsInstructionsModal from "./modals/IntegrationsInstructionsModal";
|
|
|
-import IntegrationsModal from "./modals/IntegrationsModal";
|
|
|
-import Modal from "./modals/Modal";
|
|
|
-import UpdateClusterModal from "./modals/UpdateClusterModal";
|
|
|
-import NamespaceModal from "./modals/NamespaceModal";
|
|
|
+
|
|
|
import Navbar from "./navbar/Navbar";
|
|
|
-import NewProject from "./new-project/NewProject";
|
|
|
import ProjectSettings from "./project-settings/ProjectSettings";
|
|
|
import Sidebar from "./sidebar/Sidebar";
|
|
|
import PageNotFound from "components/PageNotFound";
|
|
|
-import DeleteNamespaceModal from "./modals/DeleteNamespaceModal";
|
|
|
+
|
|
|
import { fakeGuardedRoute } from "shared/auth/RouteGuard";
|
|
|
import { withAuth, WithAuthProps } from "shared/auth/AuthorizationHoc";
|
|
|
-import EditInviteOrCollaboratorModal from "./modals/EditInviteOrCollaboratorModal";
|
|
|
-import AccountSettingsModal from "./modals/AccountSettingsModal";
|
|
|
import discordLogo from "../../assets/discord.svg";
|
|
|
-import UsageWarningModal from "./modals/UsageWarningModal";
|
|
|
+import Onboarding from "./onboarding/Onboarding";
|
|
|
+import ModalHandler from "./ModalHandler";
|
|
|
+
|
|
|
// Guarded components
|
|
|
const GuardedProjectSettings = fakeGuardedRoute("settings", "", [
|
|
|
"get",
|
|
|
@@ -141,7 +135,7 @@ class Home extends Component<PropsType, StateType> {
|
|
|
.then((res) => {
|
|
|
if (res.data) {
|
|
|
if (res.data.length === 0) {
|
|
|
- pushFiltered(this.props, "/new-project", ["project_id"]);
|
|
|
+ pushFiltered(this.props, "/onboarding/new-project", ["project_id"]);
|
|
|
} else if (res.data.length > 0 && !currentProject) {
|
|
|
setProjects(res.data);
|
|
|
|
|
|
@@ -356,7 +350,7 @@ class Home extends Component<PropsType, StateType> {
|
|
|
renderContents = () => {
|
|
|
let currentView = this.props.currentRoute;
|
|
|
|
|
|
- if (this.context.currentProject && currentView !== "new-project") {
|
|
|
+ if (this.context.currentProject && currentView !== "onboarding") {
|
|
|
if (
|
|
|
currentView === "cluster-dashboard" ||
|
|
|
currentView === "applications" ||
|
|
|
@@ -381,46 +375,8 @@ class Home extends Component<PropsType, StateType> {
|
|
|
return <GuardedProjectSettings />;
|
|
|
}
|
|
|
return <Templates />;
|
|
|
- } else if (currentView === "new-project") {
|
|
|
- return <NewProject />;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- renderSidebar = () => {
|
|
|
- if (this.context.projects.length > 0) {
|
|
|
- return (
|
|
|
- <Sidebar
|
|
|
- key="sidebar"
|
|
|
- forceSidebar={this.state.forceSidebar}
|
|
|
- setWelcome={(x: boolean) => this.setState({ showWelcome: x })}
|
|
|
- currentView={this.props.currentRoute}
|
|
|
- forceRefreshClusters={this.state.forceRefreshClusters}
|
|
|
- setRefreshClusters={(x: boolean) =>
|
|
|
- this.setState({ forceRefreshClusters: x })
|
|
|
- }
|
|
|
- />
|
|
|
- );
|
|
|
- } else {
|
|
|
- return (
|
|
|
- <>
|
|
|
- <DiscordButton href="https://discord.gg/34n7NN7FJ7" target="_blank">
|
|
|
- <Icon src={discordLogo} />
|
|
|
- Join Our Discord
|
|
|
- </DiscordButton>
|
|
|
- {this.state.showWelcomeForm &&
|
|
|
- localStorage.getItem("welcomed") != "true" && (
|
|
|
- <>
|
|
|
- <WelcomeForm
|
|
|
- closeForm={() => this.setState({ showWelcomeForm: false })}
|
|
|
- />
|
|
|
- <Navbar
|
|
|
- logOut={this.props.logOut}
|
|
|
- currentView={this.props.currentRoute} // For form feedback
|
|
|
- />
|
|
|
- </>
|
|
|
- )}
|
|
|
- </>
|
|
|
- );
|
|
|
+ } else if (currentView === "onboarding") {
|
|
|
+ return <Onboarding />;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -435,7 +391,9 @@ class Home extends Component<PropsType, StateType> {
|
|
|
setCurrentProject(res.data[0]);
|
|
|
} else {
|
|
|
setCurrentProject(null, () =>
|
|
|
- pushFiltered(this.props, "/new-project", ["project_id"])
|
|
|
+ pushFiltered(this.props, "/onboarding/new-project", [
|
|
|
+ "project_id",
|
|
|
+ ])
|
|
|
);
|
|
|
}
|
|
|
this.context.setCurrentModal(null, null);
|
|
|
@@ -488,112 +446,15 @@ class Home extends Component<PropsType, StateType> {
|
|
|
setCurrentModal,
|
|
|
currentProject,
|
|
|
currentOverlay,
|
|
|
- setCurrentOverlay,
|
|
|
+ projects,
|
|
|
} = this.context;
|
|
|
|
|
|
+ const { cluster } = this.props.match.params as any;
|
|
|
return (
|
|
|
<StyledHome>
|
|
|
- {currentModal === "ClusterInstructionsModal" && (
|
|
|
- <Modal
|
|
|
- onRequestClose={() => setCurrentModal(null, null)}
|
|
|
- width="760px"
|
|
|
- height="650px"
|
|
|
- title="Connecting to an Existing Cluster"
|
|
|
- >
|
|
|
- <ClusterInstructionsModal />
|
|
|
- </Modal>
|
|
|
- )}
|
|
|
-
|
|
|
- {/* We should be careful, as this component is named Update but is for deletion */}
|
|
|
- {this.props.isAuthorized("cluster", "", ["get", "delete"]) &&
|
|
|
- currentModal === "UpdateClusterModal" && (
|
|
|
- <Modal
|
|
|
- onRequestClose={() => setCurrentModal(null, null)}
|
|
|
- width="565px"
|
|
|
- height="275px"
|
|
|
- title="Cluster Settings"
|
|
|
- >
|
|
|
- <UpdateClusterModal
|
|
|
- setRefreshClusters={(x: boolean) =>
|
|
|
- this.setState({ forceRefreshClusters: x })
|
|
|
- }
|
|
|
- />
|
|
|
- </Modal>
|
|
|
- )}
|
|
|
- {currentModal === "IntegrationsModal" && (
|
|
|
- <Modal
|
|
|
- onRequestClose={() => setCurrentModal(null, null)}
|
|
|
- width="760px"
|
|
|
- height="380px"
|
|
|
- title="Add a New Integration"
|
|
|
- >
|
|
|
- <IntegrationsModal />
|
|
|
- </Modal>
|
|
|
- )}
|
|
|
- {currentModal === "IntegrationsInstructionsModal" && (
|
|
|
- <Modal
|
|
|
- onRequestClose={() => setCurrentModal(null, null)}
|
|
|
- width="760px"
|
|
|
- height="650px"
|
|
|
- title="Connecting to an Image Registry"
|
|
|
- >
|
|
|
- <IntegrationsInstructionsModal />
|
|
|
- </Modal>
|
|
|
- )}
|
|
|
- {this.props.isAuthorized("namespace", "", ["get", "create"]) &&
|
|
|
- currentModal === "NamespaceModal" && (
|
|
|
- <Modal
|
|
|
- onRequestClose={() => setCurrentModal(null, null)}
|
|
|
- width="600px"
|
|
|
- height="220px"
|
|
|
- title="Add Namespace"
|
|
|
- >
|
|
|
- <NamespaceModal />
|
|
|
- </Modal>
|
|
|
- )}
|
|
|
- {this.props.isAuthorized("namespace", "", ["get", "delete"]) &&
|
|
|
- currentModal === "DeleteNamespaceModal" && (
|
|
|
- <Modal
|
|
|
- onRequestClose={() => setCurrentModal(null, null)}
|
|
|
- width="700px"
|
|
|
- height="280px"
|
|
|
- title="Delete Namespace"
|
|
|
- >
|
|
|
- <DeleteNamespaceModal />
|
|
|
- </Modal>
|
|
|
- )}
|
|
|
-
|
|
|
- {currentModal === "EditInviteOrCollaboratorModal" && (
|
|
|
- <Modal
|
|
|
- onRequestClose={() => setCurrentModal(null, null)}
|
|
|
- width="600px"
|
|
|
- height="250px"
|
|
|
- >
|
|
|
- <EditInviteOrCollaboratorModal />
|
|
|
- </Modal>
|
|
|
- )}
|
|
|
- {currentModal === "AccountSettingsModal" && (
|
|
|
- <Modal
|
|
|
- onRequestClose={() => setCurrentModal(null, null)}
|
|
|
- width="760px"
|
|
|
- height="440px"
|
|
|
- title="Account Settings"
|
|
|
- >
|
|
|
- <AccountSettingsModal />
|
|
|
- </Modal>
|
|
|
- )}
|
|
|
-
|
|
|
- {currentModal === "UsageWarningModal" && (
|
|
|
- <Modal
|
|
|
- onRequestClose={() => setCurrentModal(null, null)}
|
|
|
- width="760px"
|
|
|
- height="530px"
|
|
|
- title="Usage Warning"
|
|
|
- >
|
|
|
- <UsageWarningModal />
|
|
|
- </Modal>
|
|
|
- )}
|
|
|
-
|
|
|
+ <ModalHandler
|
|
|
+ setRefreshClusters={(x) => this.setState({ forceRefreshClusters: x })}
|
|
|
+ />
|
|
|
{currentOverlay && (
|
|
|
<ConfirmOverlay
|
|
|
show={true}
|
|
|
@@ -603,7 +464,40 @@ class Home extends Component<PropsType, StateType> {
|
|
|
/>
|
|
|
)}
|
|
|
|
|
|
- {this.renderSidebar()}
|
|
|
+ {/* Render sidebar when there's at least one project */}
|
|
|
+ {projects?.length > 0 && cluster !== "new-project" ? (
|
|
|
+ <Sidebar
|
|
|
+ key="sidebar"
|
|
|
+ forceSidebar={this.state.forceSidebar}
|
|
|
+ setWelcome={(x: boolean) => this.setState({ showWelcome: x })}
|
|
|
+ currentView={this.props.currentRoute}
|
|
|
+ forceRefreshClusters={this.state.forceRefreshClusters}
|
|
|
+ setRefreshClusters={(x: boolean) =>
|
|
|
+ this.setState({ forceRefreshClusters: x })
|
|
|
+ }
|
|
|
+ />
|
|
|
+ ) : (
|
|
|
+ <>
|
|
|
+ <DiscordButton href="https://discord.gg/34n7NN7FJ7" target="_blank">
|
|
|
+ <Icon src={discordLogo} />
|
|
|
+ Join Our Discord
|
|
|
+ </DiscordButton>
|
|
|
+ {/* This should only be shown on the first render of the app */}
|
|
|
+ {this.state.showWelcomeForm &&
|
|
|
+ localStorage.getItem("welcomed") != "true" &&
|
|
|
+ projects?.length === 0 && (
|
|
|
+ <>
|
|
|
+ <WelcomeForm
|
|
|
+ closeForm={() => this.setState({ showWelcomeForm: false })}
|
|
|
+ />
|
|
|
+ <Navbar
|
|
|
+ logOut={this.props.logOut}
|
|
|
+ currentView={this.props.currentRoute} // For form feedback
|
|
|
+ />
|
|
|
+ </>
|
|
|
+ )}
|
|
|
+ </>
|
|
|
+ )}
|
|
|
|
|
|
<ViewWrapper>
|
|
|
<Navbar
|