|
@@ -24,17 +24,19 @@ import ProjectSettings from './project-settings/ProjectSettings';
|
|
|
import ConfirmOverlay from 'components/ConfirmOverlay';
|
|
import ConfirmOverlay from 'components/ConfirmOverlay';
|
|
|
import Modal from './modals/Modal';
|
|
import Modal from './modals/Modal';
|
|
|
import * as FullStory from '@fullstory/browser';
|
|
import * as FullStory from '@fullstory/browser';
|
|
|
|
|
+import { Redirect, RouteComponentProps, withRouter } from 'react-router';
|
|
|
|
|
+import PorterUrls from 'shared/urls';
|
|
|
|
|
|
|
|
-type PropsType = {
|
|
|
|
|
|
|
+type PropsType = RouteComponentProps & {
|
|
|
logOut: () => void,
|
|
logOut: () => void,
|
|
|
currentProject: ProjectType,
|
|
currentProject: ProjectType,
|
|
|
currentCluster: ClusterType,
|
|
currentCluster: ClusterType,
|
|
|
|
|
+ currentRoute: PorterUrls,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
type StateType = {
|
|
type StateType = {
|
|
|
forceSidebar: boolean,
|
|
forceSidebar: boolean,
|
|
|
showWelcome: boolean,
|
|
showWelcome: boolean,
|
|
|
- currentView: string,
|
|
|
|
|
handleDO: boolean, // Trigger DO infra calls after oauth flow if needed
|
|
handleDO: boolean, // Trigger DO infra calls after oauth flow if needed
|
|
|
ghRedirect: boolean,
|
|
ghRedirect: boolean,
|
|
|
forceRefreshClusters: boolean, // For updating ClusterSection from modal on deletion
|
|
forceRefreshClusters: boolean, // For updating ClusterSection from modal on deletion
|
|
@@ -45,11 +47,10 @@ type StateType = {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// TODO: Handle cluster connected but with some failed infras (no successful set)
|
|
// TODO: Handle cluster connected but with some failed infras (no successful set)
|
|
|
-export default class Home extends Component<PropsType, StateType> {
|
|
|
|
|
|
|
+class Home extends Component<PropsType, StateType> {
|
|
|
state = {
|
|
state = {
|
|
|
forceSidebar: true,
|
|
forceSidebar: true,
|
|
|
showWelcome: false,
|
|
showWelcome: false,
|
|
|
- currentView: 'dashboard',
|
|
|
|
|
prevProjectId: null as number | null,
|
|
prevProjectId: null as number | null,
|
|
|
forceRefreshClusters: false,
|
|
forceRefreshClusters: false,
|
|
|
sidebarReady: false,
|
|
sidebarReady: false,
|
|
@@ -71,18 +72,18 @@ export default class Home extends Component<PropsType, StateType> {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (res.data.length > 0 && (!currentCluster && !includesCompletedInfraSet(res.data))) {
|
|
|
|
|
- // force refresh if currentView is identical set to provisioner. Tentative solution before refactoring.
|
|
|
|
|
- this.setState({ currentView: 'dashboard'}, () => {
|
|
|
|
|
- this.setState({ currentView: 'provisioner', sidebarReady: true, });
|
|
|
|
|
- });
|
|
|
|
|
- } else if (this.state.ghRedirect) {
|
|
|
|
|
- this.setState({ currentView: 'integrations', sidebarReady: true, ghRedirect: false });
|
|
|
|
|
- } else {
|
|
|
|
|
- this.setState({ currentView: 'provisioner'}, () => {
|
|
|
|
|
- this.setState({ currentView: 'dashboard', sidebarReady: true });
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if (res.data.length > 0 && (!currentCluster && !includesCompletedInfraSet(res.data))) {
|
|
|
|
|
+ // // force refresh if currentView is identical set to provisioner. Tentative solution before refactoring.
|
|
|
|
|
+ // this.setState({ currentView: 'dashboard'}, () => {
|
|
|
|
|
+ // this.setState({ currentView: 'provisioner', sidebarReady: true, });
|
|
|
|
|
+ // });
|
|
|
|
|
+ // } else if (this.state.ghRedirect) {
|
|
|
|
|
+ // this.setState({ currentView: 'integrations', sidebarReady: true, ghRedirect: false });
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // this.setState({ currentView: 'provisioner'}, () => {
|
|
|
|
|
+ // this.setState({ currentView: 'dashboard', sidebarReady: true });
|
|
|
|
|
+ // })
|
|
|
|
|
+ // }
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -94,7 +95,7 @@ export default class Home extends Component<PropsType, StateType> {
|
|
|
console.log(err);
|
|
console.log(err);
|
|
|
} else if (res.data) {
|
|
} else if (res.data) {
|
|
|
if (res.data.length === 0) {
|
|
if (res.data.length === 0) {
|
|
|
- this.setState({ currentView: 'new-project', sidebarReady: true, });
|
|
|
|
|
|
|
+ <Redirect to="new-project"></Redirect>
|
|
|
} else if (res.data.length > 0 && !currentProject) {
|
|
} else if (res.data.length > 0 && !currentProject) {
|
|
|
setProjects(res.data);
|
|
setProjects(res.data);
|
|
|
|
|
|
|
@@ -106,7 +107,7 @@ export default class Home extends Component<PropsType, StateType> {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
this.context.setCurrentProject(foundProject);
|
|
this.context.setCurrentProject(foundProject);
|
|
|
- this.setState({ currentView: 'provisioner' });
|
|
|
|
|
|
|
+ <Redirect to="provisioner"></Redirect>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!foundProject) {
|
|
if (!foundProject) {
|
|
@@ -153,7 +154,7 @@ export default class Home extends Component<PropsType, StateType> {
|
|
|
console.log(err);
|
|
console.log(err);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- this.setState({ currentView: 'provisioner' });
|
|
|
|
|
|
|
+ <Redirect to="provisioner"></Redirect>
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -181,7 +182,7 @@ export default class Home extends Component<PropsType, StateType> {
|
|
|
});
|
|
});
|
|
|
} else if (infras[0] === 'docr') {
|
|
} else if (infras[0] === 'docr') {
|
|
|
this.provisionDOCR(tgtIntegration.id, tier, () => {
|
|
this.provisionDOCR(tgtIntegration.id, tier, () => {
|
|
|
- this.setState({ currentView: 'provisioner' });
|
|
|
|
|
|
|
+ <Redirect to="provisioner"></Redirect>
|
|
|
});
|
|
});
|
|
|
} else {
|
|
} else {
|
|
|
this.provisionDOKS(tgtIntegration.id, region);
|
|
this.provisionDOKS(tgtIntegration.id, region);
|
|
@@ -271,14 +272,15 @@ export default class Home extends Component<PropsType, StateType> {
|
|
|
<ClusterDashboard
|
|
<ClusterDashboard
|
|
|
currentCluster={currentCluster}
|
|
currentCluster={currentCluster}
|
|
|
setSidebar={(x: boolean) => this.setState({ forceSidebar: x })}
|
|
setSidebar={(x: boolean) => this.setState({ forceSidebar: x })}
|
|
|
- setCurrentView={(x: string) => this.setState({ currentView: x })}
|
|
|
|
|
|
|
+ // setCurrentView={(x: string) => this.setState({ currentView: x })}
|
|
|
/>
|
|
/>
|
|
|
</DashboardWrapper>
|
|
</DashboardWrapper>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
renderContents = () => {
|
|
renderContents = () => {
|
|
|
- let { currentView, handleDO } = this.state;
|
|
|
|
|
|
|
+ // let { handleDO } = this.state;
|
|
|
|
|
+ let currentView = this.props.currentRoute;
|
|
|
if (this.context.currentProject && currentView !== 'new-project') {
|
|
if (this.context.currentProject && currentView !== 'new-project') {
|
|
|
if (currentView === 'cluster-dashboard') {
|
|
if (currentView === 'cluster-dashboard') {
|
|
|
return this.renderDashboard();
|
|
return this.renderDashboard();
|
|
@@ -286,7 +288,6 @@ export default class Home extends Component<PropsType, StateType> {
|
|
|
return (
|
|
return (
|
|
|
<DashboardWrapper>
|
|
<DashboardWrapper>
|
|
|
<Dashboard
|
|
<Dashboard
|
|
|
- setCurrentView={(x: string) => this.setState({ currentView: x })}
|
|
|
|
|
projectId={this.context.currentProject?.id}
|
|
projectId={this.context.currentProject?.id}
|
|
|
/>
|
|
/>
|
|
|
</DashboardWrapper>
|
|
</DashboardWrapper>
|
|
@@ -295,51 +296,36 @@ export default class Home extends Component<PropsType, StateType> {
|
|
|
return <Integrations />;
|
|
return <Integrations />;
|
|
|
} else if (currentView === 'provisioner') {
|
|
} else if (currentView === 'provisioner') {
|
|
|
return (
|
|
return (
|
|
|
- <ProvisionerStatus
|
|
|
|
|
- setCurrentView={(x: string) => this.setState({ currentView: x })}
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <ProvisionerStatus/>
|
|
|
);
|
|
);
|
|
|
} else if (currentView === 'project-settings') {
|
|
} else if (currentView === 'project-settings') {
|
|
|
return (
|
|
return (
|
|
|
- <ProjectSettings setCurrentView={(x: string) => this.setState({ currentView: x })} />
|
|
|
|
|
|
|
+ <ProjectSettings />
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
- <Templates
|
|
|
|
|
- setCurrentView={(x: string) => this.setState({ currentView: x })}
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <Templates/>
|
|
|
);
|
|
);
|
|
|
} else if (currentView === 'new-project') {
|
|
} else if (currentView === 'new-project') {
|
|
|
return (
|
|
return (
|
|
|
- <NewProject
|
|
|
|
|
- setCurrentView={(x: string, data: any ) => this.setState({ currentView: x })}
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <NewProject/>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- setCurrentView = (x: string) => {
|
|
|
|
|
- if (x === 'dashboard') {
|
|
|
|
|
- this.initializeView();
|
|
|
|
|
- } else {
|
|
|
|
|
- this.setState({ currentView: x });
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
renderSidebar = () => {
|
|
renderSidebar = () => {
|
|
|
if (this.context.projects.length > 0) {
|
|
if (this.context.projects.length > 0) {
|
|
|
|
|
|
|
|
// Force sidebar closed on first provision
|
|
// Force sidebar closed on first provision
|
|
|
- if (this.state.currentView === 'provisioner' && this.state.forceSidebar) {
|
|
|
|
|
|
|
+ if (this.props.currentRoute === 'provisioner' && this.state.forceSidebar) {
|
|
|
this.setState({ forceSidebar: false });
|
|
this.setState({ forceSidebar: false });
|
|
|
} else {
|
|
} else {
|
|
|
return (
|
|
return (
|
|
|
<Sidebar
|
|
<Sidebar
|
|
|
forceSidebar={this.state.forceSidebar}
|
|
forceSidebar={this.state.forceSidebar}
|
|
|
setWelcome={(x: boolean) => this.setState({ showWelcome: x })}
|
|
setWelcome={(x: boolean) => this.setState({ showWelcome: x })}
|
|
|
- setCurrentView={this.setCurrentView}
|
|
|
|
|
- currentView={this.state.currentView}
|
|
|
|
|
|
|
+ currentView={this.props.currentRoute}
|
|
|
forceRefreshClusters={this.state.forceRefreshClusters}
|
|
forceRefreshClusters={this.state.forceRefreshClusters}
|
|
|
setRefreshClusters={(x: boolean) => this.setState({ forceRefreshClusters: x })}
|
|
setRefreshClusters={(x: boolean) => this.setState({ forceRefreshClusters: x })}
|
|
|
/>
|
|
/>
|
|
@@ -359,7 +345,7 @@ export default class Home extends Component<PropsType, StateType> {
|
|
|
this.context.setCurrentProject(res.data[0]);
|
|
this.context.setCurrentProject(res.data[0]);
|
|
|
} else {
|
|
} else {
|
|
|
this.context.setCurrentProject(null);
|
|
this.context.setCurrentProject(null);
|
|
|
- this.setState({ currentView: 'new-project' });
|
|
|
|
|
|
|
+ this.props.history.push("new-project");
|
|
|
}
|
|
}
|
|
|
this.context.setCurrentModal(null, null);
|
|
this.context.setCurrentModal(null, null);
|
|
|
}
|
|
}
|
|
@@ -434,7 +420,7 @@ export default class Home extends Component<PropsType, StateType> {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
setCurrentModal(null, null)
|
|
setCurrentModal(null, null)
|
|
|
- this.setState({ currentView: 'dashboard' });
|
|
|
|
|
|
|
+ this.props.history.push("dashboard");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
@@ -486,7 +472,7 @@ export default class Home extends Component<PropsType, StateType> {
|
|
|
<ViewWrapper>
|
|
<ViewWrapper>
|
|
|
<Navbar
|
|
<Navbar
|
|
|
logOut={this.props.logOut}
|
|
logOut={this.props.logOut}
|
|
|
- currentView={this.state.currentView} // For form feedback
|
|
|
|
|
|
|
+ currentView={this.props.currentRoute} // For form feedback
|
|
|
/>
|
|
/>
|
|
|
{this.renderContents()}
|
|
{this.renderContents()}
|
|
|
</ViewWrapper>
|
|
</ViewWrapper>
|
|
@@ -504,6 +490,8 @@ export default class Home extends Component<PropsType, StateType> {
|
|
|
|
|
|
|
|
Home.contextType = Context;
|
|
Home.contextType = Context;
|
|
|
|
|
|
|
|
|
|
+export default withRouter(Home);
|
|
|
|
|
+
|
|
|
const ViewWrapper = styled.div`
|
|
const ViewWrapper = styled.div`
|
|
|
height: 100%;
|
|
height: 100%;
|
|
|
width: 100vw;
|
|
width: 100vw;
|