Skip to content

Commit

Permalink
self review cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
magicznyleszek committed Dec 2, 2024
1 parent bed7f67 commit baa8002
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
6 changes: 3 additions & 3 deletions jsapp/js/account/organization/MemberActionsDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ export default function MemberActionsDropdown(
return null;
}

// Should not happen™, but let's make it foolproof :) Members are not allowed
// to do anything here.
// Should Not Happen™, but let's make it foolproof :) Members are not allowed
// to do anything here under any circumstances.
if (currentUserRole === OrganizationUserRole.member) {
return null;
}

// If logged in user is an admin and tries to remove themselves, we need
// different UI.
// different UI - thus we check it here.
const isAdminRemovingSelf = Boolean(
username === session.currentLoggedAccount?.username &&
currentUserRole === OrganizationUserRole.admin
Expand Down
16 changes: 7 additions & 9 deletions jsapp/js/account/organization/MemberRemoveModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export const REMOVE_MEMBER_TEXT = {
};

/**
* Replaces placeholders with values, assumes all placeholders want to be
* lowercase.
*/
* Replaces placeholders with values.
* Note: assumes all placeholders want to be lowercase.
*/
function replacePlaceholders(text: string, username: string, mmoLabel: string) {
return text
.replaceAll('##username##', username)
Expand All @@ -45,6 +45,9 @@ interface MemberRemoveModalProps {
/**
* A confirmation prompt modal for removing a user from organization. Displays
* two buttons and warning message.
*
* Note: it's always open - if you need to hide it, just don't render it at
* the parent level.
*/
export default function MemberRemoveModal(
{
Expand Down Expand Up @@ -74,12 +77,7 @@ export default function MemberRemoveModal(
confirmButtonLabel = replacePlaceholders(confirmButtonLabel, username, mmoLabel);

return (
<KoboModal
// It's always open, to hide it just don't render it at parent level
isOpen
size='medium'
onRequestClose={() => onCancel()}
>
<KoboModal isOpen size='medium' onRequestClose={() => onCancel()}>
<KoboModalHeader>{title}</KoboModalHeader>

<KoboModalContent>
Expand Down
4 changes: 2 additions & 2 deletions jsapp/js/account/organization/MembersRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import styles from './membersRoute.module.scss';

export default function MembersRoute() {
const orgQuery = useOrganizationQuery();
const removeMemberQuery = useRemoveOrganizationMember();
const removeMember = useRemoveOrganizationMember();

if (!orgQuery.data) {
return (
Expand Down Expand Up @@ -104,7 +104,7 @@ export default function MembersRoute() {
username={member.user__username}
currentUserRole={orgQuery.data.request_user_role}
onRequestRemove={(username) => {
removeMemberQuery.mutateAsync({orgId: orgQuery.data.id, username: username});
removeMember.mutateAsync({orgId: orgQuery.data.id, username: username});
}}
/>
);
Expand Down

0 comments on commit baa8002

Please sign in to comment.