mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Fix call of onCompleted after all promises are resolved
This commit is contained in:
@@ -866,7 +866,7 @@ export const OverviewPage = () => {
|
||||
<Button
|
||||
leftIcon={<FontAwesomeIcon icon={faFingerprint} className="pr-2" />}
|
||||
onClick={() => {
|
||||
if (subscription && subscription.dynamicSecret) {
|
||||
if (subscription?.dynamicSecret) {
|
||||
handlePopUpOpen("addDynamicSecret");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -655,7 +655,7 @@ export const ActionBar = ({
|
||||
isOpen={popUp.addDynamicSecret.isOpen}
|
||||
onToggle={(isOpen) => handlePopUpToggle("addDynamicSecret", isOpen)}
|
||||
projectSlug={projectSlug}
|
||||
environments={[{ slug: environment, name: "not-used", id: "not-used" }]}
|
||||
environments={[{ slug: environment, name: environment, id: "not-used" }]}
|
||||
secretPath={secretPath}
|
||||
/>
|
||||
<Modal
|
||||
|
||||
@@ -106,6 +106,7 @@ export const AwsElastiCacheInputForm = ({
|
||||
}: TForm) => {
|
||||
// wait till previous request is finished
|
||||
if (createDynamicSecret.isPending) return;
|
||||
let hasErrors = false;
|
||||
const promises = selectedEnvs.map(async (env) => {
|
||||
try {
|
||||
await createDynamicSecret.mutateAsync({
|
||||
@@ -117,15 +118,18 @@ export const AwsElastiCacheInputForm = ({
|
||||
projectSlug,
|
||||
environmentSlug: env.slug
|
||||
});
|
||||
onCompleted();
|
||||
} catch {
|
||||
hasErrors = true;
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: "Failed to create dynamic secret"
|
||||
text: `Failed to create dynamic secret in environment ${env.name}`
|
||||
});
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
if (hasErrors) {
|
||||
onCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -83,7 +83,8 @@ export const AwsIamInputForm = ({
|
||||
}: TForm) => {
|
||||
// wait till previous request is finished
|
||||
if (createDynamicSecret.isPending) return;
|
||||
const promises = selectedEnvs.map(async (environment) => {
|
||||
let hasErrors = false;
|
||||
const promises = selectedEnvs.map(async (env) => {
|
||||
try {
|
||||
await createDynamicSecret.mutateAsync({
|
||||
provider: { type: DynamicSecretProviders.AwsIam, inputs: provider },
|
||||
@@ -92,17 +93,20 @@ export const AwsIamInputForm = ({
|
||||
path: secretPath,
|
||||
defaultTTL,
|
||||
projectSlug,
|
||||
environmentSlug: environment.slug
|
||||
environmentSlug: env.slug
|
||||
});
|
||||
onCompleted();
|
||||
} catch {
|
||||
hasErrors = true;
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: "Failed to create dynamic secret"
|
||||
text: `Failed to create dynamic secret in environment ${env.name}`
|
||||
});
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
if (hasErrors) {
|
||||
onCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -116,8 +116,9 @@ export const AzureEntraIdInputForm = ({
|
||||
environments: selectedEnvs
|
||||
}: TForm) => {
|
||||
// wait till previous request is finished
|
||||
const promises = selectedEnvs.map(async (environment) => {
|
||||
if (createDynamicSecret.isPending) return;
|
||||
if (createDynamicSecret.isPending) return;
|
||||
let hasErrors = false;
|
||||
const promises = selectedEnvs.map(async (env) => {
|
||||
try {
|
||||
selectedUsers.map(async (user: { id: string; name: string; email: string }) => {
|
||||
await createDynamicSecret.mutateAsync({
|
||||
@@ -136,18 +137,21 @@ export const AzureEntraIdInputForm = ({
|
||||
path: secretPath,
|
||||
defaultTTL,
|
||||
projectSlug,
|
||||
environmentSlug: environment.slug
|
||||
environmentSlug: env.slug
|
||||
});
|
||||
});
|
||||
onCompleted();
|
||||
} catch {
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: "Failed to create dynamic secret"
|
||||
text: `Failed to create dynamic secret in environment ${env.name}`
|
||||
});
|
||||
hasErrors = true;
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
if (hasErrors) {
|
||||
onCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -106,7 +106,8 @@ export const CassandraInputForm = ({
|
||||
}: TForm) => {
|
||||
// wait till previous request is finished
|
||||
if (createDynamicSecret.isPending) return;
|
||||
const promises = selectedEnvs.map(async (environment) => {
|
||||
let hasErrors = false;
|
||||
const promises = selectedEnvs.map(async (env) => {
|
||||
try {
|
||||
await createDynamicSecret.mutateAsync({
|
||||
provider: { type: DynamicSecretProviders.Cassandra, inputs: provider },
|
||||
@@ -115,17 +116,20 @@ export const CassandraInputForm = ({
|
||||
path: secretPath,
|
||||
defaultTTL,
|
||||
projectSlug,
|
||||
environmentSlug: environment.slug
|
||||
environmentSlug: env.slug
|
||||
});
|
||||
onCompleted();
|
||||
} catch {
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: "Failed to create dynamic secret"
|
||||
text: `Failed to create dynamic secret in environment ${env.name}`
|
||||
});
|
||||
hasErrors = true;
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
if (hasErrors) {
|
||||
onCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -126,7 +126,8 @@ export const ElasticSearchInputForm = ({
|
||||
}: TForm) => {
|
||||
// wait till previous request is finished
|
||||
if (createDynamicSecret.isPending) return;
|
||||
const promises = selectedEnvs.map(async (environment) => {
|
||||
let hasErrors = false;
|
||||
const promises = selectedEnvs.map(async (env) => {
|
||||
try {
|
||||
await createDynamicSecret.mutateAsync({
|
||||
provider: { type: DynamicSecretProviders.ElasticSearch, inputs: provider },
|
||||
@@ -135,17 +136,20 @@ export const ElasticSearchInputForm = ({
|
||||
path: secretPath,
|
||||
defaultTTL,
|
||||
projectSlug,
|
||||
environmentSlug: environment.slug
|
||||
environmentSlug: env.slug
|
||||
});
|
||||
onCompleted();
|
||||
} catch {
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: "Failed to create dynamic secret"
|
||||
text: `Failed to create dynamic secret in environment ${env.name}`
|
||||
});
|
||||
hasErrors = true;
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
if (hasErrors) {
|
||||
onCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
const selectedAuthType = watch("provider.auth.type");
|
||||
|
||||
@@ -135,7 +135,8 @@ export const LdapInputForm = ({
|
||||
}: TForm) => {
|
||||
// wait till previous request is finished
|
||||
if (createDynamicSecret.isPending) return;
|
||||
const promises = selectedEnvs.map(async (environment) => {
|
||||
let hasErrors = false;
|
||||
const promises = selectedEnvs.map(async (env) => {
|
||||
try {
|
||||
await createDynamicSecret.mutateAsync({
|
||||
provider: { type: DynamicSecretProviders.Ldap, inputs: provider },
|
||||
@@ -144,17 +145,20 @@ export const LdapInputForm = ({
|
||||
path: secretPath,
|
||||
defaultTTL,
|
||||
projectSlug,
|
||||
environmentSlug: environment.slug
|
||||
environmentSlug: env.slug
|
||||
});
|
||||
onCompleted();
|
||||
} catch {
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: "Failed to create dynamic secret"
|
||||
text: `Failed to create dynamic secret in environment ${env.name}`
|
||||
});
|
||||
hasErrors = true;
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
if (hasErrors) {
|
||||
onCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -137,7 +137,8 @@ export const MongoAtlasInputForm = ({
|
||||
}: TForm) => {
|
||||
// wait till previous request is finished
|
||||
if (createDynamicSecret.isPending) return;
|
||||
const promises = selectedEnvs.map(async (environment) => {
|
||||
let hasErrors = false;
|
||||
const promises = selectedEnvs.map(async (env) => {
|
||||
try {
|
||||
await createDynamicSecret.mutateAsync({
|
||||
provider: { type: DynamicSecretProviders.MongoAtlas, inputs: provider },
|
||||
@@ -146,17 +147,20 @@ export const MongoAtlasInputForm = ({
|
||||
path: secretPath,
|
||||
defaultTTL,
|
||||
projectSlug,
|
||||
environmentSlug: environment.slug
|
||||
environmentSlug: env.slug
|
||||
});
|
||||
onCompleted();
|
||||
} catch {
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: "Failed to create dynamic secret"
|
||||
text: `Failed to create dynamic secret in environment ${env.name}`
|
||||
});
|
||||
hasErrors = true;
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
if (hasErrors) {
|
||||
onCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -107,7 +107,8 @@ export const MongoDBDatabaseInputForm = ({
|
||||
}: TForm) => {
|
||||
// wait till previous request is finished
|
||||
if (createDynamicSecret.isPending) return;
|
||||
const promises = selectedEnvs.map(async (environment) => {
|
||||
let hasErrors = false;
|
||||
const promises = selectedEnvs.map(async (env) => {
|
||||
try {
|
||||
await createDynamicSecret.mutateAsync({
|
||||
provider: {
|
||||
@@ -123,17 +124,20 @@ export const MongoDBDatabaseInputForm = ({
|
||||
path: secretPath,
|
||||
defaultTTL,
|
||||
projectSlug,
|
||||
environmentSlug: environment.slug
|
||||
environmentSlug: env.slug
|
||||
});
|
||||
onCompleted();
|
||||
} catch {
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: "Failed to create dynamic secret"
|
||||
text: `Failed to create dynamic secret in environment ${env.name}`
|
||||
});
|
||||
hasErrors = true;
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
if (hasErrors) {
|
||||
onCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -115,7 +115,8 @@ export const RabbitMqInputForm = ({
|
||||
}: TForm) => {
|
||||
// wait till previous request is finished
|
||||
if (createDynamicSecret.isPending) return;
|
||||
const promises = selectedEnvs.map(async (environment) => {
|
||||
let hasErrors = false;
|
||||
const promises = selectedEnvs.map(async (env) => {
|
||||
try {
|
||||
await createDynamicSecret.mutateAsync({
|
||||
provider: { type: DynamicSecretProviders.RabbitMq, inputs: provider },
|
||||
@@ -124,17 +125,20 @@ export const RabbitMqInputForm = ({
|
||||
path: secretPath,
|
||||
defaultTTL,
|
||||
projectSlug,
|
||||
environmentSlug: environment.slug
|
||||
environmentSlug: env.slug
|
||||
});
|
||||
onCompleted();
|
||||
} catch {
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: "Failed to create dynamic secret"
|
||||
text: `Failed to create dynamic secret in environment ${env.name}`
|
||||
});
|
||||
hasErrors = true;
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
if (hasErrors) {
|
||||
onCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
const selectedTags = watch("provider.tags");
|
||||
|
||||
@@ -100,7 +100,8 @@ export const RedisInputForm = ({
|
||||
}: TForm) => {
|
||||
// wait till previous request is finished
|
||||
if (createDynamicSecret.isPending) return;
|
||||
const promises = selectedEnvs.map(async (environment) => {
|
||||
let hasErrors = false;
|
||||
const promises = selectedEnvs.map(async (env) => {
|
||||
try {
|
||||
await createDynamicSecret.mutateAsync({
|
||||
provider: { type: DynamicSecretProviders.Redis, inputs: provider },
|
||||
@@ -109,17 +110,20 @@ export const RedisInputForm = ({
|
||||
path: secretPath,
|
||||
defaultTTL,
|
||||
projectSlug,
|
||||
environmentSlug: environment.slug
|
||||
environmentSlug: env.slug
|
||||
});
|
||||
onCompleted();
|
||||
} catch {
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: "Failed to create dynamic secret"
|
||||
text: `Failed to create dynamic secret in environment ${env.name}`
|
||||
});
|
||||
hasErrors = true;
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
if (hasErrors) {
|
||||
onCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -101,7 +101,8 @@ sp_droplogin '{{username}}';`
|
||||
}: TForm) => {
|
||||
// wait till previous request is finished
|
||||
if (createDynamicSecret.isPending) return;
|
||||
const promises = selectedEnvs.map(async (environment) => {
|
||||
let hasErrors = false;
|
||||
const promises = selectedEnvs.map(async (env) => {
|
||||
try {
|
||||
await createDynamicSecret.mutateAsync({
|
||||
provider: { type: DynamicSecretProviders.SapAse, inputs: provider },
|
||||
@@ -110,17 +111,20 @@ sp_droplogin '{{username}}';`
|
||||
path: secretPath,
|
||||
defaultTTL,
|
||||
projectSlug,
|
||||
environmentSlug: environment.slug
|
||||
environmentSlug: env.slug
|
||||
});
|
||||
onCompleted();
|
||||
} catch {
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: "Failed to create dynamic secret"
|
||||
text: `Failed to create dynamic secret in environment ${env.name}`
|
||||
});
|
||||
hasErrors = true;
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
if (hasErrors) {
|
||||
onCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -101,7 +101,8 @@ DROP USER {{username}};`,
|
||||
}: TForm) => {
|
||||
// wait till previous request is finished
|
||||
if (createDynamicSecret.isPending) return;
|
||||
const promises = selectedEnvs.map(async (environment) => {
|
||||
let hasErrors = false;
|
||||
const promises = selectedEnvs.map(async (env) => {
|
||||
try {
|
||||
await createDynamicSecret.mutateAsync({
|
||||
provider: { type: DynamicSecretProviders.SapHana, inputs: provider },
|
||||
@@ -110,17 +111,20 @@ DROP USER {{username}};`,
|
||||
path: secretPath,
|
||||
defaultTTL,
|
||||
projectSlug,
|
||||
environmentSlug: environment.slug
|
||||
environmentSlug: env.slug
|
||||
});
|
||||
onCompleted();
|
||||
} catch {
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: "Failed to create dynamic secret"
|
||||
text: `Failed to create dynamic secret in environment ${env.name}`
|
||||
});
|
||||
hasErrors = true;
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
if (hasErrors) {
|
||||
onCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -104,7 +104,8 @@ export const SnowflakeInputForm = ({
|
||||
}: TForm) => {
|
||||
// wait till previous request is finished
|
||||
if (createDynamicSecret.isPending) return;
|
||||
const promises = selectedEnvs.map(async (environment) => {
|
||||
let hasErrors = false;
|
||||
const promises = selectedEnvs.map(async (env) => {
|
||||
try {
|
||||
await createDynamicSecret.mutateAsync({
|
||||
provider: { type: DynamicSecretProviders.Snowflake, inputs: provider },
|
||||
@@ -113,17 +114,20 @@ export const SnowflakeInputForm = ({
|
||||
path: secretPath,
|
||||
defaultTTL,
|
||||
projectSlug,
|
||||
environmentSlug: environment.slug
|
||||
environmentSlug: env.slug
|
||||
});
|
||||
onCompleted();
|
||||
} catch (err) {
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: err instanceof Error ? err.message : "Failed to create dynamic secret"
|
||||
});
|
||||
hasErrors = true;
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
if (hasErrors) {
|
||||
onCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -194,6 +194,7 @@ export const SqlDatabaseInputForm = ({
|
||||
}: TForm) => {
|
||||
// wait till previous request is finished
|
||||
if (createDynamicSecret.isPending) return;
|
||||
let hasErrors = false;
|
||||
const promises = selectedEnvs.map(async (env) => {
|
||||
try {
|
||||
await createDynamicSecret.mutateAsync({
|
||||
@@ -205,15 +206,18 @@ export const SqlDatabaseInputForm = ({
|
||||
projectSlug,
|
||||
environmentSlug: env.slug
|
||||
});
|
||||
onCompleted();
|
||||
} catch {
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: "Failed to create dynamic secret"
|
||||
text: `Failed to create dynamic secret for environment ${env.name}`
|
||||
});
|
||||
hasErrors = true;
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
if (hasErrors) {
|
||||
onCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
const handleDatabaseChange = (type: SqlProviders) => {
|
||||
|
||||
@@ -107,7 +107,8 @@ export const TotpInputForm = ({
|
||||
}: TForm) => {
|
||||
// wait till previous request is finished
|
||||
if (createDynamicSecret.isPending) return;
|
||||
const promises = selectedEnvs.map(async (environment) => {
|
||||
let hasErrors = false;
|
||||
const promises = selectedEnvs.map(async (env) => {
|
||||
try {
|
||||
await createDynamicSecret.mutateAsync({
|
||||
provider: { type: DynamicSecretProviders.Totp, inputs: provider },
|
||||
@@ -116,17 +117,20 @@ export const TotpInputForm = ({
|
||||
path: secretPath,
|
||||
defaultTTL: "1m",
|
||||
projectSlug,
|
||||
environmentSlug: environment.slug
|
||||
environmentSlug: env.slug
|
||||
});
|
||||
onCompleted();
|
||||
} catch (err) {
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: err instanceof Error ? err.message : "Failed to create dynamic secret"
|
||||
});
|
||||
hasErrors = true;
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
if (hasErrors) {
|
||||
onCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user