Skip to content

Commit

Permalink
freeze flag (#4640)
Browse files Browse the repository at this point in the history
  • Loading branch information
jusrhee authored May 13, 2024
1 parent 63461b9 commit 409f673
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 16 deletions.
1 change: 1 addition & 0 deletions api/types/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
24 changes: 17 additions & 7 deletions dashboard/src/main/home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,14 @@ const Home: React.FC<Props> = (props) => {
<DeploymentTargetProvider>
<StyledHome
padTop={
!currentProject?.sandbox_enabled &&
showCardBanner &&
currentProject?.billing_enabled &&
currentProject?.metronome_enabled &&
!trialExpired &&
plan &&
true
(!currentProject?.sandbox_enabled &&
showCardBanner &&
currentProject?.billing_enabled &&
currentProject?.metronome_enabled &&
!trialExpired &&
plan &&
true) ||
currentProject?.freeze_enabled
}
>
{!currentProject?.sandbox_enabled &&
Expand All @@ -433,6 +434,14 @@ const Home: React.FC<Props> = (props) => {
)}
</>
)}
{currentProject?.freeze_enabled && (
<GlobalBanner>
<i className="material-icons-round">warning</i>
This project has been disabled due to recurring issues with the
connected payment method. Please contact [email protected] to
reenable this project.
</GlobalBanner>
)}
{showBillingModal && (
<BillingModal
back={() => {
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const Resources: React.FC<ResourcesProps> = ({
<>
<Spacer y={1} />
<Text>
Sleep Service
Sleep service
<a
href="https://docs.porter.run/configure/basic-configuration#sleep-mode"
target="_blank"
Expand All @@ -151,14 +151,19 @@ const Resources: React.FC<ResourcesProps> = ({
render={({ field: { value, onChange } }) => (
<Checkbox
checked={Boolean(value?.value)}
disabled={currentProject?.freeze_enabled}
toggleChecked={() => {
onChange({
...value,
value: !value?.value,
});
}}
>
<Text color="helper">Pause all instances.</Text>
<Text color="helper">
{currentProject?.freeze_enabled
? "Contact [email protected] to re-enable your project and unsleep services."
: "Pause all instances."}
</Text>
</Checkbox>
)}
/>
Expand Down
13 changes: 7 additions & 6 deletions dashboard/src/shared/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions internal/models/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -106,6 +109,7 @@ var ProjectFeatureFlags = map[FeatureFlagLabel]bool{
BillingEnabled: false,
MetronomeEnabled: false,
InfisicalEnabled: false,
FreezeEnabled: false,
DBEnabled: false,
EFSEnabled: false,
EnableReprovision: false,
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 409f673

Please sign in to comment.