-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move member remove button to dropdown
- Loading branch information
1 parent
5773763
commit 687a0bd
Showing
4 changed files
with
95 additions
and
44 deletions.
There are no files selected for viewing
39 changes: 0 additions & 39 deletions
39
apps/client/src/components/Organization/DeleteMemberButton.tsx
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
...ent/src/components/Organization/OrganizationMemberDropdown/OrganizationMemberDropdown.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Dropdown> | ||
<DropdownToggle disabled={disabled}> | ||
<ActionButton | ||
icon={BsThreeDotsVertical} | ||
title="More options" | ||
disabled={disabled} | ||
/> | ||
</DropdownToggle> | ||
<DropdownMenu> | ||
<DropdownItem | ||
icon={BsArrowRight} | ||
disabled={true} | ||
> | ||
Transfer Ownership | ||
</DropdownItem> | ||
<RemoveMemberOption | ||
organization={organization} | ||
rule={rule} | ||
/> | ||
</DropdownMenu> | ||
</Dropdown> | ||
); | ||
} | ||
|
||
export default OrganizationMemberDropdown; |
44 changes: 44 additions & 0 deletions
44
apps/client/src/components/Organization/OrganizationMemberDropdown/RemoveMemberOption.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ActionButtonProps, 'icon' | 'onClick'> { | ||
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( | ||
<ConfirmMemberDeleteModal | ||
open={open} | ||
handleClose={() => setOpen(false)} | ||
organization={organization} | ||
rule={rule} | ||
/>, | ||
document.body, | ||
)} | ||
<DropdownItem | ||
icon={BsPersonXFill} | ||
title="Remove from organization" | ||
disabled={!canManage || props.disabled} | ||
onClick={() => setOpen(true)} | ||
> | ||
Remove | ||
</DropdownItem> | ||
</> | ||
); | ||
} | ||
export default RemoveMemberOption; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters