import './../css/styles.css';
import './../img/favicon.png'; // needs to be referenced somewhere so webpack bundles it
import { BrowserRouter, Redirect, Route, Switch } from 'react-router-dom';
import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles';
import ApiHelpers from './components/util/ApiHelpers.jsx';
import AppContext from './components/util/AppContext.jsx';
import Community from './components/Community.jsx';
import CssBaseline from '@material-ui/core/CssBaseline';
import Namespace from './components/Namespace.jsx';
import Navigation from './components/Navigation.jsx';
import NoMatch from './components/NoMatch.jsx';
import React from 'react';
import ReactDOM from 'react-dom';
import ResourceDetail from './components/ResourceDetail.jsx';
import ResourceList from './components/ResourceList.jsx';
import { RouterToUrlQuery } from 'react-url-query';
import ServiceMesh from './components/ServiceMesh.jsx';
import Tap from './components/Tap.jsx';
import Top from './components/Top.jsx';
import TopRoutes from './components/TopRoutes.jsx';
import { dashboardTheme } from './components/util/theme.js';
let appMain = document.getElementById('main');
let appData = !appMain ? {} : appMain.dataset;
let pathPrefix = "";
let proxyPathMatch = window.location.pathname.match(/\/api\/v1\/namespaces\/.*\/proxy/g);
if (proxyPathMatch) {
pathPrefix = proxyPathMatch[0];
}
let selectedNamespace = "default";
let pathArray = window.location.pathname.split("/");
// if the current URL path specifies a namespace, this should become the
// selectedNamespace
if (pathArray[0] === "" && pathArray[1] === "namespaces" && pathArray[2]) {
selectedNamespace = pathArray[2];
// if the current URL path is a legacy path such as `/daemonsets`, the
// selectedNamespace should be "_all", unless the path is `/namespaces`
} else if (pathArray.length === 2 && pathArray[1] !== "" && pathArray[1] !== "namespaces") {
selectedNamespace = "_all";
}
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
...appData
};
this.state.api = ApiHelpers(pathPrefix);
this.state.pathPrefix = pathPrefix;
this.state.productName = "Linkerd";
this.state.selectedNamespace = selectedNamespace;
this.state.updateNamespaceInContext = name => {
this.setState({selectedNamespace:name});
};
this.state.checkNamespaceMatch = path => {
let pathNamespace = path.split("/")[2];
if (pathNamespace && pathNamespace !== this.state.selectedNamespace) {
this.setState({selectedNamespace:pathNamespace});
}
};
}
render() {
return (
);
}
}
function AppHTML() {
const theme = createMuiTheme(dashboardTheme);
return (
} />
} />
} />
} />
} />
} />
} />
} />
} />
} />
} />
} />
} />
} />
} />
} />
} />
} />
} />
} />
} />
);
}
ReactDOM.render(, appMain);