Fixed select a namespace title
@@ -15,6 +15,7 @@ import React from "react";
import { connect } from "react-redux";
import { TDispatchProp } from "types";
import { setCurrentNamespaceAction } from "actions/namespaces";
+import { push } from "connected-react-router";
import { RootState } from "reducers";
import ExpandLess from "@material-ui/icons/ExpandLess";
import ExpandMore from "@material-ui/icons/ExpandMore";
@@ -90,7 +91,19 @@ class NamespacesRaw extends React.PureComponent<Props, State> {
public render() {
const { classes, applications, active, dispatch, isListFirstLoading } = this.props;
const { open } = this.state;
+ const hasApplication = applications.count() > 0;
const activeNamespace = applications.find(application => application.get("name") === active);
+
+ if (isListFirstLoading) {
+ return (
+ <div className={classes.root}>
+ <Button className={classes.namespaceButton}>
+ <H4>Loading...</H4>
+ </Button>
+ </div>
+ );
+ }
+ if (!isListFirstLoading && hasApplication) {
return (
<div className={classes.root}>
<Button
@@ -100,7 +113,11 @@ class NamespacesRaw extends React.PureComponent<Props, State> {
className={classes.namespaceButton}
onClick={this.handleToggle}>
<H4>
- {isListFirstLoading ? "Loading..." : activeNamespace ? activeNamespace.get("name") : "Select a namespace"}
+ {isListFirstLoading
+ ? "Loading..."
+ : activeNamespace
+ ? activeNamespace.get("name")
+ : "Select a Application"}
</H4>
{open ? <ExpandLess /> : <ExpandMore />}
</Button>
@@ -143,6 +160,19 @@ class NamespacesRaw extends React.PureComponent<Props, State> {
</Popper>
</div>
);
+ } else {
+ return (
+ <div className={classes.root}>
+ <Button
+ className={classes.namespaceButton}
+ onClick={() => {
+ dispatch(push(`/applications/new`));
+ }}>
+ <H4>Create Your First Application</H4>
+ </Button>
+ </div>
+ );
+ }
}
}
