mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-02 22:25:44 +00:00
refactor: enhance notification handling and streamline async logic across various components
This commit is contained in:
+5
-13
@@ -72,20 +72,12 @@ export const OAuthCallbackPage = () => {
|
|||||||
if (!isReady) return;
|
if (!isReady) return;
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
await handleMicrosoftTeams();
|
||||||
await handleMicrosoftTeams();
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully created Microsoft Teams workflow integration",
|
text: "Successfully created Microsoft Teams workflow integration",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to create Microsoft Teams workflow integration",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})();
|
})();
|
||||||
}, [isReady]);
|
}, [isReady]);
|
||||||
|
|
||||||
|
|||||||
+26
-41
@@ -55,55 +55,40 @@ export const GithubOrgSyncConfigModal = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const onFormSubmit = async ({ githubOrgName, githubOrgAccessToken }: FormData) => {
|
const onFormSubmit = async ({ githubOrgName, githubOrgAccessToken }: FormData) => {
|
||||||
try {
|
if (isUpdate) {
|
||||||
if (isUpdate) {
|
await updateGithubSyncOrgConfig({
|
||||||
await updateGithubSyncOrgConfig({
|
githubOrgName,
|
||||||
githubOrgName,
|
githubOrgAccessToken
|
||||||
githubOrgAccessToken
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully updated GitHub Organization Sync",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await createGithubSyncOrgConfig({
|
|
||||||
githubOrgName,
|
|
||||||
githubOrgAccessToken,
|
|
||||||
isActive: false
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully created GitHub Organization Sync",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
handlePopUpToggle("githubOrgSyncConfig");
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Failed to setup GitHub Organization Sync",
|
text: "Successfully updated GitHub Organization Sync",
|
||||||
type: "error"
|
type: "success"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await createGithubSyncOrgConfig({
|
||||||
|
githubOrgName,
|
||||||
|
githubOrgAccessToken,
|
||||||
|
isActive: false
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully created GitHub Organization Sync",
|
||||||
|
type: "success"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
handlePopUpToggle("githubOrgSyncConfig");
|
||||||
};
|
};
|
||||||
|
|
||||||
const onDelete = async () => {
|
const onDelete = async () => {
|
||||||
try {
|
await deleteGithubSyncOrgConfig();
|
||||||
await deleteGithubSyncOrgConfig();
|
|
||||||
|
|
||||||
handlePopUpToggle("deleteGithubOrgSyncConfig", false);
|
handlePopUpToggle("deleteGithubOrgSyncConfig", false);
|
||||||
handlePopUpToggle("githubOrgSyncConfig", false);
|
handlePopUpToggle("githubOrgSyncConfig", false);
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted GitHub Organization Sync",
|
text: "Successfully deleted GitHub Organization Sync",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete GitHub Organization Sync",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+30
-53
@@ -35,64 +35,41 @@ export const OrgGithubSyncSection = () => {
|
|||||||
const data = !isPending && !githubOrgSyncConfig?.isError ? githubOrgSyncConfig?.data : undefined;
|
const data = !isPending && !githubOrgSyncConfig?.isError ? githubOrgSyncConfig?.data : undefined;
|
||||||
|
|
||||||
const handleBulkSync = async () => {
|
const handleBulkSync = async () => {
|
||||||
try {
|
const result = await syncAllTeamsMutation.mutateAsync();
|
||||||
const result = await syncAllTeamsMutation.mutateAsync();
|
let message = "Successfully synced teams";
|
||||||
let message = "Successfully synced teams";
|
|
||||||
|
|
||||||
const details = [];
|
const details = [];
|
||||||
if (result.createdTeams.length > 0) {
|
if (result.createdTeams.length > 0) {
|
||||||
details.push(
|
details.push(
|
||||||
`${result.createdTeams.length} new team${result.createdTeams.length === 1 ? "" : "s"} created`
|
`${result.createdTeams.length} new team${result.createdTeams.length === 1 ? "" : "s"} created`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (result.updatedTeams.length > 0) {
|
if (result.updatedTeams.length > 0) {
|
||||||
details.push(
|
details.push(
|
||||||
`${result.updatedTeams.length} team${result.updatedTeams.length === 1 ? "" : "s"} updated`
|
`${result.updatedTeams.length} team${result.updatedTeams.length === 1 ? "" : "s"} updated`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (result.removedMemberships > 0) {
|
if (result.removedMemberships > 0) {
|
||||||
details.push(
|
details.push(
|
||||||
`${result.removedMemberships} membership${result.removedMemberships === 1 ? "" : "s"} removed`
|
`${result.removedMemberships} membership${result.removedMemberships === 1 ? "" : "s"} removed`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (details.length > 0) {
|
if (details.length > 0) {
|
||||||
message += `. ${details.join(", ")}`;
|
message += `. ${details.join(", ")}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: message,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.errors && result.errors.length > 0) {
|
||||||
createNotification({
|
createNotification({
|
||||||
text: message,
|
text: `Sync completed with ${result.errors.length} warnings. Check the console for details.`,
|
||||||
type: "success"
|
type: "warning"
|
||||||
});
|
});
|
||||||
|
console.warn("Sync errors:", result.errors);
|
||||||
if (result.errors && result.errors.length > 0) {
|
|
||||||
createNotification({
|
|
||||||
text: `Sync completed with ${result.errors.length} warnings. Check the console for details.`,
|
|
||||||
type: "warning"
|
|
||||||
});
|
|
||||||
console.warn("Sync errors:", result.errors);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
const errorMessage =
|
|
||||||
(error as any)?.response?.data?.message || (error as Error)?.message || "Unknown error";
|
|
||||||
|
|
||||||
if (
|
|
||||||
errorMessage.includes("token") &&
|
|
||||||
(errorMessage.includes("required") ||
|
|
||||||
errorMessage.includes("invalid") ||
|
|
||||||
errorMessage.includes("expired") ||
|
|
||||||
errorMessage.includes("set a token first"))
|
|
||||||
) {
|
|
||||||
createNotification({
|
|
||||||
text: "Please set a GitHub access token in the configuration modal to continue with the sync",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to sync GitHub teams: ${errorMessage}`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+15
-22
@@ -36,30 +36,23 @@ export const OrgScimSection = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleEnableSCIMToggle = async (value: boolean) => {
|
const handleEnableSCIMToggle = async (value: boolean) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
if (!subscription?.scim) {
|
||||||
if (!subscription?.scim) {
|
handlePopUpOpen("upgradePlan", {
|
||||||
handlePopUpOpen("upgradePlan", {
|
isEnterpriseFeature: true
|
||||||
isEnterpriseFeature: true
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await mutateAsync({
|
|
||||||
orgId: currentOrg?.id,
|
|
||||||
scimEnabled: value
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${value ? "enabled" : "disabled"} SCIM provisioning`,
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
createNotification({
|
|
||||||
text: (err as { response: { data: { message: string } } }).response.data.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await mutateAsync({
|
||||||
|
orgId: currentOrg?.id,
|
||||||
|
scimEnabled: value
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${value ? "enabled" : "disabled"} SCIM provisioning`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+21
-37
@@ -92,52 +92,36 @@ export const ScimTokenModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }: Pr
|
|||||||
}, [isScimTokenCopied, isScimUrlCopied]);
|
}, [isScimTokenCopied, isScimUrlCopied]);
|
||||||
|
|
||||||
const onFormSubmit = async ({ description, ttlDays }: FormData) => {
|
const onFormSubmit = async ({ description, ttlDays }: FormData) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
|
|
||||||
const { scimToken } = await createScimTokenMutateAsync({
|
const { scimToken } = await createScimTokenMutateAsync({
|
||||||
organizationId: currentOrg.id,
|
organizationId: currentOrg.id,
|
||||||
description,
|
description,
|
||||||
ttlDays: Number(ttlDays)
|
ttlDays: Number(ttlDays)
|
||||||
});
|
});
|
||||||
|
|
||||||
setToken(scimToken);
|
setToken(scimToken);
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully created SCIM token",
|
text: "Successfully created SCIM token",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to create SCIM token",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onDeleteScimTokenSubmit = async (scimTokenId: string) => {
|
const onDeleteScimTokenSubmit = async (scimTokenId: string) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
|
|
||||||
await deleteScimTokenMutateAsync({
|
await deleteScimTokenMutateAsync({
|
||||||
organizationId: currentOrg.id,
|
organizationId: currentOrg.id,
|
||||||
scimTokenId
|
scimTokenId
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpToggle("deleteScimToken", false);
|
handlePopUpToggle("deleteScimToken", false);
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted SCIM token",
|
text: "Successfully deleted SCIM token",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete SCIM token",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const hasToken = Boolean(token);
|
const hasToken = Boolean(token);
|
||||||
|
|||||||
+28
-44
@@ -20,55 +20,39 @@ export const OrgGenericAuthSection = () => {
|
|||||||
const { mutateAsync } = useUpdateOrg();
|
const { mutateAsync } = useUpdateOrg();
|
||||||
|
|
||||||
const handleEnforceMfaToggle = async (value: boolean) => {
|
const handleEnforceMfaToggle = async (value: boolean) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
if (!subscription?.enforceMfa) {
|
||||||
if (!subscription?.enforceMfa) {
|
handlePopUpOpen("upgradePlan");
|
||||||
handlePopUpOpen("upgradePlan");
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await mutateAsync({
|
|
||||||
orgId: currentOrg?.id,
|
|
||||||
enforceMfa: value
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${value ? "enforced" : "un-enforced"} MFA`,
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: (err as { response: { data: { message: string } } }).response.data.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await mutateAsync({
|
||||||
|
orgId: currentOrg?.id,
|
||||||
|
enforceMfa: value
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${value ? "enforced" : "un-enforced"} MFA`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleUpdateSelectedMfa = async (selectedMfaMethod: MfaMethod) => {
|
const handleUpdateSelectedMfa = async (selectedMfaMethod: MfaMethod) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
if (!subscription?.enforceMfa) {
|
||||||
if (!subscription?.enforceMfa) {
|
handlePopUpOpen("upgradePlan");
|
||||||
handlePopUpOpen("upgradePlan");
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await mutateAsync({
|
|
||||||
orgId: currentOrg?.id,
|
|
||||||
selectedMfaMethod
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully updated selected MFA method",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: (err as { response: { data: { message: string } } }).response.data.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await mutateAsync({
|
||||||
|
orgId: currentOrg?.id,
|
||||||
|
selectedMfaMethod
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully updated selected MFA method",
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+9
-16
@@ -57,24 +57,17 @@ export const OrgUserAccessTokenLimitSection = () => {
|
|||||||
if (!currentOrg) return null;
|
if (!currentOrg) return null;
|
||||||
|
|
||||||
const handleUserTokenExpirationSubmit = async (formData: TForm) => {
|
const handleUserTokenExpirationSubmit = async (formData: TForm) => {
|
||||||
try {
|
const userTokenExpiration = formatDuration(formData.expirationValue, formData.expirationUnit);
|
||||||
const userTokenExpiration = formatDuration(formData.expirationValue, formData.expirationUnit);
|
|
||||||
|
|
||||||
await updateUserTokenExpiration({
|
await updateUserTokenExpiration({
|
||||||
userTokenExpiration,
|
userTokenExpiration,
|
||||||
orgId: currentOrg.id
|
orgId: currentOrg.id
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully updated user token expiration",
|
text: "Successfully updated user token expiration",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed updating user token expiration",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Units for the dropdown with readable labels
|
// Units for the dropdown with readable labels
|
||||||
|
|||||||
+20
-36
@@ -79,28 +79,20 @@ export const LDAPGroupMapModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }:
|
|||||||
});
|
});
|
||||||
|
|
||||||
const onFormSubmit = async ({ groupSlug, ldapGroupCN }: TFormData) => {
|
const onFormSubmit = async ({ groupSlug, ldapGroupCN }: TFormData) => {
|
||||||
try {
|
if (!ldapConfig) return;
|
||||||
if (!ldapConfig) return;
|
|
||||||
|
|
||||||
await createLDAPGroupMapping({
|
await createLDAPGroupMapping({
|
||||||
ldapConfigId: ldapConfig.id,
|
ldapConfigId: ldapConfig.id,
|
||||||
groupSlug,
|
groupSlug,
|
||||||
ldapGroupCN
|
ldapGroupCN
|
||||||
});
|
});
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully added LDAP group mapping for ${ldapGroupCN}`,
|
text: `Successfully added LDAP group mapping for ${ldapGroupCN}`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to add LDAP group mapping for ${ldapGroupCN}`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onDeleteGroupMapSubmit = async ({
|
const onDeleteGroupMapSubmit = async ({
|
||||||
@@ -112,25 +104,17 @@ export const LDAPGroupMapModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }:
|
|||||||
ldapGroupMapId: string;
|
ldapGroupMapId: string;
|
||||||
ldapGroupCN: string;
|
ldapGroupCN: string;
|
||||||
}) => {
|
}) => {
|
||||||
try {
|
await deleteLDAPGroupMapping({
|
||||||
await deleteLDAPGroupMapping({
|
ldapConfigId,
|
||||||
ldapConfigId,
|
ldapGroupMapId
|
||||||
ldapGroupMapId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
handlePopUpToggle("deleteLdapGroupMap", false);
|
handlePopUpToggle("deleteLdapGroupMap", false);
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully deleted LDAP group mapping ${ldapGroupCN}`,
|
text: `Successfully deleted LDAP group mapping ${ldapGroupCN}`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to delete LDAP group mapping ${ldapGroupCN}`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -62,31 +62,24 @@ export const LDAPModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
|
|||||||
if (!currentOrg) {
|
if (!currentOrg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
await updateMutateAsync({
|
||||||
await updateMutateAsync({
|
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: ""
|
});
|
||||||
});
|
|
||||||
|
|
||||||
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"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const watchUrl = watch("url");
|
const watchUrl = watch("url");
|
||||||
@@ -164,33 +157,17 @@ export const LDAPModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleTestLDAPConnection = async () => {
|
const handleTestLDAPConnection = async () => {
|
||||||
try {
|
await testLDAPConnection({
|
||||||
const result = await testLDAPConnection({
|
url: watchUrl,
|
||||||
url: watchUrl,
|
bindDN: watchBindDN,
|
||||||
bindDN: watchBindDN,
|
bindPass: watchBindPass,
|
||||||
bindPass: watchBindPass,
|
caCert: watchCaCert ?? ""
|
||||||
caCert: watchCaCert ?? ""
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if (!result) {
|
createNotification({
|
||||||
createNotification({
|
text: "Successfully tested the LDAP connection: Bind operation was successful",
|
||||||
text: "Failed to test the LDAP connection: Bind operation was unsuccessful",
|
type: "success"
|
||||||
type: "error"
|
});
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully tested the LDAP connection: Bind operation was successful",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to test the LDAP connection",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+46
-54
@@ -45,69 +45,61 @@ export const OrgGeneralAuthSection = ({
|
|||||||
const logout = useLogoutUser();
|
const logout = useLogoutUser();
|
||||||
|
|
||||||
const handleEnforceOrgAuthToggle = async (value: boolean, type: EnforceAuthType) => {
|
const handleEnforceOrgAuthToggle = async (value: boolean, type: EnforceAuthType) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
|
|
||||||
if (type === EnforceAuthType.SAML) {
|
if (type === EnforceAuthType.SAML) {
|
||||||
if (!subscription?.samlSSO) {
|
if (!subscription?.samlSSO) {
|
||||||
handlePopUpOpen("upgradePlan");
|
handlePopUpOpen("upgradePlan");
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
await mutateAsync({
|
|
||||||
orgId: currentOrg?.id,
|
|
||||||
authEnforced: value
|
|
||||||
});
|
|
||||||
} else if (type === EnforceAuthType.GOOGLE) {
|
|
||||||
if (!subscription?.enforceGoogleSSO) {
|
|
||||||
handlePopUpOpen("upgradePlan");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await mutateAsync({
|
|
||||||
orgId: currentOrg?.id,
|
|
||||||
googleSsoAuthEnforced: value
|
|
||||||
});
|
|
||||||
} else if (type === EnforceAuthType.OIDC) {
|
|
||||||
if (!subscription?.oidcSSO) {
|
|
||||||
handlePopUpOpen("upgradePlan");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await mutateAsync({
|
|
||||||
orgId: currentOrg?.id,
|
|
||||||
authEnforced: value
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
createNotification({
|
|
||||||
text: `Invalid auth enforcement type ${type}`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createNotification({
|
await mutateAsync({
|
||||||
text: `Successfully ${value ? "enabled" : "disabled"} org-level auth`,
|
orgId: currentOrg?.id,
|
||||||
type: "success"
|
authEnforced: value
|
||||||
});
|
});
|
||||||
|
} else if (type === EnforceAuthType.GOOGLE) {
|
||||||
if (value) {
|
if (!subscription?.enforceGoogleSSO) {
|
||||||
await logout.mutateAsync();
|
handlePopUpOpen("upgradePlan");
|
||||||
|
return;
|
||||||
if (type === EnforceAuthType.SAML) {
|
|
||||||
window.open(`/api/v1/sso/redirect/saml2/organizations/${currentOrg.slug}`);
|
|
||||||
} else if (type === EnforceAuthType.GOOGLE) {
|
|
||||||
window.open(`/api/v1/sso/redirect/google?org_slug=${currentOrg.slug}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.close();
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
await mutateAsync({
|
||||||
|
orgId: currentOrg?.id,
|
||||||
|
googleSsoAuthEnforced: value
|
||||||
|
});
|
||||||
|
} else if (type === EnforceAuthType.OIDC) {
|
||||||
|
if (!subscription?.oidcSSO) {
|
||||||
|
handlePopUpOpen("upgradePlan");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await mutateAsync({
|
||||||
|
orgId: currentOrg?.id,
|
||||||
|
authEnforced: value
|
||||||
|
});
|
||||||
|
} else {
|
||||||
createNotification({
|
createNotification({
|
||||||
text: (err as { response: { data: { message: string } } }).response.data.message,
|
text: `Invalid auth enforcement type ${type}`,
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${value ? "enabled" : "disabled"} org-level auth`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
await logout.mutateAsync();
|
||||||
|
|
||||||
|
if (type === EnforceAuthType.SAML) {
|
||||||
|
window.open(`/api/v1/sso/redirect/saml2/organizations/${currentOrg.slug}`);
|
||||||
|
} else if (type === EnforceAuthType.GOOGLE) {
|
||||||
|
window.open(`/api/v1/sso/redirect/google?org_slug=${currentOrg.slug}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEnableBypassOrgAuthToggle = async (value: boolean) => {
|
const handleEnableBypassOrgAuthToggle = async (value: boolean) => {
|
||||||
|
|||||||
+15
-23
@@ -31,31 +31,23 @@ export const OrgLDAPSection = (): JSX.Element => {
|
|||||||
const { mutateAsync: createMutateAsync } = useCreateLDAPConfig();
|
const { mutateAsync: createMutateAsync } = useCreateLDAPConfig();
|
||||||
|
|
||||||
const handleLDAPToggle = async (value: boolean) => {
|
const handleLDAPToggle = async (value: boolean) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
if (!subscription?.ldap) {
|
||||||
if (!subscription?.ldap) {
|
handlePopUpOpen("upgradePlan", {
|
||||||
handlePopUpOpen("upgradePlan", {
|
isEnterpriseFeature: true
|
||||||
isEnterpriseFeature: true
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await mutateAsync({
|
|
||||||
organizationId: currentOrg?.id,
|
|
||||||
isActive: value
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${value ? "enabled" : "disabled"} LDAP`,
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to ${value ? "enable" : "disable"} LDAP`,
|
|
||||||
type: "error"
|
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await mutateAsync({
|
||||||
|
organizationId: currentOrg?.id,
|
||||||
|
isActive: value
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${value ? "enabled" : "disabled"} LDAP`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const addLDAPBtnClick = async () => {
|
const addLDAPBtnClick = async () => {
|
||||||
|
|||||||
+28
-36
@@ -30,49 +30,41 @@ export const OrgOIDCSection = (): JSX.Element => {
|
|||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const handleOIDCToggle = async (value: boolean) => {
|
const handleOIDCToggle = async (value: boolean) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
|
|
||||||
if (!subscription?.oidcSSO) {
|
if (!subscription?.oidcSSO) {
|
||||||
handlePopUpOpen("upgradePlan");
|
handlePopUpOpen("upgradePlan");
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
await mutateAsync({
|
|
||||||
organizationId: currentOrg?.id,
|
|
||||||
isActive: value
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${value ? "enabled" : "disabled"} OIDC SSO`,
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await mutateAsync({
|
||||||
|
organizationId: currentOrg?.id,
|
||||||
|
isActive: value
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${value ? "enabled" : "disabled"} OIDC SSO`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOIDCGroupManagement = async (value: boolean) => {
|
const handleOIDCGroupManagement = async (value: boolean) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
|
|
||||||
if (!subscription?.oidcSSO) {
|
if (!subscription?.oidcSSO) {
|
||||||
handlePopUpOpen("upgradePlan");
|
handlePopUpOpen("upgradePlan");
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
await mutateAsync({
|
|
||||||
organizationId: currentOrg?.id,
|
|
||||||
manageGroupMemberships: value
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${value ? "enabled" : "disabled"} OIDC group membership mapping`,
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await mutateAsync({
|
||||||
|
organizationId: currentOrg?.id,
|
||||||
|
manageGroupMemberships: value
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${value ? "enabled" : "disabled"} OIDC group membership mapping`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const addOidcButtonClick = async () => {
|
const addOidcButtonClick = async () => {
|
||||||
|
|||||||
+31
-48
@@ -34,63 +34,46 @@ export const OrgSSOSection = (): JSX.Element => {
|
|||||||
const { mutateAsync: createMutateAsync } = useCreateSSOConfig();
|
const { mutateAsync: createMutateAsync } = useCreateSSOConfig();
|
||||||
|
|
||||||
const handleSamlSSOToggle = async (value: boolean) => {
|
const handleSamlSSOToggle = async (value: boolean) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
|
|
||||||
if (!subscription?.samlSSO) {
|
if (!subscription?.samlSSO) {
|
||||||
handlePopUpOpen("upgradePlan", {
|
handlePopUpOpen("upgradePlan", {
|
||||||
description: "You can use SAML SSO if you switch to Infisical's Pro plan."
|
description: "You can use SAML SSO if you switch to Infisical's Pro plan."
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await mutateAsync({
|
|
||||||
organizationId: currentOrg?.id,
|
|
||||||
isActive: value
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${value ? "enabled" : "disabled"} SAML SSO`,
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to ${value ? "enable" : "disable"} SAML SSO`,
|
|
||||||
type: "error"
|
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await mutateAsync({
|
||||||
|
organizationId: currentOrg?.id,
|
||||||
|
isActive: value
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${value ? "enabled" : "disabled"} SAML SSO`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSamlGroupManagement = async (value: boolean) => {
|
const handleSamlGroupManagement = async (value: boolean) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
|
|
||||||
if (!subscription?.samlSSO || !subscription?.groups) {
|
if (!subscription?.samlSSO || !subscription?.groups) {
|
||||||
handlePopUpOpen("upgradePlan", {
|
handlePopUpOpen("upgradePlan", {
|
||||||
isEnterpriseFeature: true,
|
isEnterpriseFeature: true,
|
||||||
description:
|
description: "You can use SAML group mapping if you switch to Infisical's Enterprise plan."
|
||||||
"You can use SAML group mapping if you switch to Infisical's Enterprise plan."
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await mutateAsync({
|
|
||||||
organizationId: currentOrg?.id,
|
|
||||||
enableGroupSync: value
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${value ? "enabled" : "disabled"} SAML group membership mapping`,
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to ${value ? "enable" : "disable"} SAML group membership mapping`,
|
|
||||||
type: "error"
|
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await mutateAsync({
|
||||||
|
organizationId: currentOrg?.id,
|
||||||
|
enableGroupSync: value
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${value ? "enabled" : "disabled"} SAML group membership mapping`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const addSSOBtnClick = async () => {
|
const addSSOBtnClick = async () => {
|
||||||
|
|||||||
+8
-17
@@ -16,25 +16,16 @@ export const DeleteProjectTemplateModal = ({ isOpen, onOpenChange, template }: P
|
|||||||
const { id: templateId, name } = template;
|
const { id: templateId, name } = template;
|
||||||
|
|
||||||
const handleDeleteProjectTemplate = async () => {
|
const handleDeleteProjectTemplate = async () => {
|
||||||
try {
|
await deleteTemplate.mutateAsync({
|
||||||
await deleteTemplate.mutateAsync({
|
templateId
|
||||||
templateId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully removed project template",
|
text: "Successfully removed project template",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: "Failed remove project template",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+8
-16
@@ -31,22 +31,14 @@ export const EditProjectTemplate = ({ isInfisicalTemplate, projectTemplate, onBa
|
|||||||
const deleteProjectTemplate = useDeleteProjectTemplate();
|
const deleteProjectTemplate = useDeleteProjectTemplate();
|
||||||
|
|
||||||
const handleRemoveTemplate = async () => {
|
const handleRemoveTemplate = async () => {
|
||||||
try {
|
await deleteProjectTemplate.mutateAsync({
|
||||||
await deleteProjectTemplate.mutateAsync({
|
templateId
|
||||||
templateId
|
});
|
||||||
});
|
createNotification({
|
||||||
createNotification({
|
text: "Successfully removed project template",
|
||||||
text: "Successfully removed project template",
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
onBack();
|
||||||
onBack();
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to remove project template",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
handlePopUpClose("removeTemplate");
|
handlePopUpClose("removeTemplate");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+17
-25
@@ -57,31 +57,23 @@ export const ProjectTemplateEditRoleForm = ({
|
|||||||
const updateProjectTemplate = useUpdateProjectTemplate();
|
const updateProjectTemplate = useUpdateProjectTemplate();
|
||||||
|
|
||||||
const onSubmit = async (form: TFormSchema) => {
|
const onSubmit = async (form: TFormSchema) => {
|
||||||
try {
|
await updateProjectTemplate.mutateAsync({
|
||||||
await updateProjectTemplate.mutateAsync({
|
templateId: projectTemplate.id,
|
||||||
templateId: projectTemplate.id,
|
roles: [
|
||||||
roles: [
|
...projectTemplate.roles.filter(
|
||||||
...projectTemplate.roles.filter(
|
(r) => r.slug !== role?.slug && isCustomProjectRole(r.slug) // filter out default roles as well
|
||||||
(r) => r.slug !== role?.slug && isCustomProjectRole(r.slug) // filter out default roles as well
|
),
|
||||||
),
|
{
|
||||||
{
|
...form,
|
||||||
...form,
|
permissions: formRolePermission2API(form.permissions)
|
||||||
permissions: formRolePermission2API(form.permissions)
|
}
|
||||||
}
|
]
|
||||||
]
|
});
|
||||||
});
|
onGoBack();
|
||||||
onGoBack();
|
createNotification({
|
||||||
createNotification({
|
text: "Template roles successfully updated",
|
||||||
text: "Template roles successfully updated",
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
} catch (e: any) {
|
|
||||||
console.error(e);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to update template roles",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+12
-20
@@ -68,28 +68,20 @@ export const ProjectTemplateEnvironmentsForm = ({
|
|||||||
const updateProjectTemplate = useUpdateProjectTemplate();
|
const updateProjectTemplate = useUpdateProjectTemplate();
|
||||||
|
|
||||||
const onFormSubmit = async (form: TFormSchema) => {
|
const onFormSubmit = async (form: TFormSchema) => {
|
||||||
try {
|
const { environments: updatedEnvs } = await updateProjectTemplate.mutateAsync({
|
||||||
const { environments: updatedEnvs } = await updateProjectTemplate.mutateAsync({
|
environments: form.environments?.map((env, index) => ({
|
||||||
environments: form.environments?.map((env, index) => ({
|
...env,
|
||||||
...env,
|
position: index + 1
|
||||||
position: index + 1
|
})),
|
||||||
})),
|
templateId: projectTemplate.id
|
||||||
templateId: projectTemplate.id
|
});
|
||||||
});
|
|
||||||
|
|
||||||
reset({ environments: updatedEnvs });
|
reset({ environments: updatedEnvs });
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Project template updated successfully",
|
text: "Project template updated successfully",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (e: any) {
|
|
||||||
console.error(e);
|
|
||||||
createNotification({
|
|
||||||
text: e.message ?? "Failed to update project template",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const isEnvironmentLimitExceeded =
|
const isEnvironmentLimitExceeded =
|
||||||
|
|||||||
+11
-19
@@ -42,26 +42,18 @@ export const ProjectTemplateRolesSection = ({ projectTemplate, isInfisicalTempla
|
|||||||
const updateProjectTemplate = useUpdateProjectTemplate();
|
const updateProjectTemplate = useUpdateProjectTemplate();
|
||||||
|
|
||||||
const handleRemoveRole = async (slug: string) => {
|
const handleRemoveRole = async (slug: string) => {
|
||||||
try {
|
await updateProjectTemplate.mutateAsync({
|
||||||
await updateProjectTemplate.mutateAsync({
|
templateId: projectTemplate.id,
|
||||||
templateId: projectTemplate.id,
|
roles: projectTemplate.roles.filter(
|
||||||
roles: projectTemplate.roles.filter(
|
(role) => role.slug !== slug && isCustomProjectRole(role.slug) // filter out default roles as well
|
||||||
(role) => role.slug !== slug && isCustomProjectRole(role.slug) // filter out default roles as well
|
)
|
||||||
)
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully removed role from template",
|
text: "Successfully removed role from template",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
handlePopUpClose("removeRole");
|
handlePopUpClose("removeRole");
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
createNotification({
|
|
||||||
text: "Error removing role from template",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const editRole = popUp?.editRole?.data as TProjectRole;
|
const editRole = popUp?.editRole?.data as TProjectRole;
|
||||||
|
|||||||
+8
-18
@@ -93,25 +93,15 @@ const ProjectTemplateForm = ({ onComplete, projectTemplate }: FormProps) => {
|
|||||||
? updateProjectTemplate.mutateAsync({ templateId: projectTemplate.id, ...data })
|
? updateProjectTemplate.mutateAsync({ templateId: projectTemplate.id, ...data })
|
||||||
: createProjectTemplate.mutateAsync({ ...data });
|
: createProjectTemplate.mutateAsync({ ...data });
|
||||||
|
|
||||||
try {
|
const template = await mutation;
|
||||||
const template = await mutation;
|
createNotification({
|
||||||
createNotification({
|
text: `Successfully ${
|
||||||
text: `Successfully ${
|
projectTemplate ? "updated template details" : "created project template"
|
||||||
projectTemplate ? "updated template details" : "created project template"
|
}`,
|
||||||
}`,
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
|
|
||||||
onComplete(template);
|
onComplete(template);
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to ${
|
|
||||||
projectTemplate ? "update template details" : "create project template"
|
|
||||||
}`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+13
-24
@@ -87,34 +87,23 @@ export const UserOrgMembershipModal = ({ popUp, handlePopUpOpen, handlePopUpTogg
|
|||||||
}, [popUp?.orgMembership?.data, roles]);
|
}, [popUp?.orgMembership?.data, roles]);
|
||||||
|
|
||||||
const onFormSubmit = async ({ role, metadata }: FormData) => {
|
const onFormSubmit = async ({ role, metadata }: FormData) => {
|
||||||
try {
|
if (!orgId) return;
|
||||||
if (!orgId) return;
|
|
||||||
|
|
||||||
await updateOrgMembership({
|
await updateOrgMembership({
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
membershipId: popUpData.membershipId,
|
membershipId: popUpData.membershipId,
|
||||||
role: role.slug,
|
role: role.slug,
|
||||||
metadata
|
metadata
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpToggle("orgMembership", false);
|
handlePopUpToggle("orgMembership", false);
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully updated user organization role",
|
text: "Successfully updated user organization role",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const error = err as any;
|
|
||||||
const text = error?.response?.data?.message ?? "Failed to update user organization role";
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+11
-22
@@ -67,30 +67,19 @@ const UserAddToProjectModalChild = ({ membershipId, popUp, handlePopUpToggle }:
|
|||||||
}, [workspaces, projectMemberships]);
|
}, [workspaces, projectMemberships]);
|
||||||
|
|
||||||
const onFormSubmit = async ({ projectId }: FormData) => {
|
const onFormSubmit = async ({ projectId }: FormData) => {
|
||||||
try {
|
await addUserToWorkspaceNonE2EE({
|
||||||
await addUserToWorkspaceNonE2EE({
|
projectId,
|
||||||
projectId,
|
usernames: [popupData.username],
|
||||||
usernames: [popupData.username],
|
orgId
|
||||||
orgId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully added user to project",
|
text: "Successfully added user to project",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
handlePopUpToggle("addUserToProject", false);
|
handlePopUpToggle("addUserToProject", 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"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+10
-17
@@ -20,25 +20,18 @@ export const UserGroupsSection = ({ orgMembership }: Props) => {
|
|||||||
const { mutateAsync: removeUserFromGroup } = useRemoveUserFromGroup();
|
const { mutateAsync: removeUserFromGroup } = useRemoveUserFromGroup();
|
||||||
|
|
||||||
const handleRemoveUserFromGroup = useCallback(async (groupId: string, groupSlug: string) => {
|
const handleRemoveUserFromGroup = useCallback(async (groupId: string, groupSlug: string) => {
|
||||||
try {
|
await removeUserFromGroup({
|
||||||
await removeUserFromGroup({
|
groupId,
|
||||||
groupId,
|
slug: groupSlug,
|
||||||
slug: groupSlug,
|
username: orgMembership.user.username
|
||||||
username: orgMembership.user.username
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
type: "success",
|
type: "success",
|
||||||
text: "User removed from group successfully"
|
text: "User removed from group successfully"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("removeUserFromGroup");
|
handlePopUpClose("removeUserFromGroup");
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
text: "Failed to remove user from group"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+11
-18
@@ -62,26 +62,19 @@ const Content = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const onFormSubmit = async ({ group, role }: FormData) => {
|
const onFormSubmit = async ({ group, role }: FormData) => {
|
||||||
try {
|
await addGroupToWorkspaceMutateAsync({
|
||||||
await addGroupToWorkspaceMutateAsync({
|
projectId: currentProject?.id || "",
|
||||||
projectId: currentProject?.id || "",
|
groupId: group.id,
|
||||||
groupId: group.id,
|
role: role.slug || undefined
|
||||||
role: role.slug || undefined
|
});
|
||||||
});
|
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
handlePopUpToggle("group", false);
|
handlePopUpToggle("group", false);
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully added group to project",
|
text: "Successfully added group to project",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to add group to project",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return filteredGroupMembershipOrgs.length ? (
|
return filteredGroupMembershipOrgs.length ? (
|
||||||
|
|||||||
+9
-20
@@ -43,28 +43,17 @@ export const GroupsSection = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onRemoveGroupSubmit = async (groupId: string) => {
|
const onRemoveGroupSubmit = async (groupId: string) => {
|
||||||
try {
|
await deleteMutateAsync({
|
||||||
await deleteMutateAsync({
|
groupId,
|
||||||
groupId,
|
projectId: currentProject?.id || ""
|
||||||
projectId: currentProject?.id || ""
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully removed identity from project",
|
text: "Successfully removed identity from project",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("deleteGroup");
|
handlePopUpClose("deleteGroup");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const error = err as any;
|
|
||||||
const text = error?.response?.data?.message ?? "Failed to remove group from project";
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+9
-20
@@ -119,28 +119,17 @@ export const IdentityTab = withProjectPermission(
|
|||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const onRemoveIdentitySubmit = async (identityId: string) => {
|
const onRemoveIdentitySubmit = async (identityId: string) => {
|
||||||
try {
|
await deleteMutateAsync({
|
||||||
await deleteMutateAsync({
|
identityId,
|
||||||
identityId,
|
projectId
|
||||||
projectId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully removed identity from project",
|
text: "Successfully removed identity from project",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("deleteIdentity");
|
handlePopUpClose("deleteIdentity");
|
||||||
} 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"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSort = (column: ProjectIdentityOrderBy) => {
|
const handleSort = (column: ProjectIdentityOrderBy) => {
|
||||||
|
|||||||
+20
-31
@@ -104,40 +104,29 @@ const Content = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const onFormSubmit = async ({ identity, role }: FormData) => {
|
const onFormSubmit = async ({ identity, role }: FormData) => {
|
||||||
try {
|
await addIdentityToWorkspaceMutateAsync({
|
||||||
await addIdentityToWorkspaceMutateAsync({
|
projectId,
|
||||||
projectId,
|
identityId: identity.id,
|
||||||
identityId: identity.id,
|
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"
|
||||||
});
|
});
|
||||||
|
|
||||||
const nextAvailableMembership = filteredIdentityMembershipOrgs.filter(
|
const nextAvailableMembership = filteredIdentityMembershipOrgs.filter(
|
||||||
(membership) => membership.identity.id !== identity.id
|
(membership) => membership.identity.id !== identity.id
|
||||||
)[0];
|
)[0];
|
||||||
|
|
||||||
// prevents combobox from displaying previously added identity
|
// prevents combobox from displaying previously added identity
|
||||||
reset({
|
reset({
|
||||||
identity: {
|
identity: {
|
||||||
name: nextAvailableMembership?.identity.name,
|
name: nextAvailableMembership?.identity.name,
|
||||||
id: nextAvailableMembership?.identity.id
|
id: nextAvailableMembership?.identity.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
handlePopUpToggle("identity", false);
|
handlePopUpToggle("identity", 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"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isMembershipsLoading || isRolesLoading)
|
if (isMembershipsLoading || isRolesLoading)
|
||||||
|
|||||||
+46
-55
@@ -110,65 +110,56 @@ export const AddMemberModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
|
|
||||||
if (!selectedMembers) return;
|
if (!selectedMembers) return;
|
||||||
|
|
||||||
try {
|
if (currentProject.version === ProjectVersion.V1) {
|
||||||
if (currentProject.version === ProjectVersion.V1) {
|
createNotification({
|
||||||
|
type: "error",
|
||||||
|
text: "Please upgrade your project to invite new members to the project."
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const inviteeEmails = selectedMembers
|
||||||
|
.map((member) => {
|
||||||
|
if (!member) return null;
|
||||||
|
|
||||||
|
if (member.user.username) {
|
||||||
|
return member.user.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (member.user.email) {
|
||||||
|
return member.user.email;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
})
|
||||||
|
.filter(Boolean) as string[];
|
||||||
|
|
||||||
|
if (inviteeEmails.length !== selectedMembers.length) {
|
||||||
createNotification({
|
createNotification({
|
||||||
type: "error",
|
text: "Failed to add users to project. One or more users were invalid.",
|
||||||
text: "Please upgrade your project to invite new members to the project."
|
type: "error"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newInvitees.length) {
|
||||||
|
await addMemberToOrg({
|
||||||
|
inviteeEmails: newInvitees,
|
||||||
|
organizationId: orgId,
|
||||||
|
organizationRoleSlug: ProjectMembershipRole.Member // only applies to new invites
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (newInvitees.length || inviteeEmails.length) {
|
||||||
|
await addUserToProject({
|
||||||
|
usernames: [...inviteeEmails, ...newInvitees],
|
||||||
|
orgId,
|
||||||
|
projectId: currentProject.id,
|
||||||
|
roleSlugs: projectRoleSlugs.map((role) => role.slug)
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
const inviteeEmails = selectedMembers
|
|
||||||
.map((member) => {
|
|
||||||
if (!member) return null;
|
|
||||||
|
|
||||||
if (member.user.username) {
|
|
||||||
return member.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (member.user.email) {
|
|
||||||
return member.user.email;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
})
|
|
||||||
.filter(Boolean) as string[];
|
|
||||||
|
|
||||||
if (inviteeEmails.length !== selectedMembers.length) {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to add users to project. One or more users were invalid.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newInvitees.length) {
|
|
||||||
await addMemberToOrg({
|
|
||||||
inviteeEmails: newInvitees,
|
|
||||||
organizationId: orgId,
|
|
||||||
organizationRoleSlug: ProjectMembershipRole.Member // only applies to new invites
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (newInvitees.length || inviteeEmails.length) {
|
|
||||||
await addUserToProject({
|
|
||||||
usernames: [...inviteeEmails, ...newInvitees],
|
|
||||||
orgId,
|
|
||||||
projectId: currentProject.id,
|
|
||||||
roleSlugs: projectRoleSlugs.map((role) => role.slug)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
createNotification({
|
|
||||||
text: "Successfully added user to the project",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to add user to project",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully added user to the project",
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
handlePopUpToggle("addMember", false);
|
handlePopUpToggle("addMember", false);
|
||||||
reset();
|
reset();
|
||||||
};
|
};
|
||||||
|
|||||||
+8
-15
@@ -182,21 +182,14 @@ export const SpecificPrivilegeSecretForm = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (deleteUserPrivilege.isPending) return;
|
if (deleteUserPrivilege.isPending) return;
|
||||||
try {
|
await deleteUserPrivilege.mutateAsync({
|
||||||
await deleteUserPrivilege.mutateAsync({
|
privilegeId: privilege.id,
|
||||||
privilegeId: privilege.id,
|
projectMembershipId: privilege.projectMembershipId
|
||||||
projectMembershipId: privilege.projectMembershipId
|
});
|
||||||
});
|
createNotification({
|
||||||
createNotification({
|
type: "success",
|
||||||
type: "success",
|
text: "Successfully deleted privilege"
|
||||||
text: "Successfully deleted privilege"
|
});
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
text: "Failed to delete privilege"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// This is used for requesting access additional privileges, not directly creating a privilege!
|
// This is used for requesting access additional privileges, not directly creating a privilege!
|
||||||
|
|||||||
+9
-17
@@ -35,23 +35,15 @@ export const MembersSection = () => {
|
|||||||
if (!currentOrg?.id) return;
|
if (!currentOrg?.id) return;
|
||||||
if (!currentProject?.id) return;
|
if (!currentProject?.id) return;
|
||||||
|
|
||||||
try {
|
await removeUserFromWorkspace({
|
||||||
await removeUserFromWorkspace({
|
projectId: currentProject.id,
|
||||||
projectId: currentProject.id,
|
usernames: [username],
|
||||||
usernames: [username],
|
orgId: currentOrg.id
|
||||||
orgId: currentOrg.id
|
});
|
||||||
});
|
createNotification({
|
||||||
createNotification({
|
text: "Successfully removed user from project",
|
||||||
text: "Successfully removed user from project",
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to remove user from the project",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
handlePopUpClose("removeMember");
|
handlePopUpClose("removeMember");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+20
-37
@@ -6,7 +6,6 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { faCheck, faCopy, faPlus, faTrashCan } from "@fortawesome/free-solid-svg-icons";
|
import { faCheck, faCopy, faPlus, faTrashCan } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { AxiosError } from "axios";
|
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
@@ -110,45 +109,29 @@ const ServiceTokenForm = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onFormSubmit = async ({ name, scopes, expiresIn, permissions }: FormData) => {
|
const onFormSubmit = async ({ name, scopes, expiresIn, permissions }: FormData) => {
|
||||||
try {
|
if (!currentProject?.id) return;
|
||||||
if (!currentProject?.id) return;
|
|
||||||
|
|
||||||
const randomBytes = crypto.randomBytes(16).toString("hex");
|
const randomBytes = crypto.randomBytes(16).toString("hex");
|
||||||
|
|
||||||
const { serviceToken } = await createServiceToken.mutateAsync({
|
const { serviceToken } = await createServiceToken.mutateAsync({
|
||||||
encryptedKey: "",
|
encryptedKey: "",
|
||||||
iv: "",
|
iv: "",
|
||||||
tag: "",
|
tag: "",
|
||||||
scopes,
|
scopes,
|
||||||
expiresIn: Number(expiresIn),
|
expiresIn: Number(expiresIn),
|
||||||
name,
|
name,
|
||||||
workspaceId: currentProject.id,
|
workspaceId: currentProject.id,
|
||||||
randomBytes,
|
randomBytes,
|
||||||
permissions: Object.entries(permissions)
|
permissions: Object.entries(permissions)
|
||||||
.filter(([, permissionsValue]) => permissionsValue)
|
.filter(([, permissionsValue]) => permissionsValue)
|
||||||
.map(([permissionsKey]) => permissionsKey)
|
.map(([permissionsKey]) => permissionsKey)
|
||||||
});
|
});
|
||||||
|
|
||||||
setToken(serviceToken);
|
setToken(serviceToken);
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully created a service token",
|
text: "Successfully created a service token",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const axiosError = err as AxiosError;
|
|
||||||
if (axiosError?.response?.status === 401) {
|
|
||||||
createNotification({
|
|
||||||
text: "You do not have access to the selected environment/path",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to create a service token",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return !hasServiceToken ? (
|
return !hasServiceToken ? (
|
||||||
|
|||||||
+8
-16
@@ -28,23 +28,15 @@ export const ServiceTokenSection = withProjectPermission(
|
|||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const onDeleteApproved = async () => {
|
const onDeleteApproved = async () => {
|
||||||
try {
|
await deleteServiceToken.mutateAsync(
|
||||||
deleteServiceToken.mutateAsync(
|
(popUp?.deleteAPITokenConfirmation?.data as DeleteModalData)?.id
|
||||||
(popUp?.deleteAPITokenConfirmation?.data as DeleteModalData)?.id
|
);
|
||||||
);
|
createNotification({
|
||||||
createNotification({
|
text: "Successfully deleted service token",
|
||||||
text: "Successfully deleted service token",
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
|
|
||||||
handlePopUpClose("deleteAPITokenConfirmation");
|
handlePopUpClose("deleteAPITokenConfirmation");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete service token",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+19
-30
@@ -35,38 +35,27 @@ export const GroupDetailsSection = ({ groupMembership }: Props) => {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const onRemoveGroupSubmit = async () => {
|
const onRemoveGroupSubmit = async () => {
|
||||||
try {
|
await deleteMutateAsync({
|
||||||
await deleteMutateAsync({
|
groupId: groupMembership.group.id,
|
||||||
groupId: groupMembership.group.id,
|
projectId: currentProject.id
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully removed group from project",
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
navigate({
|
||||||
|
to: `${getProjectBaseURL(currentProject.type)}/access-management`,
|
||||||
|
params: {
|
||||||
projectId: currentProject.id
|
projectId: currentProject.id
|
||||||
});
|
},
|
||||||
|
search: {
|
||||||
|
selectedTab: "groups"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
createNotification({
|
handlePopUpClose("deleteGroup");
|
||||||
text: "Successfully removed group from project",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
|
|
||||||
navigate({
|
|
||||||
to: `${getProjectBaseURL(currentProject.type)}/access-management`,
|
|
||||||
params: {
|
|
||||||
projectId: currentProject.id
|
|
||||||
},
|
|
||||||
search: {
|
|
||||||
selectedTab: "groups"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
handlePopUpClose("deleteGroup");
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const error = err as any;
|
|
||||||
const text = error?.response?.data?.message ?? "Failed to remove group from project";
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -76,35 +76,24 @@ const Page = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onRemoveIdentitySubmit = async () => {
|
const onRemoveIdentitySubmit = async () => {
|
||||||
try {
|
await deleteMutateAsync({
|
||||||
await deleteMutateAsync({
|
identityId,
|
||||||
identityId,
|
projectId
|
||||||
|
});
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully removed identity from project",
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
handlePopUpClose("deleteIdentity");
|
||||||
|
navigate({
|
||||||
|
to: `${getProjectBaseURL(currentProject.type)}/access-management` as const,
|
||||||
|
params: {
|
||||||
projectId
|
projectId
|
||||||
});
|
},
|
||||||
createNotification({
|
search: {
|
||||||
text: "Successfully removed identity from project",
|
selectedTab: "identities"
|
||||||
type: "success"
|
}
|
||||||
});
|
});
|
||||||
handlePopUpClose("deleteIdentity");
|
|
||||||
navigate({
|
|
||||||
to: `${getProjectBaseURL(currentProject.type)}/access-management` as const,
|
|
||||||
params: {
|
|
||||||
projectId
|
|
||||||
},
|
|
||||||
search: {
|
|
||||||
selectedTab: "identities"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} 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"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isMembershipDetailsLoading) {
|
if (isMembershipDetailsLoading) {
|
||||||
|
|||||||
@@ -83,29 +83,21 @@ export const Page = () => {
|
|||||||
const handleRemoveUser = async () => {
|
const handleRemoveUser = async () => {
|
||||||
if (!currentOrg?.id || !currentProject?.id || !membershipDetails?.user?.username) return;
|
if (!currentOrg?.id || !currentProject?.id || !membershipDetails?.user?.username) return;
|
||||||
|
|
||||||
try {
|
await removeUserFromWorkspace({
|
||||||
await removeUserFromWorkspace({
|
projectId,
|
||||||
projectId,
|
usernames: [membershipDetails?.user?.username],
|
||||||
usernames: [membershipDetails?.user?.username],
|
orgId: currentOrg.id
|
||||||
orgId: currentOrg.id
|
});
|
||||||
});
|
createNotification({
|
||||||
createNotification({
|
text: "Successfully removed user from project",
|
||||||
text: "Successfully removed user from project",
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
navigate({
|
||||||
navigate({
|
to: `${getProjectBaseURL(currentProject.type)}/access-management` as const,
|
||||||
to: `${getProjectBaseURL(currentProject.type)}/access-management` as const,
|
params: {
|
||||||
params: {
|
projectId: currentProject.id
|
||||||
projectId: currentProject.id
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to remove user from the project",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
handlePopUpClose("removeMember");
|
handlePopUpClose("removeMember");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -53,38 +53,27 @@ const Page = () => {
|
|||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const onDeleteRoleSubmit = async () => {
|
const onDeleteRoleSubmit = async () => {
|
||||||
try {
|
if (!currentProject?.slug || !data?.id) return;
|
||||||
if (!currentProject?.slug || !data?.id) return;
|
|
||||||
|
|
||||||
await deleteProjectRole({
|
await deleteProjectRole({
|
||||||
projectId,
|
projectId,
|
||||||
id: data.id
|
id: data.id
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted project role",
|
text: "Successfully deleted project role",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
handlePopUpClose("deleteRole");
|
handlePopUpClose("deleteRole");
|
||||||
navigate({
|
navigate({
|
||||||
to: `${getProjectBaseURL(currentProject.type)}/access-management` as const,
|
to: `${getProjectBaseURL(currentProject.type)}/access-management` as const,
|
||||||
params: {
|
params: {
|
||||||
projectId
|
projectId
|
||||||
},
|
},
|
||||||
search: {
|
search: {
|
||||||
selectedTab: ProjectAccessControlTabs.Roles
|
selectedTab: ProjectAccessControlTabs.Roles
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const error = err as any;
|
|
||||||
const text = error?.response?.data?.message ?? "Failed to delete project role";
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const isCustomRole = !Object.values(ProjectMembershipRole).includes(
|
const isCustomRole = !Object.values(ProjectMembershipRole).includes(
|
||||||
|
|||||||
@@ -76,63 +76,54 @@ export const RoleModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
}, [role]);
|
}, [role]);
|
||||||
|
|
||||||
const onFormSubmit = async ({ name, description, slug }: FormData) => {
|
const onFormSubmit = async ({ name, description, slug }: FormData) => {
|
||||||
try {
|
if (!projectId) return;
|
||||||
if (!projectId) return;
|
|
||||||
|
|
||||||
if (role) {
|
if (role) {
|
||||||
// update
|
// update
|
||||||
await updateProjectRole({
|
await updateProjectRole({
|
||||||
id: role.id,
|
id: role.id,
|
||||||
projectId,
|
projectId,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
slug
|
slug
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpToggle("role", false);
|
|
||||||
if (slug) {
|
|
||||||
navigate({
|
|
||||||
to: `${getProjectBaseURL(currentProject.type)}/roles/$roleSlug` as const,
|
|
||||||
params: {
|
|
||||||
roleSlug: slug,
|
|
||||||
projectId
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// create
|
|
||||||
const newRole = await createProjectRole({
|
|
||||||
projectId,
|
|
||||||
name,
|
|
||||||
description,
|
|
||||||
slug,
|
|
||||||
permissions: []
|
|
||||||
});
|
|
||||||
|
|
||||||
|
handlePopUpToggle("role", false);
|
||||||
|
if (slug) {
|
||||||
navigate({
|
navigate({
|
||||||
to: `${getProjectBaseURL(currentProject.type)}/roles/$roleSlug` as const,
|
to: `${getProjectBaseURL(currentProject.type)}/roles/$roleSlug` as const,
|
||||||
params: {
|
params: {
|
||||||
roleSlug: newRole.slug,
|
roleSlug: slug,
|
||||||
projectId
|
projectId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
handlePopUpToggle("role", false);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
createNotification({
|
// create
|
||||||
text: `Successfully ${popUp?.role?.data ? "updated" : "created"} role`,
|
const newRole = await createProjectRole({
|
||||||
type: "success"
|
projectId,
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
slug,
|
||||||
|
permissions: []
|
||||||
});
|
});
|
||||||
|
|
||||||
reset();
|
navigate({
|
||||||
} catch {
|
to: `${getProjectBaseURL(currentProject.type)}/roles/$roleSlug` as const,
|
||||||
const text = `Failed to ${popUp?.role?.data ? "update" : "create"} role`;
|
params: {
|
||||||
|
roleSlug: newRole.slug,
|
||||||
createNotification({
|
projectId
|
||||||
text,
|
}
|
||||||
type: "error"
|
|
||||||
});
|
});
|
||||||
|
handlePopUpToggle("role", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${popUp?.role?.data ? "updated" : "created"} role`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+9
-17
@@ -10,24 +10,16 @@ export const DeleteProjectProtection = () => {
|
|||||||
const { mutateAsync } = useUpdateProject();
|
const { mutateAsync } = useUpdateProject();
|
||||||
|
|
||||||
const handleToggleDeleteProjectProtection = async (state: boolean) => {
|
const handleToggleDeleteProjectProtection = async (state: boolean) => {
|
||||||
try {
|
await mutateAsync({
|
||||||
await mutateAsync({
|
projectId,
|
||||||
projectId,
|
hasDeleteProtection: state
|
||||||
hasDeleteProtection: state
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const text = `Successfully ${state ? "enabled" : "disabled"} delete protection`;
|
const text = `Successfully ${state ? "enabled" : "disabled"} delete protection`;
|
||||||
createNotification({
|
createNotification({
|
||||||
text,
|
text,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to update delete protection",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
-12
@@ -68,12 +68,6 @@ export const DeleteProjectSection = () => {
|
|||||||
to: "/organization/projects"
|
to: "/organization/projects"
|
||||||
});
|
});
|
||||||
handlePopUpClose("deleteWorkspace");
|
handlePopUpClose("deleteWorkspace");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete project",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
} finally {
|
} finally {
|
||||||
setIsDeleting.off();
|
setIsDeleting.off();
|
||||||
}
|
}
|
||||||
@@ -118,12 +112,6 @@ export const DeleteProjectSection = () => {
|
|||||||
navigate({
|
navigate({
|
||||||
to: "/organization/projects"
|
to: "/organization/projects"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to leave project",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
} finally {
|
} finally {
|
||||||
setIsLeaving.off();
|
setIsLeaving.off();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user