Skip to content
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

feat(organizations): member role selector TASK-986 #5315

Merged
merged 103 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
e17f6a7
Add endpoints to handle organization members
rajpatel24 Nov 6, 2024
024f911
Merge branch 'main' of github.com:kobotoolbox/kpi into task-963-creat…
rajpatel24 Nov 7, 2024
56cd7cf
add initial files for organization members route (WIP)
magicznyleszek Nov 12, 2024
95e48c4
pass org id to hook (WIP)
magicznyleszek Nov 12, 2024
0401fc4
Refactor organization member API to eliminate redundancy and optimize…
rajpatel24 Nov 13, 2024
1dec6eb
Merge branch 'main' into task-963-create-endpoints-to-handle-org-members
rajpatel24 Nov 13, 2024
99eea0c
Add `queryHookOptions` to `PaginatedQueryUniversalTable` to make the …
magicznyleszek Nov 13, 2024
9527848
Merge branch 'main' into leszek/task-980-members-table
magicznyleszek Nov 13, 2024
a75ca3b
add initial files for organization members route (WIP)
magicznyleszek Nov 12, 2024
f2301b7
pass org id to hook (WIP)
magicznyleszek Nov 12, 2024
2066a3b
Add `queryHookOptions` to `PaginatedQueryUniversalTable` to make the …
magicznyleszek Nov 13, 2024
864e244
style(universalTable) use Array<T> for columns prop (#5260)
magicznyleszek Nov 13, 2024
47f6cf1
Merge branch 'leszek/task-980-members-table' of github.com:kobotoolbo…
magicznyleszek Nov 13, 2024
1f1cc12
small fixes (WIP)
magicznyleszek Nov 13, 2024
3c174df
Add role-based validation tests for organization member permissions
rajpatel24 Nov 14, 2024
f432404
Merge branch 'main' into task-963-create-endpoints-to-handle-org-members
rajpatel24 Nov 14, 2024
d876fbc
Revert unintended change and fix linting issue
rajpatel24 Nov 14, 2024
89721fe
Merge branch 'task-963-create-endpoints-to-handle-org-members' into l…
magicznyleszek Nov 15, 2024
953b716
Refactor organization members API with updated permission logic and c…
rajpatel24 Nov 15, 2024
f8cb95b
Refactor organization members API with updated permission logic and c…
rajpatel24 Nov 15, 2024
3d0372a
Resolve merge conflicts
rajpatel24 Nov 15, 2024
906be3d
Fix failing tests
rajpatel24 Nov 15, 2024
d122576
Merge branch 'main' into task-963-create-endpoints-to-handle-org-members
rajpatel24 Nov 18, 2024
837c1ac
adjust MembersRoute table column sizes
magicznyleszek Nov 19, 2024
1222115
Merge branch 'task-963-create-endpoints-to-handle-org-members' into l…
magicznyleszek Nov 19, 2024
08bc12e
display badges in MembersRoute table and remove some WIP code
magicznyleszek Nov 19, 2024
78a4b51
Merge branch 'leszek/task-980-members-table' of github.com:kobotoolbo…
magicznyleszek Nov 19, 2024
94b47cb
Merge branch 'main' into task-963-create-endpoints-to-handle-org-members
magicznyleszek Nov 19, 2024
adf5cad
Merge branch 'task-963-create-endpoints-to-handle-org-members' into l…
magicznyleszek Nov 19, 2024
696bef0
Merge branch 'leszek/task-980-members-table' of github.com:kobotoolbo…
magicznyleszek Nov 19, 2024
01c189c
Update delete logic to remove user from user table along with organiz…
rajpatel24 Nov 19, 2024
89db1d1
Merge branch 'main' into task-963-create-endpoints-to-handle-org-members
magicznyleszek Nov 19, 2024
42d4f23
Merge branch 'task-963-create-endpoints-to-handle-org-members' into l…
magicznyleszek Nov 19, 2024
b5ccac7
add some comments
magicznyleszek Nov 19, 2024
3ea9420
add missing semicolon
magicznyleszek Nov 19, 2024
988b10b
Merge branch 'main' into task-963-create-endpoints-to-handle-org-members
magicznyleszek Nov 19, 2024
4951a1c
Merge branch 'task-963-create-endpoints-to-handle-org-members' into l…
magicznyleszek Nov 19, 2024
ac80999
use latest Avatar version in the table
magicznyleszek Nov 19, 2024
e5688a3
add functions for updating and removing organization member
magicznyleszek Nov 19, 2024
e5abfa0
Merge branch 'main' into task-963-create-endpoints-to-handle-org-members
magicznyleszek Nov 19, 2024
19d1b6a
Merge branch 'task-963-create-endpoints-to-handle-org-members' into l…
magicznyleszek Nov 19, 2024
7672143
Use useOrganizationQuery directly in useOrganizationMembersQuery
jamesrkiger Nov 19, 2024
c20c0f4
remove queryHookOptions from PaginatedQueryUniversalTable
magicznyleszek Nov 19, 2024
f250c27
add helpful comment
magicznyleszek Nov 20, 2024
7afa649
Merge branch 'leszek/task-980-members-table' into leszek/task-985-mem…
magicznyleszek Nov 20, 2024
4f0f55a
update comments
magicznyleszek Nov 20, 2024
1389d6e
Merge branch 'leszek/task-980-members-table' into leszek/task-985-mem…
magicznyleszek Nov 20, 2024
def1a7a
Refactor permissions to block external users from listing organizatio…
rajpatel24 Nov 20, 2024
c2cf803
Merge branch 'main' into task-963-create-endpoints-to-handle-org-members
magicznyleszek Nov 20, 2024
8c7ed27
Merge branch 'task-963-create-endpoints-to-handle-org-members' into l…
magicznyleszek Nov 20, 2024
40ca814
use OrganizationUserRole in membersQuery
magicznyleszek Nov 20, 2024
500df96
Merge branch 'leszek/task-980-members-table' into leszek/task-985-mem…
magicznyleszek Nov 21, 2024
3847958
Merge branch 'main' into leszek/task-985-member-mutation-api
magicznyleszek Nov 25, 2024
3e9048e
post merge conflict fixes
magicznyleszek Nov 25, 2024
eada4f4
create MemberRemoveModal
magicznyleszek Nov 27, 2024
a2552f9
add MemberActionsDropdown component
magicznyleszek Nov 27, 2024
3029c3b
use MemberActionsDropdown in MembersRoute
magicznyleszek Nov 27, 2024
76a39f1
Merge branch 'main' into task-987-members-table-actions-dropdown
magicznyleszek Nov 27, 2024
476df92
todo comments
magicznyleszek Nov 27, 2024
c40fe18
Merge branch 'main' into task-987-members-table-actions-dropdown
magicznyleszek Nov 28, 2024
c535196
most of work done
magicznyleszek Nov 28, 2024
3fd1042
change icon
magicznyleszek Nov 28, 2024
f44874c
polishing
magicznyleszek Nov 28, 2024
f6f1ea0
Merge branch 'main' into task-987-members-table-actions-dropdown
magicznyleszek Nov 28, 2024
126f000
linter fixes
magicznyleszek Nov 29, 2024
03c90c0
Merge branch 'leszek/task-985-member-mutation-api' into task-987-memb…
magicznyleszek Nov 29, 2024
5c8d255
Merge branch 'main' into leszek/task-985-member-mutation-api
magicznyleszek Nov 29, 2024
aa86b5b
Merge branch 'leszek/task-985-member-mutation-api' into task-987-memb…
magicznyleszek Nov 29, 2024
6774de0
Merge branch 'leszek/task-985-member-mutation-api' into task-987-memb…
magicznyleszek Nov 29, 2024
b44c430
Merge branch 'task-987-members-table-actions-dropdown' of github.com:…
magicznyleszek Nov 29, 2024
3611b5f
remove member using query
magicznyleszek Dec 2, 2024
90161f9
add hooks for member mutation
magicznyleszek Dec 2, 2024
bed7f67
Merge branch 'leszek/task-985-member-mutation-api' into task-987-memb…
magicznyleszek Dec 2, 2024
baa8002
self review cleanup
magicznyleszek Dec 2, 2024
704137b
add MemberRoleSelector that uses usePatchOrganizationMember
magicznyleszek Dec 2, 2024
680fd3b
simplify member mutation hooks
magicznyleszek Dec 2, 2024
e8bd8c4
Merge branch 'leszek/task-985-member-mutation-api' into task-987-memb…
magicznyleszek Dec 2, 2024
fd6d4a7
move removing logic closer to place it's being triggered
magicznyleszek Dec 2, 2024
88544bf
Merge branch 'task-987-members-table-actions-dropdown' into leszek/ta…
magicznyleszek Dec 2, 2024
b601abe
use simpler hook closer to the usage
magicznyleszek Dec 2, 2024
c4b8947
move member removing closer to place it's being triggered
magicznyleszek Dec 2, 2024
2d48f6a
cleanup comment
magicznyleszek Dec 2, 2024
8907bf8
Merge branch 'main' into leszek/task-985-member-mutation-api
magicznyleszek Dec 3, 2024
fb16410
Merge branch 'leszek/task-985-member-mutation-api' into task-987-memb…
magicznyleszek Dec 3, 2024
5055d06
Merge branch 'task-987-members-table-actions-dropdown' into leszek/ta…
magicznyleszek Dec 3, 2024
9ddf55d
stop requiring orgId as parameter
magicznyleszek Dec 5, 2024
afd593e
Merge branch 'leszek/task-985-member-mutation-api' into task-987-memb…
magicznyleszek Dec 5, 2024
d8c6581
stop requreing orgId
magicznyleszek Dec 5, 2024
4ef132a
Merge branch 'task-987-members-table-actions-dropdown' into leszek/ta…
magicznyleszek Dec 5, 2024
c019b1a
stop requiring orgId in MemberRoleSelector
magicznyleszek Dec 5, 2024
d4ec034
allow role modifying to admins and owner
magicznyleszek Dec 5, 2024
88646f2
Merge branch 'main' into task-987-members-table-actions-dropdown
jamesrkiger Dec 10, 2024
049492f
update placeholder
magicznyleszek Dec 10, 2024
2791697
rename username prop
magicznyleszek Dec 10, 2024
ec90b08
simplify text to display flow
magicznyleszek Dec 10, 2024
ebbc129
dont import unnecessarily
magicznyleszek Dec 10, 2024
6c9ca6f
remove comment
magicznyleszek Dec 10, 2024
1ad007f
code review fixes
magicznyleszek Dec 11, 2024
8846df1
Merge branch 'main' into task-987-members-table-actions-dropdown
magicznyleszek Dec 11, 2024
d0c9506
Merge branch 'task-987-members-table-actions-dropdown' into leszek/ta…
magicznyleszek Dec 11, 2024
5cab32c
code review fix
magicznyleszek Dec 11, 2024
2ad4a8e
linter fix
magicznyleszek Dec 11, 2024
ea7ba90
Merge branch 'main' into leszek/task-986-member-role-selector
magicznyleszek Dec 11, 2024
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
48 changes: 48 additions & 0 deletions jsapp/js/account/organization/MemberRoleSelector.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import KoboSelect from 'jsapp/js/components/common/koboSelect';
import {usePatchOrganizationMember} from './membersQuery';
import {OrganizationUserRole} from './organizationQuery';

interface MemberRoleSelectorProps {
username: string;
/** The role of the `username` user - the one we are modifying here. */
role: OrganizationUserRole;
/** The role of the currently logged in user. */
currentUserRole: OrganizationUserRole;
}

export default function MemberRoleSelector(
{username, role, currentUserRole}: MemberRoleSelectorProps
) {
const patchMember = usePatchOrganizationMember(username);

const canModifyRole = (
currentUserRole === 'owner' ||
currentUserRole === 'admin'
);

return (
<KoboSelect
name={`member-role-selector-${username}`}
type='outline'
size='m'
options={[
{
value: OrganizationUserRole.admin,
label: t('Admin'),
},
{
value: OrganizationUserRole.member,
label: t('Member'),
},
]}
selectedOption={role}
onChange={(newRole: string | null) => {
if (newRole) {
patchMember.mutateAsync({role: newRole as OrganizationUserRole});
}
}}
isPending={patchMember.isPending}
isDisabled={!canModifyRole}
/>
);
}
13 changes: 13 additions & 0 deletions jsapp/js/account/organization/MembersRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import LoadingSpinner from 'js/components/common/loadingSpinner';
import Avatar from 'js/components/common/avatar';
import Badge from 'jsapp/js/components/common/badge';
import MemberActionsDropdown from './MemberActionsDropdown';
import MemberRoleSelector from './MemberRoleSelector';

// Stores, hooks and utilities
import {formatTime} from 'js/utils';
Expand Down Expand Up @@ -67,6 +68,18 @@ export default function MembersRoute() {
key: 'role',
label: t('Role'),
size: 120,
cellFormatter: (member: OrganizationMember) => {
if (member.role === OrganizationUserRole.owner) {
return t('Owner');
}
return (
<MemberRoleSelector
username={member.user__username}
role={member.role}
currentUserRole={orgQuery.data.request_user_role}
/>
);
},
},
{
key: 'user__has_mfa_enabled',
Expand Down
Loading