|
|
@@ -37,7 +37,10 @@ const tabOptions: {
|
|
|
];
|
|
|
|
|
|
export const Dashboard: React.FunctionComponent = () => {
|
|
|
- const [currentTab, setCurrentTab] = useState<TabEnum>("preview_environments");
|
|
|
+ const { currentProject } = useContext(Context);
|
|
|
+ const [currentTab, setCurrentTab] = useState<TabEnum>(() =>
|
|
|
+ currentProject.preview_envs_enabled ? "preview_environments" : "nodes"
|
|
|
+ );
|
|
|
const [currentTabOptions, setCurrentTabOptions] = useState(tabOptions);
|
|
|
const [isAuthorized] = useAuth();
|
|
|
const location = useLocation();
|
|
|
@@ -46,7 +49,10 @@ export const Dashboard: React.FunctionComponent = () => {
|
|
|
const renderTab = () => {
|
|
|
switch (currentTab) {
|
|
|
case "preview_environments":
|
|
|
- return <EnvironmentList />;
|
|
|
+ if (currentProject.preview_envs_enabled) {
|
|
|
+ return <EnvironmentList />;
|
|
|
+ }
|
|
|
+ return <NodeList />;
|
|
|
case "events":
|
|
|
return <EventsTab />;
|
|
|
case "settings":
|
|
|
@@ -64,6 +70,10 @@ export const Dashboard: React.FunctionComponent = () => {
|
|
|
useEffect(() => {
|
|
|
setCurrentTabOptions(
|
|
|
tabOptions.filter((option) => {
|
|
|
+ if (option.value === "preview_environments") {
|
|
|
+ return currentProject.preview_envs_enabled;
|
|
|
+ }
|
|
|
+
|
|
|
if (option.value === "settings") {
|
|
|
return isAuthorized("cluster", "", ["get", "delete"]);
|
|
|
}
|