From 409f67382b935fe2ee28ee38f3fb99ce370533d8 Mon Sep 17 00:00:00 2001 From: jusrhee Date: Mon, 13 May 2024 17:04:03 -0400 Subject: [PATCH] freeze flag (#4640) --- api/types/project.go | 1 + dashboard/src/main/home/Home.tsx | 24 +++++++++++++------ .../services-settings/tabs/Resources.tsx | 9 +++++-- dashboard/src/shared/types.tsx | 13 +++++----- go.mod | 2 +- internal/models/project.go | 5 ++++ 6 files changed, 38 insertions(+), 16 deletions(-) diff --git a/api/types/project.go b/api/types/project.go index 3f537cccf7..ecf3c48d13 100644 --- a/api/types/project.go +++ b/api/types/project.go @@ -41,6 +41,7 @@ type Project struct { BillingEnabled bool `json:"billing_enabled"` MetronomeEnabled bool `json:"metronome_enabled"` InfisicalEnabled bool `json:"infisical_enabled"` + FreezeEnabled bool `json:"freeze_enabled"` DBEnabled bool `json:"db_enabled"` EFSEnabled bool `json:"efs_enabled"` EnableReprovision bool `json:"enable_reprovision"` diff --git a/dashboard/src/main/home/Home.tsx b/dashboard/src/main/home/Home.tsx index f9c5ca098e..0f4034e571 100644 --- a/dashboard/src/main/home/Home.tsx +++ b/dashboard/src/main/home/Home.tsx @@ -400,13 +400,14 @@ const Home: React.FC = (props) => { {!currentProject?.sandbox_enabled && @@ -433,6 +434,14 @@ const Home: React.FC = (props) => { )} )} + {currentProject?.freeze_enabled && ( + + warning + This project has been disabled due to recurring issues with the + connected payment method. Please contact support@porter.run to + reenable this project. + + )} {showBillingModal && ( { @@ -704,6 +713,7 @@ export default withRouter(withAuth(Home)); const GlobalBanner = styled.div` width: 100vw; z-index: 999; + padding: 20px; position: fixed; top: 0; color: #fefefe; diff --git a/dashboard/src/main/home/app-dashboard/validate-apply/services-settings/tabs/Resources.tsx b/dashboard/src/main/home/app-dashboard/validate-apply/services-settings/tabs/Resources.tsx index fd184204d7..3d2eb2ae3a 100644 --- a/dashboard/src/main/home/app-dashboard/validate-apply/services-settings/tabs/Resources.tsx +++ b/dashboard/src/main/home/app-dashboard/validate-apply/services-settings/tabs/Resources.tsx @@ -135,7 +135,7 @@ const Resources: React.FC = ({ <> - Sleep Service + Sleep service = ({ render={({ field: { value, onChange } }) => ( { onChange({ ...value, @@ -158,7 +159,11 @@ const Resources: React.FC = ({ }); }} > - Pause all instances. + + {currentProject?.freeze_enabled + ? "Contact support@porter.run to re-enable your project and unsleep services." + : "Pause all instances."} + )} /> diff --git a/dashboard/src/shared/types.tsx b/dashboard/src/shared/types.tsx index f623a998a0..b39f0b36e8 100644 --- a/dashboard/src/shared/types.tsx +++ b/dashboard/src/shared/types.tsx @@ -289,15 +289,15 @@ export type FormElement = { export type RepoType = { FullName: string; } & ( - | { + | { Kind: "github"; GHRepoID: number; } - | { + | { Kind: "gitlab"; GitIntegrationId: number; } - ); +); export type FileType = { path: string; @@ -318,6 +318,7 @@ export type ProjectType = { billing_enabled: boolean; metronome_enabled: boolean; infisical_enabled: boolean; + freeze_enabled: boolean; capi_provisioner_enabled: boolean; db_enabled: boolean; efs_enabled: boolean; @@ -380,15 +381,15 @@ export type ActionConfigType = { image_repo_uri: string; dockerfile_path?: string; } & ( - | { + | { kind: "gitlab"; gitlab_integration_id: number; } - | { + | { kind: "github"; git_repo_id: number; } - ); +); export type GithubActionConfigType = ActionConfigType & { kind: "github"; diff --git a/go.mod b/go.mod index 73ab45ba82..2f2a217e05 100644 --- a/go.mod +++ b/go.mod @@ -78,6 +78,7 @@ require ( github.com/evanphx/json-patch/v5 v5.9.0 github.com/glebarez/sqlite v1.6.0 github.com/go-chi/chi/v5 v5.0.8 + github.com/golang-jwt/jwt v3.2.1+incompatible github.com/gosimple/slug v1.13.1 github.com/honeycombio/otel-config-go v1.11.0 github.com/launchdarkly/go-sdk-common/v3 v3.0.1 @@ -148,7 +149,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/goccy/go-json v0.10.2 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect github.com/google/gnostic v0.6.9 // indirect github.com/google/s2a-go v0.1.4 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect diff --git a/internal/models/project.go b/internal/models/project.go index 4447d35c14..13c902f3ef 100644 --- a/internal/models/project.go +++ b/internal/models/project.go @@ -35,6 +35,9 @@ const ( // InfisicalEnabled enables the Infisical secrets operator integration InfisicalEnabled FeatureFlagLabel = "infisical_enabled" + // FreezeEnabled freezes the project + FreezeEnabled FeatureFlagLabel = "freeze_enabled" + // DBEnabled enables the "Databases" tab DBEnabled FeatureFlagLabel = "db_enabled" @@ -106,6 +109,7 @@ var ProjectFeatureFlags = map[FeatureFlagLabel]bool{ BillingEnabled: false, MetronomeEnabled: false, InfisicalEnabled: false, + FreezeEnabled: false, DBEnabled: false, EFSEnabled: false, EnableReprovision: false, @@ -319,6 +323,7 @@ func (p *Project) ToProjectType(launchDarklyClient *features.Client) types.Proje BillingEnabled: p.GetFeatureFlag(BillingEnabled, launchDarklyClient), MetronomeEnabled: p.GetFeatureFlag(MetronomeEnabled, launchDarklyClient), InfisicalEnabled: p.GetFeatureFlag(InfisicalEnabled, launchDarklyClient), + FreezeEnabled: p.GetFeatureFlag(FreezeEnabled, launchDarklyClient), DBEnabled: p.GetFeatureFlag(DBEnabled, launchDarklyClient), EFSEnabled: p.GetFeatureFlag(EFSEnabled, launchDarklyClient), EnableReprovision: p.GetFeatureFlag(EnableReprovision, launchDarklyClient),