|
@@ -12,13 +12,23 @@ import ClusterSettings from "./ClusterSettings";
|
|
|
import useAuth from "shared/auth/useAuth";
|
|
import useAuth from "shared/auth/useAuth";
|
|
|
import Metrics from "./Metrics";
|
|
import Metrics from "./Metrics";
|
|
|
import EventsTab from "./events/EventsTab";
|
|
import EventsTab from "./events/EventsTab";
|
|
|
-
|
|
|
|
|
-type TabEnum = "nodes" | "settings" | "namespaces" | "metrics" | "events";
|
|
|
|
|
|
|
+import EnvironmentList from "./preview-environments/EnvironmentList";
|
|
|
|
|
+import { useLocation } from "react-router";
|
|
|
|
|
+import { getQueryParam } from "shared/routing";
|
|
|
|
|
+
|
|
|
|
|
+type TabEnum =
|
|
|
|
|
+ | "preview_environments"
|
|
|
|
|
+ | "nodes"
|
|
|
|
|
+ | "settings"
|
|
|
|
|
+ | "namespaces"
|
|
|
|
|
+ | "metrics"
|
|
|
|
|
+ | "events";
|
|
|
|
|
|
|
|
const tabOptions: {
|
|
const tabOptions: {
|
|
|
label: string;
|
|
label: string;
|
|
|
value: TabEnum;
|
|
value: TabEnum;
|
|
|
}[] = [
|
|
}[] = [
|
|
|
|
|
+ { label: "PR preview", value: "preview_environments" },
|
|
|
{ label: "Nodes", value: "nodes" },
|
|
{ label: "Nodes", value: "nodes" },
|
|
|
{ label: "Events", value: "events" },
|
|
{ label: "Events", value: "events" },
|
|
|
{ label: "Metrics", value: "metrics" },
|
|
{ label: "Metrics", value: "metrics" },
|
|
@@ -27,13 +37,16 @@ const tabOptions: {
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
export const Dashboard: React.FunctionComponent = () => {
|
|
export const Dashboard: React.FunctionComponent = () => {
|
|
|
- const [currentTab, setCurrentTab] = useState<TabEnum>("nodes");
|
|
|
|
|
|
|
+ const [currentTab, setCurrentTab] = useState<TabEnum>("preview_environments");
|
|
|
const [currentTabOptions, setCurrentTabOptions] = useState(tabOptions);
|
|
const [currentTabOptions, setCurrentTabOptions] = useState(tabOptions);
|
|
|
const [isAuthorized] = useAuth();
|
|
const [isAuthorized] = useAuth();
|
|
|
|
|
+ const location = useLocation();
|
|
|
|
|
|
|
|
const context = useContext(Context);
|
|
const context = useContext(Context);
|
|
|
const renderTab = () => {
|
|
const renderTab = () => {
|
|
|
switch (currentTab) {
|
|
switch (currentTab) {
|
|
|
|
|
+ case "preview_environments":
|
|
|
|
|
+ return <EnvironmentList />;
|
|
|
case "events":
|
|
case "events":
|
|
|
return <EventsTab />;
|
|
return <EventsTab />;
|
|
|
case "settings":
|
|
case "settings":
|
|
@@ -59,6 +72,13 @@ export const Dashboard: React.FunctionComponent = () => {
|
|
|
);
|
|
);
|
|
|
}, [isAuthorized]);
|
|
}, [isAuthorized]);
|
|
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ const selectedTab = getQueryParam({ location }, "selected_tab");
|
|
|
|
|
+ if (tabOptions.find((tab) => tab.value === selectedTab)) {
|
|
|
|
|
+ setCurrentTab(selectedTab as any);
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [location]);
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
<TitleSection>
|
|
<TitleSection>
|