mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 13:27:46 +00:00
Consolidate people and groups tabs to user / user groups shared tab
This commit is contained in:
+1
@@ -71,6 +71,7 @@ export const IdentityProjectRow = ({
|
|||||||
<div className="opacity-0 transition-opacity duration-300 group-hover:opacity-100">
|
<div className="opacity-0 transition-opacity duration-300 group-hover:opacity-100">
|
||||||
<Tooltip content="Remove">
|
<Tooltip content="Remove">
|
||||||
<IconButton
|
<IconButton
|
||||||
|
colorSchema="danger"
|
||||||
ariaLabel="copy icon"
|
ariaLabel="copy icon"
|
||||||
variant="plain"
|
variant="plain"
|
||||||
className="group relative"
|
className="group relative"
|
||||||
|
|||||||
@@ -3,16 +3,10 @@ import { Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
|
|||||||
import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
|
import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
|
||||||
import { withPermission } from "@app/hoc";
|
import { withPermission } from "@app/hoc";
|
||||||
|
|
||||||
import {
|
import { OrgIdentityTab, OrgMembersTab, OrgRoleTabSection } from "./components";
|
||||||
OrgGroupsTab,
|
|
||||||
OrgIdentityTab,
|
|
||||||
OrgMembersTab,
|
|
||||||
OrgRoleTabSection
|
|
||||||
} from "./components";
|
|
||||||
|
|
||||||
enum TabSections {
|
enum TabSections {
|
||||||
Member = "members",
|
Member = "members",
|
||||||
Groups = "groups",
|
|
||||||
Roles = "roles",
|
Roles = "roles",
|
||||||
Identities = "identities"
|
Identities = "identities"
|
||||||
}
|
}
|
||||||
@@ -25,8 +19,7 @@ export const MembersPage = withPermission(
|
|||||||
<p className="mr-4 mb-4 text-3xl font-semibold text-white">Organization Access Control</p>
|
<p className="mr-4 mb-4 text-3xl font-semibold text-white">Organization Access Control</p>
|
||||||
<Tabs defaultValue={TabSections.Member}>
|
<Tabs defaultValue={TabSections.Member}>
|
||||||
<TabList>
|
<TabList>
|
||||||
<Tab value={TabSections.Member}>People</Tab>
|
<Tab value={TabSections.Member}>Users</Tab>
|
||||||
<Tab value={TabSections.Groups}>Groups</Tab>
|
|
||||||
<Tab value={TabSections.Identities}>
|
<Tab value={TabSections.Identities}>
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<p>Machine Identities</p>
|
<p>Machine Identities</p>
|
||||||
@@ -37,9 +30,6 @@ export const MembersPage = withPermission(
|
|||||||
<TabPanel value={TabSections.Member}>
|
<TabPanel value={TabSections.Member}>
|
||||||
<OrgMembersTab />
|
<OrgMembersTab />
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel value={TabSections.Groups}>
|
|
||||||
<OrgGroupsTab />
|
|
||||||
</TabPanel>
|
|
||||||
<TabPanel value={TabSections.Identities}>
|
<TabPanel value={TabSections.Identities}>
|
||||||
<OrgIdentityTab />
|
<OrgIdentityTab />
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
|
|||||||
+80
-100
@@ -3,16 +3,8 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
import { OrgPermissionCan } from "@app/components/permissions";
|
import { OrgPermissionCan } from "@app/components/permissions";
|
||||||
import {
|
import { Button, DeleteActionModal, UpgradePlanModal } from "@app/components/v2";
|
||||||
Button,
|
import { OrgPermissionActions, OrgPermissionSubjects, useSubscription } from "@app/context";
|
||||||
DeleteActionModal,
|
|
||||||
UpgradePlanModal
|
|
||||||
} from "@app/components/v2";
|
|
||||||
import {
|
|
||||||
OrgPermissionActions,
|
|
||||||
OrgPermissionSubjects,
|
|
||||||
useSubscription
|
|
||||||
} from "@app/context";
|
|
||||||
import { useDeleteGroup } from "@app/hooks/api";
|
import { useDeleteGroup } from "@app/hooks/api";
|
||||||
import { usePopUp } from "@app/hooks/usePopUp";
|
import { usePopUp } from "@app/hooks/usePopUp";
|
||||||
|
|
||||||
@@ -21,100 +13,88 @@ import { OrgGroupModal } from "./OrgGroupModal";
|
|||||||
import { OrgGroupsTable } from "./OrgGroupsTable";
|
import { OrgGroupsTable } from "./OrgGroupsTable";
|
||||||
|
|
||||||
export const OrgGroupsSection = () => {
|
export const OrgGroupsSection = () => {
|
||||||
const { subscription } = useSubscription();
|
const { subscription } = useSubscription();
|
||||||
const { mutateAsync: deleteMutateAsync } = useDeleteGroup();
|
const { mutateAsync: deleteMutateAsync } = useDeleteGroup();
|
||||||
|
|
||||||
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
|
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
|
||||||
"group",
|
"group",
|
||||||
"groupMembers",
|
"groupMembers",
|
||||||
"deleteGroup",
|
"deleteGroup",
|
||||||
"upgradePlan"
|
"upgradePlan"
|
||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const handleAddGroupModal = () => {
|
const handleAddGroupModal = () => {
|
||||||
if (!subscription?.groups) {
|
if (!subscription?.groups) {
|
||||||
handlePopUpOpen("upgradePlan", {
|
handlePopUpOpen("upgradePlan", {
|
||||||
description: "You can manage users more efficiently with groups if you upgrade your Infisical plan."
|
description:
|
||||||
});
|
"You can manage users more efficiently with groups if you upgrade your Infisical plan."
|
||||||
} else {
|
});
|
||||||
handlePopUpOpen("group");
|
} else {
|
||||||
}
|
handlePopUpOpen("group");
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const onDeleteGroupSubmit = async ({
|
const onDeleteGroupSubmit = async ({ name, slug }: { name: string; slug: string }) => {
|
||||||
name,
|
try {
|
||||||
|
await deleteMutateAsync({
|
||||||
slug
|
slug
|
||||||
}: {
|
});
|
||||||
name: string;
|
createNotification({
|
||||||
slug: string;
|
text: `Successfully deleted the group named ${name}`,
|
||||||
}) => {
|
type: "success"
|
||||||
try {
|
});
|
||||||
await deleteMutateAsync({
|
} catch (err) {
|
||||||
slug
|
console.error(err);
|
||||||
});
|
createNotification({
|
||||||
createNotification({
|
text: `Failed to delete the group named ${name}`,
|
||||||
text: `Successfully deleted the group named ${name}`,
|
type: "error"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to delete the group named ${name}`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpClose("deleteGroup");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
handlePopUpClose("deleteGroup");
|
||||||
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
|
};
|
||||||
<div className="mb-4 flex justify-between">
|
|
||||||
<p className="text-xl font-semibold text-mineshaft-100">Groups</p>
|
return (
|
||||||
<OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Groups}>
|
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
|
||||||
{(isAllowed) => (
|
<div className="mb-4 flex justify-between">
|
||||||
<Button
|
<p className="text-xl font-semibold text-mineshaft-100">User Groups</p>
|
||||||
colorSchema="primary"
|
<OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Groups}>
|
||||||
type="submit"
|
{(isAllowed) => (
|
||||||
leftIcon={<FontAwesomeIcon icon={faPlus} />}
|
<Button
|
||||||
onClick={() => handleAddGroupModal()}
|
colorSchema="primary"
|
||||||
isDisabled={!isAllowed}
|
type="submit"
|
||||||
>
|
leftIcon={<FontAwesomeIcon icon={faPlus} />}
|
||||||
Create Group
|
onClick={() => handleAddGroupModal()}
|
||||||
</Button>
|
isDisabled={!isAllowed}
|
||||||
)}
|
>
|
||||||
</OrgPermissionCan>
|
Create Group
|
||||||
</div>
|
</Button>
|
||||||
<OrgGroupsTable
|
)}
|
||||||
handlePopUpOpen={handlePopUpOpen}
|
</OrgPermissionCan>
|
||||||
/>
|
</div>
|
||||||
<OrgGroupModal
|
<OrgGroupsTable handlePopUpOpen={handlePopUpOpen} />
|
||||||
popUp={popUp}
|
<OrgGroupModal
|
||||||
handlePopUpClose={handlePopUpClose}
|
popUp={popUp}
|
||||||
handlePopUpToggle={handlePopUpToggle}
|
handlePopUpClose={handlePopUpClose}
|
||||||
/>
|
handlePopUpToggle={handlePopUpToggle}
|
||||||
<OrgGroupMembersModal
|
/>
|
||||||
popUp={popUp}
|
<OrgGroupMembersModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
|
||||||
handlePopUpToggle={handlePopUpToggle}
|
<DeleteActionModal
|
||||||
/>
|
isOpen={popUp.deleteGroup.isOpen}
|
||||||
<DeleteActionModal
|
title={`Are you sure want to delete the group named ${
|
||||||
isOpen={popUp.deleteGroup.isOpen}
|
(popUp?.deleteGroup?.data as { name: string })?.name || ""
|
||||||
title={`Are you sure want to delete the group named ${
|
}?`}
|
||||||
(popUp?.deleteGroup?.data as { name: string })?.name || ""
|
onChange={(isOpen) => handlePopUpToggle("deleteGroup", isOpen)}
|
||||||
}?`}
|
deleteKey="confirm"
|
||||||
onChange={(isOpen) => handlePopUpToggle("deleteGroup", isOpen)}
|
onDeleteApproved={() =>
|
||||||
deleteKey="confirm"
|
onDeleteGroupSubmit(popUp?.deleteGroup?.data as { name: string; slug: string })
|
||||||
onDeleteApproved={() =>
|
}
|
||||||
onDeleteGroupSubmit(
|
/>
|
||||||
(popUp?.deleteGroup?.data as { name: string; slug: string })
|
<UpgradePlanModal
|
||||||
)
|
isOpen={popUp.upgradePlan.isOpen}
|
||||||
}
|
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
|
||||||
/>
|
text={(popUp.upgradePlan?.data as { description: string })?.description}
|
||||||
<UpgradePlanModal
|
/>
|
||||||
isOpen={popUp.upgradePlan.isOpen}
|
</div>
|
||||||
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
|
);
|
||||||
text={(popUp.upgradePlan?.data as { description: string })?.description}
|
};
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
+190
-204
@@ -1,12 +1,16 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { faMagnifyingGlass, faPencil, faUsers, faXmark } from "@fortawesome/free-solid-svg-icons";
|
import { faEllipsis,faMagnifyingGlass, faUsers } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
import { OrgPermissionCan } from "@app/components/permissions";
|
import { OrgPermissionCan } from "@app/components/permissions";
|
||||||
import {
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuItem,
|
||||||
|
DropdownMenuTrigger,
|
||||||
EmptyState,
|
EmptyState,
|
||||||
IconButton,
|
|
||||||
Input,
|
Input,
|
||||||
Select,
|
Select,
|
||||||
SelectItem,
|
SelectItem,
|
||||||
@@ -17,218 +21,200 @@ import {
|
|||||||
Td,
|
Td,
|
||||||
Th,
|
Th,
|
||||||
THead,
|
THead,
|
||||||
Tooltip,
|
|
||||||
Tr
|
Tr
|
||||||
} from "@app/components/v2";
|
} from "@app/components/v2";
|
||||||
import {
|
import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
|
||||||
OrgPermissionActions,
|
import { useGetOrganizationGroups, useGetOrgRoles, useUpdateGroup } from "@app/hooks/api";
|
||||||
OrgPermissionSubjects,
|
|
||||||
useOrganization} from "@app/context";
|
|
||||||
import {
|
|
||||||
useGetOrganizationGroups,
|
|
||||||
useGetOrgRoles,
|
|
||||||
useUpdateGroup
|
|
||||||
} from "@app/hooks/api";
|
|
||||||
import { UsePopUpState } from "@app/hooks/usePopUp";
|
import { UsePopUpState } from "@app/hooks/usePopUp";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
handlePopUpOpen: (
|
handlePopUpOpen: (
|
||||||
popUpName: keyof UsePopUpState<
|
popUpName: keyof UsePopUpState<["group", "deleteGroup", "groupMembers"]>,
|
||||||
["group", "deleteGroup", "groupMembers"]
|
data?: {
|
||||||
>,
|
groupId?: string;
|
||||||
data?: {
|
name?: string;
|
||||||
groupId?: string;
|
slug?: string;
|
||||||
name?: string;
|
role?: string;
|
||||||
slug?: string;
|
customRole?: {
|
||||||
role?: string;
|
name: string;
|
||||||
customRole?: {
|
slug: string;
|
||||||
name: string;
|
};
|
||||||
slug: string;
|
}
|
||||||
}
|
) => void;
|
||||||
}
|
};
|
||||||
) => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const OrgGroupsTable = ({
|
export const OrgGroupsTable = ({ handlePopUpOpen }: Props) => {
|
||||||
handlePopUpOpen
|
const [searchGroupsFilter, setSearchGroupsFilter] = useState("");
|
||||||
}: Props) => {
|
const { currentOrg } = useOrganization();
|
||||||
const [searchGroupsFilter, setSearchGroupsFilter] = useState("");
|
const orgId = currentOrg?.id || "";
|
||||||
const { currentOrg } = useOrganization();
|
const { isLoading, data: groups } = useGetOrganizationGroups(orgId);
|
||||||
const orgId = currentOrg?.id || "";
|
const { mutateAsync: updateMutateAsync } = useUpdateGroup();
|
||||||
const { isLoading, data: groups } = useGetOrganizationGroups(orgId);
|
|
||||||
const { mutateAsync: updateMutateAsync } = useUpdateGroup();
|
|
||||||
|
|
||||||
const { data: roles } = useGetOrgRoles(orgId);
|
const { data: roles } = useGetOrgRoles(orgId);
|
||||||
|
|
||||||
const handleChangeRole = async ({
|
const handleChangeRole = async ({ currentSlug, role }: { currentSlug: string; role: string }) => {
|
||||||
|
try {
|
||||||
|
await updateMutateAsync({
|
||||||
currentSlug,
|
currentSlug,
|
||||||
role
|
role
|
||||||
}: {
|
});
|
||||||
currentSlug: string;
|
|
||||||
role: string;
|
|
||||||
}) => {
|
|
||||||
try {
|
|
||||||
await updateMutateAsync({
|
|
||||||
currentSlug,
|
|
||||||
role
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully updated group role",
|
text: "Successfully updated group role",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Failed to update group role",
|
text: "Failed to update group role",
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Input
|
<Input
|
||||||
value={searchGroupsFilter}
|
value={searchGroupsFilter}
|
||||||
onChange={(e) => setSearchGroupsFilter(e.target.value)}
|
onChange={(e) => setSearchGroupsFilter(e.target.value)}
|
||||||
leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
|
leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
|
||||||
placeholder="Search groups..."
|
placeholder="Search groups..."
|
||||||
/>
|
/>
|
||||||
<TableContainer className="mt-4">
|
<TableContainer className="mt-4">
|
||||||
<Table>
|
<Table>
|
||||||
<THead>
|
<THead>
|
||||||
<Tr>
|
<Tr>
|
||||||
<Th>Name</Th>
|
<Th>Name</Th>
|
||||||
<Th>Slug</Th>
|
<Th>Slug</Th>
|
||||||
<Th>Role</Th>
|
<Th>Role</Th>
|
||||||
<Th className="w-5" />
|
<Th className="w-5" />
|
||||||
</Tr>
|
</Tr>
|
||||||
</THead>
|
</THead>
|
||||||
<TBody>
|
<TBody>
|
||||||
{isLoading && <TableSkeleton columns={4} innerKey="org-groups" />}
|
{isLoading && <TableSkeleton columns={4} innerKey="org-groups" />}
|
||||||
{!isLoading && groups?.map(({ id, name, slug, role, customRole }) => {
|
{!isLoading &&
|
||||||
return (
|
groups?.map(({ id, name, slug, role, customRole }) => {
|
||||||
<Tr className="h-10" key={`org-group-${id}`}>
|
return (
|
||||||
<Td>{name}</Td>
|
<Tr className="h-10" key={`org-group-${id}`}>
|
||||||
<Td>{slug}</Td>
|
<Td>{name}</Td>
|
||||||
<Td>
|
<Td>{slug}</Td>
|
||||||
<OrgPermissionCan
|
<Td>
|
||||||
I={OrgPermissionActions.Edit}
|
<OrgPermissionCan
|
||||||
a={OrgPermissionSubjects.Groups}
|
I={OrgPermissionActions.Edit}
|
||||||
>
|
a={OrgPermissionSubjects.Groups}
|
||||||
{(isAllowed) => {
|
>
|
||||||
return (
|
{(isAllowed) => {
|
||||||
<Select
|
return (
|
||||||
value={role === "custom" ? (customRole?.slug as string) : role}
|
<Select
|
||||||
isDisabled={!isAllowed}
|
value={role === "custom" ? (customRole?.slug as string) : role}
|
||||||
className="w-40 bg-mineshaft-600"
|
isDisabled={!isAllowed}
|
||||||
dropdownContainerClassName="border border-mineshaft-600 bg-mineshaft-800"
|
className="w-40 bg-mineshaft-600"
|
||||||
onValueChange={(selectedRole) =>
|
dropdownContainerClassName="border border-mineshaft-600 bg-mineshaft-800"
|
||||||
handleChangeRole({
|
onValueChange={(selectedRole) =>
|
||||||
currentSlug: slug,
|
handleChangeRole({
|
||||||
role: selectedRole
|
currentSlug: slug,
|
||||||
})
|
role: selectedRole
|
||||||
}
|
})
|
||||||
>
|
}
|
||||||
{(roles || []).map(({ slug: roleSlug, name: roleName }) => (
|
>
|
||||||
<SelectItem value={roleSlug} key={`role-option-${roleSlug}`}>
|
{(roles || []).map(({ slug: roleSlug, name: roleName }) => (
|
||||||
{roleName}
|
<SelectItem value={roleSlug} key={`role-option-${roleSlug}`}>
|
||||||
</SelectItem>
|
{roleName}
|
||||||
))}
|
</SelectItem>
|
||||||
</Select>
|
))}
|
||||||
);
|
</Select>
|
||||||
}}
|
);
|
||||||
</OrgPermissionCan>
|
}}
|
||||||
</Td>
|
</OrgPermissionCan>
|
||||||
<Td>
|
</Td>
|
||||||
<div className="flex items-center justify-end">
|
<Td>
|
||||||
<OrgPermissionCan
|
<DropdownMenu>
|
||||||
I={OrgPermissionActions.Edit}
|
<DropdownMenuTrigger asChild className="rounded-lg">
|
||||||
a={OrgPermissionSubjects.Groups}
|
<div className="hover:text-primary-400 data-[state=open]:text-primary-400">
|
||||||
>
|
<FontAwesomeIcon size="sm" icon={faEllipsis} />
|
||||||
{(isAllowed) => (
|
</div>
|
||||||
<Tooltip content="Manage group members">
|
</DropdownMenuTrigger>
|
||||||
<IconButton
|
<DropdownMenuContent align="start" className="p-1">
|
||||||
onClick={() => {
|
<OrgPermissionCan
|
||||||
handlePopUpOpen("groupMembers", {
|
I={OrgPermissionActions.Edit}
|
||||||
slug
|
a={OrgPermissionSubjects.Identity}
|
||||||
});
|
>
|
||||||
}}
|
{(isAllowed) => (
|
||||||
size="lg"
|
<DropdownMenuItem
|
||||||
colorSchema="primary"
|
className={twMerge(
|
||||||
variant="plain"
|
!isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
|
||||||
ariaLabel="update"
|
)}
|
||||||
isDisabled={!isAllowed}
|
onClick={(e) => {
|
||||||
>
|
e.stopPropagation();
|
||||||
<FontAwesomeIcon icon={faUsers} />
|
handlePopUpOpen("groupMembers", {
|
||||||
</IconButton>
|
slug
|
||||||
</Tooltip>
|
});
|
||||||
)}
|
}}
|
||||||
</OrgPermissionCan>
|
disabled={!isAllowed}
|
||||||
<OrgPermissionCan
|
>
|
||||||
I={OrgPermissionActions.Edit}
|
Manage Users
|
||||||
a={OrgPermissionSubjects.Groups}
|
</DropdownMenuItem>
|
||||||
>
|
)}
|
||||||
{(isAllowed) => (
|
</OrgPermissionCan>
|
||||||
<Tooltip content="Edit group">
|
<OrgPermissionCan
|
||||||
<IconButton
|
I={OrgPermissionActions.Edit}
|
||||||
onClick={async () => {
|
a={OrgPermissionSubjects.Identity}
|
||||||
handlePopUpOpen("group", {
|
>
|
||||||
groupId: id,
|
{(isAllowed) => (
|
||||||
name,
|
<DropdownMenuItem
|
||||||
slug,
|
className={twMerge(
|
||||||
role,
|
!isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
|
||||||
customRole
|
)}
|
||||||
});
|
onClick={(e) => {
|
||||||
}}
|
e.stopPropagation();
|
||||||
size="lg"
|
handlePopUpOpen("group", {
|
||||||
colorSchema="primary"
|
groupId: id,
|
||||||
variant="plain"
|
name,
|
||||||
ariaLabel="update"
|
slug,
|
||||||
className="ml-4"
|
role,
|
||||||
isDisabled={!isAllowed}
|
customRole
|
||||||
>
|
});
|
||||||
<FontAwesomeIcon icon={faPencil} />
|
}}
|
||||||
</IconButton>
|
disabled={!isAllowed}
|
||||||
</Tooltip>
|
>
|
||||||
)}
|
Edit Group
|
||||||
</OrgPermissionCan>
|
</DropdownMenuItem>
|
||||||
<OrgPermissionCan
|
)}
|
||||||
I={OrgPermissionActions.Delete}
|
</OrgPermissionCan>
|
||||||
a={OrgPermissionSubjects.Groups}
|
<OrgPermissionCan
|
||||||
>
|
I={OrgPermissionActions.Delete}
|
||||||
{(isAllowed) => (
|
a={OrgPermissionSubjects.Groups}
|
||||||
<Tooltip content="Delete group">
|
>
|
||||||
<IconButton
|
{(isAllowed) => (
|
||||||
onClick={() => {
|
<DropdownMenuItem
|
||||||
handlePopUpOpen("deleteGroup", {
|
className={twMerge(
|
||||||
slug,
|
isAllowed
|
||||||
name
|
? "hover:!bg-red-500 hover:!text-white"
|
||||||
});
|
: "pointer-events-none cursor-not-allowed opacity-50"
|
||||||
}}
|
)}
|
||||||
size="lg"
|
onClick={(e) => {
|
||||||
colorSchema="danger"
|
e.stopPropagation();
|
||||||
variant="plain"
|
handlePopUpOpen("deleteGroup", {
|
||||||
ariaLabel="update"
|
slug,
|
||||||
className="ml-4"
|
name
|
||||||
isDisabled={!isAllowed}
|
});
|
||||||
>
|
}}
|
||||||
<FontAwesomeIcon icon={faXmark} />
|
disabled={!isAllowed}
|
||||||
</IconButton>
|
>
|
||||||
</Tooltip>
|
Delete Group
|
||||||
)}
|
</DropdownMenuItem>
|
||||||
</OrgPermissionCan>
|
)}
|
||||||
</div>
|
</OrgPermissionCan>
|
||||||
</Td>
|
</DropdownMenuContent>
|
||||||
</Tr>
|
</DropdownMenu>
|
||||||
);
|
</Td>
|
||||||
})}
|
</Tr>
|
||||||
</TBody>
|
);
|
||||||
</Table>
|
})}
|
||||||
{groups?.length === 0 && (
|
</TBody>
|
||||||
<EmptyState title="No groups found" icon={faUsers} />
|
</Table>
|
||||||
)}
|
{groups?.length === 0 && <EmptyState title="No groups found" icon={faUsers} />}
|
||||||
</TableContainer>
|
</TableContainer>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
import { motion } from "framer-motion";
|
import { motion } from "framer-motion";
|
||||||
|
|
||||||
|
import { OrgGroupsSection } from "../OrgGroupsTab/components";
|
||||||
import { OrgMembersSection } from "./components";
|
import { OrgMembersSection } from "./components";
|
||||||
|
|
||||||
export const OrgMembersTab = () => {
|
export const OrgMembersTab = () => {
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
key="panel-org-members"
|
key="panel-org-members"
|
||||||
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 }}
|
||||||
exit={{ opacity: 0, translateX: 30 }}
|
exit={{ opacity: 0, translateX: 30 }}
|
||||||
>
|
>
|
||||||
<OrgMembersSection />
|
<OrgMembersSection />
|
||||||
|
<OrgGroupsSection />
|
||||||
</motion.div>
|
</motion.div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|||||||
+1
-1
@@ -90,7 +90,7 @@ export const OrgMembersSection = () => {
|
|||||||
return (
|
return (
|
||||||
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
|
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
|
||||||
<div className="mb-4 flex justify-between">
|
<div className="mb-4 flex justify-between">
|
||||||
<p className="text-xl font-semibold text-mineshaft-100">Members</p>
|
<p className="text-xl font-semibold text-mineshaft-100">Users</p>
|
||||||
<OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Member}>
|
<OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Member}>
|
||||||
{(isAllowed) => (
|
{(isAllowed) => (
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -1,17 +1,9 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
import { motion } from "framer-motion";
|
|
||||||
|
|
||||||
import { Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
|
import { Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
|
||||||
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context";
|
||||||
import { withProjectPermission } from "@app/hoc";
|
import { withProjectPermission } from "@app/hoc";
|
||||||
|
|
||||||
import {
|
import { IdentityTab, MembersTab,ProjectRoleListTab, ServiceTokenTab } from "./components";
|
||||||
GroupsTab,
|
|
||||||
IdentityTab,
|
|
||||||
MemberListTab,
|
|
||||||
ProjectRoleListTab,
|
|
||||||
ServiceTokenTab
|
|
||||||
} from "./components";
|
|
||||||
|
|
||||||
enum TabSections {
|
enum TabSections {
|
||||||
Member = "members",
|
Member = "members",
|
||||||
@@ -23,17 +15,13 @@ enum TabSections {
|
|||||||
|
|
||||||
export const MembersPage = withProjectPermission(
|
export const MembersPage = withProjectPermission(
|
||||||
() => {
|
() => {
|
||||||
const { currentWorkspace } = useWorkspace();
|
|
||||||
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">
|
||||||
<p className="mr-4 mb-4 text-3xl font-semibold text-white">Project Access Control</p>
|
<p className="mr-4 mb-4 text-3xl font-semibold text-white">Project Access Control</p>
|
||||||
<Tabs defaultValue={TabSections.Member}>
|
<Tabs defaultValue={TabSections.Member}>
|
||||||
<TabList>
|
<TabList>
|
||||||
<Tab value={TabSections.Member}>People</Tab>
|
<Tab value={TabSections.Member}>Users</Tab>
|
||||||
{currentWorkspace?.version && currentWorkspace.version > 1 && (
|
|
||||||
<Tab value={TabSections.Groups}>Groups</Tab>
|
|
||||||
)}
|
|
||||||
<Tab value={TabSections.Identities}>
|
<Tab value={TabSections.Identities}>
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<p>Machine Identities</p>
|
<p>Machine Identities</p>
|
||||||
@@ -43,21 +31,8 @@ export const MembersPage = withProjectPermission(
|
|||||||
<Tab value={TabSections.Roles}>Project Roles</Tab>
|
<Tab value={TabSections.Roles}>Project Roles</Tab>
|
||||||
</TabList>
|
</TabList>
|
||||||
<TabPanel value={TabSections.Member}>
|
<TabPanel value={TabSections.Member}>
|
||||||
<MemberListTab />
|
<MembersTab />
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
{currentWorkspace?.version && currentWorkspace.version > 1 && (
|
|
||||||
<TabPanel value={TabSections.Groups}>
|
|
||||||
<motion.div
|
|
||||||
key="panel-groups"
|
|
||||||
transition={{ duration: 0.15 }}
|
|
||||||
initial={{ opacity: 0, translateX: 30 }}
|
|
||||||
animate={{ opacity: 1, translateX: 0 }}
|
|
||||||
exit={{ opacity: 0, translateX: 30 }}
|
|
||||||
>
|
|
||||||
<GroupsTab />
|
|
||||||
</motion.div>
|
|
||||||
</TabPanel>
|
|
||||||
)}
|
|
||||||
<TabPanel value={TabSections.Identities}>
|
<TabPanel value={TabSections.Identities}>
|
||||||
<IdentityTab />
|
<IdentityTab />
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
|
|||||||
+83
-83
@@ -3,12 +3,13 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
import { ProjectPermissionCan } from "@app/components/permissions";
|
import { ProjectPermissionCan } from "@app/components/permissions";
|
||||||
|
import { Button, DeleteActionModal, UpgradePlanModal } from "@app/components/v2";
|
||||||
import {
|
import {
|
||||||
Button,
|
ProjectPermissionActions,
|
||||||
DeleteActionModal,
|
ProjectPermissionSub,
|
||||||
UpgradePlanModal
|
useSubscription,
|
||||||
} from "@app/components/v2";
|
useWorkspace
|
||||||
import { ProjectPermissionActions, ProjectPermissionSub, useSubscription,useWorkspace } from "@app/context";
|
} from "@app/context";
|
||||||
import { usePopUp } from "@app/hooks";
|
import { usePopUp } from "@app/hooks";
|
||||||
import { useDeleteGroupFromWorkspace } from "@app/hooks/api";
|
import { useDeleteGroupFromWorkspace } from "@app/hooks/api";
|
||||||
|
|
||||||
@@ -16,90 +17,89 @@ import { GroupModal } from "./GroupModal";
|
|||||||
import { GroupTable } from "./GroupsTable";
|
import { GroupTable } from "./GroupsTable";
|
||||||
|
|
||||||
export const GroupsSection = () => {
|
export const GroupsSection = () => {
|
||||||
const { subscription } = useSubscription();
|
const { subscription } = useSubscription();
|
||||||
const { currentWorkspace } = useWorkspace();
|
const { currentWorkspace } = useWorkspace();
|
||||||
|
|
||||||
const { mutateAsync: deleteMutateAsync } = useDeleteGroupFromWorkspace();
|
const { mutateAsync: deleteMutateAsync } = useDeleteGroupFromWorkspace();
|
||||||
|
|
||||||
const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
|
const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
|
||||||
"group",
|
"group",
|
||||||
"deleteGroup",
|
"deleteGroup",
|
||||||
"upgradePlan"
|
"upgradePlan"
|
||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const handleAddGroupModal = () => {
|
const handleAddGroupModal = () => {
|
||||||
if (!subscription?.groups) {
|
if (!subscription?.groups) {
|
||||||
handlePopUpOpen("upgradePlan", {
|
handlePopUpOpen("upgradePlan", {
|
||||||
description: "You can manage users more efficiently with groups if you upgrade your Infisical plan."
|
description:
|
||||||
});
|
"You can manage users more efficiently with groups if you upgrade your Infisical plan."
|
||||||
} else {
|
});
|
||||||
handlePopUpOpen("group");
|
} else {
|
||||||
}
|
handlePopUpOpen("group");
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const onRemoveGroupSubmit = async (groupSlug: string) => {
|
const onRemoveGroupSubmit = async (groupSlug: string) => {
|
||||||
try {
|
try {
|
||||||
await deleteMutateAsync({
|
await deleteMutateAsync({
|
||||||
groupSlug,
|
groupSlug,
|
||||||
projectSlug: currentWorkspace?.slug || ""
|
projectSlug: currentWorkspace?.slug || ""
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully removed identity from project",
|
text: "Successfully removed identity from project",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("deleteGroup");
|
handlePopUpClose("deleteGroup");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
const error = err as any;
|
const error = err as any;
|
||||||
const text = error?.response?.data?.message ?? "Failed to remove group from project";
|
const text = error?.response?.data?.message ?? "Failed to remove group from project";
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text,
|
text,
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
|
||||||
|
<div className="mb-4 flex items-center justify-between">
|
||||||
|
<p className="text-xl font-semibold text-mineshaft-100">User Groups</p>
|
||||||
|
<ProjectPermissionCan I={ProjectPermissionActions.Create} a={ProjectPermissionSub.Groups}>
|
||||||
|
{(isAllowed) => (
|
||||||
|
<Button
|
||||||
|
colorSchema="primary"
|
||||||
|
type="submit"
|
||||||
|
leftIcon={<FontAwesomeIcon icon={faPlus} />}
|
||||||
|
onClick={() => handleAddGroupModal()}
|
||||||
|
isDisabled={!isAllowed}
|
||||||
|
>
|
||||||
|
Add Group
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</ProjectPermissionCan>
|
||||||
|
</div>
|
||||||
|
<GroupModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
|
||||||
|
<GroupTable handlePopUpOpen={handlePopUpOpen} />
|
||||||
|
<DeleteActionModal
|
||||||
|
isOpen={popUp.deleteGroup.isOpen}
|
||||||
|
title={`Are you sure want to remove the group ${
|
||||||
|
(popUp?.deleteGroup?.data as { name: string })?.name || ""
|
||||||
|
} from the project?`}
|
||||||
|
onChange={(isOpen) => handlePopUpToggle("deleteGroup", isOpen)}
|
||||||
|
deleteKey="confirm"
|
||||||
|
onDeleteApproved={() =>
|
||||||
|
onRemoveGroupSubmit((popUp?.deleteGroup?.data as { slug: string })?.slug)
|
||||||
}
|
}
|
||||||
};
|
/>
|
||||||
|
<UpgradePlanModal
|
||||||
return (
|
isOpen={popUp.upgradePlan.isOpen}
|
||||||
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
|
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
|
||||||
<div className="mb-4 flex items-center justify-between">
|
text={(popUp.upgradePlan?.data as { description: string })?.description}
|
||||||
<p className="text-xl font-semibold text-mineshaft-100">Groups</p>
|
/>
|
||||||
<ProjectPermissionCan I={ProjectPermissionActions.Create} a={ProjectPermissionSub.Groups}>
|
</div>
|
||||||
{(isAllowed) => (
|
);
|
||||||
<Button
|
};
|
||||||
colorSchema="primary"
|
|
||||||
type="submit"
|
|
||||||
leftIcon={<FontAwesomeIcon icon={faPlus} />}
|
|
||||||
onClick={() => handleAddGroupModal()}
|
|
||||||
isDisabled={!isAllowed}
|
|
||||||
>
|
|
||||||
Add Group
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</ProjectPermissionCan>
|
|
||||||
</div>
|
|
||||||
<GroupModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
|
|
||||||
<GroupTable handlePopUpOpen={handlePopUpOpen} />
|
|
||||||
<DeleteActionModal
|
|
||||||
isOpen={popUp.deleteGroup.isOpen}
|
|
||||||
title={`Are you sure want to remove the group ${
|
|
||||||
(popUp?.deleteGroup?.data as { name: string })?.name || ""
|
|
||||||
} from the project?`}
|
|
||||||
onChange={(isOpen) => handlePopUpToggle("deleteGroup", isOpen)}
|
|
||||||
deleteKey="confirm"
|
|
||||||
onDeleteApproved={() =>
|
|
||||||
onRemoveGroupSubmit(
|
|
||||||
(popUp?.deleteGroup?.data as { slug: string })?.slug
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<UpgradePlanModal
|
|
||||||
isOpen={popUp.upgradePlan.isOpen}
|
|
||||||
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
|
|
||||||
text={(popUp.upgradePlan?.data as { description: string })?.description}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
+66
-62
@@ -1,4 +1,4 @@
|
|||||||
import { faServer, faXmark } from "@fortawesome/free-solid-svg-icons";
|
import { faServer, faTrash } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
|
|
||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
Td,
|
Td,
|
||||||
Th,
|
Th,
|
||||||
THead,
|
THead,
|
||||||
|
Tooltip,
|
||||||
Tr
|
Tr
|
||||||
} from "@app/components/v2";
|
} from "@app/components/v2";
|
||||||
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
||||||
@@ -36,68 +37,71 @@ export const GroupTable = ({ handlePopUpOpen }: Props) => {
|
|||||||
const { data, isLoading } = useListWorkspaceGroups(currentWorkspace?.slug || "");
|
const { data, isLoading } = useListWorkspaceGroups(currentWorkspace?.slug || "");
|
||||||
return (
|
return (
|
||||||
<TableContainer>
|
<TableContainer>
|
||||||
<Table>
|
<Table>
|
||||||
<THead>
|
<THead>
|
||||||
<Tr>
|
<Tr>
|
||||||
<Th>Name</Th>
|
<Th>Name</Th>
|
||||||
<Th>Role</Th>
|
<Th>Role</Th>
|
||||||
<Th>Added on</Th>
|
<Th>Added on</Th>
|
||||||
<Th className="w-5" />
|
<Th className="w-5" />
|
||||||
</Tr>
|
</Tr>
|
||||||
</THead>
|
</THead>
|
||||||
<TBody>
|
<TBody>
|
||||||
{isLoading && <TableSkeleton columns={4} innerKey="project-groups" />}
|
{isLoading && <TableSkeleton columns={4} innerKey="project-groups" />}
|
||||||
{!isLoading &&
|
{!isLoading &&
|
||||||
data &&
|
data &&
|
||||||
data.length > 0 &&
|
data.length > 0 &&
|
||||||
data.map(({ group: { id, name, slug }, roles, createdAt }) => {
|
data.map(({ group: { id, name, slug }, roles, createdAt }) => {
|
||||||
return (
|
return (
|
||||||
<Tr className="h-10" key={`st-v3-${id}`}>
|
<Tr className="group h-10" key={`st-v3-${id}`}>
|
||||||
<Td>{name}</Td>
|
<Td>{name}</Td>
|
||||||
<Td>
|
<Td>
|
||||||
<ProjectPermissionCan
|
<ProjectPermissionCan
|
||||||
I={ProjectPermissionActions.Edit}
|
I={ProjectPermissionActions.Edit}
|
||||||
a={ProjectPermissionSub.Groups}
|
a={ProjectPermissionSub.Groups}
|
||||||
|
>
|
||||||
|
{(isAllowed) => (
|
||||||
|
<GroupRoles roles={roles} disableEdit={!isAllowed} groupSlug={slug} />
|
||||||
|
)}
|
||||||
|
</ProjectPermissionCan>
|
||||||
|
</Td>
|
||||||
|
<Td>{format(new Date(createdAt), "yyyy-MM-dd")}</Td>
|
||||||
|
<Td className="flex justify-end">
|
||||||
|
<ProjectPermissionCan
|
||||||
|
I={ProjectPermissionActions.Delete}
|
||||||
|
a={ProjectPermissionSub.Groups}
|
||||||
|
>
|
||||||
|
{(isAllowed) => (
|
||||||
|
<div className="opacity-0 transition-opacity duration-300 group-hover:opacity-100">
|
||||||
|
<Tooltip content="Remove">
|
||||||
|
<IconButton
|
||||||
|
onClick={() => {
|
||||||
|
handlePopUpOpen("deleteGroup", {
|
||||||
|
slug,
|
||||||
|
name
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
colorSchema="danger"
|
||||||
|
variant="plain"
|
||||||
|
ariaLabel="update"
|
||||||
|
className="ml-4"
|
||||||
|
isDisabled={!isAllowed}
|
||||||
>
|
>
|
||||||
{(isAllowed) => (
|
<FontAwesomeIcon icon={faTrash} />
|
||||||
<GroupRoles roles={roles} disableEdit={!isAllowed} groupSlug={slug} />
|
</IconButton>
|
||||||
)}
|
</Tooltip>
|
||||||
</ProjectPermissionCan>
|
</div>
|
||||||
</Td>
|
)}
|
||||||
<Td>{format(new Date(createdAt), "yyyy-MM-dd")}</Td>
|
</ProjectPermissionCan>
|
||||||
<Td className="flex justify-end">
|
</Td>
|
||||||
<ProjectPermissionCan
|
</Tr>
|
||||||
I={ProjectPermissionActions.Delete}
|
);
|
||||||
a={ProjectPermissionSub.Groups}
|
})}
|
||||||
>
|
</TBody>
|
||||||
{(isAllowed) => (
|
</Table>
|
||||||
<IconButton
|
{!isLoading && data?.length === 0 && (
|
||||||
onClick={() => {
|
<EmptyState title="No groups have been added to this project" icon={faServer} />
|
||||||
handlePopUpOpen("deleteGroup", {
|
)}
|
||||||
slug,
|
|
||||||
name
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
size="lg"
|
|
||||||
colorSchema="danger"
|
|
||||||
variant="plain"
|
|
||||||
ariaLabel="update"
|
|
||||||
className="ml-4"
|
|
||||||
isDisabled={!isAllowed}
|
|
||||||
>
|
|
||||||
<FontAwesomeIcon icon={faXmark} />
|
|
||||||
</IconButton>
|
|
||||||
)}
|
|
||||||
</ProjectPermissionCan>
|
|
||||||
</Td>
|
|
||||||
</Tr>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</TBody>
|
|
||||||
</Table>
|
|
||||||
{!isLoading && data?.length === 0 && (
|
|
||||||
<EmptyState title="No groups have been added to this project" icon={faServer} />
|
|
||||||
)}
|
|
||||||
</TableContainer>
|
</TableContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,505 +0,0 @@
|
|||||||
import { useMemo, useState } from "react";
|
|
||||||
import { Controller, useForm } from "react-hook-form";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import Link from "next/link";
|
|
||||||
import {
|
|
||||||
faClock,
|
|
||||||
faEdit,
|
|
||||||
faMagnifyingGlass,
|
|
||||||
faPlus,
|
|
||||||
faUsers,
|
|
||||||
faXmark
|
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import { motion } from "framer-motion";
|
|
||||||
import { twMerge } from "tailwind-merge";
|
|
||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
|
||||||
import { ProjectPermissionCan } from "@app/components/permissions";
|
|
||||||
import {
|
|
||||||
Button,
|
|
||||||
DeleteActionModal,
|
|
||||||
EmptyState,
|
|
||||||
FormControl,
|
|
||||||
HoverCard,
|
|
||||||
HoverCardContent,
|
|
||||||
HoverCardTrigger,
|
|
||||||
IconButton,
|
|
||||||
Input,
|
|
||||||
Modal,
|
|
||||||
ModalContent,
|
|
||||||
Select,
|
|
||||||
SelectItem,
|
|
||||||
Table,
|
|
||||||
TableContainer,
|
|
||||||
TableSkeleton,
|
|
||||||
Tag,
|
|
||||||
TBody,
|
|
||||||
Td,
|
|
||||||
Th,
|
|
||||||
THead,
|
|
||||||
Tooltip,
|
|
||||||
Tr,
|
|
||||||
UpgradePlanModal
|
|
||||||
} from "@app/components/v2";
|
|
||||||
import {
|
|
||||||
ProjectPermissionActions,
|
|
||||||
ProjectPermissionSub,
|
|
||||||
useOrganization,
|
|
||||||
useUser,
|
|
||||||
useWorkspace
|
|
||||||
} from "@app/context";
|
|
||||||
import { usePopUp } from "@app/hooks";
|
|
||||||
import {
|
|
||||||
useAddUserToWsE2EE,
|
|
||||||
useAddUserToWsNonE2EE,
|
|
||||||
useDeleteUserFromWorkspace,
|
|
||||||
useGetOrgUsers,
|
|
||||||
useGetUserWsKey,
|
|
||||||
useGetWorkspaceUsers
|
|
||||||
} from "@app/hooks/api";
|
|
||||||
import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
|
|
||||||
import { TWorkspaceUser } from "@app/hooks/api/types";
|
|
||||||
import { ProjectVersion } from "@app/hooks/api/workspace/types";
|
|
||||||
|
|
||||||
import { MemberRoleForm } from "./MemberRoleForm";
|
|
||||||
|
|
||||||
const addMemberFormSchema = z.object({
|
|
||||||
orgMembershipId: z.string().trim()
|
|
||||||
});
|
|
||||||
|
|
||||||
type TAddMemberForm = z.infer<typeof addMemberFormSchema>;
|
|
||||||
|
|
||||||
const MAX_ROLES_TO_BE_SHOWN_IN_TABLE = 2;
|
|
||||||
const formatRoleName = (role: string, customRoleName?: string) => {
|
|
||||||
if (role === ProjectMembershipRole.Custom) return customRoleName;
|
|
||||||
if (role === ProjectMembershipRole.Member) return "Developer";
|
|
||||||
if (role === ProjectMembershipRole.NoAccess) return "No access";
|
|
||||||
return role;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const MemberListTab = () => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
const { currentOrg } = useOrganization();
|
|
||||||
const { currentWorkspace } = useWorkspace();
|
|
||||||
const { user } = useUser();
|
|
||||||
|
|
||||||
const userId = user?.id || "";
|
|
||||||
const orgId = currentOrg?.id || "";
|
|
||||||
const workspaceId = currentWorkspace?.id || "";
|
|
||||||
|
|
||||||
const { data: wsKey } = useGetUserWsKey(workspaceId);
|
|
||||||
const { data: members, isLoading: isMembersLoading } = useGetWorkspaceUsers(workspaceId);
|
|
||||||
const { data: orgUsers } = useGetOrgUsers(orgId);
|
|
||||||
|
|
||||||
const [searchMemberFilter, setSearchMemberFilter] = useState("");
|
|
||||||
|
|
||||||
const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
|
|
||||||
"addMember",
|
|
||||||
"removeMember",
|
|
||||||
"upgradePlan",
|
|
||||||
"updateRole"
|
|
||||||
] as const);
|
|
||||||
|
|
||||||
const {
|
|
||||||
control,
|
|
||||||
handleSubmit,
|
|
||||||
reset,
|
|
||||||
formState: { isSubmitting }
|
|
||||||
} = useForm<TAddMemberForm>({ resolver: zodResolver(addMemberFormSchema) });
|
|
||||||
|
|
||||||
const { mutateAsync: addUserToWorkspace } = useAddUserToWsE2EE();
|
|
||||||
const { mutateAsync: addUserToWorkspaceNonE2EE } = useAddUserToWsNonE2EE();
|
|
||||||
const { mutateAsync: removeUserFromWorkspace } = useDeleteUserFromWorkspace();
|
|
||||||
|
|
||||||
const onAddMember = async ({ orgMembershipId }: TAddMemberForm) => {
|
|
||||||
if (!currentWorkspace) return;
|
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
// TODO(akhilmhdh): Move to memory storage
|
|
||||||
const userPrivateKey = localStorage.getItem("PRIVATE_KEY");
|
|
||||||
if (!userPrivateKey || !wsKey) {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to find private key. Try re-login"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const orgUser = (orgUsers || []).find(({ id }) => id === orgMembershipId);
|
|
||||||
if (!orgUser) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
// TODO: update
|
|
||||||
if (currentWorkspace.version === ProjectVersion.V1) {
|
|
||||||
await addUserToWorkspace({
|
|
||||||
workspaceId,
|
|
||||||
userPrivateKey,
|
|
||||||
decryptKey: wsKey,
|
|
||||||
members: [{ orgMembershipId, userPublicKey: orgUser.user.publicKey }]
|
|
||||||
});
|
|
||||||
} else if (currentWorkspace.version === ProjectVersion.V2) {
|
|
||||||
await addUserToWorkspaceNonE2EE({
|
|
||||||
projectId: workspaceId,
|
|
||||||
usernames: [orgUser.user.username]
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to add user to project, unknown project type",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully added user to the project",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to add user to project",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
handlePopUpClose("addMember");
|
|
||||||
reset();
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleRemoveUser = async () => {
|
|
||||||
const username = (popUp?.removeMember?.data as { username: string })?.username;
|
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await removeUserFromWorkspace({ workspaceId, usernames: [username] });
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully removed user from project",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to remove user from the project",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
handlePopUpClose("removeMember");
|
|
||||||
};
|
|
||||||
|
|
||||||
const filterdUsers = useMemo(
|
|
||||||
() =>
|
|
||||||
members?.filter(
|
|
||||||
({ user: u, inviteEmail }) =>
|
|
||||||
u?.firstName?.toLowerCase().includes(searchMemberFilter.toLowerCase()) ||
|
|
||||||
u?.lastName?.toLowerCase().includes(searchMemberFilter.toLowerCase()) ||
|
|
||||||
u?.username?.toLowerCase().includes(searchMemberFilter.toLowerCase()) ||
|
|
||||||
u?.email?.toLowerCase().includes(searchMemberFilter.toLowerCase()) ||
|
|
||||||
inviteEmail?.includes(searchMemberFilter.toLowerCase())
|
|
||||||
),
|
|
||||||
[members, searchMemberFilter]
|
|
||||||
);
|
|
||||||
|
|
||||||
const filteredOrgUsers = useMemo(() => {
|
|
||||||
const wsUserUsernames = new Map();
|
|
||||||
members?.forEach((member) => {
|
|
||||||
wsUserUsernames.set(member.user.username, true);
|
|
||||||
});
|
|
||||||
return (orgUsers || []).filter(
|
|
||||||
({ status, user: u }) => status === "accepted" && !wsUserUsernames.has(u.username)
|
|
||||||
);
|
|
||||||
}, [orgUsers, members]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<motion.div
|
|
||||||
key="user-role-1"
|
|
||||||
className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4"
|
|
||||||
transition={{ duration: 0.15 }}
|
|
||||||
initial={{ opacity: 0, translateX: 30 }}
|
|
||||||
animate={{ opacity: 1, translateX: 0 }}
|
|
||||||
exit={{ opacity: 0, translateX: 30 }}
|
|
||||||
>
|
|
||||||
<div className="mb-4 flex items-center justify-between">
|
|
||||||
<p className="text-xl font-semibold text-mineshaft-100">Members</p>
|
|
||||||
<ProjectPermissionCan I={ProjectPermissionActions.Create} a={ProjectPermissionSub.Member}>
|
|
||||||
{(isAllowed) => (
|
|
||||||
<Button
|
|
||||||
colorSchema="primary"
|
|
||||||
type="submit"
|
|
||||||
leftIcon={<FontAwesomeIcon icon={faPlus} />}
|
|
||||||
onClick={() => handlePopUpOpen("addMember")}
|
|
||||||
isDisabled={!isAllowed}
|
|
||||||
>
|
|
||||||
Add Member
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</ProjectPermissionCan>
|
|
||||||
</div>
|
|
||||||
<Input
|
|
||||||
value={searchMemberFilter}
|
|
||||||
onChange={(e) => setSearchMemberFilter(e.target.value)}
|
|
||||||
leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
|
|
||||||
placeholder="Search members..."
|
|
||||||
/>
|
|
||||||
<div className="mt-4">
|
|
||||||
<TableContainer>
|
|
||||||
<Table>
|
|
||||||
<THead>
|
|
||||||
<Tr>
|
|
||||||
<Th>Name</Th>
|
|
||||||
<Th>Username</Th>
|
|
||||||
<Th>Role</Th>
|
|
||||||
<Th className="w-5" />
|
|
||||||
</Tr>
|
|
||||||
</THead>
|
|
||||||
<TBody>
|
|
||||||
{isMembersLoading && <TableSkeleton columns={4} innerKey="project-members" />}
|
|
||||||
{!isMembersLoading &&
|
|
||||||
filterdUsers?.map((projectMember, index) => {
|
|
||||||
const { user: u, inviteEmail, id: membershipId, roles } = projectMember;
|
|
||||||
const name = u ? `${u.firstName} ${u.lastName}` : "-";
|
|
||||||
const email = u?.email || inviteEmail;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Tr key={`membership-${membershipId}`} className="w-full">
|
|
||||||
<Td>{name}</Td>
|
|
||||||
<Td>{email}</Td>
|
|
||||||
<Td>
|
|
||||||
<div className="flex items-center space-x-2">
|
|
||||||
{roles
|
|
||||||
.slice(0, MAX_ROLES_TO_BE_SHOWN_IN_TABLE)
|
|
||||||
.map(
|
|
||||||
({
|
|
||||||
role,
|
|
||||||
customRoleName,
|
|
||||||
id,
|
|
||||||
isTemporary,
|
|
||||||
temporaryAccessEndTime
|
|
||||||
}) => {
|
|
||||||
const isExpired =
|
|
||||||
new Date() > new Date(temporaryAccessEndTime || ("" as string));
|
|
||||||
return (
|
|
||||||
<Tag key={id}>
|
|
||||||
<div className="flex items-center space-x-2">
|
|
||||||
<div className="capitalize">
|
|
||||||
{formatRoleName(role, customRoleName)}
|
|
||||||
</div>
|
|
||||||
{isTemporary && (
|
|
||||||
<div>
|
|
||||||
<Tooltip
|
|
||||||
content={
|
|
||||||
isExpired ? "Timed role expired" : "Timed role access"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<FontAwesomeIcon
|
|
||||||
icon={faClock}
|
|
||||||
className={twMerge(isExpired && "text-red-600")}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</Tag>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
{roles.length > MAX_ROLES_TO_BE_SHOWN_IN_TABLE && (
|
|
||||||
<HoverCard>
|
|
||||||
<HoverCardTrigger>
|
|
||||||
<Tag>+{roles.length - MAX_ROLES_TO_BE_SHOWN_IN_TABLE}</Tag>
|
|
||||||
</HoverCardTrigger>
|
|
||||||
<HoverCardContent className="border border-gray-700 bg-mineshaft-800 p-4">
|
|
||||||
{roles
|
|
||||||
.slice(MAX_ROLES_TO_BE_SHOWN_IN_TABLE)
|
|
||||||
.map(
|
|
||||||
({
|
|
||||||
role,
|
|
||||||
customRoleName,
|
|
||||||
id,
|
|
||||||
isTemporary,
|
|
||||||
temporaryAccessEndTime
|
|
||||||
}) => {
|
|
||||||
const isExpired =
|
|
||||||
new Date() >
|
|
||||||
new Date(temporaryAccessEndTime || ("" as string));
|
|
||||||
return (
|
|
||||||
<Tag key={id} className="capitalize">
|
|
||||||
<div className="flex items-center space-x-2">
|
|
||||||
<div>{formatRoleName(role, customRoleName)}</div>
|
|
||||||
{isTemporary && (
|
|
||||||
<div>
|
|
||||||
<Tooltip
|
|
||||||
content={
|
|
||||||
isExpired
|
|
||||||
? "Access expired"
|
|
||||||
: "Temporary access"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<FontAwesomeIcon
|
|
||||||
icon={faClock}
|
|
||||||
className={twMerge(
|
|
||||||
new Date() >
|
|
||||||
new Date(
|
|
||||||
temporaryAccessEndTime as string
|
|
||||||
) && "text-red-600"
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</Tag>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
</HoverCardContent>
|
|
||||||
</HoverCard>
|
|
||||||
)}
|
|
||||||
{userId !== u?.id && (
|
|
||||||
<Tooltip content="Edit permission">
|
|
||||||
<IconButton
|
|
||||||
size="sm"
|
|
||||||
variant="plain"
|
|
||||||
ariaLabel="update-role"
|
|
||||||
onClick={() =>
|
|
||||||
handlePopUpOpen("updateRole", { ...projectMember, index })
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<FontAwesomeIcon icon={faEdit} />
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</Td>
|
|
||||||
<Td>
|
|
||||||
{userId !== u?.id && (
|
|
||||||
<div className="flex items-center space-x-2">
|
|
||||||
<ProjectPermissionCan
|
|
||||||
I={ProjectPermissionActions.Delete}
|
|
||||||
a={ProjectPermissionSub.Member}
|
|
||||||
>
|
|
||||||
{(isAllowed) => (
|
|
||||||
<IconButton
|
|
||||||
size="lg"
|
|
||||||
colorSchema="danger"
|
|
||||||
variant="plain"
|
|
||||||
ariaLabel="update"
|
|
||||||
className="ml-4"
|
|
||||||
isDisabled={userId === u?.id || !isAllowed}
|
|
||||||
onClick={() =>
|
|
||||||
handlePopUpOpen("removeMember", { username: u.username })
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<FontAwesomeIcon icon={faXmark} />
|
|
||||||
</IconButton>
|
|
||||||
)}
|
|
||||||
</ProjectPermissionCan>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Td>
|
|
||||||
</Tr>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</TBody>
|
|
||||||
</Table>
|
|
||||||
{!isMembersLoading && filterdUsers?.length === 0 && (
|
|
||||||
<EmptyState title="No project members found" icon={faUsers} />
|
|
||||||
)}
|
|
||||||
</TableContainer>
|
|
||||||
</div>
|
|
||||||
<Modal
|
|
||||||
isOpen={popUp?.addMember?.isOpen}
|
|
||||||
onOpenChange={(isOpen) => handlePopUpToggle("addMember", isOpen)}
|
|
||||||
>
|
|
||||||
<ModalContent
|
|
||||||
title={t("section.members.add-dialog.add-member-to-project") as string}
|
|
||||||
subTitle={t("section.members.add-dialog.user-will-email")}
|
|
||||||
>
|
|
||||||
{filteredOrgUsers.length ? (
|
|
||||||
<form onSubmit={handleSubmit(onAddMember)}>
|
|
||||||
<Controller
|
|
||||||
control={control}
|
|
||||||
defaultValue={filteredOrgUsers?.[0]?.user?.username}
|
|
||||||
name="orgMembershipId"
|
|
||||||
render={({ field, fieldState: { error } }) => (
|
|
||||||
<FormControl label="Username" isError={Boolean(error)} errorText={error?.message}>
|
|
||||||
<Select
|
|
||||||
position="popper"
|
|
||||||
className="w-full"
|
|
||||||
defaultValue={filteredOrgUsers?.[0]?.user?.username}
|
|
||||||
value={field.value}
|
|
||||||
onValueChange={field.onChange}
|
|
||||||
>
|
|
||||||
{filteredOrgUsers.map(({ id: orgUserId, user: u }) => (
|
|
||||||
<SelectItem value={orgUserId} key={`org-membership-join-${orgUserId}`}>
|
|
||||||
{u?.username}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</FormControl>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<div className="mt-8 flex items-center">
|
|
||||||
<Button
|
|
||||||
className="mr-4"
|
|
||||||
size="sm"
|
|
||||||
type="submit"
|
|
||||||
isLoading={isSubmitting}
|
|
||||||
isDisabled={isSubmitting}
|
|
||||||
>
|
|
||||||
Add Member
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
colorSchema="secondary"
|
|
||||||
variant="plain"
|
|
||||||
onClick={() => handlePopUpClose("addMember")}
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
) : (
|
|
||||||
<div className="flex flex-col space-y-4">
|
|
||||||
<div>All the users in your organization are already invited.</div>
|
|
||||||
<Link href={`/org/${currentWorkspace?.orgId}/members`}>
|
|
||||||
<Button variant="outline_bg">Add users to organization</Button>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</ModalContent>
|
|
||||||
</Modal>
|
|
||||||
<Modal
|
|
||||||
isOpen={popUp.updateRole.isOpen}
|
|
||||||
onOpenChange={(state) => handlePopUpToggle("updateRole", state)}
|
|
||||||
>
|
|
||||||
<ModalContent
|
|
||||||
className="max-w-4xl"
|
|
||||||
title={`Manage Access for ${(popUp.updateRole.data as TWorkspaceUser)?.user?.email}`}
|
|
||||||
subTitle={`
|
|
||||||
Configure role-based access control by assigning Infisical users a mix of roles and specific privileges. A user will gain access to all actions within the roles assigned to them, not just the actions those roles share in common. You must choose at least one permanent role.
|
|
||||||
`}
|
|
||||||
>
|
|
||||||
<MemberRoleForm
|
|
||||||
onOpenUpgradeModal={(description) => handlePopUpOpen("upgradePlan", { description })}
|
|
||||||
projectMember={
|
|
||||||
filterdUsers?.[
|
|
||||||
(popUp.updateRole?.data as TWorkspaceUser & { index: number })?.index
|
|
||||||
] as TWorkspaceUser
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</ModalContent>
|
|
||||||
</Modal>
|
|
||||||
<DeleteActionModal
|
|
||||||
isOpen={popUp.removeMember.isOpen}
|
|
||||||
deleteKey="remove"
|
|
||||||
title="Do you want to remove this user from the project?"
|
|
||||||
onChange={(isOpen) => handlePopUpToggle("removeMember", isOpen)}
|
|
||||||
onDeleteApproved={handleRemoveUser}
|
|
||||||
/>
|
|
||||||
<UpgradePlanModal
|
|
||||||
isOpen={popUp.upgradePlan.isOpen}
|
|
||||||
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
|
|
||||||
text={(popUp.upgradePlan?.data as { description: string })?.description}
|
|
||||||
/>
|
|
||||||
</motion.div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { MemberListTab } from "./MemberListTab";
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { motion } from "framer-motion";
|
||||||
|
|
||||||
|
import { useWorkspace } from "@app/context";
|
||||||
|
|
||||||
|
import { GroupsSection } from "../GroupsTab/components";
|
||||||
|
import { MembersSection } from "./components";
|
||||||
|
|
||||||
|
export const MembersTab = () => {
|
||||||
|
const { currentWorkspace } = useWorkspace();
|
||||||
|
return (
|
||||||
|
<motion.div
|
||||||
|
key="panel-project-members"
|
||||||
|
transition={{ duration: 0.15 }}
|
||||||
|
initial={{ opacity: 0, translateX: 30 }}
|
||||||
|
animate={{ opacity: 1, translateX: 0 }}
|
||||||
|
exit={{ opacity: 0, translateX: 30 }}
|
||||||
|
>
|
||||||
|
<MembersSection />
|
||||||
|
{currentWorkspace?.version && currentWorkspace.version > 1 && <GroupsSection />}
|
||||||
|
</motion.div>
|
||||||
|
);
|
||||||
|
};
|
||||||
+177
@@ -0,0 +1,177 @@
|
|||||||
|
import { useMemo } from "react";
|
||||||
|
import { Controller, useForm } from "react-hook-form";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import Link from "next/link";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { createNotification } from "@app/components/notifications";
|
||||||
|
import { Button,FormControl, Modal, ModalContent, Select, SelectItem } from "@app/components/v2";
|
||||||
|
import { useOrganization, useWorkspace } from "@app/context";
|
||||||
|
import {
|
||||||
|
useAddUserToWsE2EE,
|
||||||
|
useAddUserToWsNonE2EE,
|
||||||
|
useGetOrgUsers,
|
||||||
|
useGetUserWsKey,
|
||||||
|
useGetWorkspaceUsers} from "@app/hooks/api";
|
||||||
|
import { ProjectVersion } from "@app/hooks/api/workspace/types";
|
||||||
|
import { UsePopUpState } from "@app/hooks/usePopUp";
|
||||||
|
|
||||||
|
const addMemberFormSchema = z.object({
|
||||||
|
orgMembershipId: z.string().trim()
|
||||||
|
});
|
||||||
|
|
||||||
|
type TAddMemberForm = z.infer<typeof addMemberFormSchema>;
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
popUp: UsePopUpState<["addMember"]>;
|
||||||
|
handlePopUpToggle: (popUpName: keyof UsePopUpState<["addMember"]>, state?: boolean) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const AddMemberModal = ({ popUp, handlePopUpToggle }: Props) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { currentOrg } = useOrganization();
|
||||||
|
const { currentWorkspace } = useWorkspace();
|
||||||
|
|
||||||
|
const orgId = currentOrg?.id || "";
|
||||||
|
const workspaceId = currentWorkspace?.id || "";
|
||||||
|
|
||||||
|
const { data: wsKey } = useGetUserWsKey(workspaceId);
|
||||||
|
const { data: members } = useGetWorkspaceUsers(workspaceId);
|
||||||
|
const { data: orgUsers } = useGetOrgUsers(orgId);
|
||||||
|
|
||||||
|
const { mutateAsync: addUserToWorkspace } = useAddUserToWsE2EE();
|
||||||
|
const { mutateAsync: addUserToWorkspaceNonE2EE } = useAddUserToWsNonE2EE();
|
||||||
|
|
||||||
|
const {
|
||||||
|
control,
|
||||||
|
handleSubmit,
|
||||||
|
reset,
|
||||||
|
formState: { isSubmitting }
|
||||||
|
} = useForm<TAddMemberForm>({ resolver: zodResolver(addMemberFormSchema) });
|
||||||
|
|
||||||
|
const onAddMember = async ({ orgMembershipId }: TAddMemberForm) => {
|
||||||
|
if (!currentWorkspace) return;
|
||||||
|
if (!currentOrg?.id) return;
|
||||||
|
// TODO(akhilmhdh): Move to memory storage
|
||||||
|
const userPrivateKey = localStorage.getItem("PRIVATE_KEY");
|
||||||
|
if (!userPrivateKey || !wsKey) {
|
||||||
|
createNotification({
|
||||||
|
text: "Failed to find private key. Try re-login"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const orgUser = (orgUsers || []).find(({ id }) => id === orgMembershipId);
|
||||||
|
if (!orgUser) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// TODO: update
|
||||||
|
if (currentWorkspace.version === ProjectVersion.V1) {
|
||||||
|
await addUserToWorkspace({
|
||||||
|
workspaceId,
|
||||||
|
userPrivateKey,
|
||||||
|
decryptKey: wsKey,
|
||||||
|
members: [{ orgMembershipId, userPublicKey: orgUser.user.publicKey }]
|
||||||
|
});
|
||||||
|
} else if (currentWorkspace.version === ProjectVersion.V2) {
|
||||||
|
await addUserToWorkspaceNonE2EE({
|
||||||
|
projectId: workspaceId,
|
||||||
|
usernames: [orgUser.user.username]
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
createNotification({
|
||||||
|
text: "Failed to add user to project, unknown project type",
|
||||||
|
type: "error"
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully added user to the project",
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
createNotification({
|
||||||
|
text: "Failed to add user to project",
|
||||||
|
type: "error"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
handlePopUpToggle("addMember", false);
|
||||||
|
reset();
|
||||||
|
};
|
||||||
|
|
||||||
|
const filteredOrgUsers = useMemo(() => {
|
||||||
|
const wsUserUsernames = new Map();
|
||||||
|
members?.forEach((member) => {
|
||||||
|
wsUserUsernames.set(member.user.username, true);
|
||||||
|
});
|
||||||
|
return (orgUsers || []).filter(
|
||||||
|
({ status, user: u }) => status === "accepted" && !wsUserUsernames.has(u.username)
|
||||||
|
);
|
||||||
|
}, [orgUsers, members]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
isOpen={popUp?.addMember?.isOpen}
|
||||||
|
onOpenChange={(isOpen) => handlePopUpToggle("addMember", isOpen)}
|
||||||
|
>
|
||||||
|
<ModalContent
|
||||||
|
title={t("section.members.add-dialog.add-member-to-project") as string}
|
||||||
|
subTitle={t("section.members.add-dialog.user-will-email")}
|
||||||
|
>
|
||||||
|
{filteredOrgUsers.length ? (
|
||||||
|
<form onSubmit={handleSubmit(onAddMember)}>
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
defaultValue={filteredOrgUsers?.[0]?.user?.username}
|
||||||
|
name="orgMembershipId"
|
||||||
|
render={({ field, fieldState: { error } }) => (
|
||||||
|
<FormControl label="Username" isError={Boolean(error)} errorText={error?.message}>
|
||||||
|
<Select
|
||||||
|
position="popper"
|
||||||
|
className="w-full"
|
||||||
|
defaultValue={filteredOrgUsers?.[0]?.user?.username}
|
||||||
|
value={field.value}
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
>
|
||||||
|
{filteredOrgUsers.map(({ id: orgUserId, user: u }) => (
|
||||||
|
<SelectItem value={orgUserId} key={`org-membership-join-${orgUserId}`}>
|
||||||
|
{u?.username}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<div className="mt-8 flex items-center">
|
||||||
|
<Button
|
||||||
|
className="mr-4"
|
||||||
|
size="sm"
|
||||||
|
type="submit"
|
||||||
|
isLoading={isSubmitting}
|
||||||
|
isDisabled={isSubmitting}
|
||||||
|
>
|
||||||
|
Add Member
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
colorSchema="secondary"
|
||||||
|
variant="plain"
|
||||||
|
onClick={() => handlePopUpToggle("addMember", false)}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
) : (
|
||||||
|
<div className="flex flex-col space-y-4">
|
||||||
|
<div>All the users in your organization are already invited.</div>
|
||||||
|
<Link href={`/org/${currentWorkspace?.orgId}/members`}>
|
||||||
|
<Button variant="outline_bg">Add users to organization</Button>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</ModalContent>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
+86
@@ -0,0 +1,86 @@
|
|||||||
|
import { faPlus } from "@fortawesome/free-solid-svg-icons";
|
||||||
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
|
|
||||||
|
import { createNotification } from "@app/components/notifications";
|
||||||
|
import { ProjectPermissionCan } from "@app/components/permissions";
|
||||||
|
import { Button, DeleteActionModal, UpgradePlanModal } from "@app/components/v2";
|
||||||
|
import { ProjectPermissionActions, ProjectPermissionSub , useOrganization, useWorkspace } from "@app/context";
|
||||||
|
import { usePopUp } from "@app/hooks";
|
||||||
|
import { useDeleteUserFromWorkspace } from "@app/hooks/api";
|
||||||
|
|
||||||
|
import { AddMemberModal } from "./AddMemberModal";
|
||||||
|
import { MembersTable } from "./MembersTable";
|
||||||
|
|
||||||
|
export const MembersSection = () => {
|
||||||
|
const { currentOrg } = useOrganization();
|
||||||
|
const { currentWorkspace } = useWorkspace();
|
||||||
|
|
||||||
|
const { mutateAsync: removeUserFromWorkspace } = useDeleteUserFromWorkspace();
|
||||||
|
|
||||||
|
const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
|
||||||
|
"addMember",
|
||||||
|
"removeMember",
|
||||||
|
"upgradePlan",
|
||||||
|
"updateRole"
|
||||||
|
] as const);
|
||||||
|
|
||||||
|
const handleRemoveUser = async () => {
|
||||||
|
const username = (popUp?.removeMember?.data as { username: string })?.username;
|
||||||
|
if (!currentOrg?.id) return;
|
||||||
|
if (!currentWorkspace?.id) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await removeUserFromWorkspace({ workspaceId: currentWorkspace.id, usernames: [username] });
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully removed user from project",
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
createNotification({
|
||||||
|
text: "Failed to remove user from the project",
|
||||||
|
type: "error"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
handlePopUpClose("removeMember");
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
|
||||||
|
<div className="mb-4 flex justify-between">
|
||||||
|
<p className="text-xl font-semibold text-mineshaft-100">Users</p>
|
||||||
|
<ProjectPermissionCan I={ProjectPermissionActions.Create} a={ProjectPermissionSub.Member}>
|
||||||
|
{(isAllowed) => (
|
||||||
|
<Button
|
||||||
|
colorSchema="primary"
|
||||||
|
type="submit"
|
||||||
|
leftIcon={<FontAwesomeIcon icon={faPlus} />}
|
||||||
|
onClick={() => handlePopUpOpen("addMember")}
|
||||||
|
isDisabled={!isAllowed}
|
||||||
|
>
|
||||||
|
Add Member
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</ProjectPermissionCan>
|
||||||
|
</div>
|
||||||
|
<MembersTable
|
||||||
|
popUp={popUp}
|
||||||
|
handlePopUpOpen={handlePopUpOpen}
|
||||||
|
handlePopUpToggle={handlePopUpToggle}
|
||||||
|
/>
|
||||||
|
<AddMemberModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
|
||||||
|
<DeleteActionModal
|
||||||
|
isOpen={popUp.removeMember.isOpen}
|
||||||
|
deleteKey="remove"
|
||||||
|
title="Do you want to remove this user from the project?"
|
||||||
|
onChange={(isOpen) => handlePopUpToggle("removeMember", isOpen)}
|
||||||
|
onDeleteApproved={handleRemoveUser}
|
||||||
|
/>
|
||||||
|
<UpgradePlanModal
|
||||||
|
isOpen={popUp.upgradePlan.isOpen}
|
||||||
|
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
|
||||||
|
text={(popUp.upgradePlan?.data as { description: string })?.description}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
+269
@@ -0,0 +1,269 @@
|
|||||||
|
import { useMemo,useState } from "react";
|
||||||
|
import {
|
||||||
|
faClock,
|
||||||
|
faEdit,
|
||||||
|
faMagnifyingGlass,
|
||||||
|
faTrash,
|
||||||
|
faUsers} from "@fortawesome/free-solid-svg-icons";
|
||||||
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
|
import { ProjectPermissionCan } from "@app/components/permissions";
|
||||||
|
import {
|
||||||
|
EmptyState,
|
||||||
|
HoverCard,
|
||||||
|
HoverCardContent,
|
||||||
|
HoverCardTrigger,
|
||||||
|
IconButton,
|
||||||
|
Input,
|
||||||
|
Modal,
|
||||||
|
ModalContent,
|
||||||
|
Table,
|
||||||
|
TableContainer,
|
||||||
|
TableSkeleton,
|
||||||
|
Tag,
|
||||||
|
TBody,
|
||||||
|
Td,
|
||||||
|
Th,
|
||||||
|
THead,
|
||||||
|
Tooltip,
|
||||||
|
Tr} from "@app/components/v2";
|
||||||
|
import {
|
||||||
|
ProjectPermissionActions,
|
||||||
|
ProjectPermissionSub,
|
||||||
|
useUser,
|
||||||
|
useWorkspace} from "@app/context";
|
||||||
|
import { useGetWorkspaceUsers } from "@app/hooks/api";
|
||||||
|
import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
|
||||||
|
import { TWorkspaceUser } from "@app/hooks/api/types";
|
||||||
|
import { UsePopUpState } from "@app/hooks/usePopUp";
|
||||||
|
|
||||||
|
import { MemberRoleForm } from "./MemberRoleForm";
|
||||||
|
|
||||||
|
const MAX_ROLES_TO_BE_SHOWN_IN_TABLE = 2;
|
||||||
|
const formatRoleName = (role: string, customRoleName?: string) => {
|
||||||
|
if (role === ProjectMembershipRole.Custom) return customRoleName;
|
||||||
|
if (role === ProjectMembershipRole.Member) return "Developer";
|
||||||
|
if (role === ProjectMembershipRole.NoAccess) return "No access";
|
||||||
|
return role;
|
||||||
|
};
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
popUp: UsePopUpState<["updateRole"]>;
|
||||||
|
handlePopUpOpen: (
|
||||||
|
popUpName: keyof UsePopUpState<["removeMember", "updateRole", "upgradePlan"]>,
|
||||||
|
data?: {}
|
||||||
|
) => void;
|
||||||
|
handlePopUpToggle: (popUpName: keyof UsePopUpState<["updateRole"]>, state?: boolean) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const MembersTable = ({ popUp, handlePopUpOpen, handlePopUpToggle }: Props) => {
|
||||||
|
const [searchMemberFilter, setSearchMemberFilter] = useState("");
|
||||||
|
|
||||||
|
const { currentWorkspace } = useWorkspace();
|
||||||
|
const { user } = useUser();
|
||||||
|
|
||||||
|
const userId = user?.id || "";
|
||||||
|
const workspaceId = currentWorkspace?.id || "";
|
||||||
|
|
||||||
|
const { data: members, isLoading: isMembersLoading } = useGetWorkspaceUsers(workspaceId);
|
||||||
|
|
||||||
|
const filterdUsers = useMemo(
|
||||||
|
() =>
|
||||||
|
members?.filter(
|
||||||
|
({ user: u, inviteEmail }) =>
|
||||||
|
u?.firstName?.toLowerCase().includes(searchMemberFilter.toLowerCase()) ||
|
||||||
|
u?.lastName?.toLowerCase().includes(searchMemberFilter.toLowerCase()) ||
|
||||||
|
u?.username?.toLowerCase().includes(searchMemberFilter.toLowerCase()) ||
|
||||||
|
u?.email?.toLowerCase().includes(searchMemberFilter.toLowerCase()) ||
|
||||||
|
inviteEmail?.includes(searchMemberFilter.toLowerCase())
|
||||||
|
),
|
||||||
|
[members, searchMemberFilter]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Input
|
||||||
|
value={searchMemberFilter}
|
||||||
|
onChange={(e) => setSearchMemberFilter(e.target.value)}
|
||||||
|
leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
|
||||||
|
placeholder="Search members..."
|
||||||
|
/>
|
||||||
|
<TableContainer className="mt-4">
|
||||||
|
<Table>
|
||||||
|
<THead>
|
||||||
|
<Tr>
|
||||||
|
<Th>Name</Th>
|
||||||
|
<Th>Username</Th>
|
||||||
|
<Th>Role</Th>
|
||||||
|
<Th className="w-5" />
|
||||||
|
</Tr>
|
||||||
|
</THead>
|
||||||
|
<TBody>
|
||||||
|
{isMembersLoading && <TableSkeleton columns={4} innerKey="project-members" />}
|
||||||
|
{!isMembersLoading &&
|
||||||
|
filterdUsers?.map((projectMember, index) => {
|
||||||
|
const { user: u, inviteEmail, id: membershipId, roles } = projectMember;
|
||||||
|
const name = u ? `${u.firstName} ${u.lastName}` : "-";
|
||||||
|
const email = u?.email || inviteEmail;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tr key={`membership-${membershipId}`} className="group w-full">
|
||||||
|
<Td>{name}</Td>
|
||||||
|
<Td>{email}</Td>
|
||||||
|
<Td>
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
{roles
|
||||||
|
.slice(0, MAX_ROLES_TO_BE_SHOWN_IN_TABLE)
|
||||||
|
.map(
|
||||||
|
({ role, customRoleName, id, isTemporary, temporaryAccessEndTime }) => {
|
||||||
|
const isExpired =
|
||||||
|
new Date() > new Date(temporaryAccessEndTime || ("" as string));
|
||||||
|
return (
|
||||||
|
<Tag key={id}>
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<div className="capitalize">
|
||||||
|
{formatRoleName(role, customRoleName)}
|
||||||
|
</div>
|
||||||
|
{isTemporary && (
|
||||||
|
<div>
|
||||||
|
<Tooltip
|
||||||
|
content={
|
||||||
|
isExpired ? "Timed role expired" : "Timed role access"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon
|
||||||
|
icon={faClock}
|
||||||
|
className={twMerge(isExpired && "text-red-600")}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
{roles.length > MAX_ROLES_TO_BE_SHOWN_IN_TABLE && (
|
||||||
|
<HoverCard>
|
||||||
|
<HoverCardTrigger>
|
||||||
|
<Tag>+{roles.length - MAX_ROLES_TO_BE_SHOWN_IN_TABLE}</Tag>
|
||||||
|
</HoverCardTrigger>
|
||||||
|
<HoverCardContent className="border border-gray-700 bg-mineshaft-800 p-4">
|
||||||
|
{roles
|
||||||
|
.slice(MAX_ROLES_TO_BE_SHOWN_IN_TABLE)
|
||||||
|
.map(
|
||||||
|
({
|
||||||
|
role,
|
||||||
|
customRoleName,
|
||||||
|
id,
|
||||||
|
isTemporary,
|
||||||
|
temporaryAccessEndTime
|
||||||
|
}) => {
|
||||||
|
const isExpired =
|
||||||
|
new Date() >
|
||||||
|
new Date(temporaryAccessEndTime || ("" as string));
|
||||||
|
return (
|
||||||
|
<Tag key={id} className="capitalize">
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<div>{formatRoleName(role, customRoleName)}</div>
|
||||||
|
{isTemporary && (
|
||||||
|
<div>
|
||||||
|
<Tooltip
|
||||||
|
content={
|
||||||
|
isExpired ? "Access expired" : "Temporary access"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon
|
||||||
|
icon={faClock}
|
||||||
|
className={twMerge(
|
||||||
|
new Date() >
|
||||||
|
new Date(temporaryAccessEndTime as string) &&
|
||||||
|
"text-red-600"
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</HoverCardContent>
|
||||||
|
</HoverCard>
|
||||||
|
)}
|
||||||
|
{userId !== u?.id && (
|
||||||
|
<Tooltip content="Edit permission">
|
||||||
|
<IconButton
|
||||||
|
size="sm"
|
||||||
|
variant="plain"
|
||||||
|
ariaLabel="update-role"
|
||||||
|
onClick={() =>
|
||||||
|
handlePopUpOpen("updateRole", { ...projectMember, index })
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon icon={faEdit} />
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</Td>
|
||||||
|
<Td>
|
||||||
|
{userId !== u?.id && (
|
||||||
|
<div className="opacity-0 transition-opacity duration-300 group-hover:opacity-100">
|
||||||
|
<ProjectPermissionCan
|
||||||
|
I={ProjectPermissionActions.Delete}
|
||||||
|
a={ProjectPermissionSub.Member}
|
||||||
|
>
|
||||||
|
{(isAllowed) => (
|
||||||
|
<IconButton
|
||||||
|
colorSchema="danger"
|
||||||
|
variant="plain"
|
||||||
|
ariaLabel="update"
|
||||||
|
className="ml-4"
|
||||||
|
isDisabled={userId === u?.id || !isAllowed}
|
||||||
|
onClick={() =>
|
||||||
|
handlePopUpOpen("removeMember", { username: u.username })
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon icon={faTrash} />
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
</ProjectPermissionCan>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Td>
|
||||||
|
</Tr>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</TBody>
|
||||||
|
</Table>
|
||||||
|
{!isMembersLoading && filterdUsers?.length === 0 && (
|
||||||
|
<EmptyState title="No project members found" icon={faUsers} />
|
||||||
|
)}
|
||||||
|
</TableContainer>
|
||||||
|
<Modal
|
||||||
|
isOpen={popUp.updateRole.isOpen}
|
||||||
|
onOpenChange={(state) => handlePopUpToggle("updateRole", state)}
|
||||||
|
>
|
||||||
|
<ModalContent
|
||||||
|
className="max-w-4xl"
|
||||||
|
title={`Manage Access for ${(popUp.updateRole.data as TWorkspaceUser)?.user?.email}`}
|
||||||
|
subTitle={`
|
||||||
|
Configure role-based access control by assigning Infisical users a mix of roles and specific privileges. A user will gain access to all actions within the roles assigned to them, not just the actions those roles share in common. You must choose at least one permanent role.
|
||||||
|
`}
|
||||||
|
>
|
||||||
|
<MemberRoleForm
|
||||||
|
onOpenUpgradeModal={(description) => handlePopUpOpen("upgradePlan", { description })}
|
||||||
|
projectMember={
|
||||||
|
filterdUsers?.[
|
||||||
|
(popUp.updateRole?.data as TWorkspaceUser & { index: number })?.index
|
||||||
|
] as TWorkspaceUser
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</ModalContent>
|
||||||
|
</Modal>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { MembersSection } from "./MembersSection";
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { MembersTab } from "./MembersTab";
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
export { GroupsTab } from "./GroupsTab";
|
export { GroupsTab } from "./GroupsTab";
|
||||||
export { IdentityTab } from "./IdentityTab";
|
export { IdentityTab } from "./IdentityTab";
|
||||||
export { MemberListTab } from "./MemberListTab";
|
export { MembersTab } from "./MembersTab";
|
||||||
export { ProjectRoleListTab } from "./ProjectRoleListTab";
|
export { ProjectRoleListTab } from "./ProjectRoleListTab";
|
||||||
export { ServiceTokenTab } from "./ServiceTokenTab";
|
export { ServiceTokenTab } from "./ServiceTokenTab";
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
import { Modal, ModalContent } from "@app/components/v2";
|
import { Modal, ModalContent } from "@app/components/v2";
|
||||||
import { TAccessApprovalPolicy } from "@app/hooks/api/types";
|
import { TAccessApprovalPolicy } from "@app/hooks/api/types";
|
||||||
import { SpecificPrivilegeSecretForm } from "@app/views/Project/MembersPage/components/MemberListTab/MemberRoleForm/SpecificPrivilegeSection";
|
import { SpecificPrivilegeSecretForm } from "@app/views/Project/MembersPage/components/MembersTab/components/MemberRoleForm/SpecificPrivilegeSection";
|
||||||
|
|
||||||
export const RequestAccessModal = ({
|
export const RequestAccessModal = ({
|
||||||
isOpen,
|
isOpen,
|
||||||
|
|||||||
Reference in New Issue
Block a user