|
@@ -23,6 +23,7 @@ import ProvisionerStatus from './provisioner/ProvisionerStatus';
|
|
|
import ProjectSettings from './project-settings/ProjectSettings';
|
|
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';
|
|
|
|
|
|
|
|
type PropsType = {
|
|
type PropsType = {
|
|
|
logOut: () => void,
|
|
logOut: () => void,
|
|
@@ -59,28 +60,27 @@ export default class Home extends Component<PropsType, StateType> {
|
|
|
// TODO: Refactor and prevent flash + multiple reload
|
|
// TODO: Refactor and prevent flash + multiple reload
|
|
|
initializeView = () => {
|
|
initializeView = () => {
|
|
|
let { currentProject } = this.props;
|
|
let { currentProject } = this.props;
|
|
|
- if (currentProject) {
|
|
|
|
|
- let { currentCluster } = this.context;
|
|
|
|
|
-
|
|
|
|
|
- // Check if current project is provisioning
|
|
|
|
|
- api.getInfra('<token>', {}, { project_id: currentProject.id }, (err: any, res: any) => {
|
|
|
|
|
- if (err) {
|
|
|
|
|
- console.log(err);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (res.data.length > 0 && (!currentCluster || !includesCompletedInfraSet(res.data))) {
|
|
|
|
|
|
|
+ let { currentCluster } = this.context;
|
|
|
|
|
+
|
|
|
|
|
+ if (!currentProject) return;
|
|
|
|
|
+
|
|
|
|
|
+ // Check if current project is provisioning
|
|
|
|
|
+ api.getInfra('<token>', {}, { project_id: currentProject.id }, (err: any, res: any) => {
|
|
|
|
|
+ if (err) {
|
|
|
|
|
+ console.log(err);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (res.data.length > 0 && (!currentCluster && !includesCompletedInfraSet(res.data))) {
|
|
|
|
|
+ // force refresh if currentView is already set to provisioner.
|
|
|
|
|
+ this.setState({ currentView: 'dashboard'}, () => {
|
|
|
this.setState({ currentView: 'provisioner', sidebarReady: true, });
|
|
this.setState({ currentView: 'provisioner', sidebarReady: true, });
|
|
|
- } else {
|
|
|
|
|
- // console.log('getting here', currentCluster)
|
|
|
|
|
- if (this.state.ghRedirect) {
|
|
|
|
|
- this.setState({ currentView: 'integrations', sidebarReady: true, ghRedirect: false });
|
|
|
|
|
- } else {
|
|
|
|
|
- this.setState({ currentView: 'dashboard', sidebarReady: true });
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // console.log('getting here', currentCluster)
|
|
|
|
|
+ this.setState({ currentView: 'dashboard', sidebarReady: true });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
getProjects = (id?: number) => {
|
|
getProjects = (id?: number) => {
|
|
@@ -189,6 +189,8 @@ export default class Home extends Component<PropsType, StateType> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
|
|
|
+ let { user } = this.context;
|
|
|
|
|
+ FullStory.identify(user.email)
|
|
|
|
|
|
|
|
// Handle redirect from DO
|
|
// Handle redirect from DO
|
|
|
let queryString = window.location.search;
|
|
let queryString = window.location.search;
|
|
@@ -207,13 +209,13 @@ export default class Home extends Component<PropsType, StateType> {
|
|
|
this.checkDO();
|
|
this.checkDO();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this.setState({ ghRedirect: urlParams.get('gh_oauth') !== null });
|
|
|
|
|
- urlParams.delete('gh_oauth');
|
|
|
|
|
-
|
|
|
|
|
- let { user } = this.context;
|
|
|
|
|
- window.location.href.indexOf('127.0.0.1') === -1 && posthog.init(process.env.POSTHOG_API_KEY, {
|
|
|
|
|
- api_host: process.env.POSTHOG_HOST,
|
|
|
|
|
- loaded: function(posthog: any) { posthog.identify(user.email) }
|
|
|
|
|
|
|
+ // initialize posthog on non-localhosts. Gracefully fail when env vars are not set.
|
|
|
|
|
+ window.location.href.indexOf('127.0.0.1') === -1 && posthog.init(process.env.POSTHOG_API_KEY || 'placeholder', {
|
|
|
|
|
+ api_host: process.env.POSTHOG_HOST || 'placeholder',
|
|
|
|
|
+ loaded: function(posthog: any) {
|
|
|
|
|
+ posthog.identify(user.userId)
|
|
|
|
|
+ posthog.people.set({ email: user.email })
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
this.getProjects(defaultProjectId);
|
|
this.getProjects(defaultProjectId);
|