mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 19:28:16 +00:00
Resolve PR review issues
This commit is contained in:
@@ -13,7 +13,7 @@ export const registerGroupRouter = async (server: FastifyZodProvider) => {
|
|||||||
onRequest: verifyAuth([AuthMode.JWT]),
|
onRequest: verifyAuth([AuthMode.JWT]),
|
||||||
schema: {
|
schema: {
|
||||||
body: z.object({
|
body: z.object({
|
||||||
name: z.string().trim().min(1).describe(GROUPS.CREATE.name),
|
name: z.string().trim().min(1).max(50).describe(GROUPS.CREATE.name),
|
||||||
slug: z
|
slug: z
|
||||||
.string()
|
.string()
|
||||||
.min(5)
|
.min(5)
|
||||||
|
|||||||
@@ -118,9 +118,8 @@ export const groupDALFactory = (db: TDbClient) => {
|
|||||||
db.ref("firstName").withSchema(TableName.Users),
|
db.ref("firstName").withSchema(TableName.Users),
|
||||||
db.ref("lastName").withSchema(TableName.Users),
|
db.ref("lastName").withSchema(TableName.Users),
|
||||||
db.ref("id").withSchema(TableName.Users).as("userId")
|
db.ref("id").withSchema(TableName.Users).as("userId")
|
||||||
// db.raw(`CASE WHEN "${TableName.UserGroupMembership}"."groupId" IS NOT NULL THEN TRUE ELSE FALSE END as isPartOfGroup`)
|
|
||||||
)
|
)
|
||||||
.where({ isGhost: false }) // MAKE SURE USER IS NOT A GHOST USER
|
.where({ isGhost: false })
|
||||||
.offset(offset);
|
.offset(offset);
|
||||||
|
|
||||||
if (limit) {
|
if (limit) {
|
||||||
|
|||||||
@@ -12,15 +12,15 @@ export const getDefaultOnPremFeatures = () => {
|
|||||||
secretVersioning: true,
|
secretVersioning: true,
|
||||||
pitRecovery: false,
|
pitRecovery: false,
|
||||||
ipAllowlisting: true,
|
ipAllowlisting: true,
|
||||||
rbac: true,
|
rbac: false,
|
||||||
customRateLimits: false,
|
customRateLimits: false,
|
||||||
customAlerts: false,
|
customAlerts: false,
|
||||||
auditLogs: false,
|
auditLogs: false,
|
||||||
auditLogsRetentionDays: 0,
|
auditLogsRetentionDays: 0,
|
||||||
samlSSO: true,
|
samlSSO: false,
|
||||||
scim: true,
|
scim: false,
|
||||||
ldap: false,
|
ldap: false,
|
||||||
groups: true,
|
groups: false,
|
||||||
status: null,
|
status: null,
|
||||||
trial_end: null,
|
trial_end: null,
|
||||||
has_used_trial: true,
|
has_used_trial: true,
|
||||||
|
|||||||
@@ -19,15 +19,15 @@ export const getDefaultOnPremFeatures = (): TFeatureSet => ({
|
|||||||
secretVersioning: true,
|
secretVersioning: true,
|
||||||
pitRecovery: false,
|
pitRecovery: false,
|
||||||
ipAllowlisting: false,
|
ipAllowlisting: false,
|
||||||
rbac: true,
|
rbac: false,
|
||||||
customRateLimits: false,
|
customRateLimits: false,
|
||||||
customAlerts: false,
|
customAlerts: false,
|
||||||
auditLogs: false,
|
auditLogs: false,
|
||||||
auditLogsRetentionDays: 0,
|
auditLogsRetentionDays: 0,
|
||||||
samlSSO: true,
|
samlSSO: false,
|
||||||
scim: true,
|
scim: false,
|
||||||
ldap: false,
|
ldap: false,
|
||||||
groups: true,
|
groups: false,
|
||||||
status: null,
|
status: null,
|
||||||
trial_end: null,
|
trial_end: null,
|
||||||
has_used_trial: true,
|
has_used_trial: true,
|
||||||
|
|||||||
@@ -35,15 +35,15 @@ export type TFeatureSet = {
|
|||||||
secretVersioning: true;
|
secretVersioning: true;
|
||||||
pitRecovery: false;
|
pitRecovery: false;
|
||||||
ipAllowlisting: false;
|
ipAllowlisting: false;
|
||||||
rbac: true;
|
rbac: false;
|
||||||
customRateLimits: false;
|
customRateLimits: false;
|
||||||
customAlerts: false;
|
customAlerts: false;
|
||||||
auditLogs: false;
|
auditLogs: false;
|
||||||
auditLogsRetentionDays: 0;
|
auditLogsRetentionDays: 0;
|
||||||
samlSSO: true;
|
samlSSO: false;
|
||||||
scim: true;
|
scim: false;
|
||||||
ldap: false;
|
ldap: false;
|
||||||
groups: true;
|
groups: false;
|
||||||
status: null;
|
status: null;
|
||||||
trial_end: null;
|
trial_end: null;
|
||||||
has_used_trial: true;
|
has_used_trial: true;
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ export const groupProjectServiceFactory = ({
|
|||||||
role,
|
role,
|
||||||
project.id
|
project.id
|
||||||
);
|
);
|
||||||
const hasPriviledge = isAtLeastAsPrivileged(permission, rolePermission);
|
const hasPrivilege = isAtLeastAsPrivileged(permission, rolePermission);
|
||||||
if (!hasPriviledge)
|
if (!hasPrivilege)
|
||||||
throw new ForbiddenRequestError({
|
throw new ForbiddenRequestError({
|
||||||
message: "Failed to add group to project with more privileged role"
|
message: "Failed to add group to project with more privileged role"
|
||||||
});
|
});
|
||||||
@@ -226,7 +226,7 @@ export const groupProjectServiceFactory = ({
|
|||||||
|
|
||||||
const customRolesGroupBySlug = groupBy(customRoles, ({ slug }) => slug);
|
const customRolesGroupBySlug = groupBy(customRoles, ({ slug }) => slug);
|
||||||
|
|
||||||
const santiziedProjectMembershipRoles = roles.map((inputRole) => {
|
const sanitizedProjectMembershipRoles = roles.map((inputRole) => {
|
||||||
const isCustomRole = Boolean(customRolesGroupBySlug?.[inputRole.role]?.[0]);
|
const isCustomRole = Boolean(customRolesGroupBySlug?.[inputRole.role]?.[0]);
|
||||||
if (!inputRole.isTemporary) {
|
if (!inputRole.isTemporary) {
|
||||||
return {
|
return {
|
||||||
@@ -252,7 +252,7 @@ export const groupProjectServiceFactory = ({
|
|||||||
|
|
||||||
const updatedRoles = await groupProjectMembershipRoleDAL.transaction(async (tx) => {
|
const updatedRoles = await groupProjectMembershipRoleDAL.transaction(async (tx) => {
|
||||||
await groupProjectMembershipRoleDAL.delete({ projectMembershipId: projectGroup.id }, tx);
|
await groupProjectMembershipRoleDAL.delete({ projectMembershipId: projectGroup.id }, tx);
|
||||||
return groupProjectMembershipRoleDAL.insertMany(santiziedProjectMembershipRoles, tx);
|
return groupProjectMembershipRoleDAL.insertMany(sanitizedProjectMembershipRoles, tx);
|
||||||
});
|
});
|
||||||
|
|
||||||
return updatedRoles;
|
return updatedRoles;
|
||||||
@@ -325,8 +325,8 @@ export const groupProjectServiceFactory = ({
|
|||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Groups);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Groups);
|
||||||
|
|
||||||
const groupMemberhips = await groupProjectDAL.findByProjectId(project.id);
|
const groupMemberships = await groupProjectDAL.findByProjectId(project.id);
|
||||||
return groupMemberhips;
|
return groupMemberships;
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ export const identityProjectServiceFactory = ({
|
|||||||
|
|
||||||
const customRolesGroupBySlug = groupBy(customRoles, ({ slug }) => slug);
|
const customRolesGroupBySlug = groupBy(customRoles, ({ slug }) => slug);
|
||||||
|
|
||||||
const santiziedProjectMembershipRoles = roles.map((inputRole) => {
|
const sanitizedProjectMembershipRoles = roles.map((inputRole) => {
|
||||||
const isCustomRole = Boolean(customRolesGroupBySlug?.[inputRole.role]?.[0]);
|
const isCustomRole = Boolean(customRolesGroupBySlug?.[inputRole.role]?.[0]);
|
||||||
if (!inputRole.isTemporary) {
|
if (!inputRole.isTemporary) {
|
||||||
return {
|
return {
|
||||||
@@ -189,7 +189,7 @@ export const identityProjectServiceFactory = ({
|
|||||||
|
|
||||||
const updatedRoles = await identityProjectMembershipRoleDAL.transaction(async (tx) => {
|
const updatedRoles = await identityProjectMembershipRoleDAL.transaction(async (tx) => {
|
||||||
await identityProjectMembershipRoleDAL.delete({ projectMembershipId: projectIdentity.id }, tx);
|
await identityProjectMembershipRoleDAL.delete({ projectMembershipId: projectIdentity.id }, tx);
|
||||||
return identityProjectMembershipRoleDAL.insertMany(santiziedProjectMembershipRoles, tx);
|
return identityProjectMembershipRoleDAL.insertMany(sanitizedProjectMembershipRoles, tx);
|
||||||
});
|
});
|
||||||
|
|
||||||
return updatedRoles;
|
return updatedRoles;
|
||||||
@@ -226,7 +226,7 @@ export const identityProjectServiceFactory = ({
|
|||||||
if (!hasRequiredPriviledges)
|
if (!hasRequiredPriviledges)
|
||||||
throw new ForbiddenRequestError({ message: "Failed to delete more privileged identity" });
|
throw new ForbiddenRequestError({ message: "Failed to delete more privileged identity" });
|
||||||
|
|
||||||
const [deletedIdentity] = await identityProjectDAL.delete({ identityId }); // TODO: fix
|
const [deletedIdentity] = await identityProjectDAL.delete({ identityId });
|
||||||
return deletedIdentity;
|
return deletedIdentity;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -246,8 +246,8 @@ export const identityProjectServiceFactory = ({
|
|||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Identity);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Identity);
|
||||||
|
|
||||||
const identityMemberhips = await identityProjectDAL.findByProjectId(projectId);
|
const identityMemberships = await identityProjectDAL.findByProjectId(projectId);
|
||||||
return identityMemberhips;
|
return identityMemberships;
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -157,8 +157,8 @@ export const identityServiceFactory = ({
|
|||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Identity);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Identity);
|
||||||
|
|
||||||
const identityMemberhips = await identityOrgMembershipDAL.findByOrgId(orgId);
|
const identityMemberships = await identityOrgMembershipDAL.findByOrgId(orgId);
|
||||||
return identityMemberhips;
|
return identityMemberships;
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ export const projectMembershipServiceFactory = ({
|
|||||||
if (customRoles.length !== customInputRoles.length) throw new BadRequestError({ message: "Custom role not found" });
|
if (customRoles.length !== customInputRoles.length) throw new BadRequestError({ message: "Custom role not found" });
|
||||||
const customRolesGroupBySlug = groupBy(customRoles, ({ slug }) => slug);
|
const customRolesGroupBySlug = groupBy(customRoles, ({ slug }) => slug);
|
||||||
|
|
||||||
const santiziedProjectMembershipRoles = roles.map((inputRole) => {
|
const sanitizedProjectMembershipRoles = roles.map((inputRole) => {
|
||||||
const isCustomRole = Boolean(customRolesGroupBySlug?.[inputRole.role]?.[0]);
|
const isCustomRole = Boolean(customRolesGroupBySlug?.[inputRole.role]?.[0]);
|
||||||
if (!inputRole.isTemporary) {
|
if (!inputRole.isTemporary) {
|
||||||
return {
|
return {
|
||||||
@@ -388,7 +388,7 @@ export const projectMembershipServiceFactory = ({
|
|||||||
|
|
||||||
const updatedRoles = await projectMembershipDAL.transaction(async (tx) => {
|
const updatedRoles = await projectMembershipDAL.transaction(async (tx) => {
|
||||||
await projectUserMembershipRoleDAL.delete({ projectMembershipId: membershipId }, tx);
|
await projectUserMembershipRoleDAL.delete({ projectMembershipId: membershipId }, tx);
|
||||||
return projectUserMembershipRoleDAL.insertMany(santiziedProjectMembershipRoles, tx);
|
return projectUserMembershipRoleDAL.insertMany(sanitizedProjectMembershipRoles, tx);
|
||||||
});
|
});
|
||||||
|
|
||||||
return updatedRoles;
|
return updatedRoles;
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
export {
|
export {
|
||||||
useAddGroupToWorkspace,
|
useAddGroupToWorkspace,
|
||||||
|
useDeleteGroupFromWorkspace,
|
||||||
|
useUpdateGroupWorkspaceRole
|
||||||
|
} from "./mutations";
|
||||||
|
export {
|
||||||
useAddIdentityToWorkspace,
|
useAddIdentityToWorkspace,
|
||||||
useCreateWorkspace,
|
useCreateWorkspace,
|
||||||
useCreateWsEnvironment,
|
useCreateWsEnvironment,
|
||||||
useDeleteGroupFromWorkspace,
|
|
||||||
useDeleteIdentityFromWorkspace,
|
useDeleteIdentityFromWorkspace,
|
||||||
useDeleteUserFromWorkspace,
|
useDeleteUserFromWorkspace,
|
||||||
useDeleteWorkspace,
|
useDeleteWorkspace,
|
||||||
@@ -22,8 +25,8 @@ export {
|
|||||||
useNameWorkspaceSecrets,
|
useNameWorkspaceSecrets,
|
||||||
useRenameWorkspace,
|
useRenameWorkspace,
|
||||||
useToggleAutoCapitalization,
|
useToggleAutoCapitalization,
|
||||||
useUpdateGroupWorkspaceRole,
|
|
||||||
useUpdateIdentityWorkspaceRole,
|
useUpdateIdentityWorkspaceRole,
|
||||||
useUpdateUserWorkspaceRole,
|
useUpdateUserWorkspaceRole,
|
||||||
useUpdateWsEnvironment,
|
useUpdateWsEnvironment,
|
||||||
useUpgradeProject} from "./queries";
|
useUpgradeProject
|
||||||
|
} from "./queries";
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
import { apiRequest } from "@app/config/request";
|
||||||
|
|
||||||
|
import { workspaceKeys } from "./queries";
|
||||||
|
import { TUpdateWorkspaceGroupRoleDTO } from "./types";
|
||||||
|
|
||||||
|
export const useAddGroupToWorkspace = () => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async ({
|
||||||
|
groupSlug,
|
||||||
|
projectSlug,
|
||||||
|
role
|
||||||
|
}: {
|
||||||
|
groupSlug: string;
|
||||||
|
projectSlug: string;
|
||||||
|
role?: string;
|
||||||
|
}) => {
|
||||||
|
const {
|
||||||
|
data: { groupMembership }
|
||||||
|
} = await apiRequest.post(`/api/v2/workspace/${projectSlug}/groups/${groupSlug}`, {
|
||||||
|
role
|
||||||
|
});
|
||||||
|
return groupMembership;
|
||||||
|
},
|
||||||
|
onSuccess: (_, { projectSlug }) => {
|
||||||
|
queryClient.invalidateQueries(workspaceKeys.getWorkspaceGroupMemberships(projectSlug));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useUpdateGroupWorkspaceRole = () => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async ({ groupSlug, projectSlug, roles }: TUpdateWorkspaceGroupRoleDTO) => {
|
||||||
|
const {
|
||||||
|
data: { groupMembership }
|
||||||
|
} = await apiRequest.patch(`/api/v2/workspace/${projectSlug}/groups/${groupSlug}`, {
|
||||||
|
roles
|
||||||
|
});
|
||||||
|
|
||||||
|
return groupMembership;
|
||||||
|
},
|
||||||
|
onSuccess: (_, { projectSlug }) => {
|
||||||
|
queryClient.invalidateQueries(workspaceKeys.getWorkspaceGroupMemberships(projectSlug));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useDeleteGroupFromWorkspace = () => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async ({ groupSlug, projectSlug }: { groupSlug: string; projectSlug: string }) => {
|
||||||
|
const {
|
||||||
|
data: { groupMembership }
|
||||||
|
} = await apiRequest.delete(`/api/v2/workspace/${projectSlug}/groups/${groupSlug}`);
|
||||||
|
return groupMembership;
|
||||||
|
},
|
||||||
|
onSuccess: (_, { projectSlug }) => {
|
||||||
|
queryClient.invalidateQueries(workspaceKeys.getWorkspaceGroupMemberships(projectSlug));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -17,7 +17,6 @@ import {
|
|||||||
RenameWorkspaceDTO,
|
RenameWorkspaceDTO,
|
||||||
TGetUpgradeProjectStatusDTO,
|
TGetUpgradeProjectStatusDTO,
|
||||||
ToggleAutoCapitalizationDTO,
|
ToggleAutoCapitalizationDTO,
|
||||||
TUpdateWorkspaceGroupRoleDTO,
|
|
||||||
TUpdateWorkspaceIdentityRoleDTO,
|
TUpdateWorkspaceIdentityRoleDTO,
|
||||||
TUpdateWorkspaceUserRoleDTO,
|
TUpdateWorkspaceUserRoleDTO,
|
||||||
UpdateEnvironmentDTO,
|
UpdateEnvironmentDTO,
|
||||||
@@ -455,77 +454,6 @@ export const useGetWorkspaceIdentityMemberships = (workspaceId: string) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useAddGroupToWorkspace = () => {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
return useMutation({
|
|
||||||
mutationFn: async ({
|
|
||||||
groupSlug,
|
|
||||||
projectSlug,
|
|
||||||
role
|
|
||||||
}: {
|
|
||||||
groupSlug: string;
|
|
||||||
projectSlug: string;
|
|
||||||
role?: string;
|
|
||||||
}) => {
|
|
||||||
const {
|
|
||||||
data: { groupMembership }
|
|
||||||
} = await apiRequest.post(
|
|
||||||
`/api/v2/workspace/${projectSlug}/groups/${groupSlug}`,
|
|
||||||
{
|
|
||||||
role
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return groupMembership;
|
|
||||||
},
|
|
||||||
onSuccess: (_, { projectSlug }) => {
|
|
||||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceGroupMemberships(projectSlug));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const useUpdateGroupWorkspaceRole = () => {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
return useMutation({
|
|
||||||
mutationFn: async ({ groupSlug, projectSlug, roles }: TUpdateWorkspaceGroupRoleDTO) => {
|
|
||||||
const {
|
|
||||||
data: { groupMembership }
|
|
||||||
} = await apiRequest.patch(
|
|
||||||
`/api/v2/workspace/${projectSlug}/groups/${groupSlug}`, {
|
|
||||||
roles
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return groupMembership;
|
|
||||||
},
|
|
||||||
onSuccess: (_, { projectSlug }) => {
|
|
||||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceGroupMemberships(projectSlug));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const useDeleteGroupFromWorkspace = () => {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
return useMutation({
|
|
||||||
mutationFn: async ({
|
|
||||||
groupSlug,
|
|
||||||
projectSlug
|
|
||||||
}: {
|
|
||||||
groupSlug: string;
|
|
||||||
projectSlug: string;
|
|
||||||
}) => {
|
|
||||||
const {
|
|
||||||
data: { groupMembership }
|
|
||||||
} = await apiRequest.delete(
|
|
||||||
`/api/v2/workspace/${projectSlug}/groups/${groupSlug}`
|
|
||||||
);
|
|
||||||
return groupMembership;
|
|
||||||
},
|
|
||||||
onSuccess: (_, { projectSlug }) => {
|
|
||||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceGroupMemberships(projectSlug));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const useListWorkspaceGroups = (projectSlug: string) => {
|
export const useListWorkspaceGroups = (projectSlug: string) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: workspaceKeys.getWorkspaceGroupMemberships(projectSlug),
|
queryKey: workspaceKeys.getWorkspaceGroupMemberships(projectSlug),
|
||||||
|
|||||||
+20
-43
@@ -4,18 +4,22 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
import { Button, FormControl, Input, Modal, ModalContent, Select, SelectItem } from "@app/components/v2";
|
|
||||||
import { useOrganization } from "@app/context";
|
|
||||||
import {
|
import {
|
||||||
useCreateGroup,
|
Button,
|
||||||
useGetOrgRoles,
|
FormControl,
|
||||||
useUpdateGroup
|
Input,
|
||||||
} from "@app/hooks/api";
|
Modal,
|
||||||
|
ModalContent,
|
||||||
|
Select,
|
||||||
|
SelectItem
|
||||||
|
} from "@app/components/v2";
|
||||||
|
import { useOrganization } from "@app/context";
|
||||||
|
import { useCreateGroup, useGetOrgRoles, useUpdateGroup } from "@app/hooks/api";
|
||||||
import { UsePopUpState } from "@app/hooks/usePopUp";
|
import { UsePopUpState } from "@app/hooks/usePopUp";
|
||||||
|
|
||||||
const GroupFormSchema = z.object({
|
const GroupFormSchema = z.object({
|
||||||
name: z.string().min(1, "Name cannot be empty").max(50, "Name must be 50 characters or fewer"),
|
name: z.string().min(1, "Name cannot be empty").max(50, "Name must be 50 characters or fewer"),
|
||||||
slug: z.string().min(1, "Slug cannot be empty").max(36, "Slug must be 36 characters or fewer"),
|
slug: z.string().min(5, "Slug cannot be empty").max(36, "Slug must be 36 characters or fewer"),
|
||||||
role: z.string()
|
role: z.string()
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -27,21 +31,13 @@ type Props = {
|
|||||||
handlePopUpToggle: (popUpName: keyof UsePopUpState<["group"]>, state?: boolean) => void;
|
handlePopUpToggle: (popUpName: keyof UsePopUpState<["group"]>, state?: boolean) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const OrgGroupModal = ({
|
export const OrgGroupModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props) => {
|
||||||
popUp,
|
|
||||||
handlePopUpClose,
|
|
||||||
handlePopUpToggle
|
|
||||||
}: Props) => {
|
|
||||||
const { currentOrg } = useOrganization();
|
const { currentOrg } = useOrganization();
|
||||||
const { data: roles } = useGetOrgRoles(currentOrg?.id || "");
|
const { data: roles } = useGetOrgRoles(currentOrg?.id || "");
|
||||||
const { mutateAsync: createMutateAsync, isLoading: createIsLoading } = useCreateGroup();
|
const { mutateAsync: createMutateAsync, isLoading: createIsLoading } = useCreateGroup();
|
||||||
const { mutateAsync: updateMutateAsync, isLoading: updateIsLoading } = useUpdateGroup();
|
const { mutateAsync: updateMutateAsync, isLoading: updateIsLoading } = useUpdateGroup();
|
||||||
|
|
||||||
const {
|
const { control, handleSubmit, reset } = useForm<TGroupFormData>({
|
||||||
control,
|
|
||||||
handleSubmit,
|
|
||||||
reset,
|
|
||||||
} = useForm<TGroupFormData>({
|
|
||||||
resolver: zodResolver(GroupFormSchema)
|
resolver: zodResolver(GroupFormSchema)
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -74,11 +70,7 @@ export const OrgGroupModal = ({
|
|||||||
}
|
}
|
||||||
}, [popUp?.group?.data, roles]);
|
}, [popUp?.group?.data, roles]);
|
||||||
|
|
||||||
const onGroupModalSubmit = async ({
|
const onGroupModalSubmit = async ({ name, slug, role }: TGroupFormData) => {
|
||||||
name,
|
|
||||||
slug,
|
|
||||||
role
|
|
||||||
}: TGroupFormData) => {
|
|
||||||
try {
|
try {
|
||||||
if (!currentOrg?.id) return;
|
if (!currentOrg?.id) return;
|
||||||
|
|
||||||
@@ -116,7 +108,7 @@ export const OrgGroupModal = ({
|
|||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
@@ -132,15 +124,8 @@ export const OrgGroupModal = ({
|
|||||||
control={control}
|
control={control}
|
||||||
name="name"
|
name="name"
|
||||||
render={({ field, fieldState: { error } }) => (
|
render={({ field, fieldState: { error } }) => (
|
||||||
<FormControl
|
<FormControl label="Name" errorText={error?.message} isError={Boolean(error)}>
|
||||||
label="Name"
|
<Input {...field} placeholder="Engineering" />
|
||||||
errorText={error?.message}
|
|
||||||
isError={Boolean(error)}
|
|
||||||
>
|
|
||||||
<Input
|
|
||||||
{...field}
|
|
||||||
placeholder="Engineering"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
@@ -148,15 +133,8 @@ export const OrgGroupModal = ({
|
|||||||
control={control}
|
control={control}
|
||||||
name="slug"
|
name="slug"
|
||||||
render={({ field, fieldState: { error } }) => (
|
render={({ field, fieldState: { error } }) => (
|
||||||
<FormControl
|
<FormControl label="Slug" errorText={error?.message} isError={Boolean(error)}>
|
||||||
label="Slug"
|
<Input {...field} placeholder="engineering" />
|
||||||
errorText={error?.message}
|
|
||||||
isError={Boolean(error)}
|
|
||||||
>
|
|
||||||
<Input
|
|
||||||
{...field}
|
|
||||||
placeholder="engineering"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
@@ -206,6 +184,5 @@ export const OrgGroupModal = ({
|
|||||||
</form>
|
</form>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ import { Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
|
|||||||
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
||||||
import { withProjectPermission } from "@app/hoc";
|
import { withProjectPermission } from "@app/hoc";
|
||||||
|
|
||||||
import { GroupsTab, IdentityTab, MemberListTab, ProjectRoleListTab, ServiceTokenTab } from "./components";
|
import {
|
||||||
|
GroupsTab,
|
||||||
|
IdentityTab,
|
||||||
|
MemberListTab,
|
||||||
|
ProjectRoleListTab,
|
||||||
|
ServiceTokenTab
|
||||||
|
} from "./components";
|
||||||
|
|
||||||
enum TabSections {
|
enum TabSections {
|
||||||
Member = "members",
|
Member = "members",
|
||||||
@@ -18,8 +24,6 @@ enum TabSections {
|
|||||||
export const MembersPage = withProjectPermission(
|
export const MembersPage = withProjectPermission(
|
||||||
() => {
|
() => {
|
||||||
const { currentWorkspace } = useWorkspace();
|
const { currentWorkspace } = useWorkspace();
|
||||||
console.log("currentWorkspace: ", currentWorkspace);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container mx-auto flex flex-col justify-between bg-bunker-800 text-white">
|
<div className="container mx-auto flex flex-col justify-between bg-bunker-800 text-white">
|
||||||
<div className="mx-auto mb-6 w-full max-w-7xl py-6 px-6">
|
<div className="mx-auto mb-6 w-full max-w-7xl py-6 px-6">
|
||||||
@@ -44,7 +48,7 @@ export const MembersPage = withProjectPermission(
|
|||||||
{currentWorkspace?.version && currentWorkspace.version > 1 && (
|
{currentWorkspace?.version && currentWorkspace.version > 1 && (
|
||||||
<TabPanel value={TabSections.Groups}>
|
<TabPanel value={TabSections.Groups}>
|
||||||
<motion.div
|
<motion.div
|
||||||
key="panel-1"
|
key="panel-groups"
|
||||||
transition={{ duration: 0.15 }}
|
transition={{ duration: 0.15 }}
|
||||||
initial={{ opacity: 0, translateX: 30 }}
|
initial={{ opacity: 0, translateX: 30 }}
|
||||||
animate={{ opacity: 1, translateX: 0 }}
|
animate={{ opacity: 1, translateX: 0 }}
|
||||||
|
|||||||
Reference in New Issue
Block a user