Skip to content

[teams] inactivate Leave Team action for last team member #6473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions components/dashboard/src/teams/Members.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function() {
const [ showInviteModal, setShowInviteModal ] = useState<boolean>(false);
const [ searchText, setSearchText ] = useState<string>('');
const [ roleFilter, setRoleFilter ] = useState<TeamMemberRole | undefined>();
const [ leaveTeamEnabled, setLeaveTeamEnabled ] = useState<boolean>(false);

useEffect(() => {
if (!team) {
Expand All @@ -46,6 +47,10 @@ export default function() {
})();
}, [ team ]);

useEffect(() => {
setLeaveTeamEnabled(members.length > 1);
}, [ members ]);

const ownMemberInfo = members.find(m => m.userId === user?.id);

const getInviteURL = (inviteId: string) => {
Expand Down Expand Up @@ -181,6 +186,7 @@ export default function() {
? [{
title: 'Leave Team',
customFontStyle: 'text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300',
active: leaveTeamEnabled,
onClick: () => removeTeamMember(m.userId)
}]
: (ownMemberInfo?.role === 'owner'
Expand Down