-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
152 additions
and
47 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React, { useState } from "react"; | ||
import React, { useState, useContext } from "react"; | ||
import styled from "styled-components"; | ||
import { match } from "ts-pattern"; | ||
|
||
|
@@ -12,17 +12,22 @@ import PullRequestIcon from "assets/pull_request_icon.svg"; | |
import DashboardHeader from "../../DashboardHeader"; | ||
import { ConfigurableAppList } from "./ConfigurableAppList"; | ||
import PreviewEnvGrid from "./PreviewEnvGrid"; | ||
import { Context } from "shared/Context"; | ||
import ClusterProvisioningPlaceholder from "components/ClusterProvisioningPlaceholder"; | ||
import DashboardPlaceholder from "components/porter/DashboardPlaceholder"; | ||
import Text from "components/porter/Text"; | ||
|
||
const tabs = ["environments", "config"] as const; | ||
export type ValidTab = (typeof tabs)[number]; | ||
|
||
const PreviewEnvs: React.FC = () => { | ||
const { currentProject, currentCluster } = useContext(Context); | ||
const [tab, setTab] = useState<ValidTab>("environments"); | ||
|
||
const { deploymentTargetList, isDeploymentTargetListLoading } = | ||
useDeploymentTargetList({ preview: true }); | ||
|
||
const renderContents = (): JSX.Element => { | ||
const renderTab = (): JSX.Element => { | ||
if (isDeploymentTargetListLoading) { | ||
return <Loading offset="-150px" />; | ||
} | ||
|
@@ -38,30 +43,69 @@ const PreviewEnvs: React.FC = () => { | |
.exhaustive(); | ||
}; | ||
|
||
const renderContents = (): JSX.Element => { | ||
if (currentCluster?.status === "UPDATING_UNAVAILABLE") { | ||
return <ClusterProvisioningPlaceholder />; | ||
} | ||
|
||
if (currentProject?.sandbox_enabled) { | ||
return ( | ||
<DashboardPlaceholder> | ||
<Text size={16}>Preview apps are not enabled for sandbox users</Text> | ||
<Spacer y={0.5} /> | ||
|
||
<Text color={"helper"}> | ||
Eject to your own cloud account to enable preview apps. | ||
</Text> | ||
</DashboardPlaceholder> | ||
); | ||
} | ||
|
||
if (!currentProject?.db_enabled) { | ||
return ( | ||
<DashboardPlaceholder> | ||
<Text size={16}>Preview apps are not enabled for this project</Text> | ||
<Spacer y={0.5} /> | ||
|
||
<Text color={"helper"}> | ||
Reach out to [email protected] to enable preview apps on your project. | ||
</Text> | ||
</DashboardPlaceholder> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<TabSelector | ||
noBuffer | ||
options={[ | ||
{ label: "Existing Previews", value: "environments" }, | ||
{ label: "Preview Templates", value: "config" }, | ||
]} | ||
currentTab={tab} | ||
setCurrentTab={(tab: string) => { | ||
if (tab === "environments") { | ||
setTab("environments"); | ||
return; | ||
} | ||
setTab("config"); | ||
}} | ||
/> | ||
<Spacer y={1} /> | ||
{renderTab()} | ||
</> | ||
) | ||
} | ||
|
||
return ( | ||
<StyledAppDashboard> | ||
<DashboardHeader | ||
image={PullRequestIcon} | ||
title="Preview Apps" | ||
title="Preview apps" | ||
capitalize={false} | ||
description="Preview apps are created for each pull request. They are automatically deleted when the pull request is closed." | ||
disableLineBreak | ||
/> | ||
<TabSelector | ||
noBuffer | ||
options={[ | ||
{ label: "Existing Previews", value: "environments" }, | ||
{ label: "Preview Templates", value: "config" }, | ||
]} | ||
currentTab={tab} | ||
setCurrentTab={(tab: string) => { | ||
if (tab === "environments") { | ||
setTab("environments"); | ||
return; | ||
} | ||
setTab("config"); | ||
}} | ||
/> | ||
<Spacer y={1} /> | ||
{renderContents()} | ||
<Spacer y={5} /> | ||
</StyledAppDashboard> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ import { ConfigSelectors } from "./ConfigSelectors"; | |
import { ProfileHeader } from "./ProfileHeader"; | ||
import { SOC2CostConsent } from "./SOC2CostConsent"; | ||
import { VendorChecksList } from "./VendorChecksList"; | ||
import DashboardPlaceholder from "components/porter/DashboardPlaceholder"; | ||
import Text from "components/porter/Text"; | ||
|
||
const ComplianceDashboard: React.FC = () => { | ||
const { currentProject, currentCluster } = useContext(Context); | ||
|
@@ -38,6 +40,24 @@ const ComplianceDashboard: React.FC = () => { | |
/> | ||
{currentCluster?.status === "UPDATING_UNAVAILABLE" ? ( | ||
<ClusterProvisioningPlaceholder /> | ||
) : currentProject?.sandbox_enabled ? ( | ||
<DashboardPlaceholder> | ||
<Text size={16}>Compliance is not enabled for sandbox users</Text> | ||
<Spacer y={0.5} /> | ||
|
||
<Text color={"helper"}> | ||
Eject to your own cloud account to enable the Compliance dashboard. | ||
</Text> | ||
</DashboardPlaceholder> | ||
) : !currentProject?.soc2_controls_enabled ? ( | ||
<DashboardPlaceholder> | ||
<Text size={16}>Compliance is not enabled for this project</Text> | ||
<Spacer y={0.5} /> | ||
|
||
<Text color={"helper"}> | ||
Reach out to [email protected] to enable the Compliance dashboard on your project. | ||
</Text> | ||
</DashboardPlaceholder> | ||
) : ( | ||
<> | ||
<ConfigSelectors /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ import { getDatastoreIcon, getEngineIcon } from "./icons"; | |
import EngineTag from "./tags/EngineTag"; | ||
|
||
const DatabaseDashboard: React.FC = () => { | ||
const { currentCluster } = useContext(Context); | ||
const { currentProject, currentCluster } = useContext(Context); | ||
const { clusters, isLoading: isLoadingClusters } = useClusterList(); | ||
|
||
const [searchValue, setSearchValue] = useState(""); | ||
|
@@ -111,6 +111,32 @@ const DatabaseDashboard: React.FC = () => { | |
return <ClusterProvisioningPlaceholder />; | ||
} | ||
|
||
if (currentProject?.sandbox_enabled) { | ||
return ( | ||
<DashboardPlaceholder> | ||
<Text size={16}>Databases are not enabled for sandbox users</Text> | ||
<Spacer y={0.5} /> | ||
|
||
<Text color={"helper"}> | ||
Eject to your own cloud account to enable managed databases. | ||
</Text> | ||
</DashboardPlaceholder> | ||
); | ||
} | ||
|
||
if (!currentProject?.db_enabled) { | ||
return ( | ||
<DashboardPlaceholder> | ||
<Text size={16}>Databases are not enabled for this project</Text> | ||
<Spacer y={0.5} /> | ||
|
||
<Text color={"helper"}> | ||
Reach out to [email protected] to enable managed databases on your project. | ||
</Text> | ||
</DashboardPlaceholder> | ||
); | ||
} | ||
|
||
if (datastores.length === 0) { | ||
return ( | ||
<DashboardPlaceholder> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters