[Workspace] Refresh collaborators page from server on mount#12044
[Workspace] Refresh collaborators page from server on mount#12044xluo-aws wants to merge 4 commits into
Conversation
The collaborators page renders the permission list from the cached `workspaces.currentWorkspace$` BehaviorSubject. That observable is only populated by `WorkspaceClient.init()` at app boot and by the local user's own `create/update/delete` calls, so a permission revoke made by another user (e.g. an admin removing access remotely) is not reflected until the page is hard reloaded. Mirror the data-source tab pattern by fetching the current workspace via `workspaceClient.get(id)` on mount and after a successful update, and drive the rendered permission list from that response, falling back to the cached value if the request fails. Signed-off-by: Xuesong Luo <lxuesong@amazon.com>
PR Reviewer Guide 🔍(Review updated until commit dcc0b20)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to dcc0b20 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit c893657
Suggestions up to commit f2f7be6
Suggestions up to commit 6eb74cb
|
Asserting on rendered DOM rows after the on-mount fetch is flaky because the file's prior tests leave React 18 state updates pending that pollute the next test's render. Assert only that `workspaceClient.get(workspaceId)` is invoked on mount, which is the behaviour the production change introduces; the data path itself is covered by the existing `WorkspaceCollaboratorTable` snapshot. Signed-off-by: Xuesong Luo <lxuesong@amazon.com>
|
Persistent review updated to latest commit f2f7be6 |
✅ All unit and integration tests passing
|
- Cancel the on-mount fetch in the effect's cleanup so that switching workspaces mid-fetch can't overwrite the new workspace's permissions with the previous one's response. - Drop the optional chain on `workspaceClient.get` and the separate `useCallback`; fold both into a single self-contained `useEffect`. - Log unexpected fetch failures via `console.warn` instead of swallowing them, while still falling back to the cached `currentWorkspace$`. - After a successful collaborator update, reflect the just-persisted permissions locally instead of triggering a second `workspaceClient.get` round-trip. Signed-off-by: Xuesong Luo <lxuesong@amazon.com>
|
Pushed
All 5 unit tests in the file still pass. |
|
Persistent review updated to latest commit c893657 |
…resh If another user revokes the current user's access while their tab is on the Collaborators page, the on-mount workspaceClient.get(...) now returns success=false with an "Invalid saved objects permission" error. Previously this fell through to a console.warn and the page kept showing the cached collaborator list. Push the error onto workspaces.workspaceError$ instead, mirroring how WorkspaceValidationService already handles WORKSPACE_IS_STALE so the user is redirected to the fatal-error app rather than seeing stale data. Verified end-to-end against a security-enabled cluster: - Workspace with admin (write) + bar (read). - bar opens Collaborators in an incognito tab, sees both rows. - admin revokes bar from a separate tab. - bar navigates within the workspace without hard-reloading. - bar is redirected to the fatal-error app. Signed-off-by: Xuesong Luo <lxuesong@amazon.com>
|
Verified end-to-end against a security-enabled cluster Setup: local OpenSearch 3.6.0-SNAPSHOT with security plugin (demo install), local OSD with security-dashboards-plugin cloned in, separate Manual repro:
|
|
Persistent review updated to latest commit dcc0b20 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12044 +/- ##
===========================================
- Coverage 61.58% 0 -61.59%
===========================================
Files 4995 0 -4995
Lines 137542 0 -137542
Branches 23901 0 -23901
===========================================
- Hits 84707 0 -84707
+ Misses 46692 0 -46692
+ Partials 6143 0 -6143
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:
|
Description
The Workspace Collaborators page renders the permission list from the cached
workspaces.currentWorkspace$BehaviorSubject. If a different user (e.g. an admin) revokes someone's access remotely, the affected user's UI keeps showing the old collaborator list until the page is hard reloaded.This PR mirrors that pattern for the Collaborators page: on mount (and whenever the workspace id changes, plus after a successful permission update), call
workspaceClient.get(currentWorkspace.id)and render the rendered permission list from the server response. The cachedcurrentWorkspace$.permissionsis used only as a fallback if the request fails.Testing the changes
Existing snapshot test for
WorkspaceCollaboratorsretained. Added a new test that asserts:workspaceClient.get(workspaceId)is called on mount.currentWorkspace$but not in the server response is no longer rendered.Existing tests updated to provide
workspaceClient.getin their mock services.Check List
yarn test:jest(only the changed test file was run locally; full suite via CI)yarn test:jest_integrationchangelogs/fragments/once a PR number is assigned--signoffBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.