mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 12:27:28 +00:00
refactor: streamline error handling and notification logic across various components
This commit is contained in:
@@ -25,27 +25,20 @@ const TotpRegistration = ({ onComplete, shouldCenterQr }: Props) => {
|
|||||||
|
|
||||||
const handleTotpVerify = async (event: React.FormEvent<HTMLFormElement>) => {
|
const handleTotpVerify = async (event: React.FormEvent<HTMLFormElement>) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
try {
|
const result = await verifyUserTotp({
|
||||||
const result = await verifyUserTotp({
|
totp
|
||||||
totp
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully configured mobile authenticator",
|
text: "Successfully configured mobile authenticator",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.recoveryCodes && result.recoveryCodes.length > 0) {
|
if (result.recoveryCodes && result.recoveryCodes.length > 0) {
|
||||||
setRecoveryCodes(result.recoveryCodes);
|
setRecoveryCodes(result.recoveryCodes);
|
||||||
setShowRecoveryModal(true);
|
setShowRecoveryModal(true);
|
||||||
} else if (onComplete) {
|
} else if (onComplete) {
|
||||||
onComplete();
|
onComplete();
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to verify TOTP code",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+9
-20
@@ -145,27 +145,16 @@ export const IdentityTable = ({ handlePopUpOpen }: Props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleChangeRole = async ({ identityId, role }: { identityId: string; role: string }) => {
|
const handleChangeRole = async ({ identityId, role }: { identityId: string; role: string }) => {
|
||||||
try {
|
await updateMutateAsync({
|
||||||
await updateMutateAsync({
|
identityId,
|
||||||
identityId,
|
role,
|
||||||
role,
|
organizationId
|
||||||
organizationId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully updated identity role",
|
text: "Successfully updated identity role",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const error = err as any;
|
|
||||||
const text = error?.response?.data?.message ?? "Failed to update identity role";
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRoleToggle = useCallback(
|
const handleRoleToggle = useCallback(
|
||||||
|
|||||||
+30
-37
@@ -134,47 +134,40 @@ export const IdentityTlsCertAuthForm = ({
|
|||||||
accessTokenNumUsesLimit,
|
accessTokenNumUsesLimit,
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!identityId) return;
|
||||||
if (!identityId) return;
|
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
await updateMutateAsync({
|
await updateMutateAsync({
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
caCertificate,
|
caCertificate,
|
||||||
allowedCommonNames: allowedCommonNames || null,
|
allowedCommonNames: allowedCommonNames || null,
|
||||||
identityId,
|
identityId,
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await addMutateAsync({
|
|
||||||
organizationId: orgId,
|
|
||||||
identityId,
|
|
||||||
caCertificate,
|
|
||||||
allowedCommonNames: allowedCommonNames || undefined,
|
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
|
||||||
accessTokenTrustedIps
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpToggle("identityAuthMethod", false);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
reset();
|
await addMutateAsync({
|
||||||
} catch {
|
organizationId: orgId,
|
||||||
createNotification({
|
identityId,
|
||||||
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
|
caCertificate,
|
||||||
type: "error"
|
allowedCommonNames: allowedCommonNames || undefined,
|
||||||
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
|
accessTokenTrustedIps
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+26
-33
@@ -127,43 +127,36 @@ export const IdentityTokenAuthForm = ({
|
|||||||
accessTokenNumUsesLimit,
|
accessTokenNumUsesLimit,
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!identityId) return;
|
||||||
if (!identityId) return;
|
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
await updateMutateAsync({
|
await updateMutateAsync({
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
identityId,
|
identityId,
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await addMutateAsync({
|
|
||||||
organizationId: orgId,
|
|
||||||
identityId,
|
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
|
||||||
accessTokenTrustedIps
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpToggle("identityAuthMethod", false);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
reset();
|
await addMutateAsync({
|
||||||
} catch {
|
organizationId: orgId,
|
||||||
createNotification({
|
identityId,
|
||||||
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
type: "error"
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
|
accessTokenTrustedIps
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+43
-52
@@ -220,64 +220,55 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
lockoutCounterResetValue,
|
lockoutCounterResetValue,
|
||||||
lockoutCounterResetUnit
|
lockoutCounterResetUnit
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!identityId) return;
|
||||||
if (!identityId) return;
|
|
||||||
|
|
||||||
const lockoutDurationSeconds = ms(`${lockoutDurationValue}${lockoutDurationUnit}`) / 1000;
|
const lockoutDurationSeconds = ms(`${lockoutDurationValue}${lockoutDurationUnit}`) / 1000;
|
||||||
const lockoutCounterResetSeconds =
|
const lockoutCounterResetSeconds =
|
||||||
ms(`${lockoutCounterResetValue}${lockoutCounterResetUnit}`) / 1000;
|
ms(`${lockoutCounterResetValue}${lockoutCounterResetUnit}`) / 1000;
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
// update universal auth configuration
|
// update universal auth configuration
|
||||||
await updateMutateAsync({
|
await updateMutateAsync({
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
identityId,
|
identityId,
|
||||||
clientSecretTrustedIps,
|
clientSecretTrustedIps,
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
accessTokenTrustedIps,
|
accessTokenTrustedIps,
|
||||||
accessTokenPeriod: Number(accessTokenPeriod),
|
accessTokenPeriod: Number(accessTokenPeriod),
|
||||||
lockoutEnabled,
|
lockoutEnabled,
|
||||||
lockoutThreshold: Number(lockoutThreshold),
|
lockoutThreshold: Number(lockoutThreshold),
|
||||||
lockoutDurationSeconds,
|
lockoutDurationSeconds,
|
||||||
lockoutCounterResetSeconds
|
lockoutCounterResetSeconds
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// create new universal auth configuration
|
|
||||||
|
|
||||||
await addMutateAsync({
|
|
||||||
organizationId: orgId,
|
|
||||||
identityId,
|
|
||||||
clientSecretTrustedIps,
|
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
|
||||||
accessTokenTrustedIps,
|
|
||||||
accessTokenPeriod: Number(accessTokenPeriod),
|
|
||||||
lockoutEnabled,
|
|
||||||
lockoutThreshold: Number(lockoutThreshold),
|
|
||||||
lockoutDurationSeconds: Number(lockoutDurationSeconds),
|
|
||||||
lockoutCounterResetSeconds: Number(lockoutCounterResetSeconds)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpToggle("identityAuthMethod", false);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${isUpdate ? "updated" : "created"} auth method`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// create new universal auth configuration
|
||||||
|
|
||||||
reset();
|
await addMutateAsync({
|
||||||
} catch {
|
organizationId: orgId,
|
||||||
const text = `Failed to ${isUpdate ? "update" : "configure"} identity`;
|
identityId,
|
||||||
|
clientSecretTrustedIps,
|
||||||
createNotification({
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
text,
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
type: "error"
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
|
accessTokenTrustedIps,
|
||||||
|
accessTokenPeriod: Number(accessTokenPeriod),
|
||||||
|
lockoutEnabled,
|
||||||
|
lockoutThreshold: Number(lockoutThreshold),
|
||||||
|
lockoutDurationSeconds: Number(lockoutDurationSeconds),
|
||||||
|
lockoutCounterResetSeconds: Number(lockoutCounterResetSeconds)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${isUpdate ? "updated" : "created"} auth method`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+40
-49
@@ -122,64 +122,55 @@ export const AddOrgMemberModal = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const parsedEmails = emails
|
||||||
const parsedEmails = emails
|
.replace(/\s/g, "")
|
||||||
.replace(/\s/g, "")
|
.split(",")
|
||||||
.split(",")
|
.map((email) => {
|
||||||
.map((email) => {
|
if (EmailSchema.safeParse(email).success) {
|
||||||
if (EmailSchema.safeParse(email).success) {
|
return email.trim();
|
||||||
return email.trim();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
});
|
|
||||||
|
|
||||||
if (parsedEmails.includes(null)) {
|
|
||||||
createNotification({
|
|
||||||
text: "Invalid email addresses provided.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const usernames = emails.split(",").map((email) => email.trim());
|
|
||||||
const { data } = await addUsersMutateAsync({
|
|
||||||
organizationId: currentOrg?.id,
|
|
||||||
inviteeEmails: usernames,
|
|
||||||
organizationRoleSlug: organizationRole.slug
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await Promise.allSettled(
|
if (parsedEmails.includes(null)) {
|
||||||
selectedProjects.map((el) =>
|
|
||||||
addUserToProject({
|
|
||||||
orgId: currentOrg.id,
|
|
||||||
projectId: el.id,
|
|
||||||
roleSlugs: [projectRoleSlug],
|
|
||||||
usernames
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
setCompleteInviteLinks(data?.completeInviteLinks ?? null);
|
|
||||||
|
|
||||||
// only show this notification when email is configured.
|
|
||||||
// A [completeInviteLink] will not be sent if smtp is configured
|
|
||||||
|
|
||||||
if (!data.completeInviteLinks) {
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully invited user to the organization.",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Failed to invite user to org",
|
text: "Invalid email addresses provided.",
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const usernames = emails.split(",").map((email) => email.trim());
|
||||||
|
const { data } = await addUsersMutateAsync({
|
||||||
|
organizationId: currentOrg?.id,
|
||||||
|
inviteeEmails: usernames,
|
||||||
|
organizationRoleSlug: organizationRole.slug
|
||||||
|
});
|
||||||
|
|
||||||
|
await Promise.allSettled(
|
||||||
|
selectedProjects.map((el) =>
|
||||||
|
addUserToProject({
|
||||||
|
orgId: currentOrg.id,
|
||||||
|
projectId: el.id,
|
||||||
|
roleSlugs: [projectRoleSlug],
|
||||||
|
usernames
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
setCompleteInviteLinks(data?.completeInviteLinks ?? null);
|
||||||
|
|
||||||
|
// only show this notification when email is configured.
|
||||||
|
// A [completeInviteLink] will not be sent if smtp is configured
|
||||||
|
|
||||||
|
if (!data.completeInviteLinks) {
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully invited user to the organization.",
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (serverDetails?.emailConfigured) {
|
if (serverDetails?.emailConfigured) {
|
||||||
handlePopUpToggle("addMember", false);
|
handlePopUpToggle("addMember", false);
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-25
@@ -106,32 +106,24 @@ export const AddSubOrgMemberModal = ({ onClose }: Props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const usernames = users.map((el) => el.username);
|
||||||
const usernames = users.map((el) => el.username);
|
await addUsersMutateAsync({
|
||||||
await addUsersMutateAsync({
|
organizationId: currentOrg?.id,
|
||||||
organizationId: currentOrg?.id,
|
inviteeEmails: usernames,
|
||||||
inviteeEmails: usernames,
|
organizationRoleSlug: organizationRole.slug
|
||||||
organizationRoleSlug: organizationRole.slug
|
});
|
||||||
});
|
|
||||||
|
|
||||||
await Promise.allSettled(
|
await Promise.allSettled(
|
||||||
selectedProjects.map((el) =>
|
selectedProjects.map((el) =>
|
||||||
addUserToProject({
|
addUserToProject({
|
||||||
orgId: currentOrg.id,
|
orgId: currentOrg.id,
|
||||||
projectId: el.id,
|
projectId: el.id,
|
||||||
roleSlugs: [projectRoleSlug],
|
roleSlugs: [projectRoleSlug],
|
||||||
usernames
|
usernames
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
onClose();
|
onClose();
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to add user to suborganization",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getGroupHeaderLabel = (type: ProjectType) => {
|
const getGroupHeaderLabel = (type: ProjectType) => {
|
||||||
|
|||||||
+6
-13
@@ -44,21 +44,14 @@ export const UpgradePrivilegeSystemModal = ({ isOpen, onOpenChange }: Props) =>
|
|||||||
acknowledgesPermanentChange;
|
acknowledgesPermanentChange;
|
||||||
|
|
||||||
const handlePrivilegeSystemUpgrade = async () => {
|
const handlePrivilegeSystemUpgrade = async () => {
|
||||||
try {
|
await upgradePrivilegeSystem();
|
||||||
await upgradePrivilegeSystem();
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Privilege system upgrade completed",
|
text: "Privilege system upgrade completed",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to upgrade privilege system",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
|
|||||||
+9
-18
@@ -18,26 +18,17 @@ export const DeleteAppConnectionModal = ({ isOpen, onOpenChange, appConnection }
|
|||||||
const { id: connectionId, name, app } = appConnection;
|
const { id: connectionId, name, app } = appConnection;
|
||||||
|
|
||||||
const handleDeleteAppConnection = async () => {
|
const handleDeleteAppConnection = async () => {
|
||||||
try {
|
await deleteAppConnection.mutateAsync({
|
||||||
await deleteAppConnection.mutateAsync({
|
connectionId,
|
||||||
connectionId,
|
app
|
||||||
app
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully removed ${APP_CONNECTION_MAP[app].name} connection`,
|
text: `Successfully removed ${APP_CONNECTION_MAP[app].name} connection`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to remove ${APP_CONNECTION_MAP[app].name} connection`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+9
-18
@@ -43,24 +43,15 @@ const Content = ({ appConnection, onComplete }: ContentProps) => {
|
|||||||
} = form;
|
} = form;
|
||||||
|
|
||||||
const onSubmit = async (formData: FormData) => {
|
const onSubmit = async (formData: FormData) => {
|
||||||
try {
|
await updateAppConnection.mutateAsync({
|
||||||
await updateAppConnection.mutateAsync({
|
connectionId: appConnection.id,
|
||||||
connectionId: appConnection.id,
|
...formData
|
||||||
...formData
|
});
|
||||||
});
|
createNotification({
|
||||||
createNotification({
|
text: `Successfully updated ${appName} Connection`,
|
||||||
text: `Successfully updated ${appName} Connection`,
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
onComplete();
|
||||||
onComplete();
|
|
||||||
} catch (err: any) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
title: `Failed to update ${appName} Connection`,
|
|
||||||
text: err.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+8
-48
@@ -127,12 +127,7 @@ export const OAuthCallbackPage = () => {
|
|||||||
projectId,
|
projectId,
|
||||||
connection
|
connection
|
||||||
};
|
};
|
||||||
} catch (err: any) {
|
} catch {
|
||||||
createNotification({
|
|
||||||
title: `Failed to ${connectionId ? "update" : "add"} GitLab Connection`,
|
|
||||||
text: err?.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
navigate({
|
navigate({
|
||||||
to: returnUrl,
|
to: returnUrl,
|
||||||
params: {
|
params: {
|
||||||
@@ -176,12 +171,7 @@ export const OAuthCallbackPage = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch {
|
||||||
createNotification({
|
|
||||||
title: `Failed to ${connectionId ? "update" : "add"} Azure Key Vault Connection`,
|
|
||||||
text: err?.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
navigate({
|
navigate({
|
||||||
to: returnUrl,
|
to: returnUrl,
|
||||||
params: {
|
params: {
|
||||||
@@ -233,12 +223,7 @@ export const OAuthCallbackPage = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch {
|
||||||
createNotification({
|
|
||||||
title: `Failed to ${connectionId ? "update" : "add"} Azure App Configuration Connection`,
|
|
||||||
text: err?.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
navigate({
|
navigate({
|
||||||
to: returnUrl,
|
to: returnUrl,
|
||||||
params: {
|
params: {
|
||||||
@@ -290,12 +275,7 @@ export const OAuthCallbackPage = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch {
|
||||||
createNotification({
|
|
||||||
title: `Failed to ${connectionId ? "update" : "add"} Azure Client Secrets Connection`,
|
|
||||||
text: err?.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
navigate({
|
navigate({
|
||||||
to: returnUrl,
|
to: returnUrl,
|
||||||
params: {
|
params: {
|
||||||
@@ -353,12 +333,7 @@ export const OAuthCallbackPage = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch {
|
||||||
createNotification({
|
|
||||||
title: `Failed to ${connectionId ? "update" : "add"} Azure DevOps Connection`,
|
|
||||||
text: err?.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
navigate({
|
navigate({
|
||||||
to: returnUrl,
|
to: returnUrl,
|
||||||
params: {
|
params: {
|
||||||
@@ -441,12 +416,7 @@ export const OAuthCallbackPage = () => {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch {
|
||||||
createNotification({
|
|
||||||
title: `Failed to ${connectionId ? "update" : "add"} GitHub Connection`,
|
|
||||||
text: e.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
navigate({
|
navigate({
|
||||||
to: returnUrl,
|
to: returnUrl,
|
||||||
params: {
|
params: {
|
||||||
@@ -498,12 +468,7 @@ export const OAuthCallbackPage = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch {
|
||||||
createNotification({
|
|
||||||
title: `Failed to ${connectionId ? "update" : "add"} GitHub Radar Connection`,
|
|
||||||
text: e.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
navigate({
|
navigate({
|
||||||
to: returnUrl,
|
to: returnUrl,
|
||||||
params: {
|
params: {
|
||||||
@@ -553,12 +518,7 @@ export const OAuthCallbackPage = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch {
|
||||||
createNotification({
|
|
||||||
title: `Failed to ${connectionId ? "update" : "add"} Heroku Connection`,
|
|
||||||
text: e.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
navigate({
|
navigate({
|
||||||
to: returnUrl,
|
to: returnUrl,
|
||||||
params: {
|
params: {
|
||||||
|
|||||||
+10
-18
@@ -35,25 +35,17 @@ export const CompanyNameSection = () => {
|
|||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
const onFormSubmit = async ({ name }: { name: string }) => {
|
const onFormSubmit = async ({ name }: { name: string }) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
if (name === "") return;
|
||||||
if (name === "") return;
|
await mutateAsync({
|
||||||
await mutateAsync({
|
name,
|
||||||
name,
|
organizationId: currentOrg.id
|
||||||
organizationId: currentOrg.id
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully updated business name",
|
text: "Successfully updated business name",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to update business name",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+10
-18
@@ -35,26 +35,18 @@ export const InvoiceEmailSection = () => {
|
|||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
const onFormSubmit = async ({ email }: { email: string }) => {
|
const onFormSubmit = async ({ email }: { email: string }) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
if (email === "") return;
|
||||||
if (email === "") return;
|
|
||||||
|
|
||||||
await mutateAsync({
|
await mutateAsync({
|
||||||
email,
|
email,
|
||||||
organizationId: currentOrg.id
|
organizationId: currentOrg.id
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully updated invoice email recipient",
|
text: "Successfully updated invoice email recipient",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to update invoice email recipient",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+9
-16
@@ -39,22 +39,15 @@ export const PmtMethodsTable = () => {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
await deleteOrgPmtMethod.mutateAsync({
|
||||||
await deleteOrgPmtMethod.mutateAsync({
|
organizationId: currentOrg.id,
|
||||||
organizationId: currentOrg.id,
|
pmtMethodId: pmtMethodToRemove.id
|
||||||
pmtMethodId: pmtMethodToRemove.id
|
});
|
||||||
});
|
createNotification({
|
||||||
createNotification({
|
type: "success",
|
||||||
type: "success",
|
text: "Successfully removed payment method"
|
||||||
text: "Successfully removed payment method"
|
});
|
||||||
});
|
handlePopUpClose("removeCard");
|
||||||
handlePopUpClose("removeCard");
|
|
||||||
} catch (error: any) {
|
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
text: error.message ?? "Error removing payment method"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+11
-19
@@ -98,26 +98,18 @@ export const TaxIDModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props
|
|||||||
});
|
});
|
||||||
|
|
||||||
const onTaxIDModalSubmit = async ({ type, value }: AddTaxIDFormData) => {
|
const onTaxIDModalSubmit = async ({ type, value }: AddTaxIDFormData) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
await addOrgTaxId.mutateAsync({
|
||||||
await addOrgTaxId.mutateAsync({
|
organizationId: currentOrg.id,
|
||||||
organizationId: currentOrg.id,
|
type,
|
||||||
type,
|
value
|
||||||
value
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully added Tax ID",
|
text: "Successfully added Tax ID",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
handlePopUpClose("addTaxID");
|
handlePopUpClose("addTaxID");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to add Tax ID",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -56,27 +56,19 @@ const Page = () => {
|
|||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const onDeleteGroupSubmit = async ({ name, id }: { name: string; id: string }) => {
|
const onDeleteGroupSubmit = async ({ name, id }: { name: string; id: string }) => {
|
||||||
try {
|
await deleteMutateAsync({
|
||||||
await deleteMutateAsync({
|
id
|
||||||
id
|
});
|
||||||
});
|
createNotification({
|
||||||
createNotification({
|
text: `Successfully deleted the ${name} group`,
|
||||||
text: `Successfully deleted the ${name} group`,
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
navigate({
|
||||||
navigate({
|
to: "/organization/access-management" as const,
|
||||||
to: "/organization/access-management" as const,
|
search: {
|
||||||
search: {
|
selectedTab: TabSections.Groups
|
||||||
selectedTab: TabSections.Groups
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to delete the ${name} group`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpClose("deleteGroup");
|
handlePopUpClose("deleteGroup");
|
||||||
};
|
};
|
||||||
|
|||||||
+14
-21
@@ -63,31 +63,24 @@ export const AddGroupMembersModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
const { mutateAsync: addUserToGroupMutateAsync } = useAddUserToGroup();
|
const { mutateAsync: addUserToGroupMutateAsync } = useAddUserToGroup();
|
||||||
|
|
||||||
const handleAddMember = async (username: string) => {
|
const handleAddMember = async (username: string) => {
|
||||||
try {
|
if (!popUpData?.slug) {
|
||||||
if (!popUpData?.slug) {
|
|
||||||
createNotification({
|
|
||||||
text: "Some data is missing, please refresh the page and try again",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await addUserToGroupMutateAsync({
|
|
||||||
groupId: popUpData.groupId,
|
|
||||||
username,
|
|
||||||
slug: popUpData.slug
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully assigned user to the group",
|
text: "Some data is missing, please refresh the page and try again",
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to assign user to the group",
|
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await addUserToGroupMutateAsync({
|
||||||
|
groupId: popUpData.groupId,
|
||||||
|
username,
|
||||||
|
slug: popUpData.slug
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully assigned user to the group",
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+10
-17
@@ -29,25 +29,18 @@ export const GroupMembersSection = ({ groupId, groupSlug }: Props) => {
|
|||||||
|
|
||||||
const { mutateAsync: removeUserFromGroupMutateAsync } = useRemoveUserFromGroup();
|
const { mutateAsync: removeUserFromGroupMutateAsync } = useRemoveUserFromGroup();
|
||||||
const handleRemoveUserFromGroup = async (username: string) => {
|
const handleRemoveUserFromGroup = async (username: string) => {
|
||||||
try {
|
await removeUserFromGroupMutateAsync({
|
||||||
await removeUserFromGroupMutateAsync({
|
groupId,
|
||||||
groupId,
|
username,
|
||||||
username,
|
slug: groupSlug
|
||||||
slug: groupSlug
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully removed user ${username} from the group`,
|
text: `Successfully removed user ${username} from the group`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpToggle("removeMemberFromGroup", false);
|
handlePopUpToggle("removeMemberFromGroup", false);
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to remove user ${username} from the group`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+11
-22
@@ -75,30 +75,19 @@ const Content = ({ identityId, handlePopUpToggle }: Omit<Props, "popUp">) => {
|
|||||||
}, [workspaces, projectMemberships]);
|
}, [workspaces, projectMemberships]);
|
||||||
|
|
||||||
const onFormSubmit = async ({ project: selectedProject, role }: FormData) => {
|
const onFormSubmit = async ({ project: selectedProject, role }: FormData) => {
|
||||||
try {
|
await addIdentityToWorkspace({
|
||||||
await addIdentityToWorkspace({
|
projectId: selectedProject.id,
|
||||||
projectId: selectedProject.id,
|
identityId,
|
||||||
identityId,
|
role: role.slug || undefined
|
||||||
role: role.slug || undefined
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully added identity to project",
|
text: "Successfully added identity to project",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
handlePopUpToggle("addIdentityToProject", false);
|
handlePopUpToggle("addIdentityToProject", false);
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const error = err as any;
|
|
||||||
const text = error?.response?.data?.message ?? "Failed to add identity to project";
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const isProjectSelected = Boolean(projectId);
|
const isProjectSelected = Boolean(projectId);
|
||||||
|
|||||||
+9
-20
@@ -22,28 +22,17 @@ export const IdentityProjectsSection = ({ identityId }: Props) => {
|
|||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const onRemoveIdentitySubmit = async (id: string, projectId: string) => {
|
const onRemoveIdentitySubmit = async (id: string, projectId: string) => {
|
||||||
try {
|
await deleteMutateAsync({
|
||||||
await deleteMutateAsync({
|
identityId: id,
|
||||||
identityId: id,
|
projectId
|
||||||
projectId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully removed identity from project",
|
text: "Successfully removed identity from project",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("removeIdentityFromProject");
|
handlePopUpClose("removeIdentityFromProject");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const error = err as any;
|
|
||||||
const text = error?.response?.data?.message ?? "Failed to remove identity from project";
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+21
-34
@@ -72,46 +72,33 @@ export const IdentityTokenModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
}, [popUp?.token?.data]);
|
}, [popUp?.token?.data]);
|
||||||
|
|
||||||
const onFormSubmit = async ({ name }: FormData) => {
|
const onFormSubmit = async ({ name }: FormData) => {
|
||||||
try {
|
if (tokenData?.tokenId) {
|
||||||
if (tokenData?.tokenId) {
|
// update
|
||||||
// update
|
|
||||||
|
|
||||||
await updateToken({
|
await updateToken({
|
||||||
identityId: tokenData.identityId,
|
identityId: tokenData.identityId,
|
||||||
tokenId: tokenData.tokenId,
|
tokenId: tokenData.tokenId,
|
||||||
name
|
name
|
||||||
});
|
|
||||||
|
|
||||||
handlePopUpToggle("token", false);
|
|
||||||
} else {
|
|
||||||
// create
|
|
||||||
|
|
||||||
const newTokenData = await createToken({
|
|
||||||
identityId: tokenData.identityId,
|
|
||||||
name
|
|
||||||
});
|
|
||||||
|
|
||||||
setToken(newTokenData.accessToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${popUp?.token?.data ? "updated" : "created"} token`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
|
|
||||||
reset();
|
handlePopUpToggle("token", false);
|
||||||
} catch (err) {
|
} else {
|
||||||
console.error(err);
|
// create
|
||||||
const error = err as any;
|
|
||||||
const text =
|
|
||||||
error?.response?.data?.message ??
|
|
||||||
`Failed to ${popUp?.token?.data ? "update" : "create"} token`;
|
|
||||||
|
|
||||||
createNotification({
|
const newTokenData = await createToken({
|
||||||
text,
|
identityId: tokenData.identityId,
|
||||||
type: "error"
|
name
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setToken(newTokenData.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${popUp?.token?.data ? "updated" : "created"} token`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+9
-17
@@ -31,23 +31,15 @@ export const LockoutFields = ({
|
|||||||
|
|
||||||
const [lockedOutState, setLockedOutState] = useState(lockedOut);
|
const [lockedOutState, setLockedOutState] = useState(lockedOut);
|
||||||
|
|
||||||
async function clearLockouts() {
|
const clearLockouts = async () => {
|
||||||
try {
|
const deleted = await mutateAsync({ identityId });
|
||||||
const deleted = await mutateAsync({ identityId });
|
createNotification({
|
||||||
createNotification({
|
text: `Successfully cleared ${deleted} lockout${deleted === 1 ? "" : "s"}`,
|
||||||
text: `Successfully cleared ${deleted} lockout${deleted === 1 ? "" : "s"}`,
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
setLockedOutState(false);
|
||||||
setLockedOutState(false);
|
onResetAllLockouts();
|
||||||
onResetAllLockouts();
|
};
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to clear lockouts. Please try again.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
+9
-20
@@ -51,28 +51,17 @@ export const IdentityTokenAuthTokensTable = ({ tokens, identityId }: Props) => {
|
|||||||
tokenId: string;
|
tokenId: string;
|
||||||
name: string;
|
name: string;
|
||||||
}) => {
|
}) => {
|
||||||
try {
|
await revokeToken({
|
||||||
await revokeToken({
|
identityId: parentIdentityId,
|
||||||
identityId: parentIdentityId,
|
tokenId
|
||||||
tokenId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
handlePopUpClose("revokeToken");
|
handlePopUpClose("revokeToken");
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully revoked token ${name ?? ""}`,
|
text: `Successfully revoked token ${name ?? ""}`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const error = err as any;
|
|
||||||
const text = error?.response?.data?.message ?? "Failed to revoke token";
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+9
-17
@@ -43,25 +43,17 @@ export const IdentityUniversalAuthClientSecretsTable = ({ clientSecrets, identit
|
|||||||
const { mutateAsync: revokeClientSecret } = useRevokeIdentityUniversalAuthClientSecret();
|
const { mutateAsync: revokeClientSecret } = useRevokeIdentityUniversalAuthClientSecret();
|
||||||
|
|
||||||
const onDeleteClientSecretSubmit = async (clientSecretId: string) => {
|
const onDeleteClientSecretSubmit = async (clientSecretId: string) => {
|
||||||
try {
|
await revokeClientSecret({
|
||||||
await revokeClientSecret({
|
identityId,
|
||||||
identityId,
|
clientSecretId
|
||||||
clientSecretId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
handlePopUpToggle("revokeClientSecret", false);
|
handlePopUpToggle("revokeClientSecret", false);
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted client secret",
|
text: "Successfully deleted client secret",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete client secret",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+10
-18
@@ -140,25 +140,17 @@ export const Content = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleDeleteAuthMethod = async () => {
|
const handleDeleteAuthMethod = async () => {
|
||||||
try {
|
await revokeMethod({
|
||||||
await revokeMethod({
|
identityId,
|
||||||
identityId,
|
organizationId: orgId
|
||||||
organizationId: orgId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully removed auth method",
|
text: "Successfully removed auth method",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
handlePopUpToggle("revokeAuthMethod", false);
|
||||||
handlePopUpToggle("revokeAuthMethod", false);
|
onDeleteAuthMethod();
|
||||||
onDeleteAuthMethod();
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to remove auth method",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+1
-6
@@ -168,12 +168,7 @@ export const GatewayCliDeploymentMethod = () => {
|
|||||||
type: "info"
|
type: "info"
|
||||||
});
|
});
|
||||||
setStep("command");
|
setStep("command");
|
||||||
} catch (err) {
|
} catch {
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to generate token for the selected identity",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
setIdentityToken("");
|
setIdentityToken("");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+1
-6
@@ -141,12 +141,7 @@ export const RelayCliDeploymentMethod = () => {
|
|||||||
type: "info"
|
type: "info"
|
||||||
});
|
});
|
||||||
setStep("command");
|
setStep("command");
|
||||||
} catch (err) {
|
} catch {
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to generate token for the selected identity",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
setIdentityToken("");
|
setIdentityToken("");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import { useNavigate } from "@tanstack/react-router";
|
|||||||
import { CheckIcon } from "lucide-react";
|
import { CheckIcon } from "lucide-react";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
|
||||||
import { OrgPermissionCan } from "@app/components/permissions";
|
import { OrgPermissionCan } from "@app/components/permissions";
|
||||||
import { RequestProjectAccessModal } from "@app/components/projects/RequestProjectAccessModal";
|
import { RequestProjectAccessModal } from "@app/components/projects/RequestProjectAccessModal";
|
||||||
import {
|
import {
|
||||||
@@ -103,22 +102,15 @@ export const AllProjectView = ({
|
|||||||
projectId: string,
|
projectId: string,
|
||||||
environments: ProjectEnv[]
|
environments: ProjectEnv[]
|
||||||
) => {
|
) => {
|
||||||
try {
|
await orgAdminAccessProject.mutateAsync({
|
||||||
await orgAdminAccessProject.mutateAsync({
|
projectId
|
||||||
|
});
|
||||||
|
await navigate({
|
||||||
|
to: getProjectHomePage(type, environments),
|
||||||
|
params: {
|
||||||
projectId
|
projectId
|
||||||
});
|
}
|
||||||
await navigate({
|
});
|
||||||
to: getProjectHomePage(type, environments),
|
|
||||||
params: {
|
|
||||||
projectId
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to access project",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useResetPageHelper({
|
useResetPageHelper({
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|||||||
import { useNavigate } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
|
||||||
import { OrgPermissionCan } from "@app/components/permissions";
|
import { OrgPermissionCan } from "@app/components/permissions";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -158,32 +157,18 @@ export const MyProjectView = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const addProjectToFavorites = async (projectId: string) => {
|
const addProjectToFavorites = async (projectId: string) => {
|
||||||
try {
|
if (currentOrg?.id) {
|
||||||
if (currentOrg?.id) {
|
await updateUserProjectFavorites({
|
||||||
await updateUserProjectFavorites({
|
orgId: currentOrg?.id,
|
||||||
orgId: currentOrg?.id,
|
projectFavorites: [...(projectFavorites || []), projectId]
|
||||||
projectFavorites: [...(projectFavorites || []), projectId]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to add project to favorites.",
|
|
||||||
type: "error"
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const removeProjectFromFavorites = async (projectId: string) => {
|
const removeProjectFromFavorites = async (projectId: string) => {
|
||||||
try {
|
if (currentOrg?.id) {
|
||||||
if (currentOrg?.id) {
|
await updateUserProjectFavorites({
|
||||||
await updateUserProjectFavorites({
|
orgId: currentOrg?.id,
|
||||||
orgId: currentOrg?.id,
|
projectFavorites: [...(projectFavorites || []).filter((entry) => entry !== projectId)]
|
||||||
projectFavorites: [...(projectFavorites || []).filter((entry) => entry !== projectId)]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to remove project from favorites.",
|
|
||||||
type: "error"
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,36 +42,25 @@ export const Page = () => {
|
|||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const onDeleteOrgRoleSubmit = async () => {
|
const onDeleteOrgRoleSubmit = async () => {
|
||||||
try {
|
if (!orgId || !roleId) return;
|
||||||
if (!orgId || !roleId) return;
|
|
||||||
|
|
||||||
await deleteOrgRole({
|
await deleteOrgRole({
|
||||||
orgId,
|
orgId,
|
||||||
id: roleId
|
id: roleId
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted organization role",
|
text: "Successfully deleted organization role",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("deleteOrgRole");
|
handlePopUpClose("deleteOrgRole");
|
||||||
navigate({
|
navigate({
|
||||||
to: "/organization/access-management" as const,
|
to: "/organization/access-management" as const,
|
||||||
search: {
|
search: {
|
||||||
selectedTab: OrgAccessControlTabSections.Roles
|
selectedTab: OrgAccessControlTabSections.Roles
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const error = err as any;
|
|
||||||
const text = error?.response?.data?.message ?? "Failed to delete organization role";
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const isCustomRole = !["admin", "member", "no-access"].includes(data?.slug ?? "");
|
const isCustomRole = !["admin", "member", "no-access"].includes(data?.slug ?? "");
|
||||||
|
|||||||
@@ -70,55 +70,46 @@ export const RoleModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
}, [role]);
|
}, [role]);
|
||||||
|
|
||||||
const onFormSubmit = async ({ name, description, slug }: FormData) => {
|
const onFormSubmit = async ({ name, description, slug }: FormData) => {
|
||||||
try {
|
if (!orgId) return;
|
||||||
if (!orgId) return;
|
|
||||||
|
|
||||||
if (role) {
|
if (role) {
|
||||||
// update
|
// update
|
||||||
|
|
||||||
await updateOrgRole({
|
await updateOrgRole({
|
||||||
orgId,
|
orgId,
|
||||||
id: role.id,
|
id: role.id,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
slug
|
slug
|
||||||
});
|
|
||||||
|
|
||||||
handlePopUpToggle("role", false);
|
|
||||||
} else {
|
|
||||||
// create
|
|
||||||
|
|
||||||
const newRole = await createOrgRole({
|
|
||||||
orgId,
|
|
||||||
name,
|
|
||||||
description,
|
|
||||||
slug,
|
|
||||||
permissions: []
|
|
||||||
});
|
|
||||||
|
|
||||||
handlePopUpToggle("role", false);
|
|
||||||
navigate({
|
|
||||||
to: "/organization/roles/$roleId",
|
|
||||||
params: {
|
|
||||||
roleId: newRole.id
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${popUp?.role?.data ? "updated" : "created"} role`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
|
|
||||||
reset();
|
handlePopUpToggle("role", false);
|
||||||
} catch {
|
} else {
|
||||||
const text = `Failed to ${popUp?.role?.data ? "update" : "create"} role`;
|
// create
|
||||||
|
|
||||||
createNotification({
|
const newRole = await createOrgRole({
|
||||||
text,
|
orgId,
|
||||||
type: "error"
|
name,
|
||||||
|
description,
|
||||||
|
slug,
|
||||||
|
permissions: []
|
||||||
|
});
|
||||||
|
|
||||||
|
handlePopUpToggle("role", false);
|
||||||
|
navigate({
|
||||||
|
to: "/organization/roles/$roleId",
|
||||||
|
params: {
|
||||||
|
roleId: newRole.id
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${popUp?.role?.data ? "updated" : "created"} role`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+19
-27
@@ -56,35 +56,27 @@ export const RequestSecretForm = () => {
|
|||||||
const onFormSubmit = async ({ name, accessType, expiresIn }: FormData) => {
|
const onFormSubmit = async ({ name, accessType, expiresIn }: FormData) => {
|
||||||
const expiresAt = new Date(new Date().getTime() + Number(expiresIn));
|
const expiresAt = new Date(new Date().getTime() + Number(expiresIn));
|
||||||
|
|
||||||
try {
|
const { id } = await createSecretRequest({
|
||||||
const { id } = await createSecretRequest({
|
name,
|
||||||
name,
|
accessType,
|
||||||
accessType,
|
expiresAt
|
||||||
expiresAt
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const link = new URL(`${window.location.origin}/secret-request/secret/${id}`);
|
const link = new URL(`${window.location.origin}/secret-request/secret/${id}`);
|
||||||
if (subOrganization) {
|
if (subOrganization) {
|
||||||
link.searchParams.set("subOrganization", subOrganization);
|
link.searchParams.set("subOrganization", subOrganization);
|
||||||
}
|
|
||||||
|
|
||||||
setSecretLink(link.toString());
|
|
||||||
reset();
|
|
||||||
|
|
||||||
navigator.clipboard.writeText(link.toString());
|
|
||||||
setCopyTextSecret("secret");
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: "Shared secret link copied to clipboard.",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to create a shared secret.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setSecretLink(link.toString());
|
||||||
|
reset();
|
||||||
|
|
||||||
|
navigator.clipboard.writeText(link.toString());
|
||||||
|
setCopyTextSecret("secret");
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: "Shared secret link copied to clipboard.",
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const hasSecretLink = Boolean(secretLink);
|
const hasSecretLink = Boolean(secretLink);
|
||||||
|
|||||||
+8
-16
@@ -22,23 +22,15 @@ export const RequestSecretTab = () => {
|
|||||||
const { mutateAsync: deleteSecretRequest } = useDeleteSecretRequest();
|
const { mutateAsync: deleteSecretRequest } = useDeleteSecretRequest();
|
||||||
|
|
||||||
const onDeleteApproved = async () => {
|
const onDeleteApproved = async () => {
|
||||||
try {
|
await deleteSecretRequest({
|
||||||
await deleteSecretRequest({
|
secretRequestId: popUp.deleteSecretRequestConfirmation.data?.id
|
||||||
secretRequestId: popUp.deleteSecretRequestConfirmation.data?.id
|
});
|
||||||
});
|
createNotification({
|
||||||
createNotification({
|
text: "Successfully deleted secret request",
|
||||||
text: "Successfully deleted secret request",
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
|
|
||||||
handlePopUpClose("deleteSecretRequestConfirmation");
|
handlePopUpClose("deleteSecretRequestConfirmation");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete shared secret",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+12
-19
@@ -90,28 +90,21 @@ export const OrgSecretShareLimitSection = () => {
|
|||||||
}, [currentOrg, reset]);
|
}, [currentOrg, reset]);
|
||||||
|
|
||||||
const handleFormSubmit = async (formData: TForm) => {
|
const handleFormSubmit = async (formData: TForm) => {
|
||||||
try {
|
const maxSharedSecretLifetimeSeconds =
|
||||||
const maxSharedSecretLifetimeSeconds =
|
ms(`${formData.maxLifetimeValue}${formData.maxLifetimeUnit}`) / 1000;
|
||||||
ms(`${formData.maxLifetimeValue}${formData.maxLifetimeUnit}`) / 1000;
|
|
||||||
|
|
||||||
await mutateAsync({
|
await mutateAsync({
|
||||||
orgId: currentOrg.id,
|
orgId: currentOrg.id,
|
||||||
maxSharedSecretViewLimit: formData.shouldLimitView ? Number(formData.maxViewLimit) : null,
|
maxSharedSecretViewLimit: formData.shouldLimitView ? Number(formData.maxViewLimit) : null,
|
||||||
maxSharedSecretLifetime: maxSharedSecretLifetimeSeconds
|
maxSharedSecretLifetime: maxSharedSecretLifetimeSeconds
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully updated secret share limits",
|
text: "Successfully updated secret share limits",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
reset(formData);
|
reset(formData);
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to update secret share limits",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Units for the dropdown with readable labels
|
// Units for the dropdown with readable labels
|
||||||
|
|||||||
+9
-17
@@ -9,25 +9,17 @@ export const SecretSharingAllowShareToAnyone = () => {
|
|||||||
const { mutateAsync } = useUpdateOrg();
|
const { mutateAsync } = useUpdateOrg();
|
||||||
|
|
||||||
const handleSecretSharingToggle = async (value: boolean) => {
|
const handleSecretSharingToggle = async (value: boolean) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
|
|
||||||
await mutateAsync({
|
await mutateAsync({
|
||||||
orgId: currentOrg.id,
|
orgId: currentOrg.id,
|
||||||
allowSecretSharingOutsideOrganization: value
|
allowSecretSharingOutsideOrganization: value
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully ${value ? "enabled" : "disabled"} secret sharing to members outside of this organization`,
|
text: `Successfully ${value ? "enabled" : "disabled"} secret sharing to members outside of this organization`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: (err as { response: { data: { message: string } } }).response.data.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+8
-16
@@ -20,23 +20,15 @@ export const ShareSecretTab = () => {
|
|||||||
const deleteSecretShare = useDeleteSharedSecret();
|
const deleteSecretShare = useDeleteSharedSecret();
|
||||||
|
|
||||||
const onDeleteApproved = async () => {
|
const onDeleteApproved = async () => {
|
||||||
try {
|
deleteSecretShare.mutateAsync({
|
||||||
deleteSecretShare.mutateAsync({
|
sharedSecretId: (popUp?.deleteSharedSecretConfirmation?.data as DeleteModalData)?.id
|
||||||
sharedSecretId: (popUp?.deleteSharedSecretConfirmation?.data as DeleteModalData)?.id
|
});
|
||||||
});
|
createNotification({
|
||||||
createNotification({
|
text: "Successfully deleted shared secret",
|
||||||
text: "Successfully deleted shared secret",
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
|
|
||||||
handlePopUpClose("deleteSharedSecretConfirmation");
|
handlePopUpClose("deleteSharedSecretConfirmation");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete shared secret",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+15
-33
@@ -28,21 +28,12 @@ const CreateForm = ({ provider, onComplete }: CreateFormProps) => {
|
|||||||
const onSubmit = async (
|
const onSubmit = async (
|
||||||
formData: DiscriminativePick<TAuditLogStream, "provider" | "credentials">
|
formData: DiscriminativePick<TAuditLogStream, "provider" | "credentials">
|
||||||
) => {
|
) => {
|
||||||
try {
|
const logStream = await createAuditLogStream.mutateAsync(formData);
|
||||||
const logStream = await createAuditLogStream.mutateAsync(formData);
|
createNotification({
|
||||||
createNotification({
|
text: `Successfully created ${providerName} Log Stream`,
|
||||||
text: `Successfully created ${providerName} Log Stream`,
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
onComplete(logStream);
|
||||||
onComplete(logStream);
|
|
||||||
} catch (err: any) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
title: `Failed to create ${providerName} Log Stream`,
|
|
||||||
text: err.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (provider) {
|
switch (provider) {
|
||||||
@@ -68,24 +59,15 @@ const UpdateForm = ({ auditLogStream, onComplete }: UpdateFormProps) => {
|
|||||||
const onSubmit = async (
|
const onSubmit = async (
|
||||||
formData: DiscriminativePick<TAuditLogStream, "provider" | "credentials">
|
formData: DiscriminativePick<TAuditLogStream, "provider" | "credentials">
|
||||||
) => {
|
) => {
|
||||||
try {
|
const connection = await updateAuditLogStream.mutateAsync({
|
||||||
const connection = await updateAuditLogStream.mutateAsync({
|
auditLogStreamId: auditLogStream.id,
|
||||||
auditLogStreamId: auditLogStream.id,
|
...formData
|
||||||
...formData
|
});
|
||||||
});
|
createNotification({
|
||||||
createNotification({
|
text: `Successfully updated ${providerName} Log Stream`,
|
||||||
text: `Successfully updated ${providerName} Log Stream`,
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
onComplete(connection);
|
||||||
onComplete(connection);
|
|
||||||
} catch (err: any) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
title: `Failed to update ${providerName} Log Stream`,
|
|
||||||
text: err.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (auditLogStream.provider) {
|
switch (auditLogStream.provider) {
|
||||||
|
|||||||
+9
-18
@@ -20,26 +20,17 @@ export const DeleteAuditLogStreamModal = ({ isOpen, onOpenChange, auditLogStream
|
|||||||
const providerDetails = AUDIT_LOG_STREAM_PROVIDER_MAP[provider];
|
const providerDetails = AUDIT_LOG_STREAM_PROVIDER_MAP[provider];
|
||||||
|
|
||||||
const handleDelete = async () => {
|
const handleDelete = async () => {
|
||||||
try {
|
await deleteAuditLogStream.mutateAsync({
|
||||||
await deleteAuditLogStream.mutateAsync({
|
auditLogStreamId,
|
||||||
auditLogStreamId,
|
provider
|
||||||
provider
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully deleted ${providerDetails.name} stream`,
|
text: `Successfully deleted ${providerDetails.name} stream`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to delete ${providerDetails.name} stream`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+7
-15
@@ -54,21 +54,13 @@ export const VaultConnectionSection = () => {
|
|||||||
const handleDeleteConfirm = async () => {
|
const handleDeleteConfirm = async () => {
|
||||||
if (!configToDelete) return;
|
if (!configToDelete) return;
|
||||||
|
|
||||||
try {
|
await deleteConfig({ id: configToDelete.id });
|
||||||
await deleteConfig({ id: configToDelete.id });
|
createNotification({
|
||||||
createNotification({
|
type: "success",
|
||||||
type: "success",
|
text: "Namespace configuration deleted successfully"
|
||||||
text: "Namespace configuration deleted successfully"
|
});
|
||||||
});
|
setIsDeleteModalOpen(false);
|
||||||
setIsDeleteModalOpen(false);
|
setConfigToDelete(null);
|
||||||
setConfigToDelete(null);
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to delete namespace config:", error);
|
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
text: "Failed to delete namespace configuration"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getConnectionName = (connectionId: string | null) => {
|
const getConnectionName = (connectionId: string | null) => {
|
||||||
|
|||||||
+19
-27
@@ -74,36 +74,28 @@ export const VaultNamespaceConfigModal = ({ isOpen, onOpenChange, editConfig }:
|
|||||||
}, [isOpen, editConfig, reset]);
|
}, [isOpen, editConfig, reset]);
|
||||||
|
|
||||||
const onFormSubmit = async (data: FormData) => {
|
const onFormSubmit = async (data: FormData) => {
|
||||||
try {
|
if (isEdit && editConfig) {
|
||||||
if (isEdit && editConfig) {
|
await updateConfig({
|
||||||
await updateConfig({
|
id: editConfig.id,
|
||||||
id: editConfig.id,
|
namespace: data.namespace,
|
||||||
namespace: data.namespace,
|
connectionId: data.connectionId
|
||||||
connectionId: data.connectionId
|
});
|
||||||
});
|
|
||||||
createNotification({
|
|
||||||
type: "success",
|
|
||||||
text: "Namespace configuration updated successfully"
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await createConfig({
|
|
||||||
namespace: data.namespace,
|
|
||||||
connectionId: data.connectionId
|
|
||||||
});
|
|
||||||
createNotification({
|
|
||||||
type: "success",
|
|
||||||
text: "Namespace configuration created successfully"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
reset();
|
|
||||||
onOpenChange(false);
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to save namespace config:", error);
|
|
||||||
createNotification({
|
createNotification({
|
||||||
type: "error",
|
type: "success",
|
||||||
text: `Failed to ${isEdit ? "update" : "create"} namespace configuration`
|
text: "Namespace configuration updated successfully"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await createConfig({
|
||||||
|
namespace: data.namespace,
|
||||||
|
connectionId: data.connectionId
|
||||||
|
});
|
||||||
|
createNotification({
|
||||||
|
type: "success",
|
||||||
|
text: "Namespace configuration created successfully"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
reset();
|
||||||
|
onOpenChange(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
|
|||||||
+10
-18
@@ -19,27 +19,19 @@ export const OrgDeleteSection = () => {
|
|||||||
const { mutateAsync, isPending } = useDeleteOrgById();
|
const { mutateAsync, isPending } = useDeleteOrgById();
|
||||||
|
|
||||||
const handleDeleteOrgSubmit = async () => {
|
const handleDeleteOrgSubmit = async () => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
|
|
||||||
await mutateAsync({
|
await mutateAsync({
|
||||||
organizationId: currentOrg?.id
|
organizationId: currentOrg?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted organization",
|
text: "Successfully deleted organization",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
clearSession();
|
clearSession();
|
||||||
navigate({ to: "/login" });
|
navigate({ to: "/login" });
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete organization",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+6
-10
@@ -51,18 +51,14 @@ export const OrgEncryptionTab = withPermission(
|
|||||||
kmsId: string;
|
kmsId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
await removeExternalKms(kmsId);
|
||||||
await removeExternalKms(kmsId);
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted external KMS",
|
text: "Successfully deleted external KMS",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpToggle("removeExternalKms", false);
|
handlePopUpToggle("removeExternalKms", false);
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+13
-21
@@ -35,31 +35,23 @@ export const AddOrgIncidentContactModal = ({
|
|||||||
const { mutateAsync, isPending } = useAddIncidentContact();
|
const { mutateAsync, isPending } = useAddIncidentContact();
|
||||||
|
|
||||||
const onFormSubmit = async ({ email }: TAddContactForm) => {
|
const onFormSubmit = async ({ email }: TAddContactForm) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
|
|
||||||
await mutateAsync({
|
await mutateAsync({
|
||||||
orgId: currentOrg.id,
|
orgId: currentOrg.id,
|
||||||
email
|
email
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully added incident contact",
|
text: "Successfully added incident contact",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (serverDetails?.emailConfigured) {
|
if (serverDetails?.emailConfigured) {
|
||||||
handlePopUpClose("addContact");
|
handlePopUpClose("addContact");
|
||||||
}
|
|
||||||
|
|
||||||
reset();
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to add incident contact",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+11
-19
@@ -33,28 +33,20 @@ export const OrgIncidentContactsTable = () => {
|
|||||||
const { mutateAsync } = useDeleteIncidentContact();
|
const { mutateAsync } = useDeleteIncidentContact();
|
||||||
|
|
||||||
const onRemoveIncidentContact = async () => {
|
const onRemoveIncidentContact = async () => {
|
||||||
try {
|
const incidentContactId = (popUp?.removeContact?.data as { id: string })?.id;
|
||||||
const incidentContactId = (popUp?.removeContact?.data as { id: string })?.id;
|
|
||||||
|
|
||||||
if (!currentOrg?.id) return;
|
if (!currentOrg?.id) return;
|
||||||
await mutateAsync({
|
await mutateAsync({
|
||||||
orgId: currentOrg.id,
|
orgId: currentOrg.id,
|
||||||
incidentContactId
|
incidentContactId
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully removed incident contact",
|
text: "Successfully removed incident contact",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("removeContact");
|
handlePopUpClose("removeContact");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to remove incident contact",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const filteredContacts = contacts
|
const filteredContacts = contacts
|
||||||
|
|||||||
+11
-19
@@ -56,27 +56,19 @@ export const OrgNameChangeSection = (): JSX.Element => {
|
|||||||
}, [roles]);
|
}, [roles]);
|
||||||
|
|
||||||
const onFormSubmit = async ({ name, slug, defaultMembershipRole }: FormData) => {
|
const onFormSubmit = async ({ name, slug, defaultMembershipRole }: FormData) => {
|
||||||
try {
|
if (!currentOrg?.id || !roles?.length) return;
|
||||||
if (!currentOrg?.id || !roles?.length) return;
|
|
||||||
|
|
||||||
await mutateAsync({
|
await mutateAsync({
|
||||||
orgId: currentOrg?.id,
|
orgId: currentOrg?.id,
|
||||||
name,
|
name,
|
||||||
slug,
|
slug,
|
||||||
defaultMembershipRoleSlug: defaultMembershipRole
|
defaultMembershipRoleSlug: defaultMembershipRole
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully updated organization details",
|
text: "Successfully updated organization details",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to update organization details",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isFormInitialized) {
|
if (!isFormInitialized) {
|
||||||
|
|||||||
+11
-19
@@ -39,26 +39,18 @@ export const SubOrgNameChangeSection = (): JSX.Element => {
|
|||||||
const { mutateAsync, isPending } = useUpdateSubOrganization();
|
const { mutateAsync, isPending } = useUpdateSubOrganization();
|
||||||
|
|
||||||
const onFormSubmit = async ({ name }: FormData) => {
|
const onFormSubmit = async ({ name }: FormData) => {
|
||||||
try {
|
await mutateAsync({
|
||||||
await mutateAsync({
|
name,
|
||||||
name,
|
subOrgId: currentOrg.id
|
||||||
subOrgId: currentOrg.id
|
});
|
||||||
});
|
|
||||||
|
|
||||||
navigate({ to: "/organization/settings", search: { subOrganization: name } });
|
navigate({ to: "/organization/settings", search: { subOrganization: name } });
|
||||||
queryClient.invalidateQueries();
|
queryClient.invalidateQueries();
|
||||||
await router.invalidate({ sync: true });
|
await router.invalidate({ sync: true });
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully updated sub-organization details",
|
text: "Successfully updated sub-organization details",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to update sub-organization details",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+4
-16
@@ -1,7 +1,5 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import axios from "axios";
|
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
|
||||||
import { Switch } from "@app/components/v2";
|
import { Switch } from "@app/components/v2";
|
||||||
import { useOrganization } from "@app/context";
|
import { useOrganization } from "@app/context";
|
||||||
import { useUpdateOrg } from "@app/hooks/api";
|
import { useUpdateOrg } from "@app/hooks/api";
|
||||||
@@ -60,20 +58,10 @@ export const OrgProductSelectSection = () => {
|
|||||||
[key]: { ...products[key], enabled: value }
|
[key]: { ...products[key], enabled: value }
|
||||||
}));
|
}));
|
||||||
|
|
||||||
try {
|
await mutateAsync({
|
||||||
await mutateAsync({
|
orgId: currentOrg.id,
|
||||||
orgId: currentOrg.id,
|
[key]: value
|
||||||
[key]: value
|
});
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
if (axios.isAxiosError(e)) {
|
|
||||||
const { message = "Something went wrong" } = e.response?.data as { message: string };
|
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
text: message
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
};
|
};
|
||||||
|
|||||||
-6
@@ -30,12 +30,6 @@ export const OrgProductSettingsTab = () => {
|
|||||||
text: `Successfully ${state ? "enabled" : "disabled"} blocking duplicate secret sync destinations for this organization`,
|
text: `Successfully ${state ? "enabled" : "disabled"} blocking duplicate secret sync destinations for this organization`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to update blocking duplicate secret sync destinations setting for this organization",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-13
@@ -75,19 +75,11 @@ export const ExternalGroupOrgRoleMappings = () => {
|
|||||||
const mappingField = useFieldArray({ control, name: "mappings" });
|
const mappingField = useFieldArray({ control, name: "mappings" });
|
||||||
|
|
||||||
const handleUpdateMappings = async (form: TForm) => {
|
const handleUpdateMappings = async (form: TForm) => {
|
||||||
try {
|
await updateMappings.mutateAsync(form);
|
||||||
await updateMappings.mutateAsync(form);
|
createNotification({
|
||||||
createNotification({
|
text: "Group organization role mappings updated.",
|
||||||
text: "Group organization role mappings updated.",
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to update group organization role mappings.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const disableScimEdit = permission.cannot(OrgPermissionActions.Edit, OrgPermissionSubjects.Scim);
|
const disableScimEdit = permission.cannot(OrgPermissionActions.Edit, OrgPermissionSubjects.Scim);
|
||||||
|
|||||||
@@ -122,53 +122,45 @@ export const LDAPModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
|
|||||||
caCert,
|
caCert,
|
||||||
shouldCloseModal = true
|
shouldCloseModal = true
|
||||||
}: TLDAPFormData & { shouldCloseModal?: boolean }) => {
|
}: TLDAPFormData & { shouldCloseModal?: boolean }) => {
|
||||||
try {
|
if (!currentOrg) return;
|
||||||
if (!currentOrg) return;
|
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
await createMutateAsync({
|
await createMutateAsync({
|
||||||
organizationId: currentOrg.id,
|
organizationId: currentOrg.id,
|
||||||
isActive: false,
|
isActive: false,
|
||||||
url,
|
url,
|
||||||
bindDN,
|
bindDN,
|
||||||
bindPass,
|
bindPass,
|
||||||
searchBase,
|
searchBase,
|
||||||
searchFilter,
|
searchFilter,
|
||||||
uniqueUserAttribute,
|
uniqueUserAttribute,
|
||||||
groupSearchBase,
|
groupSearchBase,
|
||||||
groupSearchFilter,
|
groupSearchFilter,
|
||||||
caCert
|
caCert
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await updateMutateAsync({
|
|
||||||
organizationId: currentOrg.id,
|
|
||||||
url,
|
|
||||||
bindDN,
|
|
||||||
bindPass,
|
|
||||||
searchBase,
|
|
||||||
searchFilter,
|
|
||||||
uniqueUserAttribute,
|
|
||||||
groupSearchBase,
|
|
||||||
groupSearchFilter,
|
|
||||||
caCert
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldCloseModal) {
|
|
||||||
handlePopUpClose("addLDAP");
|
|
||||||
}
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${!data ? "added" : "updated"} LDAP configuration`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} else {
|
||||||
console.error(err);
|
await updateMutateAsync({
|
||||||
createNotification({
|
organizationId: currentOrg.id,
|
||||||
text: `Failed to ${!data ? "add" : "update"} LDAP configuration`,
|
url,
|
||||||
type: "error"
|
bindDN,
|
||||||
|
bindPass,
|
||||||
|
searchBase,
|
||||||
|
searchFilter,
|
||||||
|
uniqueUserAttribute,
|
||||||
|
groupSearchBase,
|
||||||
|
groupSearchFilter,
|
||||||
|
caCert
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shouldCloseModal) {
|
||||||
|
handlePopUpClose("addLDAP");
|
||||||
|
}
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${!data ? "added" : "updated"} LDAP configuration`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTestLDAPConnection = async () => {
|
const handleTestLDAPConnection = async () => {
|
||||||
|
|||||||
@@ -122,31 +122,24 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
|
|||||||
if (!currentOrg) {
|
if (!currentOrg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
await updateMutateAsync({
|
||||||
await updateMutateAsync({
|
issuer: "",
|
||||||
issuer: "",
|
discoveryURL: "",
|
||||||
discoveryURL: "",
|
authorizationEndpoint: "",
|
||||||
authorizationEndpoint: "",
|
allowedEmailDomains: "",
|
||||||
allowedEmailDomains: "",
|
jwksUri: "",
|
||||||
jwksUri: "",
|
tokenEndpoint: "",
|
||||||
tokenEndpoint: "",
|
userinfoEndpoint: "",
|
||||||
userinfoEndpoint: "",
|
clientId: "",
|
||||||
clientId: "",
|
clientSecret: "",
|
||||||
clientSecret: "",
|
isActive: false,
|
||||||
isActive: false,
|
organizationId: currentOrg.id
|
||||||
organizationId: currentOrg.id
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted OIDC configuration.",
|
text: "Successfully deleted OIDC configuration.",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed deleting OIDC configuration.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -178,58 +171,50 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
|
|||||||
clientSecret,
|
clientSecret,
|
||||||
jwtSignatureAlgorithm
|
jwtSignatureAlgorithm
|
||||||
}: OIDCFormData) => {
|
}: OIDCFormData) => {
|
||||||
try {
|
if (!currentOrg) {
|
||||||
if (!currentOrg) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
await createMutateAsync({
|
await createMutateAsync({
|
||||||
issuer,
|
issuer,
|
||||||
configurationType,
|
configurationType,
|
||||||
discoveryURL,
|
discoveryURL,
|
||||||
authorizationEndpoint,
|
authorizationEndpoint,
|
||||||
allowedEmailDomains,
|
allowedEmailDomains,
|
||||||
jwksUri,
|
jwksUri,
|
||||||
tokenEndpoint,
|
tokenEndpoint,
|
||||||
userinfoEndpoint,
|
userinfoEndpoint,
|
||||||
clientId,
|
clientId,
|
||||||
clientSecret,
|
clientSecret,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
organizationId: currentOrg.id,
|
organizationId: currentOrg.id,
|
||||||
jwtSignatureAlgorithm
|
jwtSignatureAlgorithm
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await updateMutateAsync({
|
|
||||||
issuer,
|
|
||||||
configurationType,
|
|
||||||
discoveryURL,
|
|
||||||
authorizationEndpoint,
|
|
||||||
allowedEmailDomains,
|
|
||||||
jwksUri,
|
|
||||||
tokenEndpoint,
|
|
||||||
userinfoEndpoint,
|
|
||||||
clientId,
|
|
||||||
clientSecret,
|
|
||||||
isActive: true,
|
|
||||||
organizationId: currentOrg.id,
|
|
||||||
jwtSignatureAlgorithm
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpClose("addOIDC");
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${!data ? "added" : "updated"} OIDC SSO configuration`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} else {
|
||||||
console.error(err);
|
await updateMutateAsync({
|
||||||
createNotification({
|
issuer,
|
||||||
text: `Failed to ${!data ? "add" : "update"} OIDC SSO configuration`,
|
configurationType,
|
||||||
type: "error"
|
discoveryURL,
|
||||||
|
authorizationEndpoint,
|
||||||
|
allowedEmailDomains,
|
||||||
|
jwksUri,
|
||||||
|
tokenEndpoint,
|
||||||
|
userinfoEndpoint,
|
||||||
|
clientId,
|
||||||
|
clientSecret,
|
||||||
|
isActive: true,
|
||||||
|
organizationId: currentOrg.id,
|
||||||
|
jwtSignatureAlgorithm
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpClose("addOIDC");
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${!data ? "added" : "updated"} OIDC SSO configuration`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -108,64 +108,49 @@ export const SSOModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDelet
|
|||||||
if (!currentOrg) {
|
if (!currentOrg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
await updateMutateAsync({
|
||||||
await updateMutateAsync({
|
organizationId: currentOrg.id,
|
||||||
organizationId: currentOrg.id,
|
isActive: false,
|
||||||
isActive: false,
|
entryPoint: "",
|
||||||
entryPoint: "",
|
issuer: "",
|
||||||
issuer: "",
|
cert: ""
|
||||||
cert: ""
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted SAML SSO configuration.",
|
text: "Successfully deleted SAML SSO configuration.",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed deleting SAML SSO configuration.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSSOModalSubmit = async ({ authProvider, entryPoint, issuer, cert }: AddSSOFormData) => {
|
const onSSOModalSubmit = async ({ authProvider, entryPoint, issuer, cert }: AddSSOFormData) => {
|
||||||
try {
|
if (!currentOrg) return;
|
||||||
if (!currentOrg) return;
|
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
await createMutateAsync({
|
await createMutateAsync({
|
||||||
organizationId: currentOrg.id,
|
organizationId: currentOrg.id,
|
||||||
authProvider,
|
authProvider,
|
||||||
isActive: false,
|
isActive: false,
|
||||||
entryPoint,
|
entryPoint,
|
||||||
issuer,
|
issuer,
|
||||||
cert
|
cert
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await updateMutateAsync({
|
|
||||||
organizationId: currentOrg.id,
|
|
||||||
authProvider,
|
|
||||||
isActive: false,
|
|
||||||
entryPoint,
|
|
||||||
issuer,
|
|
||||||
cert
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpClose("addSSO");
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${!data ? "added" : "updated"} SAML SSO configuration`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} else {
|
||||||
console.error(err);
|
await updateMutateAsync({
|
||||||
createNotification({
|
organizationId: currentOrg.id,
|
||||||
text: `Failed to ${!data ? "add" : "update"} SAML SSO configuration`,
|
authProvider,
|
||||||
type: "error"
|
isActive: false,
|
||||||
|
entryPoint,
|
||||||
|
issuer,
|
||||||
|
cert
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpClose("addSSO");
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${!data ? "added" : "updated"} SAML SSO configuration`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderLabels = (authProvider: string) => {
|
const renderLabels = (authProvider: string) => {
|
||||||
|
|||||||
+8
-12
@@ -253,18 +253,14 @@ const GroupRolesForm = ({ projectRoles, roles, groupId, onClose }: FormProps) =>
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
await updateGroupWorkspaceRole.mutateAsync({
|
||||||
await updateGroupWorkspaceRole.mutateAsync({
|
projectId: currentProject?.id || "",
|
||||||
projectId: currentProject?.id || "",
|
groupId,
|
||||||
groupId,
|
roles: selectedRoles
|
||||||
roles: selectedRoles
|
});
|
||||||
});
|
createNotification({ text: "Successfully updated group role", type: "success" });
|
||||||
createNotification({ text: "Successfully updated group role", type: "success" });
|
onClose();
|
||||||
onClose();
|
setSearchRoles("");
|
||||||
setSearchRoles("");
|
|
||||||
} catch {
|
|
||||||
createNotification({ text: "Failed to update group role", type: "error" });
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+6
-11
@@ -77,17 +77,12 @@ export const ProjectRoleList = () => {
|
|||||||
|
|
||||||
const handleRoleDelete = async () => {
|
const handleRoleDelete = async () => {
|
||||||
const { id } = popUp?.deleteRole?.data as TProjectRole;
|
const { id } = popUp?.deleteRole?.data as TProjectRole;
|
||||||
try {
|
await deleteRole({
|
||||||
await deleteRole({
|
projectId,
|
||||||
projectId,
|
id
|
||||||
id
|
});
|
||||||
});
|
createNotification({ type: "success", text: "Successfully removed the role" });
|
||||||
createNotification({ type: "success", text: "Successfully removed the role" });
|
handlePopUpClose("deleteRole");
|
||||||
handlePopUpClose("deleteRole");
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
createNotification({ type: "error", text: "Failed to delete role" });
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|||||||
+21
-26
@@ -131,33 +131,28 @@ export const IdentityProjectAdditionalPrivilegeModifySection = ({
|
|||||||
temporaryAccessStartTime: el.temporaryAccess.temporaryAccessStartTime
|
temporaryAccessStartTime: el.temporaryAccess.temporaryAccessStartTime
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
if (isCreate) {
|
||||||
if (isCreate) {
|
await createIdentityProjectAdditionalPrivilege({
|
||||||
await createIdentityProjectAdditionalPrivilege({
|
permissions: formRolePermission2API(el.permissions),
|
||||||
permissions: formRolePermission2API(el.permissions),
|
identityId,
|
||||||
identityId,
|
projectId,
|
||||||
projectId,
|
slug: el.slug || undefined,
|
||||||
slug: el.slug || undefined,
|
type: accessType
|
||||||
type: accessType
|
});
|
||||||
});
|
createNotification({ type: "success", text: "Successfully created privilege" });
|
||||||
createNotification({ type: "success", text: "Successfully created privilege" });
|
} else {
|
||||||
} else {
|
if (!projectId || !privilegeDetails?.id) return;
|
||||||
if (!projectId || !privilegeDetails?.id) return;
|
await updateIdentityProjectAdditionalPrivilege({
|
||||||
await updateIdentityProjectAdditionalPrivilege({
|
privilegeId: privilegeDetails.id,
|
||||||
privilegeId: privilegeDetails.id,
|
permissions: formRolePermission2API(el.permissions),
|
||||||
permissions: formRolePermission2API(el.permissions),
|
projectId,
|
||||||
projectId,
|
identityId,
|
||||||
identityId,
|
slug: el.slug || undefined,
|
||||||
slug: el.slug || undefined,
|
type: accessType
|
||||||
type: accessType
|
});
|
||||||
});
|
createNotification({ type: "success", text: "Successfully updated privilege" });
|
||||||
createNotification({ type: "success", text: "Successfully updated privilege" });
|
|
||||||
}
|
|
||||||
onGoBack();
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
createNotification({ type: "error", text: "Failed to update privilege" });
|
|
||||||
}
|
}
|
||||||
|
onGoBack();
|
||||||
};
|
};
|
||||||
|
|
||||||
const privilegeTemporaryAccess = form.watch("temporaryAccess");
|
const privilegeTemporaryAccess = form.watch("temporaryAccess");
|
||||||
|
|||||||
+7
-12
@@ -57,18 +57,13 @@ export const IdentityProjectAdditionalPrivilegeSection = ({ identityMembershipDe
|
|||||||
|
|
||||||
const handlePrivilegeDelete = async () => {
|
const handlePrivilegeDelete = async () => {
|
||||||
const { id } = popUp?.deletePrivilege?.data as { id: string };
|
const { id } = popUp?.deletePrivilege?.data as { id: string };
|
||||||
try {
|
await deletePrivilege({
|
||||||
await deletePrivilege({
|
privilegeId: id,
|
||||||
privilegeId: id,
|
projectId,
|
||||||
projectId,
|
identityId
|
||||||
identityId
|
});
|
||||||
});
|
createNotification({ type: "success", text: "Successfully removed the privilege" });
|
||||||
createNotification({ type: "success", text: "Successfully removed the privilege" });
|
handlePopUpClose("deletePrivilege");
|
||||||
handlePopUpClose("deletePrivilege");
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
createNotification({ type: "error", text: "Failed to delete privilege" });
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+31
-36
@@ -50,42 +50,37 @@ export const IdentityRoleDetailsSection = ({
|
|||||||
|
|
||||||
const handleRoleDelete = async () => {
|
const handleRoleDelete = async () => {
|
||||||
const { id } = popUp?.deleteRole?.data as TProjectRole;
|
const { id } = popUp?.deleteRole?.data as TProjectRole;
|
||||||
try {
|
const updatedRoles = identityMembershipDetails?.roles?.filter((el) => el.id !== id);
|
||||||
const updatedRoles = identityMembershipDetails?.roles?.filter((el) => el.id !== id);
|
await updateIdentityWorkspaceRole({
|
||||||
await updateIdentityWorkspaceRole({
|
projectId: currentProject?.id || "",
|
||||||
projectId: currentProject?.id || "",
|
identityId: identityMembershipDetails.identity.id,
|
||||||
identityId: identityMembershipDetails.identity.id,
|
roles: updatedRoles.map(
|
||||||
roles: updatedRoles.map(
|
({
|
||||||
({
|
role,
|
||||||
role,
|
customRoleSlug,
|
||||||
customRoleSlug,
|
isTemporary,
|
||||||
isTemporary,
|
temporaryMode,
|
||||||
temporaryMode,
|
temporaryRange,
|
||||||
temporaryRange,
|
temporaryAccessStartTime,
|
||||||
temporaryAccessStartTime,
|
temporaryAccessEndTime
|
||||||
temporaryAccessEndTime
|
}) => ({
|
||||||
}) => ({
|
role: role === "custom" ? customRoleSlug : role,
|
||||||
role: role === "custom" ? customRoleSlug : role,
|
...(isTemporary
|
||||||
...(isTemporary
|
? {
|
||||||
? {
|
isTemporary,
|
||||||
isTemporary,
|
temporaryMode,
|
||||||
temporaryMode,
|
temporaryRange,
|
||||||
temporaryRange,
|
temporaryAccessStartTime,
|
||||||
temporaryAccessStartTime,
|
temporaryAccessEndTime
|
||||||
temporaryAccessEndTime
|
}
|
||||||
}
|
: {
|
||||||
: {
|
isTemporary
|
||||||
isTemporary
|
})
|
||||||
})
|
})
|
||||||
})
|
)
|
||||||
)
|
});
|
||||||
});
|
createNotification({ type: "success", text: "Successfully removed role" });
|
||||||
createNotification({ type: "success", text: "Successfully removed role" });
|
handlePopUpClose("deleteRole");
|
||||||
handlePopUpClose("deleteRole");
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
createNotification({ type: "error", text: "Failed to delete role" });
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+6
-11
@@ -60,17 +60,12 @@ export const MemberProjectAdditionalPrivilegeSection = ({ membershipDetails }: P
|
|||||||
|
|
||||||
const handlePrivilegeDelete = async () => {
|
const handlePrivilegeDelete = async () => {
|
||||||
const { id } = popUp?.deletePrivilege?.data as { id: string };
|
const { id } = popUp?.deletePrivilege?.data as { id: string };
|
||||||
try {
|
await deletePrivilege({
|
||||||
await deletePrivilege({
|
privilegeId: id,
|
||||||
privilegeId: id,
|
projectMembershipId: membershipDetails.id
|
||||||
projectMembershipId: membershipDetails.id
|
});
|
||||||
});
|
createNotification({ type: "success", text: "Successfully removed the privilege" });
|
||||||
createNotification({ type: "success", text: "Successfully removed the privilege" });
|
handlePopUpClose("deletePrivilege");
|
||||||
handlePopUpClose("deletePrivilege");
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
createNotification({ type: "error", text: "Failed to delete privilege" });
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+19
-24
@@ -129,31 +129,26 @@ export const MembershipProjectAdditionalPrivilegeModifySection = ({
|
|||||||
temporaryAccessStartTime: el.temporaryAccess.temporaryAccessStartTime
|
temporaryAccessStartTime: el.temporaryAccess.temporaryAccessStartTime
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
if (isCreate) {
|
||||||
if (isCreate) {
|
await createUserProjectAdditionalPrivilege({
|
||||||
await createUserProjectAdditionalPrivilege({
|
permissions: formRolePermission2API(el.permissions),
|
||||||
permissions: formRolePermission2API(el.permissions),
|
projectMembershipId,
|
||||||
projectMembershipId,
|
slug: el.slug || undefined,
|
||||||
slug: el.slug || undefined,
|
type: accessType
|
||||||
type: accessType
|
});
|
||||||
});
|
createNotification({ type: "success", text: "Successfully created privilege" });
|
||||||
createNotification({ type: "success", text: "Successfully created privilege" });
|
} else {
|
||||||
} else {
|
if (!projectId || !privilegeDetails?.id) return;
|
||||||
if (!projectId || !privilegeDetails?.id) return;
|
await updateUserProjectAdditionalPrivilege({
|
||||||
await updateUserProjectAdditionalPrivilege({
|
privilegeId: privilegeDetails.id,
|
||||||
privilegeId: privilegeDetails.id,
|
permissions: formRolePermission2API(el.permissions),
|
||||||
permissions: formRolePermission2API(el.permissions),
|
projectMembershipId,
|
||||||
projectMembershipId,
|
slug: el.slug || undefined,
|
||||||
slug: el.slug || undefined,
|
type: accessType
|
||||||
type: accessType
|
});
|
||||||
});
|
createNotification({ type: "success", text: "Successfully updated privilege" });
|
||||||
createNotification({ type: "success", text: "Successfully updated privilege" });
|
|
||||||
}
|
|
||||||
onGoBack();
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
createNotification({ type: "error", text: "Failed to update privilege" });
|
|
||||||
}
|
}
|
||||||
|
onGoBack();
|
||||||
};
|
};
|
||||||
|
|
||||||
const privilegeTemporaryAccess = form.watch("temporaryAccess");
|
const privilegeTemporaryAccess = form.watch("temporaryAccess");
|
||||||
|
|||||||
+8
-13
@@ -122,19 +122,14 @@ export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
|
|||||||
const { mutateAsync: updateRole } = useUpdateProjectRole();
|
const { mutateAsync: updateRole } = useUpdateProjectRole();
|
||||||
|
|
||||||
const onSubmit = async (el: TFormSchema) => {
|
const onSubmit = async (el: TFormSchema) => {
|
||||||
try {
|
if (!projectId || !role?.id) return;
|
||||||
if (!projectId || !role?.id) return;
|
await updateRole({
|
||||||
await updateRole({
|
id: role?.id as string,
|
||||||
id: role?.id as string,
|
projectId,
|
||||||
projectId,
|
...el,
|
||||||
...el,
|
permissions: formRolePermission2API(el.permissions)
|
||||||
permissions: formRolePermission2API(el.permissions)
|
});
|
||||||
});
|
createNotification({ type: "success", text: "Successfully updated role" });
|
||||||
createNotification({ type: "success", text: "Successfully updated role" });
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
createNotification({ type: "error", text: "Failed to update role" });
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const isCustomRole = !Object.values(ProjectMembershipRole).includes(
|
const isCustomRole = !Object.values(ProjectMembershipRole).includes(
|
||||||
|
|||||||
+2
-6
@@ -13,12 +13,8 @@ export const BackfillSecretReferenceSecretion = () => {
|
|||||||
|
|
||||||
const handleBackfill = async () => {
|
const handleBackfill = async () => {
|
||||||
if (backfillSecretReferences.isPending) return;
|
if (backfillSecretReferences.isPending) return;
|
||||||
try {
|
await backfillSecretReferences.mutateAsync({ projectId: currentProject.id || "" });
|
||||||
await backfillSecretReferences.mutateAsync({ projectId: currentProject.id || "" });
|
createNotification({ text: "Successfully re-indexed secret references", type: "success" });
|
||||||
createNotification({ text: "Successfully re-indexed secret references", type: "success" });
|
|
||||||
} catch {
|
|
||||||
createNotification({ text: "Failed to re-index secret references", type: "error" });
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const isAdmin = hasProjectRole(ProjectMembershipRole.Admin);
|
const isAdmin = hasProjectRole(ProjectMembershipRole.Admin);
|
||||||
|
|||||||
Reference in New Issue
Block a user