Skip to content

Update Organizations and Groups module to use info banners#3563

Merged
Baalmart merged 6 commits into
airqo-platform:stagingfrom
BwanikaRobert:Update-Organizations-Groups-Module-to-use-InfoBanners
Jun 2, 2026
Merged

Update Organizations and Groups module to use info banners#3563
Baalmart merged 6 commits into
airqo-platform:stagingfrom
BwanikaRobert:Update-Organizations-Groups-Module-to-use-InfoBanners

Conversation

@BwanikaRobert

@BwanikaRobert BwanikaRobert commented May 31, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes (What does this PR do?)

Replaces the ReusableToast call in OrganizationPicker with the centralized InfoBanner system.

Status of maturity (all need to be checked before merging):

How should this be manually tested?

  1. Log in with an account that belongs to multiple organizations.
  2. Click the organization picker in the topbar and select a different organization.
  3. Success banner removed.
  4. To test the error path, temporarily add throw new Error() as the very first line inside the try block in handleOrganizationChange (before removeQueries runs), switch any org, and confirm a red error banner appears after the modal closes.

What are the relevant tickets?

Screenshots

gp2

Summary by CodeRabbit

  • Improvements

    • Organization switching now uses centralized banners for errors and success, giving clearer feedback.
    • Progress indicator only appears when navigation proceeds, reducing false loading states and improving reliability during switches.
  • Documentation

    • Changelog updated with the organization picker banner migration and behavior changes.

@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d65b02df-34b5-41d7-ae83-0125f9b0b7e6

📥 Commits

Reviewing files that changed from the base of the PR and between d3d32a6 and e2040a7.

📒 Files selected for processing (1)
  • src/vertex/app/changelog.md
✅ Files skipped from review due to trivial changes (1)
  • src/vertex/app/changelog.md

📝 Walkthrough

Walkthrough

OrganizationPicker now uses useBannerWithDelay for error/success banners, closes the modal and clears forbidden state before async cleanup, moves the Redux switching flag dispatch to just before navigation, conditionally refreshes or pushes /home, and documents the change in the changelog.

Changes

Organization Switching Notification Flow

Layer / File(s) Summary
Banner Hook Integration
src/vertex/components/features/org-picker/organization-picker.tsx
Adds useBannerWithDelay import and derives showBannerWithDelay in component scope for banner-driven feedback during organization switching.
Organization Switching Flow Refactor
src/vertex/components/features/org-picker/organization-picker.tsx
Reorders handleOrganizationChange to close modal and clear forbidden state before async work, compute new UserContext, cancel/remove React Query keys, update setActiveGroup/setUserContext, dispatch organizationSwitching immediately before routing, conditionally router.refresh() or router.push('/home'), and replace ReusableToast with showBannerWithDelay for errors (no direct catch-path clearing of switching flag).
Changelog entry
src/vertex/app/changelog.md
Inserts Version 1.23.57 entry describing the Organization Picker banner migration and the change in when the switching shimmer is set.

Sequence Diagram

sequenceDiagram
  participant OrganizationPicker
  participant ReactQuery
  participant ReduxStore
  participant Router
  participant useBannerWithDelay
  OrganizationPicker->>ReduxStore: clear forbidden state, close modal
  OrganizationPicker->>ReactQuery: cancel/remove previous context keys
  OrganizationPicker->>ReduxStore: setActiveGroup, setUserContext
  OrganizationPicker->>ReduxStore: setOrganizationSwitching(isSwitching:true, switchingTo)
  OrganizationPicker->>Router: if pathname==/home -> refresh() else push('/home')
  Router->>ReduxStore: pathname-change effect clears organizationSwitching
  OrganizationPicker->>useBannerWithDelay: showBannerWithDelay(success|error)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

ready for review

Suggested reviewers

  • Baalmart
  • OchiengPaul442
  • Codebmk

Poem

🎪 The org-picker dances free,
From toast to banner—clear as day,
Close the modal, tidy state,
Refresh or push to lead the way,
Banners sing whether fail or sway.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements partial requirements from issue #3452: it successfully migrates OrganizationPicker to use useBannerWithDelay for error feedback [#3452], but does not implement required changes for Network Admin pages, Network Requests, or success banners. Complete the remaining requirements: add banner integration to admin/networks/page.tsx, admin/networks/[id]/page.tsx, admin/networks/requests/page.tsx, and implement global success banners after organization switch [#3452].
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: migrating from ReusableToast to the centralized InfoBanner system in the Organizations and Groups module, specifically in OrganizationPicker.
Out of Scope Changes check ✅ Passed The changelog update is a proper documentation change in scope. The OrganizationPicker refactoring and updated dispatch timing are directly aligned with the stated objective of migrating to the InfoBanner system.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/vertex/components/features/org-picker/organization-picker.tsx (1)

65-111: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix unreachable error banner in handleOrganizationChange (async failures won’t hit catch)
In src/vertex/components/features/org-picker/organization-picker.tsx (handleOrganizationChange, try/catch around lines 65-111), the try block contains no await; it only voids queryClient.cancelQueries(...), does synchronous removeQueries/dispatch/router calls, then shows the success banner. As a result, the catch can only handle synchronous throws, so the “Failed to switch organization” banner won’t surface for real async switch/query failures.

♻️ Option: await the cancellation work so failures can reach the catch
-      orgScopedQueryKeys.forEach((queryKey) => {
-        void queryClient.cancelQueries({ queryKey })
-        queryClient.removeQueries({ queryKey });
-      });
+      await Promise.all(
+        orgScopedQueryKeys.map((queryKey) =>
+          queryClient.cancelQueries({ queryKey })
+        )
+      );
+      orgScopedQueryKeys.forEach((queryKey) => {
+        queryClient.removeQueries({ queryKey });
+      });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/vertex/components/features/org-picker/organization-picker.tsx` around
lines 65 - 111, The try/catch is currently ineffective for async failures
because cancelQueries is voided and router calls are not awaited; update
handleOrganizationChange to await the async operations so errors propagate to
the catch: change the orgScopedQueryKeys loop to collect and await
Promise.all(orgScopedQueryKeys.map(k => queryClient.cancelQueries({ queryKey: k
}))) (keep queryClient.removeQueries synchronous afterwards), await
router.push("/home") or await router.refresh() where used, and optionally accept
the error parameter in the catch to include error details when calling
showBannerWithDelay for the failure path; reference functions/identifiers:
handleOrganizationChange, queryClient.cancelQueries, queryClient.removeQueries,
router.push, router.refresh, showBannerWithDelay, setOrganizationSwitching.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/vertex/components/features/org-picker/organization-picker.tsx`:
- Around line 65-111: The try/catch is currently ineffective for async failures
because cancelQueries is voided and router calls are not awaited; update
handleOrganizationChange to await the async operations so errors propagate to
the catch: change the orgScopedQueryKeys loop to collect and await
Promise.all(orgScopedQueryKeys.map(k => queryClient.cancelQueries({ queryKey: k
}))) (keep queryClient.removeQueries synchronous afterwards), await
router.push("/home") or await router.refresh() where used, and optionally accept
the error parameter in the catch to include error details when calling
showBannerWithDelay for the failure path; reference functions/identifiers:
handleOrganizationChange, queryClient.cancelQueries, queryClient.removeQueries,
router.push, router.refresh, showBannerWithDelay, setOrganizationSwitching.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f5965c88-927a-4f48-a8cc-7f63cfec6942

📥 Commits

Reviewing files that changed from the base of the PR and between e57e9ef and 19f972e.

📒 Files selected for processing (1)
  • src/vertex/components/features/org-picker/organization-picker.tsx

message: `Switched to ${formatTitle(group.grp_title)}`,
scoped: false,
});
} catch {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please remove this success banner for Switched to ..., it is not necessary @BwanikaRobert

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Codebmk Actually in the production even the error banner won't be shown because all the switching happens at the client side.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Kindly remove it still @BwanikaRobert. Thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The success banner has been removed. We only have the error banner left.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

New azure vertex changes available for preview here

@Codebmk

Codebmk commented Jun 2, 2026

Copy link
Copy Markdown
Member

One last change, please update changelog accordingly @BwanikaRobert

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

New azure vertex changes available for preview here

@Codebmk Codebmk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Amazing thanks @BwanikaRobert

@Baalmart
Baalmart merged commit 7a70e44 into airqo-platform:staging Jun 2, 2026
15 checks passed
@Baalmart Baalmart mentioned this pull request Jun 2, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Vertex: Migration] Update Organizations & Groups Module to use InfoBanners

3 participants