Skip to content

OpenConceptLab/ocl_online#648 | Organization roles on the org page - #105

Merged
snyaggarwal merged 23 commits into
mainfrom
ocl_online-648-org-roles
Nov 23, 2026
Merged

snyaggarwal merged 23 commits into
mainfrom
ocl_online-648-org-roles

Conversation

@paynejd

@paynejd paynejd commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

The TBv3 side of organization roles, part of OpenConceptLab/ocl_online#648. The API enforces every permission; this shows each role and gives admins the controls.

This needs OpenConceptLab/oclapi2#983, which has been on production since Nov 11. Against an older API, user_role is missing, so anyone who isn't staff loses Edit Members, Edit and Delete until the API is upgraded.

What changes

  • Manage menu: only an admin or staff sees Edit Members, Edit and Delete. Any member still sees New Repository, and can now choose Leave Organization. Before, Edit Members was the only way to leave.
  • Delete: was for the org's creator or staff. It's now for an admin or staff, and still never for the OCL org.
  • Browse members: each member shows their role, with an Admin chip.
  • Edit Members: lists each member once, with a role dropdown and a remove action at the right. The dropdown offers Member and Admin, and keeps a role the app doesn't know yet, so more roles can be added. Add Member adds one user, as a Member unless another role is picked. With none picked, the add sends no role, so someone already in the org keeps theirs: Edit Members loads 100 members, and a larger org can have an admin past them. Each change is saved as it's made, one at a time, and then the org and its members are fetched again.
  • Confirms: removing a member asks first, and removing yourself asks with the Leave wording. Changing your own role away from Admin asks first, since another admin would have to give it back. Leave no longer says an admin can add you back.
  • Refusals: the API's reason shows as it does today, for example when demoting or removing the last admin.
  • Members request: asks for up to 100, because the default page of 25 hid members of the largest organizations from these controls.

New strings are in en, es, pt-BR and zh. It also adds the Spanish for "Member", which was missing.

Design system: no gap. This reuses the existing dialogs, buttons and user search, Chip as AccessChip uses it, and MUI's Select.

Tested

  • CI's eslint is clean, npm test gives 158 OK, and the production build (npm run build, as the Dockerfile runs it) compiles.
  • In the real app against a local API with OpenConceptLab/ocl_online#648 | Organization roles: admin and member oclapi2#983: adding a user (with no role picked the request carries none and they join as a Member; with Admin picked it sends admin), promoting, removing through the confirm, removing yourself, Leave, and changing your own role (Cancel sends nothing, the only admin is refused with the API's reason, and with a second admin it goes through and Edit Members closes). At 360 px the add row and long names wrap. Each confirm's warning is its dialog's accessible description. No page errors.

Reviews

Codex passes, checks and simplification reviews, in full on the ticket, for the first version, for the fixes from review, and for the new Edit Members, plus a Claude review with a Codex second opinion of 0c362ec, whose fixes are in. No P0 or P1 is open. Four edge cases are accepted: a refresh that fails after a save leaves the list as it was until a reload; a self-removal whose response is lost doesn't run the Leave steps until a reload; if another admin removes you from a private org while its page is open, its admin controls stay until a reload, and the API refuses each one; and if two admins add the same person at the same moment, the later role wins, because the members PUT both adds and changes a role (OpenConceptLab/ocl_online#712). There's no adversarial pass on this side, since it only hides controls and the API enforces them.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK

paynejd and others added 4 commits November 17, 2026 23:49
The org page uses the role the API sends. Only an admin or staff sees Edit
Members, Edit and Delete. Any member still sees New Repository, and can now
leave from the Manage menu, as Edit Members was the only way to before.

Browse members shows each member's role, and Edit Members lets an admin set
it. A save sends what gives rights before what takes them away, so that handing
over to a new admin in one save works.

The members request asks for up to 100, as the default page of 25 hid members
of the largest organizations from these controls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…es last, re-selecting keeps a role

An admin who demotes themselves in a save could lose the right to finish the
rest of it, so their own change now goes last and a failure stops what follows.

An existing admin taken off and selected again from a user search stays an
admin: a search result has no role, so the role comes from the membership.

Leaving finishes on the page even if refreshing the cached user fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…rty is just a username

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…er and repeated tests

A role picked in the members dialog now stays on the selected member. Adds the
Spanish for "Member", which the new controls show.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
@paynejd
paynejd requested a review from snyaggarwal November 18, 2026 04:54

@snyaggarwal snyaggarwal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review with extra focus on race conditions, null pointers, new patterns and reuse. The main points are two double-submit races (Edit Members Submit, Leave), parallel demotions racing the API's last-admin check, stale admin UI after removing yourself via Edit Members, and the Manage button still gated by the cached org list while its items use user_role. Details inline.

🤖 Generated with Claude Code

Comment thread src/components/orgs/EditMembers.jsx Outdated
t(`org.member_${action}_failed`, {user: member.username, detail})
)

const onSubmit = async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Race: Submit has no in-flight guard. The Submit link stays enabled while onSubmit runs. A double-click, or a second Submit before fetchOrg's refetch updates members, re-sends every batch against the stale list. The losing DELETE members/<user>/ gets a 404, which shows "Could not remove …" and keeps the dialog open although the change went through. Suggest a saving state that disables Submit until the refetch lands.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e7db18a and 7b85f03. Submit is off from the click until the members are fetched again, and the dialog can't be dismissed in the meantime, so neither a second click nor reopening it resends a change. 1b540cf also locks the search and role fields while it saves, so nothing typed then is lost.

Since then, Jon asked for a different Edit Members (c6d6526): there's no Submit, and each change is saved as it's made. The same guard holds there: every control is off from the change until the org and its members are fetched again, and a second change can't start before then.

Comment thread src/components/orgs/EditMembers.jsx Outdated
for(const batch of batches) {
// A batch can rely on the ones before it, so a failure stops the rest, and saving again retries them.
if(!results.some(({error}) => error))
results.push(...await Promise.all(batch.map(updateMember)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Race: revocations run in parallel. Promise.all sends every demotion and removal in the revocations batch at once, so the API's last-admin check can see the others as still admin. For example, a staff user who isn't a member demotes both of an org's two admins in one save, and both succeed. Running this batch one request at a time lets the API refuse the last one.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e7db18a: every change went one request at a time, in order, and the first failure stopped the rest, so the second demotion in your example got the API's 409.

Since then, Jon asked for a different Edit Members (c6d6526): there's no batch. Each change is saved as it's made, and the next can't start until the org and its members are fetched again, so two demotions never overlap. Demoting the last admin gets the API's 409, and the role stays as it was.

Comment thread src/components/orgs/EditMembers.jsx Outdated
}

fetchMembers()
fetchOrg()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing yourself here leaves the admin view up. getMemberChanges allows the requester to remove themselves, but after the save only fetchOrg() runs. For a private org that refetch returns 403/404, which fetchOrg ignores, so org.user_role stays admin and Edit, Delete and Edit Members stay visible. Unlike onLeave, the cached user isn't refreshed either, so subscribed_orgs is stale. Maybe route a self-removal through the same path as Leave.

Minor: fetchOrg also re-fetches the overview on every save; only a change to the requester's own role (batches[2].length) needs user_role refreshed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e7db18a. Removing yourself in Edit Members now goes the way Leave does: the cached user is refreshed and the page moves to your profile. 1b540cf keeps the dialog up until then.

On the minor point: I tried refetching the org only after a change to your own role. A Codex check then showed that this misses a demotion someone else makes while the dialog is open, which leaves the admin controls up after a 403. So a8c259b refetches the org, then the members, after every save, and closes Edit Members once you aren't an admin.

Comment thread src/components/orgs/EditMembers.jsx Outdated

const newMembers = selectedMembers.filter(member => !members.map(user => user.username).includes(member.username))
const deletedMembers = members.filter(member => !selectedMembers.map(user => user.username).includes(member.username))
const batches = getMemberChanges(members, selectedMembers, getCurrentUser()?.username)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small things here:

  • selectedMembers starts as [] and is filled by the mount effect above, so on the first render every member counts as a removal and the "- Remove" text flashes. React.useState(() => members || []) avoids the effect.
  • getCurrentUser()?.username JSON-parses localStorage on every render; getCurrentUserUsername() in common/utils already does this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both done in e7db18a: useState(() => members || []) with no effect, and getCurrentUserUsername() once per dialog.

Since Jon's redesign (c6d6526), the dialog keeps no copy of the members at all: it lists the members the page fetched, so there's nothing to flash.

Comment thread src/components/orgs/EditMembers.jsx Outdated
{
selectedMembers.map(member => (
<ListItem key={member.username} disableGutters>
<ListItemText primary={getMemberDisplayName(member)} />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible crash: getMemberDisplayName calls member.name.trim() with no guard, and this list now calls it for every selected member. A member or search result with a null name would throw and break the dialog. (member.name || '').trim() avoids that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e7db18a: (member.name || '').trim().

})
}

const onLeave = () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Race: Leave can be submitted twice. LeaveOrgDialog's button stays enabled during the DELETE and the cache refresh. A double-click sends two DELETEs: the first returns 204 and navigates, the second returns 404 and runs the else-branch, so an error alert shows right after a successful leave. A pending flag that disables the button would fix it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e7db18a: the Leave button is off while the request runs. 1b540cf also ignores a click while the dialog fades out after a refusal.

Comment thread src/components/orgs/OrgHome.jsx Outdated
refreshCurrentUserCache(onLeft, onLeft)
} else {
setLeaveOrg(false)
setAlert({severity: 'error', message: response?.response?.data?.detail || t('common.generic_error')})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reuse: this reads only response?.response?.data?.detail, while EditMembers has getErrorDetail / normalizeErrorDetail for the same members/<user>/ endpoint, which also handle error, __all__, list and object bodies. Moving that helper to common/utils and using it in both places keeps them from drifting.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in e7db18a: getErrorDetail is in common/utils, and Leave uses it too.

</MenuItem>
}
{
org.user_role &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two sources of truth for access. These items now follow the API's org.user_role, but the Manage button that opens this menu is still gated by currentUserHasAccess(), which reads subscribed_orgs from the cached user. A user added or promoted since their cache was last refreshed has user_role from the API but no Manage button, so they can't leave or administer until they reload. Gating Manage on isAdminUser() || org.user_role would make the API the one source.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e7db18a: Manage shows for isAdminUser() || org.user_role, so the button and its items both follow the API.

Comment thread src/components/orgs/MemberList.jsx Outdated
/>
{
member.role &&
<Chip size='small' variant='outlined' sx={{marginTop: '8px', marginLeft: '8px'}} label={t(`org.${member.role}`)} />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t(org.${member.role}) builds the key from raw API data. A role other than admin/member would show as the literal key (e.g. org.owner), and in EditMembers the Select would get an out-of-range value. A role→label map with a fallback next to ROLE_ADMIN/ROLE_MEMBER in orgRoles.js would keep the roles in one place.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in e7db18a: ROLE_LABEL_KEYS and getRoleLabel sit next to the role constants in orgRoles.js. A role the app doesn't know shows as the API sent it. In Edit Members it shows but can't be picked, so the Select never gets an out-of-range value.

@snyaggarwal

snyaggarwal commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

@paynejd
Tried this in browser

Edit Members Dialog

Screenshot 2026-11-18 at 19 24 09
  1. In this screenshot I am org admin (or even OCL staff) of the org can remove ocladmin (superuser) and sny (staff) as well -- I think those should be locked because they belong to higher tiers.
  2. The select/text field must use MUI outlined input or can be replaced with MUI ButtonGroup for Member | Admin
  3. Also it should use User Chip representation on left

Leave org dialog

Screenshot 2026-11-18 at 19 24 48
  1. Leave Organization button must be "error" color (red).
  2. Org name should be distinct (bold?)

Members List dialog

Screenshot 2026-11-18 at 19 33 47
  1. Admin chip needs to show some colors, need to make it look like important role and differentiate from Member -- Suggest Admin primary outlined and Member default outlined

@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

On point 1 of the Edit Members review (an org admin can remove superuser and staff members): @paynejd decided on Nov 18 to keep it as it works today. An org admin manages all of that org's members, staff and superusers included. Blocking it only in the dialog wouldn't stop the same API call, so if a real case for the rule appears, it gets its own oclapi2 ticket. No change is needed in this PR for point 1. The other review points still stand.

paynejd and others added 18 commits November 18, 2026 23:38
… changes go one at a time, and removing yourself is leaving

From review:
- Edit Members sends its changes one request at a time, so the API's last-admin
  check sees each one, and Submit is off until the members are fetched again.
- Leave is off while its request runs.
- Removing yourself in Edit Members refreshes your cached user and leaves the page,
  as Leave does. A change to your own role refetches the org, and anything else
  only the members.
- The Manage button follows the role the API gives you, like the items in it.
- Role labels come from one map, and a role the app doesn't know shows as sent.
- getErrorDetail moves to common/utils and Leave uses it too; a member with no name
  no longer breaks the dialog, and it no longer flashes every member as removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…mbers are fetched again, and only a 2xx counts as done

From the Codex check of the review fixes:
- The dialog stays up, with Submit off and no way to dismiss it, until the members
  are fetched again, so reopening it can't resend a change that went through.
- A request with no response, such as a network error, is a failure, so the save
  stops there instead of going on as if it worked.
- Adding yourself refetches the org too, so Leave shows without a reload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…aving, and leaving holds until the page moves on

From the second Codex check:
- The member search and role controls are off while a save and its refresh run,
  so nothing typed then is dropped when the dialog closes.
- After you remove yourself, the dialog stays up until your cached user is fresh
  and the page is on its way to your profile.
- Leave ignores a click while its dialog fades out after a refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
… through refetches the org, and role labels use own keys only

From the third Codex check:
- A change to your own role that failed without a response may still have been
  made, so the org is fetched again for your role either way.
- A role named like an object property, such as `constructor`, shows as sent
  instead of picking up an inherited property as its label.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…etched again, and the org too after an own role change

From the final Codex check: the org request failing must not skip the members,
or the next save compares against a list the API has moved past.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…etched before the members, so the count matches the list

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…he members, and Edit Members closes when you stop being an admin

From the final Codex check: refetching the org only after a change to your own
role missed a demotion someone else made while the dialog was open, which left the
admin controls up. The org now comes back after every save, and Edit Members
closes once you aren't an admin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…top being an admin

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…es it

Closing it toggled it, so a backdrop click while it faded out could open it again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…in Edit Members, a red Leave, and an Admin chip that stands out

From Sunny's look in the browser:
- Edit Members shows each member as a user chip with their name, and picks the
  role with a Member | Admin toggle group instead of a select.
- Leave Organization is red, and the org's name is bold.
- In Browse members, Admin is a primary outlined chip and Member a default one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…with a role dropdown and a remove action, and adds one user at a time

Each member shows once, in the list, with a role dropdown and a remove action
at the right. Each change goes to the API as soon as it's made. Removing
someone asks first in a dialog, and removing yourself asks with the Leave
wording. Add Member opens the user search for a single user, with the role to
add them as. The dropdown offers the roles this app knows, and keeps a role it
doesn't know yet, so more roles can be added.

The Leave message no longer says an admin can add you back, and opening Edit
Members closes the Manage menu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…arch shows, Leave can't be cancelled once sent, and Edit Members fits a phone

- Typing a new search drops the user picked before it, and a user who has
  become a member since being picked is no longer picked, so Add never changes
  an existing member's role.
- Leave's Cancel, Escape and backdrop are off while it's being sent.
- The add row wraps, and avatars hide, at phone width.
- The Leave and Remove messages show the org's name as typed, with no HTML
  entities.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…dds the picked user only while the search shows them

Clearing the pick on typing made the search box empty itself. The pick now
stays, and Add is on only while the search shows that user and they aren't a
member. A pick who becomes a member is dropped. The Edit Members header wraps,
so a long org name can't push Add Member off a phone screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…what you typed or picked, and one search runs at a time

- The box is controlled in Edit Members: typing drops the pick, and MUI's own
  resets on blur or a pick change are ignored, so leaving the box can't bring
  back an earlier pick.
- One delayed search lasts for the dialog's life, and a response counts only
  while its query is still the one in the box.
- Long names and usernames wrap in their column at phone width.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…dule level

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…e a member stays dropped

Add needs a new pick even if that user leaves the org again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…n asks first

Edit Members asks before an admin takes away their own admin rights, since another admin would have to give them back. The role changes only on Change Role; Cancel leaves it as it was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
…irm's warning

Change Role, Remove Member and Leave Organization each point the dialog's description at their message, so it's read out with the title rather than only the buttons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Claude review, with a Codex second opinion (commit 0c362ec)

Verdict: fix-first. The role logic is sound and the API enforces every rule, but changes agreed on the ticket aren't on this commit yet, and three small fixes belong in the same pass.

The full review, with the acceptance criteria, is on the ticket. In short:

  • Changes agreed on the ticket since the last review aren't on this commit yet. The details are on the ticket.
  • [P2] Removing yourself through Edit Members on a private org leaves the admin controls showing: the follow-up org request gets a 403 and the page keeps its old state. Handle it as Leave does, or don't offer removal on your own row.
  • [P2] The Manage button still follows the cached organizations list while its items follow user_role, so someone just added sees no Manage until their cache refreshes. Gate it on isAdminUser() || org.user_role.
  • [P2] An add that nobody picked a role for sends role: member. In an org with more than 100 members, picking an existing admin past the first page from search would demote them. Send no role unless one was picked.
  • On Sunny's review: the parallel-demotion race isn't reachable, because the API locks the org and checks for the last admin after taking the lock. The self-removal and Manage points hold (above), and the double-submit point holds in a smaller form: a repeated DELETE of another member is a no-op 204, so only a repeated self-change or Leave shows an error after it worked (P3).

CI's lint and tests pass on this commit, and the 8 new tests pass locally. The app wasn't run in a browser. Codex (0.169.0, xhigh) found the same three, rating them P1, and one more retry edge case (P2, on the ticket); I disagree with its one other point, that the org edit route needs its own gate, since the API refuses the save and the form shows why.

…picked

The add row still shows Member, but until someone picks a role the
request carries none: the API makes a new member a plain member and
leaves an existing member's role alone. Edit Members loads the first
100 members, so in a larger org, adding someone past them who is
already an admin no longer demotes them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUSJnKeDYRubKa6DYK
@paynejd

paynejd commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

@snyaggarwal I've pushed the fixes for your 08:00Z review, e7db18a to bd9f0ff, and the visual changes after them, and replied to each inline comment.

Codex checked each round of fixes until a check came back clean. On the way it found more problems of the same kind, and those are fixed too:

  • The dialog closed before the refresh landed.
  • A network error counted as success.
  • Adding yourself didn't refresh your role.
  • Edits made during a save were dropped.
  • The guard was released before the page left after removing yourself.
  • Leave could be clicked again while its dialog faded out.
  • A role named like an object property got past the label fallback.
  • A demotion someone else made while the dialog was open left the admin controls up. That one is why every save now refetches the org: see my reply on the self-removal comment.

The full checks are on OpenConceptLab/ocl_online#648.

Two edge cases are accepted rather than fixed:

  • A refresh that fails or stalls after a save leaves the list as it was until a reload. Resending from it is harmless, because the API refuses a change that's already made or repeats it as a no-op.
  • A self-removal whose response is lost doesn't run the Leave steps. The next request shows the refusal, and a reload fixes it.

Your 14:03Z points are done too, and Jon asked for more after seeing them, so Edit Members changed shape (a6982f8 to 60ad1bb):

  • Edit Members: each member shows once, with a role dropdown and a remove action that asks first. Add Member adds one user at a time, with their role. Each change is saved as it's made, then the org and its members are fetched again.
  • Your own role: changing it away from Admin asks first, since another admin would have to give it back. Cancel leaves it as it was.
  • Leave: a red button, with the org name in bold, and no "until an admin adds you back".
  • Browse members: a primary outlined Admin chip.

Codex reviewed these in three passes and five checks, and no P0 or P1 is open. One check found that the confirms' warnings weren't read out by screen readers, only their titles and buttons; Change Role, Remove Member and Leave Organization now announce them. One more edge case is accepted: if two admins add the same person at the same moment, the later role wins, because the members PUT both adds and changes a role. Point 1 is answered above.

The review of 0c362ec posted here on Nov 19 asked for four fixes. The commits above already cover three: Jon's Nov 19 changes, removing yourself in Edit Members now runs the Leave steps, and Manage shows for anyone with a role in the org. The fourth is 0fb84e6: an add sends a role only when someone picks one, so in an org with more than the 100 members Edit Members loads, adding an existing admin past them can't demote them. Codex's check of that commit suggested that choosing Member from the menu when it already shows Member should send it; I've left that out, since the add row adds people and shouldn't take an admin's rights away. One part of its self-removal point is left: if another admin removes you from a private org while you have its page open, the admin controls stay until a reload, and the API refuses each one with its reason.

npm test gives 158 OK (the batch-save helpers and their tests are gone), CI's eslint is clean, and the production build compiles.

@snyaggarwal snyaggarwal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 0fb84e6. Everything from my Nov 18 review is answered as your replies describe:

  • Saving: a change saves one at a time behind busy/saving. Every control and the dialog's close stay off until the org and its members are fetched again, so a double click or a second change can't race.
  • Removing yourself goes the Leave way (onSaved({left})), and the Leave button is disabled while its DELETE runs.
  • Manage follows the API: isAdminUser() || org.user_role.
  • Roles have one home in orgRoles.js: getRoleLabel, getRoleOptions (an unknown role shows as sent and can't be picked) and demotesSelf, which asks first.
  • Small fixes: getErrorDetail is shared in common/utils, and getMemberName guards a null name.

Against my screenshots of Nov 18:

  • Removing superuser and staff members: kept as it works today, by Jon's decision, since the API allows it.
  • The role control is now an outlined Select.
  • User chips: the rows show the user's avatar, name and username, like Browse members, rather than UserChip. That's fine with Jon's redesign.
  • Leave has a red (error) button, and the org name is in bold in all four locales.
  • Browse members: Admin is a primary outlined chip, and Member a default outlined one.

Nit, pre-existing: the Add Member search box's texts are hard-coded English ('Loading...', 'Type atleast 2 characters to search', 'No results', 'Start typing...'), with "atleast" for "at least". This PR moves those lines, so translating them here would be cheap.

I haven't run it in a browser. CI's lint and tests pass, and it merges cleanly with main.

@snyaggarwal
snyaggarwal merged commit 0288fb3 into main Nov 23, 2026
2 checks passed
@snyaggarwal
snyaggarwal deleted the ocl_online-648-org-roles branch November 23, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants