diff --git a/apps/client/src/components/Organization/DeleteMemberButton.tsx b/apps/client/src/components/Organization/DeleteMemberButton.tsx deleted file mode 100644 index 3579dde..0000000 --- a/apps/client/src/components/Organization/DeleteMemberButton.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { useState } from 'react'; -import { BsPersonXFill } from 'react-icons/bs'; -import { OrganizationDto, SecurityRuleDto } from 'shared-types'; -import useUserRole from '../../hooks/useUserRole'; -import { SecurityUtils } from '../../utils/securityUtils'; -import ActionButton, { ActionButtonProps } from '../ActionButton'; -import ConfirmMemberDeleteModal from './ConfirmMemberDeleteModal'; - -export interface DeleteMemberButtonProps extends Omit { - organization: OrganizationDto; - rule: SecurityRuleDto; -} - -function DeleteMemberButton({ rule, organization, ...props }: DeleteMemberButtonProps) { - const [open, setOpen] = useState(false); - - const { role } = useUserRole(organization.id); - const canManage = role && SecurityUtils.canManageRole(role, rule.role); - - return ( - <> - setOpen(true)} - /> - setOpen(false)} - organization={organization} - rule={rule} - /> - - ); -} -export default DeleteMemberButton; diff --git a/apps/client/src/components/Organization/OrganizationMemberDropdown/OrganizationMemberDropdown.tsx b/apps/client/src/components/Organization/OrganizationMemberDropdown/OrganizationMemberDropdown.tsx new file mode 100644 index 0000000..cad5529 --- /dev/null +++ b/apps/client/src/components/Organization/OrganizationMemberDropdown/OrganizationMemberDropdown.tsx @@ -0,0 +1,46 @@ +import { BsArrowRight, BsThreeDotsVertical } from 'react-icons/bs'; +import { OrganizationDto, SecurityRuleDto } from 'shared-types'; +import ActionButton from '../../ActionButton'; +import Dropdown from '../../Dropdown/Dropdown'; +import DropdownItem from '../../Dropdown/DropdownItem'; +import DropdownMenu from '../../Dropdown/DropdownMenu'; +import DropdownToggle from '../../Dropdown/DropdownToggle'; +import RemoveMemberOption from './RemoveMemberOption'; + +export interface OrganizationMemberDropdownProps { + organization: OrganizationDto; + rule: SecurityRuleDto; + disabled: boolean; +} + +function OrganizationMemberDropdown({ + organization, + rule, + disabled = false, +}: OrganizationMemberDropdownProps) { + return ( + + + + + + + Transfer Ownership + + + + + ); +} + +export default OrganizationMemberDropdown; diff --git a/apps/client/src/components/Organization/OrganizationMemberDropdown/RemoveMemberOption.tsx b/apps/client/src/components/Organization/OrganizationMemberDropdown/RemoveMemberOption.tsx new file mode 100644 index 0000000..251e0ce --- /dev/null +++ b/apps/client/src/components/Organization/OrganizationMemberDropdown/RemoveMemberOption.tsx @@ -0,0 +1,44 @@ +import { useState } from 'react'; +import { createPortal } from 'react-dom'; +import { BsPersonXFill } from 'react-icons/bs'; +import { OrganizationDto, SecurityRuleDto } from 'shared-types'; +import useUserRole from '../../../hooks/useUserRole'; +import { SecurityUtils } from '../../../utils/securityUtils'; +import { ActionButtonProps } from '../../ActionButton'; +import DropdownItem from '../../Dropdown/DropdownItem'; +import ConfirmMemberDeleteModal from '../ConfirmMemberDeleteModal'; + +export interface RemoveMemberOptionProps extends Omit { + organization: OrganizationDto; + rule: SecurityRuleDto; +} + +function RemoveMemberOption({ rule, organization, ...props }: RemoveMemberOptionProps) { + const [open, setOpen] = useState(false); + + const { role } = useUserRole(organization.id); + const canManage = role && SecurityUtils.canManageRole(role, rule.role); + + return ( + <> + {createPortal( + setOpen(false)} + organization={organization} + rule={rule} + />, + document.body, + )} + setOpen(true)} + > + Remove + + + ); +} +export default RemoveMemberOption; diff --git a/apps/client/src/components/Organization/OrganizationMemberRow.tsx b/apps/client/src/components/Organization/OrganizationMemberRow.tsx index c8dea91..517ae2d 100644 --- a/apps/client/src/components/Organization/OrganizationMemberRow.tsx +++ b/apps/client/src/components/Organization/OrganizationMemberRow.tsx @@ -5,7 +5,7 @@ import useUser from '../../hooks/useUser'; import useUserData from '../../hooks/useUserData'; import RealtimeOrgRoleSelect from '../RealtimeOrgRoleSelect'; import UserAvatar from '../UserAvatar'; -import DeleteMemberButton from './DeleteMemberButton'; +import OrganizationMemberDropdown from './OrganizationMemberDropdown/OrganizationMemberDropdown'; export interface OrganizationMemberRow { organization: OrganizationDto; @@ -32,13 +32,13 @@ function OrganizationMemberRow({ organization, rule }: OrganizationMemberRow) {
- -