Improvements on dynamic secrets overview

This commit is contained in:
carlosmonastyrski
2025-03-14 23:18:57 -03:00
parent 6905029455
commit e53439d586
18 changed files with 121 additions and 68 deletions

View File

@@ -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 = () => {
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<div className="flex flex-col space-y-1 p-1.5">
<Button
leftIcon={<FontAwesomeIcon icon={faFingerprint} className="pr-2" />}
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
</Button>
<ProjectPermissionCan
I={ProjectPermissionActions.Create}
a={ProjectPermissionSub.SecretFolders}
>
{(isAllowed) => (
<Button
leftIcon={<FontAwesomeIcon icon={faFolderPlus} />}
leftIcon={<FontAwesomeIcon icon={faFolderPlus} className="pr-2" />}
onClick={() => {
handlePopUpOpen("addFolder");
handlePopUpClose("misc");
}}
isDisabled={!isAllowed}
variant="outline_bg"
className="h-10"
className="h-10 text-left"
isFullWidth
>
Add Folder
</Button>
)}
</ProjectPermissionCan>
<Tooltip
content={
userAvailableDynamicSecretEnvs.length === 0 ? "Access restricted" : ""
}
>
<Button
leftIcon={<FontAwesomeIcon icon={faFingerprint} className="pr-2" />}
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
</Button>
</Tooltip>
</div>
</DropdownMenuContent>
</DropdownMenu>

View File

@@ -657,6 +657,7 @@ export const ActionBar = ({
projectSlug={projectSlug}
environments={[{ slug: environment, name: environment, id: "not-used" }]}
secretPath={secretPath}
isSingleEnvironmentMode
/>
<Modal
isOpen={popUp.addFolder.isOpen}

View File

@@ -63,6 +63,7 @@ type Props = {
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
isSingleEnvironmentMode?: boolean;
};
export const AwsElastiCacheInputForm = ({
@@ -70,7 +71,8 @@ export const AwsElastiCacheInputForm = ({
onCancel,
environments,
secretPath,
projectSlug
projectSlug,
isSingleEnvironmentMode
}: Props) => {
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 = ({
</AccordionContent>
</AccordionItem>
</Accordion>
{environments.length > 1 && (
{!isSingleEnvironmentMode && (
<Controller
control={control}
name="environment"

View File

@@ -52,6 +52,7 @@ type Props = {
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
isSingleEnvironmentMode?: boolean;
};
export const AwsIamInputForm = ({
@@ -59,7 +60,8 @@ export const AwsIamInputForm = ({
onCancel,
environments,
secretPath,
projectSlug
projectSlug,
isSingleEnvironmentMode
}: Props) => {
const {
control,
@@ -68,7 +70,7 @@ export const AwsIamInputForm = ({
} = useForm<TForm>({
resolver: zodResolver(formSchema),
defaultValues: {
environment: environments.length === 1 ? environments[0] : undefined
environment: isSingleEnvironmentMode ? environments[0] : undefined
}
});
@@ -298,7 +300,7 @@ export const AwsIamInputForm = ({
</FormControl>
)}
/>
{environments.length > 1 && (
{!isSingleEnvironmentMode && (
<Controller
control={control}
name="environment"

View File

@@ -72,6 +72,7 @@ type Props = {
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
isSingleEnvironmentMode?: boolean;
};
export const AzureEntraIdInputForm = ({
@@ -79,7 +80,8 @@ export const AzureEntraIdInputForm = ({
onCancel,
environments,
secretPath,
projectSlug
projectSlug,
isSingleEnvironmentMode
}: Props) => {
const {
control,
@@ -89,7 +91,7 @@ export const AzureEntraIdInputForm = ({
} = useForm<TForm>({
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 = ({
</div>
</div>
</div>
{environments.length > 1 && (
{!isSingleEnvironmentMode && (
<Controller
control={control}
name="environment"

View File

@@ -65,6 +65,7 @@ type Props = {
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
isSingleEnvironmentMode?: boolean;
};
const getSqlStatements = () => {
@@ -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 = ({
</AccordionContent>
</AccordionItem>
</Accordion>
{environments.length > 1 && (
{!isSingleEnvironmentMode && (
<Controller
control={control}
name="environment"

View File

@@ -41,6 +41,7 @@ type Props = {
projectSlug: string;
environments: WorkspaceEnv[];
secretPath: string;
isSingleEnvironmentMode?: boolean;
};
enum WizardSteps {
@@ -131,7 +132,8 @@ export const CreateDynamicSecretForm = ({
onToggle,
projectSlug,
environments,
secretPath
secretPath,
isSingleEnvironmentMode
}: Props) => {
const [wizardStep, setWizardStep] = useState(WizardSteps.SelectProvider);
const [selectedProvider, setSelectedProvider] = useState<DynamicSecretProviders | null>(null);
@@ -199,6 +201,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
</motion.div>
)}
@@ -217,6 +220,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
</motion.div>
)}
@@ -235,6 +239,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
</motion.div>
)}
@@ -253,6 +258,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
</motion.div>
)}
@@ -271,6 +277,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
</motion.div>
)}
@@ -289,6 +296,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
</motion.div>
)}
@@ -307,6 +315,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
</motion.div>
)}
@@ -325,6 +334,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
</motion.div>
)}
@@ -343,6 +353,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
</motion.div>
)}
@@ -361,6 +372,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
</motion.div>
)}
@@ -379,6 +391,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
</motion.div>
)}
@@ -397,6 +410,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
</motion.div>
)}
@@ -415,6 +429,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
</motion.div>
)}
@@ -434,6 +449,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
</motion.div>
)}
@@ -452,6 +468,7 @@ export const CreateDynamicSecretForm = ({
projectSlug={projectSlug}
secretPath={secretPath}
environments={environments}
isSingleEnvironmentMode={isSingleEnvironmentMode}
/>
</motion.div>
)}

View File

@@ -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 = ({
)}
/>
</div>
{environments.length > 1 && (
{!isSingleEnvironmentMode && (
<Controller
control={control}
name="environment"

View File

@@ -90,6 +90,7 @@ type Props = {
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
isSingleEnvironmentMode?: boolean;
};
export const LdapInputForm = ({
@@ -97,7 +98,8 @@ export const LdapInputForm = ({
onCancel,
secretPath,
projectSlug,
environments
environments,
isSingleEnvironmentMode
}: Props) => {
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 && (
<Controller
control={control}
name="environment"

View File

@@ -76,6 +76,7 @@ type Props = {
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
isSingleEnvironmentMode?: boolean;
};
const ATLAS_SCOPE_TYPES = [
@@ -98,7 +99,8 @@ export const MongoAtlasInputForm = ({
onCancel,
environments,
secretPath,
projectSlug
projectSlug,
isSingleEnvironmentMode
}: Props) => {
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 = ({
</AccordionContent>
</AccordionItem>
</Accordion>
{environments.length > 1 && (
{!isSingleEnvironmentMode && (
<Controller
control={control}
name="environment"

View File

@@ -66,6 +66,7 @@ type Props = {
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
isSingleEnvironmentMode?: boolean;
};
export const MongoDBDatabaseInputForm = ({
@@ -73,7 +74,8 @@ export const MongoDBDatabaseInputForm = ({
onCancel,
environments,
secretPath,
projectSlug
projectSlug,
isSingleEnvironmentMode
}: Props) => {
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 = ({
)}
/>
</div>
{environments.length > 1 && (
{!isSingleEnvironmentMode && (
<Controller
control={control}
name="environment"

View File

@@ -70,6 +70,7 @@ type Props = {
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
isSingleEnvironmentMode?: boolean;
};
export const RabbitMqInputForm = ({
@@ -77,7 +78,8 @@ export const RabbitMqInputForm = ({
onCancel,
environments,
secretPath,
projectSlug
projectSlug,
isSingleEnvironmentMode
}: Props) => {
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 = ({
)}
/>
</div>
{environments.length > 1 && (
{!isSingleEnvironmentMode && (
<Controller
control={control}
name="environment"

View File

@@ -63,6 +63,7 @@ type Props = {
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
isSingleEnvironmentMode?: boolean;
};
export const RedisInputForm = ({
@@ -70,7 +71,8 @@ export const RedisInputForm = ({
onCancel,
environments,
secretPath,
projectSlug
projectSlug,
isSingleEnvironmentMode
}: Props) => {
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 = ({
</AccordionContent>
</AccordionItem>
</Accordion>
{environments.length > 1 && (
{!isSingleEnvironmentMode && (
<Controller
control={control}
name="environment"

View File

@@ -61,6 +61,7 @@ type Props = {
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
isSingleEnvironmentMode?: boolean;
};
export const SapAseInputForm = ({
@@ -68,7 +69,8 @@ export const SapAseInputForm = ({
onCancel,
environments,
secretPath,
projectSlug
projectSlug,
isSingleEnvironmentMode
}: Props) => {
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}}';`
</AccordionContent>
</AccordionItem>
</Accordion>
{environments.length > 1 && (
{!isSingleEnvironmentMode && (
<Controller
control={control}
name="environment"

View File

@@ -63,6 +63,7 @@ type Props = {
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
isSingleEnvironmentMode?: boolean;
};
export const SapHanaInputForm = ({
@@ -70,7 +71,8 @@ export const SapHanaInputForm = ({
onCancel,
environments,
secretPath,
projectSlug
projectSlug,
isSingleEnvironmentMode
}: Props) => {
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}};`,
</AccordionContent>
</AccordionItem>
</Accordion>
{environments.length > 1 && (
{!isSingleEnvironmentMode && (
<Controller
control={control}
name="environment"

View File

@@ -67,6 +67,7 @@ type Props = {
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
isSingleEnvironmentMode?: boolean;
};
export const SnowflakeInputForm = ({
@@ -74,7 +75,8 @@ export const SnowflakeInputForm = ({
onCancel,
environments,
secretPath,
projectSlug
projectSlug,
isSingleEnvironmentMode
}: Props) => {
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 = ({
</AccordionContent>
</AccordionItem>
</Accordion>
{environments.length > 1 && (
{!isSingleEnvironmentMode && (
<Controller
control={control}
name="environment"

View File

@@ -92,6 +92,7 @@ type Props = {
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
isSingleEnvironmentMode?: boolean;
};
const getSqlStatements = (provider: SqlProviders) => {
@@ -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 = ({
</AccordionContent>
</AccordionItem>
</Accordion>
{environments.length > 1 && (
{!isSingleEnvironmentMode && (
<Controller
control={control}
name="environment"

View File

@@ -72,6 +72,7 @@ type Props = {
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
isSingleEnvironmentMode?: boolean;
};
export const TotpInputForm = ({
@@ -79,7 +80,8 @@ export const TotpInputForm = ({
onCancel,
environments,
secretPath,
projectSlug
projectSlug,
isSingleEnvironmentMode
}: Props) => {
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 = ({
</p>
</>
)}
{environments.length > 1 && (
{!isSingleEnvironmentMode && (
<Controller
control={control}
name="environment"