feat(team): Role in team members list#6423
Conversation
|
| Filename | Overview |
|---|---|
| dashboard/src/components/settings/Team.vue | Adds role select dropdown to team member list; introduces updateRole/updateTeam resources. Role Select is shown to all active members with no admin guard, causing a silent failure for non-admins. |
| press/press/doctype/team/team.py | Adds perm_team_members guard and validate_member_role validation. validate_member_role runs unconditionally on every save rather than only when team_members changes. |
| press/press/doctype/team/team_members.py | get_members now reads actual role from DB instead of hardcoding "Developer"; get_roles gains RoleDict TypedDict and proper type hint. Clean change. |
| press/patches/v0_8_0/team_member_default_role.py | Back-fills NULL role values on existing Team Member rows to "Developer"; correctly uses frappe.qb and explicit commit. |
| press/press/doctype/team_member/team_member.json | Adds role field as Data type with reqd=1 and default "Developer"; role is free-text rather than Select, so invalid values are only caught server-side. |
| press/press/doctype/team_member/team_member.py | Adds role: DF.Data to auto-generated type stubs; removes legacy encoding comment. Straightforward. |
| press/patches.txt | Registers the new team_member_default_role patch in the correct position. |
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
dashboard/src/components/settings/Team.vue:150-172
**Role Select rendered for non-admin members with no feedback on failure**
The Role column always renders an interactive `Select` for active members, but `rowActions` at line 202 correctly gates admin-only actions behind `session.isTeamAdmin`. A non-admin team member can open the role dropdown, pick a new value, and trigger `updateTeam.submit`. The server will throw a `PermissionError` via `perm_team_members`, but `updateTeam` has no `onError` handler, so the failure is completely silent — no toast, no revert indicator. The `members.fetch()` in `onSuccess` is never called, leaving the user with no acknowledgement of what happened. The role Select should be replaced with a read-only `Badge` (similar to the Pending branch) when the current user is not a team admin.
### Issue 2 of 2
press/press/doctype/team/team.py:282-290
`validate_member_role` runs on every `Team.validate()` call regardless of whether `team_members` actually changed. This means saves triggered by billing updates, partner-email changes, or any other unrelated field will re-validate all member roles. If a row somehow carries an invalid role value (direct DB edit, future import), it will block all subsequent team saves permanently — not just role-change saves. Adding the same `has_value_changed` guard used by `perm_team_members` keeps the validation scoped to the affected field.
```suggestion
def validate_member_role(self):
"""
Validate that the role assigned to each team member is a valid role.
This is to prevent any issues with role-based access control and ensure
that team members have the correct permissions based on their assigned
roles.
"""
if not self.has_value_changed("team_members"):
return
# Get a list of valid roles for this team.
roles = [role["label"] for role in get_roles(self.name)]
```
Reviews (3): Last reviewed commit: "fix(team): Skip `team_members` perm chec..." | Re-trigger Greptile
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6423 +/- ##
===========================================
+ Coverage 49.79% 56.47% +6.68%
===========================================
Files 945 945
Lines 78270 78333 +63
Branches 355 509 +154
===========================================
+ Hits 38972 44237 +5265
+ Misses 39275 34072 -5203
- Partials 23 24 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@greptileai rereview |
516f2d7 to
2210451
Compare
f91db89 to
1021216
Compare
No description provided.