[PER-10758] [Merge only if access role makes it on prod] Map the stela accessRole values to the old v1 shape - #1139
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1139 +/- ##
==========================================
+ Coverage 52.30% 52.36% +0.06%
==========================================
Files 355 355
Lines 12108 12114 +6
Branches 2189 2191 +2
==========================================
+ Hits 6333 6344 +11
+ Misses 5547 5542 -5
Partials 228 228 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
9efa5b4 to
054c5af
Compare
slifty
left a comment
There was a problem hiding this comment.
Code looks good -- let's get claude to stop commenting so much; we should generally try to write self-documenting code and use commit messages if needed.
If something truly needs a comment then it probably needs to have a better name or a function with a better name + a docblock!
There was a problem hiding this comment.
Pull request overview
This PR restores backwards compatibility for Stela’s newly-populated accessRole by translating Stela’s role vocabulary (e.g., "owner", "manager") into the web-app’s existing AccessRoleType strings (e.g., "access.role.owner"), preventing permission-gated UI from breaking across the file browser.
Changes:
- Introduces
ArchiveMembershipRoleTypeplus a dedicated translation map/function to convert Stela roles intoAccessRoleType. - Updates Stela folder/record converters to translate
accessRoleinstead of passing the raw Stela value through. - Adds unit coverage for the new translation behavior in model, folder repo, and record repo specs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/app/shared/services/api/record.repo.ts | Translates Stela record accessRole to legacy AccessRoleType during conversion. |
| src/app/shared/services/api/record.repo.spec.ts | Adds tests to verify record role translation and merge/update behavior. |
| src/app/shared/services/api/folder.repo.ts | Translates Stela folder accessRole to legacy AccessRoleType during conversion (including children). |
| src/app/shared/services/api/folder.repo.spec.ts | Adds tests to verify folder role translation and regression coverage for updates/children. |
| src/app/models/access-role.ts | Adds Stela-role type and translation map/function into app roles. |
| src/app/models/access-role.spec.ts | Adds unit tests ensuring translation coverage and compatibility with getAccessAsEnum. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Totally agree with that. Will add a rule to make sure we only add comments that are truly needed from now on. |
054c5af to
ff63993
Compare
Until we will be able to change all the mappings in the app to the new version from stela, we have to make sure that we make all stela properties backwards compatible, so the web-app does not break. In the case of the accessRole, up until now, because it was omitted in the stela responses, it was always overriden by values from the old backend. But now, the accessRole comes back from stela as well, the web-app recognises the property, but it breaks because it does not recognise the value. Mapping it to the old version solves the issue. Issue: PER-10758
ff63993 to
f6a62ae
Compare
omnignorant
left a comment
There was a problem hiding this comment.
Upload and Create Folder no longer stay disabled after repeat navigation (the reported bug), and role-gated permissions hold correctly for Viewer (Download only) and Curator (matches owner-level file actions, but not Share/Publish). Owner permissions were also confirmed unaffected on both a folder and a record selection. I didn't get to the anonymous/logged-out scenarios (share links, public archive) but I think risk to unauthenticated share behavior looks low. Approving.
Merge only if access role makes it on prod
Until we will be able to change all the mappings in the app to the new version from stela, we have to make sure that we make all stela properties backwards compatible, so the web-app does not break.
In the case of the accessRole, up until now, because it was omitted in the stela responses, it was always overriden by values from the old backend. But now, the accessRole comes back from stela as well, the web-app recognises the property, but it breaks because it does not recognise the value. Mapping it to the old version solves the issue.
Issue: PER-10758
Manual test cases
The change: the caller's role from Stela is now translated into the app's
access.role.*form instead of being passed through raw.Warning
This affects permission-gated controls across the whole file browser, not just one
screen — 12 code paths feed the two converters that changed. Any earlier test plan
that recorded a missing action button as expected behaviour needs re-running.
The reported bug ⭐
(this is the symptom that prompted the change — run it first)
Scenario — upload and create stay enabled
/privateand enter a folder that has no display date set.disabled together at exactly this point.
/privateand back into the same folder, then clear the selection again.Owner keeps every action
Scenario — folder and record actions
/private, click on a folderare all present.
Scenario — after a refresh cycle
Roles other than owner ⭐
Scenario — viewer stays restricted
Scenario — curator enables functionality
Newly reached: anonymous and public access
Scenario — logged-out share link
Scenario — public archive(cannot test on local, need to see if I can test on dev)
Scenario — share dialog
and its mapping is unchanged.
Scenario — archive-level permissions