mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-19 23:23:59 +00:00
Merge remote-tracking branch 'origin/main' into feat/pki-ENG-3666
This commit is contained in:
@@ -3,9 +3,9 @@ import { useTranslation } from "react-i18next";
|
||||
import { useNavigate, useSearch } from "@tanstack/react-router";
|
||||
|
||||
import { PageHeader, Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
|
||||
import { useWorkspace } from "@app/context";
|
||||
import { useProject } from "@app/context";
|
||||
import { getProjectBaseURL } from "@app/helpers/project";
|
||||
import { ProjectType } from "@app/hooks/api/workspace/types";
|
||||
import { ProjectType } from "@app/hooks/api/projects/types";
|
||||
import { ProjectAccessControlTabs } from "@app/types/project";
|
||||
|
||||
import {
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
|
||||
const Page = () => {
|
||||
const navigate = useNavigate();
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
const selectedTab = useSearch({
|
||||
strict: false,
|
||||
select: (el) => el.selectedTab
|
||||
@@ -26,15 +26,15 @@ const Page = () => {
|
||||
|
||||
const updateSelectedTab = (tab: string) => {
|
||||
navigate({
|
||||
to: `${getProjectBaseURL(currentWorkspace.type)}/access-management` as const,
|
||||
to: `${getProjectBaseURL(currentProject.type)}/access-management` as const,
|
||||
search: (prev) => ({ ...prev, selectedTab: tab }),
|
||||
params: {
|
||||
projectId: currentWorkspace.id
|
||||
projectId: currentProject.id
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const isSecretManager = currentWorkspace.type === ProjectType.SecretManager;
|
||||
const isSecretManager = currentProject.type === ProjectType.SecretManager;
|
||||
|
||||
return (
|
||||
<div className="container mx-auto flex flex-col justify-between bg-bunker-800 text-white">
|
||||
|
||||
+5
-5
@@ -6,7 +6,7 @@ import { z } from "zod";
|
||||
|
||||
import { createNotification } from "@app/components/notifications";
|
||||
import { Button, FilterableSelect, FormControl, Modal, ModalContent } from "@app/components/v2";
|
||||
import { useOrganization, useWorkspace } from "@app/context";
|
||||
import { useOrganization, useProject } from "@app/context";
|
||||
import {
|
||||
useAddGroupToWorkspace,
|
||||
useGetOrganizationGroups,
|
||||
@@ -31,14 +31,14 @@ type Props = {
|
||||
|
||||
const Content = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
const { currentOrg } = useOrganization();
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
|
||||
const orgId = currentOrg?.id || "";
|
||||
|
||||
const { data: groups } = useGetOrganizationGroups(orgId);
|
||||
const { data: groupMemberships } = useListWorkspaceGroups(currentWorkspace?.id || "");
|
||||
const { data: groupMemberships } = useListWorkspaceGroups(currentProject?.id || "");
|
||||
|
||||
const { data: roles } = useGetProjectRoles(currentWorkspace?.id || "");
|
||||
const { data: roles } = useGetProjectRoles(currentProject?.id || "");
|
||||
|
||||
const { mutateAsync: addGroupToWorkspaceMutateAsync } = useAddGroupToWorkspace();
|
||||
|
||||
@@ -64,7 +64,7 @@ const Content = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
const onFormSubmit = async ({ group, role }: FormData) => {
|
||||
try {
|
||||
await addGroupToWorkspaceMutateAsync({
|
||||
projectId: currentWorkspace?.id || "",
|
||||
projectId: currentProject?.id || "",
|
||||
groupId: group.id,
|
||||
role: role.slug || undefined
|
||||
});
|
||||
|
||||
+6
-6
@@ -24,13 +24,13 @@ import {
|
||||
Tag,
|
||||
Tooltip
|
||||
} from "@app/components/v2";
|
||||
import { useWorkspace } from "@app/context";
|
||||
import { useProject } from "@app/context";
|
||||
import { formatProjectRoleName } from "@app/helpers/roles";
|
||||
import { usePopUp } from "@app/hooks";
|
||||
import { useGetProjectRoles, useUpdateGroupWorkspaceRole } from "@app/hooks/api";
|
||||
import { TGroupMembership } from "@app/hooks/api/groups/types";
|
||||
import { ProjectUserMembershipTemporaryMode } from "@app/hooks/api/projects/types";
|
||||
import { TProjectRole } from "@app/hooks/api/roles/types";
|
||||
import { ProjectUserMembershipTemporaryMode } from "@app/hooks/api/workspace/types";
|
||||
import { groupBy } from "@app/lib/fn/array";
|
||||
|
||||
const temporaryRoleFormSchema = z.object({
|
||||
@@ -213,7 +213,7 @@ type FormProps = {
|
||||
};
|
||||
|
||||
const GroupRolesForm = ({ projectRoles, roles, groupId, onClose }: FormProps) => {
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
|
||||
const [searchRoles, setSearchRoles] = useState("");
|
||||
|
||||
@@ -255,7 +255,7 @@ const GroupRolesForm = ({ projectRoles, roles, groupId, onClose }: FormProps) =>
|
||||
|
||||
try {
|
||||
await updateGroupWorkspaceRole.mutateAsync({
|
||||
projectId: currentWorkspace?.id || "",
|
||||
projectId: currentProject?.id || "",
|
||||
groupId,
|
||||
roles: selectedRoles
|
||||
});
|
||||
@@ -373,11 +373,11 @@ export const GroupRoles = ({
|
||||
className,
|
||||
popperContentProps
|
||||
}: TMemberRolesProp) => {
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
const { popUp, handlePopUpToggle } = usePopUp(["editRole"] as const);
|
||||
|
||||
const { data: projectRoles, isPending: isRolesLoading } = useGetProjectRoles(
|
||||
currentWorkspace?.id ?? ""
|
||||
currentProject?.id ?? ""
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
+4
-4
@@ -8,8 +8,8 @@ import { Button, DeleteActionModal } from "@app/components/v2";
|
||||
import {
|
||||
ProjectPermissionActions,
|
||||
ProjectPermissionSub,
|
||||
useSubscription,
|
||||
useWorkspace
|
||||
useProject,
|
||||
useSubscription
|
||||
} from "@app/context";
|
||||
import { usePopUp } from "@app/hooks";
|
||||
import { useDeleteGroupFromWorkspace } from "@app/hooks/api";
|
||||
@@ -19,7 +19,7 @@ import { GroupTable } from "./GroupsTable";
|
||||
|
||||
export const GroupsSection = () => {
|
||||
const { subscription } = useSubscription();
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
|
||||
const { mutateAsync: deleteMutateAsync } = useDeleteGroupFromWorkspace();
|
||||
|
||||
@@ -44,7 +44,7 @@ export const GroupsSection = () => {
|
||||
try {
|
||||
await deleteMutateAsync({
|
||||
groupId,
|
||||
projectId: currentWorkspace?.id || ""
|
||||
projectId: currentProject?.id || ""
|
||||
});
|
||||
|
||||
createNotification({
|
||||
|
||||
+7
-7
@@ -32,7 +32,7 @@ import {
|
||||
Tooltip,
|
||||
Tr
|
||||
} from "@app/components/v2";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
|
||||
import { getProjectBaseURL } from "@app/helpers/project";
|
||||
import {
|
||||
getUserTablePreference,
|
||||
@@ -61,7 +61,7 @@ enum GroupsOrderBy {
|
||||
}
|
||||
|
||||
export const GroupTable = ({ handlePopUpOpen }: Props) => {
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const {
|
||||
@@ -85,7 +85,7 @@ export const GroupTable = ({ handlePopUpOpen }: Props) => {
|
||||
};
|
||||
|
||||
const { data: groupMemberships = [], isPending } = useListWorkspaceGroups(
|
||||
currentWorkspace?.id || ""
|
||||
currentProject?.id || ""
|
||||
);
|
||||
|
||||
const filteredGroupMemberships = useMemo(() => {
|
||||
@@ -159,9 +159,9 @@ export const GroupTable = ({ handlePopUpOpen }: Props) => {
|
||||
onKeyDown={(evt) => {
|
||||
if (evt.key === "Enter") {
|
||||
navigate({
|
||||
to: `${getProjectBaseURL(currentWorkspace.type)}/groups/$groupId` as const,
|
||||
to: `${getProjectBaseURL(currentProject.type)}/groups/$groupId` as const,
|
||||
params: {
|
||||
projectId: currentWorkspace.id,
|
||||
projectId: currentProject.id,
|
||||
groupId: id
|
||||
}
|
||||
});
|
||||
@@ -169,9 +169,9 @@ export const GroupTable = ({ handlePopUpOpen }: Props) => {
|
||||
}}
|
||||
onClick={() =>
|
||||
navigate({
|
||||
to: `${getProjectBaseURL(currentWorkspace.type)}/groups/$groupId` as const,
|
||||
to: `${getProjectBaseURL(currentProject.type)}/groups/$groupId` as const,
|
||||
params: {
|
||||
projectId: currentWorkspace.id,
|
||||
projectId: currentProject.id,
|
||||
groupId: id
|
||||
}
|
||||
})
|
||||
|
||||
+9
-11
@@ -45,7 +45,7 @@ import {
|
||||
Tooltip,
|
||||
Tr
|
||||
} from "@app/components/v2";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
|
||||
import { getProjectBaseURL } from "@app/helpers/project";
|
||||
import { formatProjectRoleName } from "@app/helpers/roles";
|
||||
import {
|
||||
@@ -57,7 +57,7 @@ import { withProjectPermission } from "@app/hoc";
|
||||
import { usePagination, useResetPageHelper } from "@app/hooks";
|
||||
import { useDeleteIdentityFromWorkspace, useGetWorkspaceIdentityMemberships } from "@app/hooks/api";
|
||||
import { OrderByDirection } from "@app/hooks/api/generic/types";
|
||||
import { ProjectIdentityOrderBy } from "@app/hooks/api/workspace/types";
|
||||
import { ProjectIdentityOrderBy } from "@app/hooks/api/projects/types";
|
||||
import { usePopUp } from "@app/hooks/usePopUp";
|
||||
|
||||
import { IdentityModal } from "./components/IdentityModal";
|
||||
@@ -66,7 +66,7 @@ const MAX_ROLES_TO_BE_SHOWN_IN_TABLE = 2;
|
||||
|
||||
export const IdentityTab = withProjectPermission(
|
||||
() => {
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject, projectId } = useProject();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const {
|
||||
@@ -92,11 +92,9 @@ export const IdentityTab = withProjectPermission(
|
||||
setUserTablePreference("projectIdentityTable", PreferenceKey.PerPage, newPerPage);
|
||||
};
|
||||
|
||||
const workspaceId = currentWorkspace?.id ?? "";
|
||||
|
||||
const { data, isPending, isFetching } = useGetWorkspaceIdentityMemberships(
|
||||
{
|
||||
workspaceId: currentWorkspace?.id || "",
|
||||
projectId,
|
||||
offset,
|
||||
limit,
|
||||
orderDirection,
|
||||
@@ -126,7 +124,7 @@ export const IdentityTab = withProjectPermission(
|
||||
try {
|
||||
await deleteMutateAsync({
|
||||
identityId,
|
||||
workspaceId
|
||||
projectId
|
||||
});
|
||||
|
||||
createNotification({
|
||||
@@ -261,9 +259,9 @@ export const IdentityTab = withProjectPermission(
|
||||
onKeyDown={(evt) => {
|
||||
if (evt.key === "Enter") {
|
||||
navigate({
|
||||
to: `${getProjectBaseURL(currentWorkspace.type)}/identities/$identityId` as const,
|
||||
to: `${getProjectBaseURL(currentProject.type)}/identities/$identityId` as const,
|
||||
params: {
|
||||
projectId: currentWorkspace.id,
|
||||
projectId: currentProject.id,
|
||||
identityId: id
|
||||
}
|
||||
});
|
||||
@@ -271,9 +269,9 @@ export const IdentityTab = withProjectPermission(
|
||||
}}
|
||||
onClick={() =>
|
||||
navigate({
|
||||
to: `${getProjectBaseURL(currentWorkspace.type)}/identities/$identityId` as const,
|
||||
to: `${getProjectBaseURL(currentProject.type)}/identities/$identityId` as const,
|
||||
params: {
|
||||
projectId: currentWorkspace.id,
|
||||
projectId: currentProject.id,
|
||||
identityId: id
|
||||
}
|
||||
})
|
||||
|
||||
+5
-6
@@ -14,7 +14,7 @@ import {
|
||||
ModalContent,
|
||||
Spinner
|
||||
} from "@app/components/v2";
|
||||
import { useOrganization, useWorkspace } from "@app/context";
|
||||
import { useOrganization, useProject } from "@app/context";
|
||||
import {
|
||||
useAddIdentityToWorkspace,
|
||||
useGetIdentityMembershipOrgs,
|
||||
@@ -37,10 +37,9 @@ type Props = {
|
||||
|
||||
const Content = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
const { currentOrg } = useOrganization();
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { projectId } = useProject();
|
||||
|
||||
const organizationId = currentOrg?.id || "";
|
||||
const workspaceId = currentWorkspace?.id || "";
|
||||
|
||||
const { data: identityMembershipOrgsData, isPending: isMembershipsLoading } =
|
||||
useGetIdentityMembershipOrgs({
|
||||
@@ -49,12 +48,12 @@ const Content = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
});
|
||||
const identityMembershipOrgs = identityMembershipOrgsData?.identityMemberships;
|
||||
const { data: identityMembershipsData } = useGetWorkspaceIdentityMemberships({
|
||||
workspaceId,
|
||||
projectId,
|
||||
limit: 20000 // TODO: this is temp to preserve functionality for larger projects, will optimize in PR referenced above
|
||||
});
|
||||
const identityMemberships = identityMembershipsData?.identityMemberships;
|
||||
|
||||
const { data: roles, isPending: isRolesLoading } = useGetProjectRoles(workspaceId);
|
||||
const { data: roles, isPending: isRolesLoading } = useGetProjectRoles(projectId);
|
||||
|
||||
const { mutateAsync: addIdentityToWorkspaceMutateAsync } = useAddIdentityToWorkspace();
|
||||
|
||||
@@ -80,7 +79,7 @@ const Content = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
const onFormSubmit = async ({ identity, role }: FormData) => {
|
||||
try {
|
||||
await addIdentityToWorkspaceMutateAsync({
|
||||
workspaceId,
|
||||
projectId,
|
||||
identityId: identity.id,
|
||||
role: role.slug || undefined
|
||||
});
|
||||
|
||||
+10
-10
@@ -22,7 +22,7 @@ import {
|
||||
OrgPermissionSubjects,
|
||||
useOrganization,
|
||||
useOrgPermission,
|
||||
useWorkspace
|
||||
useProject
|
||||
} from "@app/context";
|
||||
import {
|
||||
useAddUsersToOrg,
|
||||
@@ -30,8 +30,8 @@ import {
|
||||
useGetProjectRoles,
|
||||
useGetWorkspaceUsers
|
||||
} from "@app/hooks/api";
|
||||
import { ProjectVersion } from "@app/hooks/api/projects/types";
|
||||
import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
|
||||
import { ProjectVersion } from "@app/hooks/api/workspace/types";
|
||||
import { UsePopUpState } from "@app/hooks/usePopUp";
|
||||
|
||||
const addMemberFormSchema = z.object({
|
||||
@@ -57,7 +57,7 @@ type Props = {
|
||||
export const AddMemberModal = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
const { t } = useTranslation();
|
||||
const { currentOrg } = useOrganization();
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
const navigate = useNavigate({ from: "" });
|
||||
const { permission } = useOrgPermission();
|
||||
const requesterEmail = useSearch({
|
||||
@@ -66,12 +66,12 @@ export const AddMemberModal = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
});
|
||||
|
||||
const orgId = currentOrg?.id || "";
|
||||
const workspaceId = currentWorkspace?.id || "";
|
||||
const projectId = currentProject?.id || "";
|
||||
|
||||
const { data: members } = useGetWorkspaceUsers(workspaceId);
|
||||
const { data: members } = useGetWorkspaceUsers(projectId);
|
||||
const { data: orgUsers } = useGetOrgUsers(orgId);
|
||||
|
||||
const { data: roles } = useGetProjectRoles(currentWorkspace?.id || "");
|
||||
const { data: roles } = useGetProjectRoles(currentProject?.id || "");
|
||||
|
||||
const {
|
||||
control,
|
||||
@@ -94,7 +94,7 @@ export const AddMemberModal = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
}, [requesterEmail]);
|
||||
|
||||
const onAddMembers = async ({ orgMemberships, projectRoleSlugs }: TAddMemberForm) => {
|
||||
if (!currentWorkspace) return;
|
||||
if (!currentProject) return;
|
||||
if (!currentOrg?.id) return;
|
||||
|
||||
const existingMembers = orgMemberships.filter((membership) => !membership.isNewInvitee);
|
||||
@@ -109,7 +109,7 @@ export const AddMemberModal = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
if (!selectedMembers) return;
|
||||
|
||||
try {
|
||||
if (currentWorkspace.version === ProjectVersion.V1) {
|
||||
if (currentProject.version === ProjectVersion.V1) {
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: "Please upgrade your project to invite new members to the project."
|
||||
@@ -146,8 +146,8 @@ export const AddMemberModal = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
organizationRoleSlug: ProjectMembershipRole.Member, // only applies to new invites
|
||||
projects: [
|
||||
{
|
||||
slug: currentWorkspace.slug,
|
||||
id: currentWorkspace.id,
|
||||
slug: currentProject.slug,
|
||||
id: currentProject.id,
|
||||
projectRoleSlug: projectRoleSlugs.map((role) => role.slug)
|
||||
}
|
||||
]
|
||||
|
||||
+6
-7
@@ -29,14 +29,14 @@ import {
|
||||
ProjectPermissionActions,
|
||||
ProjectPermissionMemberActions,
|
||||
ProjectPermissionSub,
|
||||
useProject,
|
||||
useProjectPermission,
|
||||
useSubscription,
|
||||
useWorkspace
|
||||
useSubscription
|
||||
} from "@app/context";
|
||||
import { useGetProjectRoles, useUpdateUserWorkspaceRole } from "@app/hooks/api";
|
||||
import { ProjectUserMembershipTemporaryMode } from "@app/hooks/api/projects/types";
|
||||
import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
|
||||
import { TWorkspaceUser } from "@app/hooks/api/types";
|
||||
import { ProjectUserMembershipTemporaryMode } from "@app/hooks/api/workspace/types";
|
||||
|
||||
const roleFormSchema = z.object({
|
||||
roles: z
|
||||
@@ -64,9 +64,8 @@ type Props = {
|
||||
};
|
||||
export const MemberRbacSection = ({ projectMember, onOpenUpgradeModal }: Props) => {
|
||||
const { subscription } = useSubscription();
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const workspaceId = currentWorkspace?.id || "";
|
||||
const { data: projectRoles, isPending: isRolesLoading } = useGetProjectRoles(workspaceId);
|
||||
const { projectId } = useProject();
|
||||
const { data: projectRoles, isPending: isRolesLoading } = useGetProjectRoles(projectId);
|
||||
const { permission } = useProjectPermission();
|
||||
const isMemberEditDisabled = permission.cannot(
|
||||
ProjectPermissionMemberActions.Edit,
|
||||
@@ -130,7 +129,7 @@ export const MemberRbacSection = ({ projectMember, onOpenUpgradeModal }: Props)
|
||||
|
||||
try {
|
||||
await updateMembershipRole.mutateAsync({
|
||||
workspaceId,
|
||||
projectId,
|
||||
membershipId: projectMember.id,
|
||||
roles: sanitizedRoles
|
||||
});
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
import { Link } from "@tanstack/react-router";
|
||||
|
||||
import { Alert, AlertDescription } from "@app/components/v2";
|
||||
import { useWorkspace } from "@app/context";
|
||||
import { useProject } from "@app/context";
|
||||
import { getProjectBaseURL } from "@app/helpers/project";
|
||||
import { TWorkspaceUser } from "@app/hooks/api/types";
|
||||
|
||||
@@ -12,7 +12,7 @@ type Props = {
|
||||
onOpenUpgradeModal: (title: string) => void;
|
||||
};
|
||||
export const MemberRoleForm = ({ projectMember, onOpenUpgradeModal }: Props) => {
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
return (
|
||||
<div>
|
||||
<MemberRbacSection projectMember={projectMember} onOpenUpgradeModal={onOpenUpgradeModal} />
|
||||
@@ -22,9 +22,9 @@ export const MemberRoleForm = ({ projectMember, onOpenUpgradeModal }: Props) =>
|
||||
>
|
||||
<AlertDescription>
|
||||
<Link
|
||||
to={`${getProjectBaseURL(currentWorkspace.type)}/members/$membershipId` as const}
|
||||
to={`${getProjectBaseURL(currentProject.type)}/members/$membershipId` as const}
|
||||
params={{
|
||||
projectId: currentWorkspace.id,
|
||||
projectId: currentProject.id,
|
||||
membershipId: projectMember.id
|
||||
}}
|
||||
>
|
||||
|
||||
+7
-7
@@ -43,8 +43,8 @@ import {
|
||||
ProjectPermissionActions,
|
||||
ProjectPermissionMemberActions,
|
||||
ProjectPermissionSub,
|
||||
useProjectPermission,
|
||||
useWorkspace
|
||||
useProject,
|
||||
useProjectPermission
|
||||
} from "@app/context";
|
||||
import { removeTrailingSlash } from "@app/helpers/string";
|
||||
import { usePopUp } from "@app/hooks";
|
||||
@@ -89,7 +89,7 @@ export const SpecificPrivilegeSecretForm = ({
|
||||
secretPath?: string;
|
||||
onClose?: () => void;
|
||||
}) => {
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
|
||||
const { popUp, handlePopUpOpen, handlePopUpToggle, handlePopUpClose } = usePopUp([
|
||||
"deletePrivilege",
|
||||
@@ -129,7 +129,7 @@ export const SpecificPrivilegeSecretForm = ({
|
||||
temporaryAccess: privilege
|
||||
}
|
||||
: {
|
||||
environmentSlug: currentWorkspace.environments?.[0]?.slug,
|
||||
environmentSlug: currentProject.environments?.[0]?.slug,
|
||||
secretPath: initialSecretPath,
|
||||
read: selectedActions.includes(ProjectPermissionActions.Read),
|
||||
edit: selectedActions.includes(ProjectPermissionActions.Edit),
|
||||
@@ -202,7 +202,7 @@ export const SpecificPrivilegeSecretForm = ({
|
||||
// This is used for requesting access additional privileges, not directly creating a privilege!
|
||||
const handleRequestAccess = async (data: TSecretPermissionForm) => {
|
||||
if (!policies) return;
|
||||
if (!currentWorkspace) {
|
||||
if (!currentProject) {
|
||||
createNotification({
|
||||
type: "error",
|
||||
text: "No workspace found.",
|
||||
@@ -253,7 +253,7 @@ export const SpecificPrivilegeSecretForm = ({
|
||||
...(data.temporaryAccess.isTemporary && {
|
||||
temporaryRange: data.temporaryAccess.temporaryRange
|
||||
}),
|
||||
projectSlug: currentWorkspace.slug,
|
||||
projectSlug: currentProject.slug,
|
||||
isTemporary: data.temporaryAccess.isTemporary,
|
||||
permissions: actions
|
||||
.filter(({ allowed }) => allowed)
|
||||
@@ -307,7 +307,7 @@ export const SpecificPrivilegeSecretForm = ({
|
||||
position="popper"
|
||||
dropdownContainerClassName="max-w-none"
|
||||
>
|
||||
{currentWorkspace?.environments?.map(({ slug, id, name }) => (
|
||||
{currentProject?.environments?.map(({ slug, id, name }) => (
|
||||
<SelectItem value={slug} key={id}>
|
||||
{name}
|
||||
</SelectItem>
|
||||
|
||||
+4
-4
@@ -9,7 +9,7 @@ import {
|
||||
ProjectPermissionActions,
|
||||
ProjectPermissionSub,
|
||||
useOrganization,
|
||||
useWorkspace
|
||||
useProject
|
||||
} from "@app/context";
|
||||
import { usePopUp } from "@app/hooks";
|
||||
import { useDeleteUserFromWorkspace } from "@app/hooks/api";
|
||||
@@ -19,7 +19,7 @@ import { MembersTable } from "./MembersTable";
|
||||
|
||||
export const MembersSection = () => {
|
||||
const { currentOrg } = useOrganization();
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
|
||||
const { mutateAsync: removeUserFromWorkspace } = useDeleteUserFromWorkspace();
|
||||
|
||||
@@ -32,11 +32,11 @@ export const MembersSection = () => {
|
||||
const handleRemoveUser = async () => {
|
||||
const username = (popUp?.removeMember?.data as { username: string })?.username;
|
||||
if (!currentOrg?.id) return;
|
||||
if (!currentWorkspace?.id) return;
|
||||
if (!currentProject?.id) return;
|
||||
|
||||
try {
|
||||
await removeUserFromWorkspace({
|
||||
workspaceId: currentWorkspace.id,
|
||||
projectId: currentProject.id,
|
||||
usernames: [username],
|
||||
orgId: currentOrg.id
|
||||
});
|
||||
|
||||
+9
-14
@@ -44,12 +44,7 @@ import {
|
||||
Tooltip,
|
||||
Tr
|
||||
} from "@app/components/v2";
|
||||
import {
|
||||
ProjectPermissionActions,
|
||||
ProjectPermissionSub,
|
||||
useUser,
|
||||
useWorkspace
|
||||
} from "@app/context";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useProject, useUser } from "@app/context";
|
||||
import { getProjectBaseURL } from "@app/helpers/project";
|
||||
import { formatProjectRoleName } from "@app/helpers/roles";
|
||||
import {
|
||||
@@ -81,7 +76,7 @@ type Filter = {
|
||||
};
|
||||
|
||||
export const MembersTable = ({ handlePopUpOpen }: Props) => {
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
const { user } = useUser();
|
||||
const navigate = useNavigate();
|
||||
const [filter, setFilter] = useState<Filter>({
|
||||
@@ -90,8 +85,8 @@ export const MembersTable = ({ handlePopUpOpen }: Props) => {
|
||||
const filterRoles = useMemo(() => filter.roles, [filter.roles]);
|
||||
|
||||
const userId = user?.id || "";
|
||||
const workspaceId = currentWorkspace?.id || "";
|
||||
const { data: projectRoles } = useGetProjectRoles(workspaceId);
|
||||
const projectId = currentProject?.id || "";
|
||||
const { data: projectRoles } = useGetProjectRoles(projectId);
|
||||
|
||||
const {
|
||||
search,
|
||||
@@ -116,7 +111,7 @@ export const MembersTable = ({ handlePopUpOpen }: Props) => {
|
||||
};
|
||||
|
||||
const { data: members = [], isPending: isMembersLoading } = useGetWorkspaceUsers(
|
||||
workspaceId,
|
||||
projectId,
|
||||
undefined,
|
||||
filterRoles
|
||||
);
|
||||
@@ -312,9 +307,9 @@ export const MembersTable = ({ handlePopUpOpen }: Props) => {
|
||||
onKeyDown={(evt) => {
|
||||
if (evt.key === "Enter") {
|
||||
navigate({
|
||||
to: `${getProjectBaseURL(currentWorkspace.type)}/members/$membershipId`,
|
||||
to: `${getProjectBaseURL(currentProject.type)}/members/$membershipId`,
|
||||
params: {
|
||||
projectId: workspaceId,
|
||||
projectId,
|
||||
membershipId
|
||||
}
|
||||
});
|
||||
@@ -322,9 +317,9 @@ export const MembersTable = ({ handlePopUpOpen }: Props) => {
|
||||
}}
|
||||
onClick={() =>
|
||||
navigate({
|
||||
to: `${getProjectBaseURL(currentWorkspace.type)}/members/$membershipId`,
|
||||
to: `${getProjectBaseURL(currentProject.type)}/members/$membershipId`,
|
||||
params: {
|
||||
projectId: workspaceId,
|
||||
projectId,
|
||||
membershipId
|
||||
}
|
||||
})
|
||||
|
||||
+7
-7
@@ -39,7 +39,7 @@ import {
|
||||
Tooltip,
|
||||
Tr
|
||||
} from "@app/components/v2";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
|
||||
import { getProjectBaseURL } from "@app/helpers/project";
|
||||
import { isCustomProjectRole } from "@app/helpers/roles";
|
||||
import {
|
||||
@@ -67,8 +67,8 @@ export const ProjectRoleList = () => {
|
||||
"deleteRole",
|
||||
"duplicateRole"
|
||||
] as const);
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const projectId = currentWorkspace?.id || "";
|
||||
const { currentProject } = useProject();
|
||||
const projectId = currentProject?.id || "";
|
||||
|
||||
const { data: roles, isPending: isRolesLoading } = useGetProjectRoles(projectId);
|
||||
|
||||
@@ -250,9 +250,9 @@ export const ProjectRoleList = () => {
|
||||
className="h-10 cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700"
|
||||
onClick={() =>
|
||||
navigate({
|
||||
to: `${getProjectBaseURL(currentWorkspace.type)}/roles/$roleSlug`,
|
||||
to: `${getProjectBaseURL(currentProject.type)}/roles/$roleSlug`,
|
||||
params: {
|
||||
projectId: currentWorkspace.id,
|
||||
projectId: currentProject.id,
|
||||
roleSlug: slug
|
||||
}
|
||||
})
|
||||
@@ -292,9 +292,9 @@ export const ProjectRoleList = () => {
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
navigate({
|
||||
to: `${getProjectBaseURL(currentWorkspace.type)}/roles/$roleSlug`,
|
||||
to: `${getProjectBaseURL(currentProject.type)}/roles/$roleSlug`,
|
||||
params: {
|
||||
projectId: currentWorkspace.id,
|
||||
projectId: currentProject.id,
|
||||
roleSlug: slug
|
||||
}
|
||||
});
|
||||
|
||||
+10
-10
@@ -22,7 +22,7 @@ import {
|
||||
Select,
|
||||
SelectItem
|
||||
} from "@app/components/v2";
|
||||
import { useWorkspace } from "@app/context";
|
||||
import { useProject } from "@app/context";
|
||||
import { useToggle } from "@app/hooks";
|
||||
import { useCreateServiceToken } from "@app/hooks/api";
|
||||
import { UsePopUpState } from "@app/hooks/usePopUp";
|
||||
@@ -70,7 +70,7 @@ type Props = {
|
||||
const ServiceTokenForm = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
@@ -81,7 +81,7 @@ const ServiceTokenForm = () => {
|
||||
scopes: [
|
||||
{
|
||||
secretPath: "/",
|
||||
environment: currentWorkspace?.environments?.[0]?.slug
|
||||
environment: currentProject?.environments?.[0]?.slug
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -111,7 +111,7 @@ const ServiceTokenForm = () => {
|
||||
|
||||
const onFormSubmit = async ({ name, scopes, expiresIn, permissions }: FormData) => {
|
||||
try {
|
||||
if (!currentWorkspace?.id) return;
|
||||
if (!currentProject?.id) return;
|
||||
|
||||
const randomBytes = crypto.randomBytes(16).toString("hex");
|
||||
|
||||
@@ -122,7 +122,7 @@ const ServiceTokenForm = () => {
|
||||
scopes,
|
||||
expiresIn: Number(expiresIn),
|
||||
name,
|
||||
workspaceId: currentWorkspace.id,
|
||||
workspaceId: currentProject.id,
|
||||
randomBytes,
|
||||
permissions: Object.entries(permissions)
|
||||
.filter(([, permissionsValue]) => permissionsValue)
|
||||
@@ -172,7 +172,7 @@ const ServiceTokenForm = () => {
|
||||
<Controller
|
||||
control={control}
|
||||
name={`scopes.${index}.environment`}
|
||||
defaultValue={currentWorkspace?.environments?.[0]?.slug}
|
||||
defaultValue={currentProject?.environments?.[0]?.slug}
|
||||
render={({ field: { onChange, ...field }, fieldState: { error } }) => (
|
||||
<FormControl
|
||||
className="mb-0"
|
||||
@@ -186,7 +186,7 @@ const ServiceTokenForm = () => {
|
||||
onValueChange={(e) => onChange(e)}
|
||||
className="w-full"
|
||||
>
|
||||
{currentWorkspace?.environments.map(({ name, slug }) => (
|
||||
{currentProject?.environments.map(({ name, slug }) => (
|
||||
<SelectItem value={slug} key={slug}>
|
||||
{name}
|
||||
</SelectItem>
|
||||
@@ -225,7 +225,7 @@ const ServiceTokenForm = () => {
|
||||
variant="outline_bg"
|
||||
onClick={() =>
|
||||
append({
|
||||
environment: currentWorkspace?.environments?.[0]?.slug || "",
|
||||
environment: currentProject?.environments?.[0]?.slug || "",
|
||||
secretPath: ""
|
||||
})
|
||||
}
|
||||
@@ -334,7 +334,7 @@ const ServiceTokenForm = () => {
|
||||
export const AddServiceTokenModal = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
|
||||
return (
|
||||
<Modal
|
||||
@@ -346,7 +346,7 @@ export const AddServiceTokenModal = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
<ModalContent
|
||||
title={
|
||||
t("section.token.add-dialog.title", {
|
||||
target: currentWorkspace?.name
|
||||
target: currentProject?.name
|
||||
}) as string
|
||||
}
|
||||
subTitle={t("section.token.add-dialog.description") as string}
|
||||
|
||||
+3
-3
@@ -33,7 +33,7 @@ import {
|
||||
Tooltip,
|
||||
Tr
|
||||
} from "@app/components/v2";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
|
||||
import {
|
||||
getUserTablePreference,
|
||||
PreferenceKey,
|
||||
@@ -63,9 +63,9 @@ enum TokensOrderBy {
|
||||
}
|
||||
|
||||
export const ServiceTokenTable = ({ handlePopUpOpen }: Props) => {
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
const { data, isPending } = useGetUserWsServiceTokens({
|
||||
workspaceID: currentWorkspace?.id || ""
|
||||
workspaceID: currentProject?.id || ""
|
||||
});
|
||||
|
||||
const {
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Helmet } from "react-helmet";
|
||||
|
||||
import { PageHeader } from "@app/components/v2";
|
||||
import { useProject } from "@app/context";
|
||||
import {
|
||||
ProjectPermissionAppConnectionActions,
|
||||
ProjectPermissionSub
|
||||
} from "@app/context/ProjectPermissionContext/types";
|
||||
import { withProjectPermission } from "@app/hoc";
|
||||
import { AppConnectionsTable } from "@app/pages/organization/AppConnections/AppConnectionsPage/components";
|
||||
|
||||
export const AppConnectionsPage = withProjectPermission(
|
||||
() => {
|
||||
const { currentProject } = useProject();
|
||||
|
||||
return (
|
||||
<div className="bg-bunker-800">
|
||||
<Helmet>
|
||||
<title>Infisical | App Connections</title>
|
||||
<link rel="icon" href="/infisical.ico" />
|
||||
<meta property="og:image" content="/images/message.png" />
|
||||
</Helmet>
|
||||
<div className="flex w-full justify-center bg-bunker-800 text-white">
|
||||
<div className="w-full max-w-7xl">
|
||||
<PageHeader
|
||||
className="w-full"
|
||||
title="App Connections"
|
||||
description="Manage project App Connections"
|
||||
/>
|
||||
|
||||
<AppConnectionsTable projectId={currentProject.id} projectType={currentProject.type} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
{
|
||||
action: ProjectPermissionAppConnectionActions.Read,
|
||||
subject: ProjectPermissionSub.AppConnections
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,19 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
import { AppConnectionsPage } from "./AppConnectionsPage";
|
||||
|
||||
export const Route = createFileRoute(
|
||||
"/_authenticate/_inject-org-details/_org-layout/projects/cert-management/$projectId/_cert-manager-layout/app-connections"
|
||||
)({
|
||||
component: AppConnectionsPage,
|
||||
beforeLoad: ({ context }) => {
|
||||
return {
|
||||
breadcrumbs: [
|
||||
...context.breadcrumbs,
|
||||
{
|
||||
label: "App Connections"
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
import { AppConnectionsPage } from "./AppConnectionsPage";
|
||||
|
||||
export const Route = createFileRoute(
|
||||
"/_authenticate/_inject-org-details/_org-layout/projects/secret-management/$projectId/_secret-manager-layout/app-connections"
|
||||
)({
|
||||
component: AppConnectionsPage,
|
||||
beforeLoad: ({ context }) => {
|
||||
return {
|
||||
breadcrumbs: [
|
||||
...context.breadcrumbs,
|
||||
{
|
||||
label: "App Connections"
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
import { AppConnectionsPage } from "./AppConnectionsPage";
|
||||
|
||||
export const Route = createFileRoute(
|
||||
"/_authenticate/_inject-org-details/_org-layout/projects/secret-scanning/$projectId/_secret-scanning-layout/app-connections"
|
||||
)({
|
||||
component: AppConnectionsPage,
|
||||
beforeLoad: ({ context }) => {
|
||||
return {
|
||||
breadcrumbs: [
|
||||
...context.breadcrumbs,
|
||||
{
|
||||
label: "App Connections"
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Helmet } from "react-helmet";
|
||||
|
||||
import { PageHeader } from "@app/components/v2";
|
||||
import { useWorkspace } from "@app/context";
|
||||
import { useProject } from "@app/context";
|
||||
import { LogsSection } from "@app/pages/organization/AuditLogsPage/components";
|
||||
|
||||
export const AuditLogsPage = () => {
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
|
||||
return (
|
||||
<div className="container mx-auto flex flex-col justify-between bg-bunker-800 text-white">
|
||||
@@ -19,7 +19,7 @@ export const AuditLogsPage = () => {
|
||||
title="Audit logs"
|
||||
description="Audit logs for security and compliance teams to monitor information access."
|
||||
/>
|
||||
<LogsSection pageView project={currentWorkspace} />
|
||||
<LogsSection pageView project={currentProject} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,8 +4,8 @@ import { useParams } from "@tanstack/react-router";
|
||||
|
||||
import { ProjectPermissionCan } from "@app/components/permissions";
|
||||
import { EmptyState, PageHeader, Spinner } from "@app/components/v2";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
||||
import { useGetWorkspaceGroupMembershipDetails } from "@app/hooks/api/workspace/queries";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
|
||||
import { useGetWorkspaceGroupMembershipDetails } from "@app/hooks/api/projects/queries";
|
||||
|
||||
import { GroupDetailsSection } from "./components/GroupDetailsSection";
|
||||
import { GroupMembersSection } from "./components/GroupMembersSection";
|
||||
@@ -16,10 +16,10 @@ const Page = () => {
|
||||
select: (el) => el.groupId as string
|
||||
});
|
||||
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
|
||||
const { data: groupMembership, isPending } = useGetWorkspaceGroupMembershipDetails(
|
||||
currentWorkspace.id,
|
||||
currentProject.id,
|
||||
groupId
|
||||
);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
IconButton
|
||||
} from "@app/components/v2";
|
||||
import { CopyButton } from "@app/components/v2/CopyButton";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
|
||||
import { getProjectBaseURL } from "@app/helpers/project";
|
||||
import { usePopUp } from "@app/hooks";
|
||||
import { useDeleteGroupFromWorkspace } from "@app/hooks/api";
|
||||
@@ -31,14 +31,14 @@ export const GroupDetailsSection = ({ groupMembership }: Props) => {
|
||||
] as const);
|
||||
|
||||
const { mutateAsync: deleteMutateAsync } = useDeleteGroupFromWorkspace();
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const onRemoveGroupSubmit = async () => {
|
||||
try {
|
||||
await deleteMutateAsync({
|
||||
groupId: groupMembership.group.id,
|
||||
projectId: currentWorkspace.id
|
||||
projectId: currentProject.id
|
||||
});
|
||||
|
||||
createNotification({
|
||||
@@ -47,9 +47,9 @@ export const GroupDetailsSection = ({ groupMembership }: Props) => {
|
||||
});
|
||||
|
||||
navigate({
|
||||
to: `${getProjectBaseURL(currentWorkspace.type)}/access-management`,
|
||||
to: `${getProjectBaseURL(currentProject.type)}/access-management`,
|
||||
params: {
|
||||
projectId: currentWorkspace.id
|
||||
projectId: currentProject.id
|
||||
},
|
||||
search: {
|
||||
selectedTab: "groups"
|
||||
|
||||
+6
-6
@@ -23,7 +23,7 @@ import {
|
||||
THead,
|
||||
Tr
|
||||
} from "@app/components/v2";
|
||||
import { useWorkspace } from "@app/context";
|
||||
import { useProject } from "@app/context";
|
||||
import { getProjectHomePage } from "@app/helpers/project";
|
||||
import {
|
||||
getUserTablePreference,
|
||||
@@ -69,12 +69,12 @@ export const GroupMembersTable = ({ groupMembership }: Props) => {
|
||||
setUserTablePreference("projectGroupMembersTable", PreferenceKey.PerPage, newPerPage);
|
||||
};
|
||||
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
|
||||
const { data: groupMemberships, isPending } = useListProjectGroupUsers({
|
||||
id: groupMembership.group.id,
|
||||
groupSlug: groupMembership.group.slug,
|
||||
projectId: currentWorkspace.id,
|
||||
projectId: currentProject.id,
|
||||
offset,
|
||||
limit: perPage,
|
||||
search,
|
||||
@@ -127,7 +127,7 @@ export const GroupMembersTable = ({ groupMembership }: Props) => {
|
||||
{
|
||||
actorId: userId,
|
||||
actorType: ActorType.USER,
|
||||
projectId: currentWorkspace.id
|
||||
projectId: currentProject.id
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
@@ -136,8 +136,8 @@ export const GroupMembersTable = ({ groupMembership }: Props) => {
|
||||
text: "User privilege assumption has started"
|
||||
});
|
||||
|
||||
const url = getProjectHomePage(currentWorkspace.type, currentWorkspace.environments);
|
||||
window.location.href = url.replace("$projectId", currentWorkspace.id);
|
||||
const url = getProjectHomePage(currentProject.type, currentProject.environments);
|
||||
window.location.href = url.replace("$projectId", currentProject.id);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
ProjectPermissionActions,
|
||||
ProjectPermissionIdentityActions,
|
||||
ProjectPermissionSub,
|
||||
useWorkspace
|
||||
useProject
|
||||
} from "@app/context";
|
||||
import { getProjectBaseURL, getProjectHomePage } from "@app/helpers/project";
|
||||
import { usePopUp } from "@app/hooks";
|
||||
@@ -38,12 +38,10 @@ const Page = () => {
|
||||
strict: false,
|
||||
select: (el) => el.identityId as string
|
||||
});
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
|
||||
const workspaceId = currentWorkspace?.id || "";
|
||||
const { currentProject, projectId } = useProject();
|
||||
|
||||
const { data: identityMembershipDetails, isPending: isMembershipDetailsLoading } =
|
||||
useGetWorkspaceIdentityMembershipDetails(workspaceId, identityId);
|
||||
useGetWorkspaceIdentityMembershipDetails(projectId, identityId);
|
||||
|
||||
const { mutateAsync: deleteMutateAsync, isPending: isDeletingIdentity } =
|
||||
useDeleteIdentityFromWorkspace();
|
||||
@@ -59,7 +57,7 @@ const Page = () => {
|
||||
{
|
||||
actorId: identityId,
|
||||
actorType: ActorType.IDENTITY,
|
||||
projectId: workspaceId
|
||||
projectId
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
@@ -67,8 +65,8 @@ const Page = () => {
|
||||
type: "success",
|
||||
text: "Identity privilege assumption has started"
|
||||
});
|
||||
const url = getProjectHomePage(currentWorkspace.type, currentWorkspace.environments);
|
||||
window.location.href = url.replace("$projectId", currentWorkspace.id);
|
||||
const url = getProjectHomePage(currentProject.type, currentProject.environments);
|
||||
window.location.href = url.replace("$projectId", currentProject.id);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -78,7 +76,7 @@ const Page = () => {
|
||||
try {
|
||||
await deleteMutateAsync({
|
||||
identityId,
|
||||
workspaceId
|
||||
projectId
|
||||
});
|
||||
createNotification({
|
||||
text: "Successfully removed identity from project",
|
||||
@@ -86,9 +84,9 @@ const Page = () => {
|
||||
});
|
||||
handlePopUpClose("deleteIdentity");
|
||||
navigate({
|
||||
to: `${getProjectBaseURL(currentWorkspace.type)}/access-management` as const,
|
||||
to: `${getProjectBaseURL(currentProject.type)}/access-management` as const,
|
||||
params: {
|
||||
projectId: workspaceId
|
||||
projectId
|
||||
},
|
||||
search: {
|
||||
selectedTab: "identities"
|
||||
|
||||
+5
-5
@@ -24,8 +24,8 @@ import {
|
||||
import {
|
||||
ProjectPermissionIdentityActions,
|
||||
ProjectPermissionSub,
|
||||
useProjectPermission,
|
||||
useWorkspace
|
||||
useProject,
|
||||
useProjectPermission
|
||||
} from "@app/context";
|
||||
import {
|
||||
useCreateIdentityProjectAdditionalPrivilege,
|
||||
@@ -78,8 +78,8 @@ export const IdentityProjectAdditionalPrivilegeModifySection = ({
|
||||
isDisabled
|
||||
}: Props) => {
|
||||
const isCreate = !privilegeId;
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const projectId = currentWorkspace?.id || "";
|
||||
const { currentProject } = useProject();
|
||||
const projectId = currentProject?.id || "";
|
||||
const { data: privilegeDetails, isPending } = useGetIdentityProjectPrivilegeDetails({
|
||||
identityId,
|
||||
projectId,
|
||||
@@ -225,7 +225,7 @@ export const IdentityProjectAdditionalPrivilegeModifySection = ({
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
<AddPoliciesButton isDisabled={isDisabled} projectType={currentWorkspace.type} />
|
||||
<AddPoliciesButton isDisabled={isDisabled} projectType={currentProject.type} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+3
-3
@@ -23,7 +23,7 @@ import {
|
||||
Tooltip,
|
||||
Tr
|
||||
} from "@app/components/v2";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
|
||||
import { formatProjectRoleName } from "@app/helpers/roles";
|
||||
import { usePopUp } from "@app/hooks";
|
||||
import { useUpdateIdentityWorkspaceRole } from "@app/hooks/api";
|
||||
@@ -41,7 +41,7 @@ export const IdentityRoleDetailsSection = ({
|
||||
identityMembershipDetails,
|
||||
isMembershipDetailsLoading
|
||||
}: Props) => {
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
const { popUp, handlePopUpOpen, handlePopUpToggle, handlePopUpClose } = usePopUp([
|
||||
"deleteRole",
|
||||
"modifyRole"
|
||||
@@ -53,7 +53,7 @@ export const IdentityRoleDetailsSection = ({
|
||||
try {
|
||||
const updatedRoles = identityMembershipDetails?.roles?.filter((el) => el.id !== id);
|
||||
await updateIdentityWorkspaceRole({
|
||||
workspaceId: currentWorkspace?.id || "",
|
||||
projectId: currentProject?.id || "",
|
||||
identityId: identityMembershipDetails.identity.id,
|
||||
roles: updatedRoles.map(
|
||||
({
|
||||
|
||||
+6
-7
@@ -29,13 +29,13 @@ import {
|
||||
ProjectPermissionActions,
|
||||
ProjectPermissionIdentityActions,
|
||||
ProjectPermissionSub,
|
||||
useProjectPermission,
|
||||
useWorkspace
|
||||
useProject,
|
||||
useProjectPermission
|
||||
} from "@app/context";
|
||||
import { useGetProjectRoles, useUpdateIdentityWorkspaceRole } from "@app/hooks/api";
|
||||
import { IdentityMembership } from "@app/hooks/api/identities/types";
|
||||
import { ProjectUserMembershipTemporaryMode } from "@app/hooks/api/projects/types";
|
||||
import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
|
||||
import { ProjectUserMembershipTemporaryMode } from "@app/hooks/api/workspace/types";
|
||||
|
||||
const roleFormSchema = z.object({
|
||||
roles: z
|
||||
@@ -62,9 +62,8 @@ type Props = {
|
||||
};
|
||||
|
||||
export const IdentityRoleModify = ({ identityProjectMembership }: Props) => {
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const workspaceId = currentWorkspace?.id || "";
|
||||
const { data: projectRoles, isPending: isRolesLoading } = useGetProjectRoles(workspaceId);
|
||||
const { projectId } = useProject();
|
||||
const { data: projectRoles, isPending: isRolesLoading } = useGetProjectRoles(projectId);
|
||||
const { permission } = useProjectPermission();
|
||||
const isIdentityEditDisabled = permission.cannot(
|
||||
ProjectPermissionIdentityActions.Edit,
|
||||
@@ -117,7 +116,7 @@ export const IdentityRoleModify = ({ identityProjectMembership }: Props) => {
|
||||
|
||||
try {
|
||||
await updateIdentityWorkspaceRole.mutateAsync({
|
||||
workspaceId,
|
||||
projectId,
|
||||
identityId: identityProjectMembership.identity.id,
|
||||
roles: sanitizedRoles
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
ProjectPermissionMemberActions,
|
||||
ProjectPermissionSub,
|
||||
useOrganization,
|
||||
useWorkspace
|
||||
useProject
|
||||
} from "@app/context";
|
||||
import { getProjectBaseURL, getProjectHomePage } from "@app/helpers/project";
|
||||
import { usePopUp } from "@app/hooks";
|
||||
@@ -40,12 +40,10 @@ export const Page = () => {
|
||||
select: (el) => el.membershipId as string
|
||||
});
|
||||
const { currentOrg } = useOrganization();
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
|
||||
const workspaceId = currentWorkspace?.id || "";
|
||||
const { currentProject, projectId } = useProject();
|
||||
|
||||
const { data: membershipDetails, isPending: isMembershipDetailsLoading } =
|
||||
useGetWorkspaceUserDetails(workspaceId, membershipId);
|
||||
useGetWorkspaceUserDetails(projectId, membershipId);
|
||||
|
||||
const { mutateAsync: removeUserFromWorkspace, isPending: isRemovingUserFromWorkspace } =
|
||||
useDeleteUserFromWorkspace();
|
||||
@@ -63,7 +61,7 @@ export const Page = () => {
|
||||
{
|
||||
actorId: userId,
|
||||
actorType: ActorType.USER,
|
||||
projectId: workspaceId
|
||||
projectId
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
@@ -72,19 +70,19 @@ export const Page = () => {
|
||||
text: "User privilege assumption has started"
|
||||
});
|
||||
|
||||
const url = getProjectHomePage(currentWorkspace.type, currentWorkspace.environments);
|
||||
window.location.href = url.replace("$projectId", currentWorkspace.id);
|
||||
const url = getProjectHomePage(currentProject.type, currentProject.environments);
|
||||
window.location.href = url.replace("$projectId", currentProject.id);
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const handleRemoveUser = async () => {
|
||||
if (!currentOrg?.id || !currentWorkspace?.id || !membershipDetails?.user?.username) return;
|
||||
if (!currentOrg?.id || !currentProject?.id || !membershipDetails?.user?.username) return;
|
||||
|
||||
try {
|
||||
await removeUserFromWorkspace({
|
||||
workspaceId: currentWorkspace.id,
|
||||
projectId,
|
||||
usernames: [membershipDetails?.user?.username],
|
||||
orgId: currentOrg.id
|
||||
});
|
||||
@@ -93,9 +91,9 @@ export const Page = () => {
|
||||
type: "success"
|
||||
});
|
||||
navigate({
|
||||
to: `${getProjectBaseURL(currentWorkspace.type)}/access-management` as const,
|
||||
to: `${getProjectBaseURL(currentProject.type)}/access-management` as const,
|
||||
params: {
|
||||
projectId: currentWorkspace.id
|
||||
projectId: currentProject.id
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
+5
-5
@@ -23,8 +23,8 @@ import {
|
||||
import {
|
||||
ProjectPermissionMemberActions,
|
||||
ProjectPermissionSub,
|
||||
useProjectPermission,
|
||||
useWorkspace
|
||||
useProject,
|
||||
useProjectPermission
|
||||
} from "@app/context";
|
||||
import {
|
||||
useCreateProjectUserAdditionalPrivilege,
|
||||
@@ -77,8 +77,8 @@ export const MembershipProjectAdditionalPrivilegeModifySection = ({
|
||||
isDisabled
|
||||
}: Props) => {
|
||||
const isCreate = !privilegeId;
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const projectId = currentWorkspace?.id || "";
|
||||
const { currentProject } = useProject();
|
||||
const projectId = currentProject?.id || "";
|
||||
const { data: privilegeDetails, isPending } = useGetProjectUserPrivilegeDetails(
|
||||
privilegeId || ""
|
||||
);
|
||||
@@ -221,7 +221,7 @@ export const MembershipProjectAdditionalPrivilegeModifySection = ({
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
<AddPoliciesButton isDisabled={isDisabled} projectType={currentWorkspace.type} />
|
||||
<AddPoliciesButton isDisabled={isDisabled} projectType={currentProject.type} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+3
-8
@@ -22,12 +22,7 @@ import {
|
||||
Tooltip,
|
||||
Tr
|
||||
} from "@app/components/v2";
|
||||
import {
|
||||
ProjectPermissionActions,
|
||||
ProjectPermissionSub,
|
||||
useUser,
|
||||
useWorkspace
|
||||
} from "@app/context";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useProject, useUser } from "@app/context";
|
||||
import { formatProjectRoleName } from "@app/helpers/roles";
|
||||
import { usePopUp } from "@app/hooks";
|
||||
import { useUpdateUserWorkspaceRole } from "@app/hooks/api";
|
||||
@@ -49,7 +44,7 @@ export const MemberRoleDetailsSection = ({
|
||||
}: Props) => {
|
||||
const { user } = useUser();
|
||||
const userId = user?.id;
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { projectId } = useProject();
|
||||
const { popUp, handlePopUpOpen, handlePopUpToggle, handlePopUpClose } = usePopUp([
|
||||
"deleteRole",
|
||||
"modifyRole"
|
||||
@@ -63,7 +58,7 @@ export const MemberRoleDetailsSection = ({
|
||||
try {
|
||||
const updatedRoles = membershipDetails?.roles?.filter((el) => el.id !== id);
|
||||
await updateUserWorkspaceRole({
|
||||
workspaceId: currentWorkspace?.id || "",
|
||||
projectId,
|
||||
roles: updatedRoles.map(
|
||||
({
|
||||
role,
|
||||
|
||||
+6
-7
@@ -29,14 +29,14 @@ import {
|
||||
ProjectPermissionActions,
|
||||
ProjectPermissionMemberActions,
|
||||
ProjectPermissionSub,
|
||||
useProject,
|
||||
useProjectPermission,
|
||||
useSubscription,
|
||||
useWorkspace
|
||||
useSubscription
|
||||
} from "@app/context";
|
||||
import { useGetProjectRoles, useUpdateUserWorkspaceRole } from "@app/hooks/api";
|
||||
import { ProjectUserMembershipTemporaryMode } from "@app/hooks/api/projects/types";
|
||||
import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
|
||||
import { TWorkspaceUser } from "@app/hooks/api/types";
|
||||
import { ProjectUserMembershipTemporaryMode } from "@app/hooks/api/workspace/types";
|
||||
|
||||
const roleFormSchema = z.object({
|
||||
roles: z
|
||||
@@ -65,9 +65,8 @@ type Props = {
|
||||
|
||||
export const MemberRoleModify = ({ projectMember, onOpenUpgradeModal }: Props) => {
|
||||
const { subscription } = useSubscription();
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const workspaceId = currentWorkspace?.id || "";
|
||||
const { data: projectRoles, isPending: isRolesLoading } = useGetProjectRoles(workspaceId);
|
||||
const { projectId } = useProject();
|
||||
const { data: projectRoles, isPending: isRolesLoading } = useGetProjectRoles(projectId);
|
||||
const { permission } = useProjectPermission();
|
||||
const isMemberEditDisabled = permission.cannot(
|
||||
ProjectPermissionMemberActions.Edit,
|
||||
@@ -131,7 +130,7 @@ export const MemberRoleModify = ({ projectMember, onOpenUpgradeModal }: Props) =
|
||||
|
||||
try {
|
||||
await updateMembershipRole.mutateAsync({
|
||||
workspaceId,
|
||||
projectId,
|
||||
membershipId: projectMember.id,
|
||||
roles: sanitizedRoles
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
DropdownMenuTrigger,
|
||||
PageHeader
|
||||
} from "@app/components/v2";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
|
||||
import { getProjectBaseURL } from "@app/helpers/project";
|
||||
import { useDeleteProjectRole, useGetProjectRoleBySlug } from "@app/hooks/api";
|
||||
import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
|
||||
@@ -33,8 +33,8 @@ const Page = () => {
|
||||
strict: false,
|
||||
select: (el) => el.roleSlug as string
|
||||
});
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const projectId = currentWorkspace?.id || "";
|
||||
const { currentProject } = useProject();
|
||||
const projectId = currentProject?.id || "";
|
||||
|
||||
const { data } = useGetProjectRoleBySlug(projectId, roleSlug as string);
|
||||
|
||||
@@ -48,7 +48,7 @@ const Page = () => {
|
||||
|
||||
const onDeleteRoleSubmit = async () => {
|
||||
try {
|
||||
if (!currentWorkspace?.slug || !data?.id) return;
|
||||
if (!currentProject?.slug || !data?.id) return;
|
||||
|
||||
await deleteProjectRole({
|
||||
projectId,
|
||||
@@ -61,7 +61,7 @@ const Page = () => {
|
||||
});
|
||||
handlePopUpClose("deleteRole");
|
||||
navigate({
|
||||
to: `${getProjectBaseURL(currentWorkspace.type)}/access-management` as const,
|
||||
to: `${getProjectBaseURL(currentProject.type)}/access-management` as const,
|
||||
params: {
|
||||
projectId
|
||||
},
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
IconButton
|
||||
} from "@app/components/v2";
|
||||
import { usePopUp } from "@app/hooks";
|
||||
import { ProjectType } from "@app/hooks/api/workspace/types";
|
||||
import { ProjectType } from "@app/hooks/api/projects/types";
|
||||
import { PolicySelectionModal } from "@app/pages/project/RoleDetailsBySlugPage/components/PolicySelectionModal";
|
||||
import { PolicyTemplateModal } from "@app/pages/project/RoleDetailsBySlugPage/components/PolicyTemplateModal";
|
||||
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import { ProjectPermissionSub } from "@app/context/ProjectPermissionContext/types";
|
||||
|
||||
import { ConditionsFields } from "./ConditionsFields";
|
||||
|
||||
type Props = {
|
||||
position?: number;
|
||||
isDisabled?: boolean;
|
||||
};
|
||||
|
||||
export const AppConnectionPermissionConditions = ({ position = 0, isDisabled }: Props) => {
|
||||
return (
|
||||
<ConditionsFields
|
||||
isDisabled={isDisabled}
|
||||
subject={ProjectPermissionSub.AppConnections}
|
||||
position={position}
|
||||
selectOptions={[{ value: "connectionId", label: "Connection ID" }]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
+7
-7
@@ -5,7 +5,7 @@ import { z } from "zod";
|
||||
|
||||
import { createNotification } from "@app/components/notifications";
|
||||
import { Button, FormControl, Input, Modal, ModalContent, Spinner } from "@app/components/v2";
|
||||
import { ProjectPermissionSub, useWorkspace } from "@app/context";
|
||||
import { ProjectPermissionSub, useProject } from "@app/context";
|
||||
import { ProjectPermissionSecretActions } from "@app/context/ProjectPermissionContext/types";
|
||||
import { getProjectBaseURL } from "@app/helpers/project";
|
||||
import { useCreateProjectRole, useGetProjectRoleBySlug } from "@app/hooks/api";
|
||||
@@ -45,7 +45,7 @@ const Content = ({ role, onClose }: ContentProps) => {
|
||||
resolver: zodResolver(schema)
|
||||
});
|
||||
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
|
||||
const createRole = useCreateProjectRole();
|
||||
const navigate = useNavigate();
|
||||
@@ -70,7 +70,7 @@ const Content = ({ role, onClose }: ContentProps) => {
|
||||
});
|
||||
|
||||
const newRole = await createRole.mutateAsync({
|
||||
projectId: currentWorkspace.id,
|
||||
projectId: currentProject.id,
|
||||
permissions: sanitizedPermission,
|
||||
...form
|
||||
});
|
||||
@@ -81,10 +81,10 @@ const Content = ({ role, onClose }: ContentProps) => {
|
||||
});
|
||||
|
||||
navigate({
|
||||
to: `${getProjectBaseURL(currentWorkspace.type)}/roles/$roleSlug` as const,
|
||||
to: `${getProjectBaseURL(currentProject.type)}/roles/$roleSlug` as const,
|
||||
params: {
|
||||
roleSlug: newRole.slug,
|
||||
projectId: currentWorkspace.id
|
||||
projectId: currentProject.id
|
||||
}
|
||||
});
|
||||
|
||||
@@ -142,9 +142,9 @@ const Content = ({ role, onClose }: ContentProps) => {
|
||||
};
|
||||
|
||||
export const DuplicateProjectRoleModal = ({ isOpen, onOpenChange, roleSlug }: Props) => {
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
|
||||
const { data: role, isPending } = useGetProjectRoleBySlug(currentWorkspace.id, roleSlug ?? "");
|
||||
const { data: role, isPending } = useGetProjectRoleBySlug(currentProject.id, roleSlug ?? "");
|
||||
|
||||
if (!roleSlug) return null;
|
||||
|
||||
|
||||
+1
@@ -23,6 +23,7 @@ export const renderOperatorSelectItems = (type: string) => {
|
||||
case "secretTags":
|
||||
return <SelectItem value={PermissionConditionOperators.$IN}>Contains</SelectItem>;
|
||||
case "identityId":
|
||||
case "connectionId":
|
||||
return (
|
||||
<>
|
||||
<SelectItem value={PermissionConditionOperators.$EQ}>Equal</SelectItem>
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import {
|
||||
Tr
|
||||
} from "@app/components/v2";
|
||||
import { ProjectPermissionSub } from "@app/context";
|
||||
import { ProjectType } from "@app/hooks/api/workspace/types";
|
||||
import { ProjectType } from "@app/hooks/api/projects/types";
|
||||
|
||||
import {
|
||||
EXCLUDED_PERMISSION_SUBS,
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
ModalContent
|
||||
} from "@app/components/v2";
|
||||
import { ProjectPermissionSub } from "@app/context";
|
||||
import { ProjectType } from "@app/hooks/api/workspace/types";
|
||||
import { ProjectType } from "@app/hooks/api/projects/types";
|
||||
|
||||
import {
|
||||
PROJECT_PERMISSION_OBJECT,
|
||||
|
||||
+78
-9
@@ -12,6 +12,7 @@ import {
|
||||
} from "@app/context";
|
||||
import {
|
||||
PermissionConditionOperators,
|
||||
ProjectPermissionAppConnectionActions,
|
||||
ProjectPermissionAuditLogsActions,
|
||||
ProjectPermissionCommitsActions,
|
||||
ProjectPermissionDynamicSecretActions,
|
||||
@@ -33,8 +34,8 @@ import {
|
||||
TPermissionCondition,
|
||||
TPermissionConditionOperators
|
||||
} from "@app/context/ProjectPermissionContext/types";
|
||||
import { ProjectType } from "@app/hooks/api/projects/types";
|
||||
import { TProjectPermission } from "@app/hooks/api/roles/types";
|
||||
import { ProjectType } from "@app/hooks/api/workspace/types";
|
||||
|
||||
const GeneralPolicyActionSchema = z.object({
|
||||
read: z.boolean().optional(),
|
||||
@@ -145,6 +146,14 @@ const SecretScanningConfigPolicyActionSchema = z.object({
|
||||
[ProjectPermissionSecretScanningConfigActions.Update]: z.boolean().optional()
|
||||
});
|
||||
|
||||
const AppConnectionPolicyActionSchema = z.object({
|
||||
[ProjectPermissionAppConnectionActions.Create]: z.boolean().optional(),
|
||||
[ProjectPermissionAppConnectionActions.Read]: z.boolean().optional(),
|
||||
[ProjectPermissionAppConnectionActions.Edit]: z.boolean().optional(),
|
||||
[ProjectPermissionAppConnectionActions.Delete]: z.boolean().optional(),
|
||||
[ProjectPermissionAppConnectionActions.Connect]: z.boolean().optional()
|
||||
});
|
||||
|
||||
const KmipPolicyActionSchema = z.object({
|
||||
[ProjectPermissionKmipActions.ReadClients]: z.boolean().optional(),
|
||||
[ProjectPermissionKmipActions.CreateClients]: z.boolean().optional(),
|
||||
@@ -322,6 +331,12 @@ export const projectRoleFormSchema = z.object({
|
||||
})
|
||||
.array()
|
||||
.default([]),
|
||||
[ProjectPermissionSub.AppConnections]: AppConnectionPolicyActionSchema.extend({
|
||||
inverted: z.boolean().optional(),
|
||||
conditions: ConditionSchema
|
||||
})
|
||||
.array()
|
||||
.default([]),
|
||||
[ProjectPermissionSub.PkiSyncs]: PkiSyncPolicyActionSchema.extend({
|
||||
inverted: z.boolean().optional(),
|
||||
conditions: ConditionSchema
|
||||
@@ -411,7 +426,8 @@ type TConditionalFields =
|
||||
| ProjectPermissionSub.Identity
|
||||
| ProjectPermissionSub.SecretSyncs
|
||||
| ProjectPermissionSub.PkiSyncs
|
||||
| ProjectPermissionSub.SecretEvents;
|
||||
| ProjectPermissionSub.SecretEvents
|
||||
| ProjectPermissionSub.AppConnections;
|
||||
|
||||
export const isConditionalSubjects = (
|
||||
subject: ProjectPermissionSub
|
||||
@@ -427,7 +443,8 @@ export const isConditionalSubjects = (
|
||||
subject === ProjectPermissionSub.CertificateTemplates ||
|
||||
subject === ProjectPermissionSub.SecretSyncs ||
|
||||
subject === ProjectPermissionSub.PkiSyncs ||
|
||||
subject === ProjectPermissionSub.SecretEvents;
|
||||
subject === ProjectPermissionSub.SecretEvents ||
|
||||
subject === ProjectPermissionSub.AppConnections;
|
||||
|
||||
const convertCaslConditionToFormOperator = (caslConditions: TPermissionCondition) => {
|
||||
const formConditions: z.infer<typeof ConditionSchema> = [];
|
||||
@@ -535,7 +552,8 @@ export const rolePermission2Form = (permissions: TProjectPermission[] = []) => {
|
||||
ProjectPermissionSub.SshHostGroups,
|
||||
ProjectPermissionSub.SecretSyncs,
|
||||
ProjectPermissionSub.PkiSyncs,
|
||||
ProjectPermissionSub.SecretEvents
|
||||
ProjectPermissionSub.SecretEvents,
|
||||
ProjectPermissionSub.AppConnections
|
||||
].includes(subject)
|
||||
) {
|
||||
// from above statement we are sure it won't be undefined
|
||||
@@ -706,6 +724,27 @@ export const rolePermission2Form = (permissions: TProjectPermission[] = []) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (subject === ProjectPermissionSub.AppConnections) {
|
||||
const canCreate = action.includes(ProjectPermissionAppConnectionActions.Create);
|
||||
const canRead = action.includes(ProjectPermissionAppConnectionActions.Read);
|
||||
const canEdit = action.includes(ProjectPermissionAppConnectionActions.Edit);
|
||||
const canDelete = action.includes(ProjectPermissionAppConnectionActions.Delete);
|
||||
const canConnect = action.includes(ProjectPermissionAppConnectionActions.Connect);
|
||||
|
||||
// from above statement we are sure it won't be undefined
|
||||
formVal[subject]!.push({
|
||||
[ProjectPermissionAppConnectionActions.Read]: canRead,
|
||||
[ProjectPermissionAppConnectionActions.Create]: canCreate,
|
||||
[ProjectPermissionAppConnectionActions.Edit]: canEdit,
|
||||
[ProjectPermissionAppConnectionActions.Delete]: canDelete,
|
||||
[ProjectPermissionAppConnectionActions.Connect]: canConnect,
|
||||
conditions: conditions ? convertCaslConditionToFormOperator(conditions) : [],
|
||||
inverted
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// for other subjects
|
||||
const canRead = action.includes(ProjectPermissionActions.Read);
|
||||
const canEdit = action.includes(ProjectPermissionActions.Edit);
|
||||
@@ -1667,6 +1706,31 @@ export const PROJECT_PERMISSION_OBJECT: TProjectPermissionObject = {
|
||||
value: ProjectPermissionSecretEventActions.SubscribeImportMutations
|
||||
}
|
||||
]
|
||||
},
|
||||
[ProjectPermissionSub.AppConnections]: {
|
||||
title: "App Connections",
|
||||
actions: [
|
||||
{
|
||||
label: "Read",
|
||||
value: ProjectPermissionAppConnectionActions.Read
|
||||
},
|
||||
{
|
||||
label: "Create",
|
||||
value: ProjectPermissionAppConnectionActions.Create
|
||||
},
|
||||
{
|
||||
label: "Update",
|
||||
value: ProjectPermissionAppConnectionActions.Edit
|
||||
},
|
||||
{
|
||||
label: "Delete",
|
||||
value: ProjectPermissionAppConnectionActions.Delete
|
||||
},
|
||||
{
|
||||
label: "Connect",
|
||||
value: ProjectPermissionAppConnectionActions.Connect
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1740,7 +1804,8 @@ export const ProjectTypePermissionSubjects: Record<
|
||||
...KmsPermissionSubjects(),
|
||||
...CertificateManagerPermissionSubjects(),
|
||||
...SshPermissionSubjects(),
|
||||
...SecretScanningSubject()
|
||||
...SecretScanningSubject(),
|
||||
[ProjectPermissionSub.AppConnections]: true
|
||||
},
|
||||
[ProjectType.KMS]: {
|
||||
...SharedPermissionSubjects,
|
||||
@@ -1748,7 +1813,8 @@ export const ProjectTypePermissionSubjects: Record<
|
||||
...SecretsManagerPermissionSubjects(),
|
||||
...CertificateManagerPermissionSubjects(),
|
||||
...SshPermissionSubjects(),
|
||||
...SecretScanningSubject()
|
||||
...SecretScanningSubject(),
|
||||
[ProjectPermissionSub.AppConnections]: false
|
||||
},
|
||||
[ProjectType.CertificateManager]: {
|
||||
...SharedPermissionSubjects,
|
||||
@@ -1756,7 +1822,8 @@ export const ProjectTypePermissionSubjects: Record<
|
||||
...KmsPermissionSubjects(),
|
||||
...SecretsManagerPermissionSubjects(),
|
||||
...SshPermissionSubjects(),
|
||||
...SecretScanningSubject()
|
||||
...SecretScanningSubject(),
|
||||
[ProjectPermissionSub.AppConnections]: true
|
||||
},
|
||||
[ProjectType.SSH]: {
|
||||
...SharedPermissionSubjects,
|
||||
@@ -1764,7 +1831,8 @@ export const ProjectTypePermissionSubjects: Record<
|
||||
...CertificateManagerPermissionSubjects(),
|
||||
...KmsPermissionSubjects(),
|
||||
...SecretsManagerPermissionSubjects(),
|
||||
...SecretScanningSubject()
|
||||
...SecretScanningSubject(),
|
||||
[ProjectPermissionSub.AppConnections]: false
|
||||
},
|
||||
[ProjectType.SecretScanning]: {
|
||||
...SharedPermissionSubjects,
|
||||
@@ -1772,7 +1840,8 @@ export const ProjectTypePermissionSubjects: Record<
|
||||
...SshPermissionSubjects(),
|
||||
...CertificateManagerPermissionSubjects(),
|
||||
...KmsPermissionSubjects(),
|
||||
...SecretsManagerPermissionSubjects()
|
||||
...SecretsManagerPermissionSubjects(),
|
||||
[ProjectPermissionSub.AppConnections]: true
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { z } from "zod";
|
||||
|
||||
import { createNotification } from "@app/components/notifications";
|
||||
import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2";
|
||||
import { useWorkspace } from "@app/context";
|
||||
import { useProject } from "@app/context";
|
||||
import { getProjectBaseURL } from "@app/helpers/project";
|
||||
import {
|
||||
useCreateProjectRole,
|
||||
@@ -38,8 +38,8 @@ export const RoleModal = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
roleSlug: string;
|
||||
};
|
||||
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const projectId = currentWorkspace?.id || "";
|
||||
const { currentProject } = useProject();
|
||||
const projectId = currentProject?.id || "";
|
||||
|
||||
const { data: role } = useGetProjectRoleBySlug(projectId, popupData?.roleSlug ?? "");
|
||||
|
||||
@@ -101,7 +101,7 @@ export const RoleModal = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
});
|
||||
|
||||
navigate({
|
||||
to: `${getProjectBaseURL(currentWorkspace.type)}/roles/$roleSlug` as const,
|
||||
to: `${getProjectBaseURL(currentProject.type)}/roles/$roleSlug` as const,
|
||||
params: {
|
||||
roleSlug: newRole.slug,
|
||||
projectId
|
||||
|
||||
+12
-7
@@ -8,14 +8,15 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { createNotification } from "@app/components/notifications";
|
||||
import { AccessTree } from "@app/components/permissions";
|
||||
import { Button } from "@app/components/v2";
|
||||
import { ProjectPermissionSub, useWorkspace } from "@app/context";
|
||||
import { ProjectPermissionSub, useProject } from "@app/context";
|
||||
import { ProjectPermissionSet } from "@app/context/ProjectPermissionContext";
|
||||
import { evaluatePermissionsAbility } from "@app/helpers/permissions";
|
||||
import { useGetProjectRoleBySlug, useUpdateProjectRole } from "@app/hooks/api";
|
||||
import { ProjectType } from "@app/hooks/api/projects/types";
|
||||
import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
|
||||
import { ProjectType } from "@app/hooks/api/workspace/types";
|
||||
|
||||
import { AddPoliciesButton } from "./AddPoliciesButton";
|
||||
import { AppConnectionPermissionConditions } from "./AppConnectionPermissionConditions";
|
||||
import { DynamicSecretPermissionConditions } from "./DynamicSecretPermissionConditions";
|
||||
import { GeneralPermissionConditions } from "./GeneralPermissionConditions";
|
||||
import { GeneralPermissionPolicies } from "./GeneralPermissionPolicies";
|
||||
@@ -77,6 +78,10 @@ export const renderConditionalComponents = (
|
||||
return <SecretEventPermissionConditions isDisabled={isDisabled} />;
|
||||
}
|
||||
|
||||
if (subject === ProjectPermissionSub.AppConnections) {
|
||||
return <AppConnectionPermissionConditions isDisabled={isDisabled} />;
|
||||
}
|
||||
|
||||
return <GeneralPermissionConditions isDisabled={isDisabled} type={subject} />;
|
||||
}
|
||||
|
||||
@@ -84,10 +89,10 @@ export const renderConditionalComponents = (
|
||||
};
|
||||
|
||||
export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const projectId = currentWorkspace?.id || "";
|
||||
const { currentProject } = useProject();
|
||||
const projectId = currentProject?.id || "";
|
||||
const { data: role, isPending } = useGetProjectRoleBySlug(
|
||||
currentWorkspace?.id ?? "",
|
||||
currentProject?.id ?? "",
|
||||
roleSlug as string
|
||||
);
|
||||
|
||||
@@ -126,7 +131,7 @@ export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
|
||||
(role?.slug ?? "") as ProjectMembershipRole
|
||||
);
|
||||
|
||||
const isSecretManagerProject = currentWorkspace.type === ProjectType.SecretManager;
|
||||
const isSecretManagerProject = currentProject.type === ProjectType.SecretManager;
|
||||
|
||||
const permissions = form.watch("permissions");
|
||||
|
||||
@@ -178,7 +183,7 @@ export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
|
||||
Save
|
||||
</Button>
|
||||
<div className="ml-2 border-l border-mineshaft-500 pl-4">
|
||||
<AddPoliciesButton isDisabled={isDisabled} projectType={currentWorkspace.type} />
|
||||
<AddPoliciesButton isDisabled={isDisabled} projectType={currentProject.type} />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
+6
-6
@@ -5,10 +5,10 @@ import { z } from "zod";
|
||||
import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
|
||||
import { createNotification } from "@app/components/notifications";
|
||||
import { Button, FormControl, Input } from "@app/components/v2";
|
||||
import { useProjectPermission, useSubscription, useWorkspace } from "@app/context";
|
||||
import { useProject, useProjectPermission, useSubscription } from "@app/context";
|
||||
import { usePopUp } from "@app/hooks";
|
||||
import { useUpdateWorkspaceAuditLogsRetention } from "@app/hooks/api/projects/queries";
|
||||
import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
|
||||
import { useUpdateWorkspaceAuditLogsRetention } from "@app/hooks/api/workspace/queries";
|
||||
|
||||
const formSchema = z.object({
|
||||
auditLogsRetentionDays: z.coerce.number().min(0)
|
||||
@@ -19,7 +19,7 @@ type TForm = z.infer<typeof formSchema>;
|
||||
export const AuditLogsRetentionSection = () => {
|
||||
const { mutateAsync: updateAuditLogsRetention } = useUpdateWorkspaceAuditLogsRetention();
|
||||
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
const { membership } = useProjectPermission();
|
||||
const { subscription } = useSubscription();
|
||||
const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["upgradePlan"] as const);
|
||||
@@ -32,11 +32,11 @@ export const AuditLogsRetentionSection = () => {
|
||||
resolver: zodResolver(formSchema),
|
||||
values: {
|
||||
auditLogsRetentionDays:
|
||||
currentWorkspace?.auditLogsRetentionDays ?? subscription?.auditLogsRetentionDays ?? 0
|
||||
currentProject?.auditLogsRetentionDays ?? subscription?.auditLogsRetentionDays ?? 0
|
||||
}
|
||||
});
|
||||
|
||||
if (!currentWorkspace) return null;
|
||||
if (!currentProject) return null;
|
||||
|
||||
const handleAuditLogsRetentionSubmit = async ({ auditLogsRetentionDays }: TForm) => {
|
||||
try {
|
||||
@@ -59,7 +59,7 @@ export const AuditLogsRetentionSection = () => {
|
||||
|
||||
await updateAuditLogsRetention({
|
||||
auditLogsRetentionDays,
|
||||
projectSlug: currentWorkspace.slug
|
||||
projectSlug: currentProject.slug
|
||||
});
|
||||
|
||||
createNotification({
|
||||
|
||||
+8
-9
@@ -1,20 +1,19 @@
|
||||
import { createNotification } from "@app/components/notifications";
|
||||
import { ProjectPermissionCan } from "@app/components/permissions";
|
||||
import { Checkbox } from "@app/components/v2";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
||||
import { useToggleDeleteProjectProtection } from "@app/hooks/api/workspace/queries";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
|
||||
import { useUpdateProject } from "@app/hooks/api";
|
||||
|
||||
export const DeleteProjectProtection = () => {
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { mutateAsync } = useToggleDeleteProjectProtection();
|
||||
const { projectId, currentProject } = useProject();
|
||||
|
||||
const { mutateAsync } = useUpdateProject();
|
||||
|
||||
const handleToggleDeleteProjectProtection = async (state: boolean) => {
|
||||
try {
|
||||
if (!currentWorkspace?.id) return;
|
||||
|
||||
await mutateAsync({
|
||||
workspaceID: currentWorkspace.id,
|
||||
state
|
||||
projectId,
|
||||
hasDeleteProtection: state
|
||||
});
|
||||
|
||||
const text = `Successfully ${state ? "enabled" : "disabled"} delete protection`;
|
||||
@@ -40,7 +39,7 @@ export const DeleteProjectProtection = () => {
|
||||
<Checkbox
|
||||
id="hasDeleteProtection"
|
||||
isDisabled={!isAllowed}
|
||||
isChecked={currentWorkspace?.hasDeleteProtection ?? false}
|
||||
isChecked={currentProject?.hasDeleteProtection ?? false}
|
||||
onCheckedChange={(state) => {
|
||||
handleToggleDeleteProjectProtection(state as boolean);
|
||||
}}
|
||||
|
||||
+12
-12
@@ -9,8 +9,8 @@ import {
|
||||
ProjectPermissionActions,
|
||||
ProjectPermissionSub,
|
||||
useOrganization,
|
||||
useProjectPermission,
|
||||
useWorkspace
|
||||
useProject,
|
||||
useProjectPermission
|
||||
} from "@app/context";
|
||||
import { useToggle } from "@app/hooks";
|
||||
import { useDeleteWorkspace, useGetWorkspaceUsers, useLeaveProject } from "@app/hooks/api";
|
||||
@@ -26,13 +26,13 @@ export const DeleteProjectSection = () => {
|
||||
|
||||
const { currentOrg } = useOrganization();
|
||||
const { hasProjectRole, membership } = useProjectPermission();
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
const [isDeleting, setIsDeleting] = useToggle();
|
||||
const [isLeaving, setIsLeaving] = useToggle();
|
||||
const deleteWorkspace = useDeleteWorkspace();
|
||||
const leaveProject = useLeaveProject();
|
||||
const { data: members, isPending: isMembersLoading } = useGetWorkspaceUsers(
|
||||
currentWorkspace?.id || ""
|
||||
currentProject?.id || ""
|
||||
);
|
||||
|
||||
// If isNoAccessMember is true, then the user can't read the workspace members. So we need to handle this case separately.
|
||||
@@ -51,10 +51,10 @@ export const DeleteProjectSection = () => {
|
||||
const handleDeleteWorkspaceSubmit = async () => {
|
||||
setIsDeleting.on();
|
||||
try {
|
||||
if (!currentWorkspace?.id) return;
|
||||
if (!currentProject?.id) return;
|
||||
|
||||
await deleteWorkspace.mutateAsync({
|
||||
workspaceID: currentWorkspace?.id
|
||||
projectID: currentProject?.id
|
||||
});
|
||||
|
||||
createNotification({
|
||||
@@ -81,7 +81,7 @@ export const DeleteProjectSection = () => {
|
||||
try {
|
||||
setIsLeaving.on();
|
||||
|
||||
if (!currentWorkspace?.id || !currentOrg?.id) return;
|
||||
if (!currentProject?.id || !currentOrg?.id) return;
|
||||
|
||||
// If there's no members, and the user has access to read members, something went wrong.
|
||||
if (!members && !isNoAccessMember) return;
|
||||
@@ -110,7 +110,7 @@ export const DeleteProjectSection = () => {
|
||||
// If it's actually a no-access member, then we don't really care about the members.
|
||||
|
||||
await leaveProject.mutateAsync({
|
||||
workspaceId: currentWorkspace.id
|
||||
projectId: currentProject.id
|
||||
});
|
||||
|
||||
navigate({
|
||||
@@ -141,7 +141,7 @@ export const DeleteProjectSection = () => {
|
||||
type="submit"
|
||||
onClick={() => handlePopUpOpen("deleteWorkspace")}
|
||||
>
|
||||
{`Delete ${currentWorkspace?.name}`}
|
||||
{`Delete ${currentProject?.name}`}
|
||||
</Button>
|
||||
)}
|
||||
</ProjectPermissionCan>
|
||||
@@ -154,7 +154,7 @@ export const DeleteProjectSection = () => {
|
||||
type="submit"
|
||||
onClick={() => handlePopUpOpen("leaveWorkspace")}
|
||||
>
|
||||
{`Leave ${currentWorkspace?.name}`}
|
||||
{`Leave ${currentProject?.name}`}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
@@ -162,7 +162,7 @@ export const DeleteProjectSection = () => {
|
||||
<DeleteActionModal
|
||||
isOpen={popUp.deleteWorkspace.isOpen}
|
||||
title="Are you sure you want to delete this project?"
|
||||
subTitle={`Permanently delete ${currentWorkspace?.name} and all of its data. This action is not reversible, so please be careful.`}
|
||||
subTitle={`Permanently delete ${currentProject?.name} and all of its data. This action is not reversible, so please be careful.`}
|
||||
onChange={(isOpen) => handlePopUpToggle("deleteWorkspace", isOpen)}
|
||||
deleteKey="confirm"
|
||||
buttonText="Delete Project"
|
||||
@@ -172,7 +172,7 @@ export const DeleteProjectSection = () => {
|
||||
<LeaveProjectModal
|
||||
isOpen={popUp.leaveWorkspace.isOpen}
|
||||
title="Are you sure you want to leave this project?"
|
||||
subTitle={`If you leave ${currentWorkspace?.name} you will lose access to the project and its contents.`}
|
||||
subTitle={`If you leave ${currentProject?.name} you will lose access to the project and its contents.`}
|
||||
onChange={(isOpen) => handlePopUpToggle("leaveWorkspace", isOpen)}
|
||||
deleteKey="confirm"
|
||||
buttonText="Leave Project"
|
||||
|
||||
Reference in New Issue
Block a user