From cb13428c4ecd78a296ee8e592272d4fe5ebfdca0 Mon Sep 17 00:00:00 2001 From: ianedwards Date: Tue, 23 Apr 2024 14:07:12 -0400 Subject: [PATCH] infisical feature flag (#4572) --- api/types/project.go | 1 + .../integrations/IntegrationCategories.tsx | 2 +- .../main/home/integrations/Integrations.tsx | 43 +++++++++++-------- dashboard/src/shared/types.tsx | 3 +- go.work.sum | 2 + internal/models/project.go | 5 +++ 6 files changed, 37 insertions(+), 19 deletions(-) diff --git a/api/types/project.go b/api/types/project.go index 596d62ce01..1bf9497dac 100644 --- a/api/types/project.go +++ b/api/types/project.go @@ -40,6 +40,7 @@ type Project struct { CapiProvisionerEnabled bool `json:"capi_provisioner_enabled"` BillingEnabled bool `json:"billing_enabled"` MetronomeEnabled bool `json:"metronome_enabled"` + InfisicalEnabled bool `json:"infisical_enabled"` DBEnabled bool `json:"db_enabled"` EFSEnabled bool `json:"efs_enabled"` EnableReprovision bool `json:"enable_reprovision"` diff --git a/dashboard/src/main/home/integrations/IntegrationCategories.tsx b/dashboard/src/main/home/integrations/IntegrationCategories.tsx index 8f18e108aa..c5c291b9fd 100644 --- a/dashboard/src/main/home/integrations/IntegrationCategories.tsx +++ b/dashboard/src/main/home/integrations/IntegrationCategories.tsx @@ -176,7 +176,7 @@ const IntegrationCategories: React.FC = (props) => { ) : props.category === "doppler" ? ( - ) : props.category === "infisical" ? ( + ) : props.category === "infisical" && currentProject?.infisical_enabled ? ( ) : ( = (props) => { const IntegrationCategoryStrings = useMemo(() => { if (!enableGitlab) { - return ["slack", "doppler", "infisical"]; + return currentProject?.infisical_enabled + ? ["slack", "doppler", "infisical"] + : ["slack", "doppler"]; } - return ["slack", "doppler", "infisical", "gitlab"]; - }, [enableGitlab]); + return currentProject?.infisical_enabled + ? ["slack", "doppler", "infisical", "gitlab"] + : ["slack", "doppler", "gitlab"]; + }, [enableGitlab, currentProject]); return ( @@ -37,16 +47,15 @@ const Integrations: React.FC = (props) => { if (!IntegrationCategoryStrings.includes(category)) { pushFiltered(props, "/integrations", ["project_id"]); } - let icon = - integrationList[integration] && integrationList[integration].icon; + const icon = integrationList[integration]?.icon; return ( + handleNavBack={() => { pushFiltered(props, `/integrations/${category}`, [ "project_id", - ]) - } + ]); + }} icon={icon} > {integrationList[integration].label} @@ -86,9 +95,9 @@ const Integrations: React.FC = (props) => { - pushFiltered(props, `/integrations/${x}`, ["project_id"]) - } + setCurrent={(x) => { + pushFiltered(props, `/integrations/${x}`, ["project_id"]); + }} isCategory={true} updateIntegrationList={() => {}} /> diff --git a/dashboard/src/shared/types.tsx b/dashboard/src/shared/types.tsx index 8e925ccbac..30a80a2ade 100644 --- a/dashboard/src/shared/types.tsx +++ b/dashboard/src/shared/types.tsx @@ -317,6 +317,7 @@ export type ProjectType = { beta_features_enabled: boolean; billing_enabled: boolean; metronome_enabled: boolean; + infisical_enabled: boolean; capi_provisioner_enabled: boolean; db_enabled: boolean; efs_enabled: boolean; @@ -779,4 +780,4 @@ export type AppEventWebhook = { app_event_type: string; app_event_status: string; payload_encryption_key: string; -} \ No newline at end of file +}; diff --git a/go.work.sum b/go.work.sum index e57c6ecc58..fb0c9a1156 100644 --- a/go.work.sum +++ b/go.work.sum @@ -857,6 +857,8 @@ github.com/porter-dev/api-contracts v0.2.78 h1:Iyp1DL33mPxJZQSjH8W/ylv5Ch8i30eJJ github.com/porter-dev/api-contracts v0.2.78/go.mod h1:fX6JmP5QuzxDLvqP3evFOTXjI4dHxsG0+VKNTjImZU8= github.com/porter-dev/api-contracts v0.2.93/go.mod h1:fX6JmP5QuzxDLvqP3evFOTXjI4dHxsG0+VKNTjImZU8= github.com/porter-dev/api-contracts v0.2.110/go.mod h1:fX6JmP5QuzxDLvqP3evFOTXjI4dHxsG0+VKNTjImZU8= +github.com/porter-dev/api-contracts v0.2.150 h1:4BMuDuRboUg5aeuQOTy+/MWK+zFmKQ6Vdgek3/1nKOk= +github.com/porter-dev/api-contracts v0.2.150/go.mod h1:VV5BzXd02ZdbWIPLVP+PX3GKawJSGQnxorVT2sUZALU= github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= github.com/pquerna/cachecontrol v0.1.0 h1:yJMy84ti9h/+OEWa752kBTKv4XC30OtVVHYv/8cTqKc= github.com/pquerna/cachecontrol v0.1.0/go.mod h1:NrUG3Z7Rdu85UNR3vm7SOsl1nFIeSiQnrHV5K9mBcUI= diff --git a/internal/models/project.go b/internal/models/project.go index 029d5b7edb..058ac3e86a 100644 --- a/internal/models/project.go +++ b/internal/models/project.go @@ -32,6 +32,9 @@ const ( // MetronomeEnabled enables all Metronome business logic MetronomeEnabled FeatureFlagLabel = "metronome_enabled" + // InfisicalEnabled enables the Infisical secrets operator integration + InfisicalEnabled FeatureFlagLabel = "infisical_enabled" + // DBEnabled enables the "Databases" tab DBEnabled FeatureFlagLabel = "db_enabled" @@ -102,6 +105,7 @@ var ProjectFeatureFlags = map[FeatureFlagLabel]bool{ CapiProvisionerEnabled: true, BillingEnabled: false, MetronomeEnabled: false, + InfisicalEnabled: false, DBEnabled: false, EFSEnabled: false, EnableReprovision: false, @@ -308,6 +312,7 @@ func (p *Project) ToProjectType(launchDarklyClient *features.Client) types.Proje CapiProvisionerEnabled: p.GetFeatureFlag(CapiProvisionerEnabled, launchDarklyClient), BillingEnabled: p.GetFeatureFlag(BillingEnabled, launchDarklyClient), MetronomeEnabled: p.GetFeatureFlag(MetronomeEnabled, launchDarklyClient), + InfisicalEnabled: p.GetFeatureFlag(InfisicalEnabled, launchDarklyClient), DBEnabled: p.GetFeatureFlag(DBEnabled, launchDarklyClient), EFSEnabled: p.GetFeatureFlag(EFSEnabled, launchDarklyClient), EnableReprovision: p.GetFeatureFlag(EnableReprovision, launchDarklyClient),