mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-12 11:29:15 +00:00
feat: resolving bugs in checklist testing
This commit is contained in:
@@ -78,7 +78,7 @@ export const useGetProjectRoleBySlug = (projectId: string, roleSlug: string) =>
|
||||
|
||||
const getOrgRoles = async (orgId: string) => {
|
||||
const { data } = await apiRequest.get<{
|
||||
data: { roles: Array<Omit<TOrgRole, "permissions"> & { permissions: unknown }> };
|
||||
data: { roles: Array<Omit<TOrgRole, "permissions"> & { permissions: TPermission[] }> };
|
||||
}>(`/api/v1/organization/${orgId}/roles`);
|
||||
return data.data.roles;
|
||||
};
|
||||
|
||||
@@ -190,20 +190,11 @@ export const useAddUsersToOrg = () => {
|
||||
mutationFn: (dto) => {
|
||||
return apiRequest.post("/api/v1/invite-org/signup", dto);
|
||||
},
|
||||
onSuccess: (_, { organizationId, projects }) => {
|
||||
onSuccess: (_, { organizationId }) => {
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.getOrgUsers(organizationId) });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: subscriptionQueryKeys.getOrgSubsription(organizationId)
|
||||
});
|
||||
|
||||
projects?.forEach((project) => {
|
||||
if (project.slug) {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: projectKeys.getProjectGroupMemberships(project.slug)
|
||||
});
|
||||
}
|
||||
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectUsers(project.id) });
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -167,9 +167,6 @@ export type AddUserToOrgDTO = {
|
||||
inviteeEmails: string[];
|
||||
organizationRoleSlug: string;
|
||||
organizationId: string;
|
||||
|
||||
// We need the slug in order to invalidate the groups query. `slug` is only used for invalidation purposes.
|
||||
projects?: { id: string; slug?: string; projectRoleSlug: string[] }[];
|
||||
};
|
||||
|
||||
export type CreateAPIKeyRes = {
|
||||
|
||||
+16
-3
@@ -19,6 +19,7 @@ import { useOrganization } from "@app/context";
|
||||
import { findOrgMembershipRole } from "@app/helpers/roles";
|
||||
import {
|
||||
useAddUsersToOrg,
|
||||
useAddUserToWsNonE2EE,
|
||||
useFetchServerStatus,
|
||||
useGetOrgRoles,
|
||||
useGetUserProjects
|
||||
@@ -76,6 +77,7 @@ export const AddOrgMemberModal = ({
|
||||
const { data: organizationRoles } = useGetOrgRoles(currentOrg?.id ?? "");
|
||||
const { data: serverDetails } = useFetchServerStatus();
|
||||
const { mutateAsync: addUsersMutateAsync } = useAddUsersToOrg();
|
||||
const { mutateAsync: addUserToProject } = useAddUserToWsNonE2EE();
|
||||
const { data: projects, isPending: isProjectsLoading } = useGetUserProjects({
|
||||
includeRoles: true
|
||||
});
|
||||
@@ -140,13 +142,24 @@ export const AddOrgMemberModal = ({
|
||||
return;
|
||||
}
|
||||
|
||||
const usernames = emails.split(",").map((email) => email.trim());
|
||||
const { data } = await addUsersMutateAsync({
|
||||
organizationId: currentOrg?.id,
|
||||
inviteeEmails: emails.split(",").map((email) => email.trim()),
|
||||
organizationRoleSlug: organizationRole.slug,
|
||||
projects: selectedProjects.map(({ id }) => ({ id, projectRoleSlug: [projectRoleSlug] }))
|
||||
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.
|
||||
|
||||
+15
-12
@@ -26,6 +26,7 @@ import {
|
||||
} from "@app/context";
|
||||
import {
|
||||
useAddUsersToOrg,
|
||||
useAddUserToWsNonE2EE,
|
||||
useGetOrgUsers,
|
||||
useGetProjectRoles,
|
||||
useGetWorkspaceUsers
|
||||
@@ -85,7 +86,8 @@ export const AddMemberModal = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
defaultValues: { orgMemberships: [], projectRoleSlugs: [] }
|
||||
});
|
||||
|
||||
const { mutateAsync: addMembersToProject } = useAddUsersToOrg();
|
||||
const { mutateAsync: addMemberToOrg } = useAddUsersToOrg();
|
||||
const { mutateAsync: addUserToProject } = useAddUserToWsNonE2EE();
|
||||
|
||||
useEffect(() => {
|
||||
if (requesterEmail) {
|
||||
@@ -139,18 +141,19 @@ export const AddMemberModal = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (inviteeEmails.length || newInvitees.length) {
|
||||
await addMembersToProject({
|
||||
inviteeEmails: [...inviteeEmails, ...newInvitees],
|
||||
if (newInvitees.length) {
|
||||
await addMemberToOrg({
|
||||
inviteeEmails: newInvitees,
|
||||
organizationId: orgId,
|
||||
organizationRoleSlug: ProjectMembershipRole.Member, // only applies to new invites
|
||||
projects: [
|
||||
{
|
||||
slug: currentProject.slug,
|
||||
id: currentProject.id,
|
||||
projectRoleSlug: projectRoleSlugs.map((role) => role.slug)
|
||||
}
|
||||
]
|
||||
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)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user