From e53439d586c24413182c57520ddbb1a11d556a08 Mon Sep 17 00:00:00 2001
From: carlosmonastyrski
Date: Fri, 14 Mar 2025 23:18:57 -0300
Subject: [PATCH] Improvements on dynamic secrets overview
---
.../OverviewPage/OverviewPage.tsx | 49 ++++++++++---------
.../components/ActionBar/ActionBar.tsx | 1 +
.../AwsElastiCacheInputForm.tsx | 8 +--
.../AwsIamInputForm.tsx | 8 +--
.../AzureEntraIdInputForm.tsx | 8 +--
.../CassandraInputForm.tsx | 8 +--
.../CreateDynamicSecretForm.tsx | 19 ++++++-
.../ElasticSearchInputForm.tsx | 8 +--
.../CreateDynamicSecretForm/LdapInputForm.tsx | 8 +--
.../MongoAtlasInputForm.tsx | 8 +--
.../MongoDBInputForm.tsx | 8 +--
.../RabbitMqInputForm.tsx | 8 +--
.../RedisInputForm.tsx | 8 +--
.../SapAseInputForm.tsx | 8 +--
.../SapHanaInputForm.tsx | 8 +--
.../SnowflakeInputForm.tsx | 8 +--
.../SqlDatabaseInputForm.tsx | 8 +--
.../CreateDynamicSecretForm/TotpInputForm.tsx | 8 +--
18 files changed, 121 insertions(+), 68 deletions(-)
diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
index 12e0100b6..34012bb2f 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
@@ -187,10 +187,8 @@ export const OverviewPage = () => {
permission.can(
ProjectPermissionDynamicSecretActions.CreateRootCredential,
subject(ProjectPermissionSub.DynamicSecrets, {
- environment: env.id,
- secretPath,
- secretName: "*",
- secretTags: ["*"]
+ environment: env.slug,
+ secretPath
})
)
);
@@ -863,42 +861,49 @@ export const OverviewPage = () => {
-
}
- onClick={() => {
- if (subscription?.dynamicSecret) {
- handlePopUpOpen("addDynamicSecret");
- return;
- }
- handlePopUpOpen("upgradePlan");
- }}
- isDisabled={userAvailableDynamicSecretEnvs.length === 0}
- variant="outline_bg"
- className="h-10 text-left"
- isFullWidth
- >
- Add Dynamic Secret
-
{(isAllowed) => (
}
+ leftIcon={}
onClick={() => {
handlePopUpOpen("addFolder");
handlePopUpClose("misc");
}}
isDisabled={!isAllowed}
variant="outline_bg"
- className="h-10"
+ className="h-10 text-left"
isFullWidth
>
Add Folder
)}
+
+ }
+ onClick={() => {
+ if (subscription?.dynamicSecret) {
+ handlePopUpOpen("addDynamicSecret");
+ handlePopUpClose("misc");
+ return;
+ }
+ handlePopUpOpen("upgradePlan");
+ }}
+ isDisabled={userAvailableDynamicSecretEnvs.length === 0}
+ variant="outline_bg"
+ className="h-10 text-left"
+ isFullWidth
+ >
+ Add Dynamic Secret
+
+
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ActionBar.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ActionBar.tsx
index 0cf131ba8..681ad99e3 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ActionBar.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ActionBar.tsx
@@ -657,6 +657,7 @@ export const ActionBar = ({
projectSlug={projectSlug}
environments={[{ slug: environment, name: environment, id: "not-used" }]}
secretPath={secretPath}
+ isSingleEnvironmentMode
/>
{
const {
control,
@@ -91,7 +93,7 @@ export const AwsElastiCacheInputForm = ({
"UserId": "{{username}}"
}`
},
- environment: environments.length === 1 ? environments[0] : undefined
+ environment: isSingleEnvironmentMode ? environments[0] : undefined
}
});
@@ -309,7 +311,7 @@ export const AwsElastiCacheInputForm = ({
- {environments.length > 1 && (
+ {!isSingleEnvironmentMode && (
{
const {
control,
@@ -68,7 +70,7 @@ export const AwsIamInputForm = ({
} = useForm({
resolver: zodResolver(formSchema),
defaultValues: {
- environment: environments.length === 1 ? environments[0] : undefined
+ environment: isSingleEnvironmentMode ? environments[0] : undefined
}
});
@@ -298,7 +300,7 @@ export const AwsIamInputForm = ({
)}
/>
- {environments.length > 1 && (
+ {!isSingleEnvironmentMode && (
{
const {
control,
@@ -89,7 +91,7 @@ export const AzureEntraIdInputForm = ({
} = useForm({
resolver: zodResolver(formSchema),
defaultValues: {
- environment: environments.length === 1 ? environments[0] : undefined
+ environment: isSingleEnvironmentMode ? environments[0] : undefined
}
});
const tenantId = watch("provider.tenantId");
@@ -379,7 +381,7 @@ export const AzureEntraIdInputForm = ({
- {environments.length > 1 && (
+ {!isSingleEnvironmentMode && (
{
@@ -81,7 +82,8 @@ export const CassandraInputForm = ({
onCancel,
environments,
secretPath,
- projectSlug
+ projectSlug,
+ isSingleEnvironmentMode
}: Props) => {
const {
control,
@@ -91,7 +93,7 @@ export const CassandraInputForm = ({
resolver: zodResolver(formSchema),
defaultValues: {
provider: getSqlStatements(),
- environment: environments.length === 1 ? environments[0] : undefined
+ environment: isSingleEnvironmentMode ? environments[0] : undefined
}
});
@@ -356,7 +358,7 @@ export const CassandraInputForm = ({
- {environments.length > 1 && (
+ {!isSingleEnvironmentMode && (
{
const [wizardStep, setWizardStep] = useState(WizardSteps.SelectProvider);
const [selectedProvider, setSelectedProvider] = useState(null);
@@ -199,6 +201,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
)}
@@ -217,6 +220,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
)}
@@ -235,6 +239,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
)}
@@ -253,6 +258,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
)}
@@ -271,6 +277,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
)}
@@ -289,6 +296,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
)}
@@ -307,6 +315,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
)}
@@ -325,6 +334,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
)}
@@ -343,6 +353,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
)}
@@ -361,6 +372,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
)}
@@ -379,6 +391,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
)}
@@ -397,6 +410,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
)}
@@ -415,6 +429,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
)}
@@ -434,6 +449,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
)}
@@ -452,6 +468,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
)}
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/ElasticSearchInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/ElasticSearchInputForm.tsx
index eea23a2e5..a7c84cb50 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/ElasticSearchInputForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/ElasticSearchInputForm.tsx
@@ -86,6 +86,7 @@ type Props = {
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
+ isSingleEnvironmentMode?: boolean;
};
export const ElasticSearchInputForm = ({
@@ -93,7 +94,8 @@ export const ElasticSearchInputForm = ({
onCancel,
environments,
secretPath,
- projectSlug
+ projectSlug,
+ isSingleEnvironmentMode
}: Props) => {
const {
control,
@@ -111,7 +113,7 @@ export const ElasticSearchInputForm = ({
roles: ["superuser"],
port: 443
},
- environment: environments.length === 1 ? environments[0] : undefined
+ environment: isSingleEnvironmentMode ? environments[0] : undefined
}
});
@@ -416,7 +418,7 @@ export const ElasticSearchInputForm = ({
)}
/>
- {environments.length > 1 && (
+ {!isSingleEnvironmentMode && (
{
const {
control,
@@ -118,7 +120,7 @@ export const LdapInputForm = ({
rollbackLdif: "",
credentialType: CredentialType.Dynamic
},
- environment: environments.length === 1 ? environments[0] : undefined
+ environment: isSingleEnvironmentMode ? environments[0] : undefined
}
});
@@ -386,7 +388,7 @@ export const LdapInputForm = ({
)}
/>
)}
- {environments.length > 1 && (
+ {!isSingleEnvironmentMode && (
{
const {
control,
@@ -112,7 +114,7 @@ export const MongoAtlasInputForm = ({
provider: {
roles: [{ databaseName: "", roleName: "" }]
},
- environment: environments.length === 1 ? environments[0] : undefined
+ environment: isSingleEnvironmentMode ? environments[0] : undefined
}
});
@@ -448,7 +450,7 @@ export const MongoAtlasInputForm = ({
- {environments.length > 1 && (
+ {!isSingleEnvironmentMode && (
{
const {
control,
@@ -87,7 +89,7 @@ export const MongoDBDatabaseInputForm = ({
provider: {
roles: [{ roleName: "readWrite" }]
},
- environment: environments.length === 1 ? environments[0] : undefined
+ environment: isSingleEnvironmentMode ? environments[0] : undefined
}
});
@@ -338,7 +340,7 @@ export const MongoDBDatabaseInputForm = ({
)}
/>
- {environments.length > 1 && (
+ {!isSingleEnvironmentMode && (
{
const {
control,
@@ -100,7 +102,7 @@ export const RabbitMqInputForm = ({
},
tags: []
},
- environment: environments.length === 1 ? environments[0] : undefined
+ environment: isSingleEnvironmentMode ? environments[0] : undefined
}
});
@@ -422,7 +424,7 @@ export const RabbitMqInputForm = ({
)}
/>
- {environments.length > 1 && (
+ {!isSingleEnvironmentMode && (
{
const {
control,
@@ -85,7 +87,7 @@ export const RedisInputForm = ({
creationStatement: "ACL SETUSER {{username}} on >{{password}} ~* &* +@all",
revocationStatement: "ACL DELUSER {{username}}"
},
- environment: environments.length === 1 ? environments[0] : undefined
+ environment: isSingleEnvironmentMode ? environments[0] : undefined
}
});
@@ -323,7 +325,7 @@ export const RedisInputForm = ({
- {environments.length > 1 && (
+ {!isSingleEnvironmentMode && (
{
const {
control,
@@ -86,7 +88,7 @@ sp_role 'grant', 'mon_role', '{{username}}';`,
revocationStatement: `sp_dropuser '{{username}}';
sp_droplogin '{{username}}';`
},
- environment: environments.length === 1 ? environments[0] : undefined
+ environment: isSingleEnvironmentMode ? environments[0] : undefined
}
});
@@ -301,7 +303,7 @@ sp_droplogin '{{username}}';`
- {environments.length > 1 && (
+ {!isSingleEnvironmentMode && (
{
const {
control,
@@ -86,7 +88,7 @@ GRANT "MONITORING" TO {{username}};`,
DROP USER {{username}};`,
renewStatement: "ALTER USER {{username}} VALID UNTIL '{{expiration}}';"
},
- environment: environments.length === 1 ? environments[0] : undefined
+ environment: isSingleEnvironmentMode ? environments[0] : undefined
}
});
@@ -321,7 +323,7 @@ DROP USER {{username}};`,
- {environments.length > 1 && (
+ {!isSingleEnvironmentMode && (
{
const {
control,
@@ -89,7 +91,7 @@ export const SnowflakeInputForm = ({
revocationStatement: "DROP USER {{username}};",
renewStatement: "ALTER USER {{username}} SET DAYS_TO_EXPIRY = {{expiration}};"
},
- environment: environments.length === 1 ? environments[0] : undefined
+ environment: isSingleEnvironmentMode ? environments[0] : undefined
}
});
@@ -324,7 +326,7 @@ export const SnowflakeInputForm = ({
- {environments.length > 1 && (
+ {!isSingleEnvironmentMode && (
{
@@ -150,7 +151,8 @@ export const SqlDatabaseInputForm = ({
onCancel,
environments,
secretPath,
- projectSlug
+ projectSlug,
+ isSingleEnvironmentMode
}: Props) => {
const { currentWorkspace } = useWorkspace();
@@ -176,7 +178,7 @@ export const SqlDatabaseInputForm = ({
allowedSymbols: "-_.~!*"
}
},
- environment: environments.length === 1 ? environments[0] : undefined
+ environment: isSingleEnvironmentMode ? environments[0] : undefined
}
});
@@ -660,7 +662,7 @@ export const SqlDatabaseInputForm = ({
- {environments.length > 1 && (
+ {!isSingleEnvironmentMode && (
{
const {
control,
@@ -92,7 +94,7 @@ export const TotpInputForm = ({
provider: {
configType: ConfigType.URL
},
- environment: environments.length === 1 ? environments[0] : environments[0]
+ environment: isSingleEnvironmentMode ? environments[0] : undefined
}
});
@@ -305,7 +307,7 @@ export const TotpInputForm = ({
>
)}
- {environments.length > 1 && (
+ {!isSingleEnvironmentMode && (