Skip to content

feat(vertex/devices): migrate device management toasts to InfoBanner …#3503

Merged
Baalmart merged 10 commits into
airqo-platform:stagingfrom
BwanikaRobert:Update-Device-Management-Module-to-use-InfoBanners
May 19, 2026
Merged

feat(vertex/devices): migrate device management toasts to InfoBanner …#3503
Baalmart merged 10 commits into
airqo-platform:stagingfrom
BwanikaRobert:Update-Device-Management-Module-to-use-InfoBanners

Conversation

@BwanikaRobert

@BwanikaRobert BwanikaRobert commented May 18, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes (What does this PR do?)

Replaces ReusableToast calls with useBanner across device management
components. Error and validation feedback now renders as an InfoBanner
inside the active modal or dialog container instead of a floating toast.

No new dependencies required. Depends on the BannerContext infrastructure
and the updated ReusableDialog from PR #3498.

Changes per component:

  • create-device-modaluseBanner added; showBanner replaces old inline red error div for missing network error
  • import-device-modaluseBanner added; showBanner surfaces the previously silent missing user ID error; removes old inline red error div
  • add-maintenance-log-modalReusableToast replaced with showBanner for validation error
  • deploy-device-component — 3 ReusableToast calls replaced with showBanner
  • recall-device-dialoguseBanner added; success and error feedback moved from hook callbacks to component try/catch
  • device-details-modalReusableToast replaced with showBanner for all validation, update, and key decryption feedback; success/error callbacks added to updateLocal and updateGlobal mutate calls
  • device-assignment-modaluseBanner added with scoped: false (uses base Dialog, not ReusableDialog); assignment success and error feedback moved from hook to component
  • useDevices.ts — removed ReusableToast from onSuccess/onError in useRecallDevice, useUpdateDeviceLocal, useUpdateDeviceGlobal, useAssignDeviceToOrganization, and useDecryptDeviceKeys; hooks now only handle API calls and cache invalidation

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

How should this be manually tested?

Deploy Device (/devices/overview/[device-id] → Deploy action)

  1. Open the Deploy Device flow
  2. Click Next without filling required fields — confirm error banner appears inside the dialog
  3. Select "Previous site" without picking a site — confirm the site selection error banner appears

Add Maintenance Log (Device detail page → Maintenance tab)

  1. Open the Add Maintenance Log dialog
  2. Click Save Log without selecting tags — confirm error banner appears inside the dialog
  3. Fill all required fields and save — confirm the dialog closes normally

Import Device (/devices/overview or /devices/my-devices)

  1. Open the Import Device dialog and confirm the layout is intact

Create Device (/admin/networks/[id] — requires admin access)

  1. Open the Add AirQo Device dialog and confirm the layout is intact

Recall Device (Device detail page → Recall action)

  1. Open the Recall Device dialog, select a recall type and submit — confirm success banner appears
  2. Submit with network down — confirm error banner appears with API error detail

Device Details (Device detail page → Edit)

  1. Click Edit, change a field and click Save Local — confirm success banner appears inside the dialog
  2. Click Sync Global — confirm success banner appears
  3. Trigger a failure (e.g. network down) — confirm error banner appears with API error detail
  4. Click the key icon on Write Key or Read Key — confirm decryption feedback appears as a banner

Share Device (/devices/my-devices → Share action)

  1. Select an organization and device, click Share Device — confirm success banner appears at the top of the page
  2. Trigger a failure — confirm error banner appears at the top of the page with API error detail

What are the relevant tickets?

Screenshots (optional)

Full coverage was not possible for all modals — admin-gated pages
(Create Device, Recall Device) could not be reached during local testing.

Deploy Device — validation error banner
Deploy_after

Maintenance Log — validation error banner
matainance_banner

Summary by CodeRabbit

  • Bug Fixes
    • Replaced toast alerts with unified inline banner messages across device workflows (create, import, deploy, assign, recall, maintenance, details) for clearer success/error/warning feedback.
    • API errors, missing required fields, clipboard/decrypt results, and auth-related issues now show scoped, formatted banner messages.
    • Success banners are shown consistently (some with short delay), and redundant pop-up notifications have been removed.

Review Change Stack

…system

Replaces ReusableToast with useBanner across device management components.
ReusableDialog now natively includes BannerSlot so no manual slot placement
is needed for dialog-based components
@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@Codebmk has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 43 minutes and 33 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 05c0835a-f881-4a9d-97b3-63064bd82239

📥 Commits

Reviewing files that changed from the base of the PR and between 47160d9 and 978f753.

📒 Files selected for processing (6)
  • src/vertex/app/changelog.md
  • src/vertex/components/features/devices/add-maintenance-log-modal.tsx
  • src/vertex/components/features/devices/create-device-modal.tsx
  • src/vertex/components/features/devices/deploy-device-component.tsx
  • src/vertex/components/features/devices/import-device-modal.tsx
  • src/vertex/components/features/devices/recall-device-dialog.tsx
📝 Walkthrough

Walkthrough

This PR replaces toast and inline-form errors with the centralized banner system via useBanner().showBanner across device components and removes in-hook toast callbacks from useDevices so components emit banners instead.

Changes

Device Management Toast-to-Banner Migration

Layer / File(s) Summary
Device Details Modal Banner Integrations
src/vertex/components/features/devices/device-details-modal.tsx
Replaces ReusableToast with useBanner/getApiErrorMessage, initializes showBanner, and emits scoped warning/success/error banners across submit, local/global updates, copy, and decrypt flows.
Add Maintenance Log Modal Banner Integration
src/vertex/components/features/devices/add-maintenance-log-modal.tsx
Imports useBanner/getApiErrorMessage, initializes showBanner, replaces missing-fields toast with a scoped error banner, and wraps the addMaintenanceLog mutation in try/catch to show success/error banners.
Create Device Modal Banner Integration
src/vertex/components/features/devices/create-device-modal.tsx
Adds useBanner, initializes showBanner, surfaces the "no effective network name" error via scoped banner, shows success banner on create then resets/closes, and removes inline errors.general rendering.
Deploy Device Component Banner Integration
src/vertex/components/features/devices/deploy-device-component.tsx
Adds useBanner/getApiErrorMessage, initializes showBanner, replaces validation/toast early-returns in handleNext/handleDeploy with scoped banners, shows delayed success banner on deploy, and constructs scoped error banners on deployment failures.
Import Device Modal Banner Integration
src/vertex/components/features/devices/import-device-modal.tsx
Adds useBanner/getApiErrorMessage, initializes showBanner, shows a scoped error banner when userDetails._id is missing, triggers delayed success banner on import success, shows scoped error banner on failure, and removes inline errors.general.
Device Assignment Modal Banner Integration
src/vertex/components/features/devices/device-assignment-modal.tsx
Adds useBanner/getApiErrorMessage, rewrites handleAssign to try/catch the mutation, shows success banner then calls onSuccess(), and shows scoped error banner on failure.
Recall Device Dialog Banner Integration
src/vertex/components/features/devices/recall-device-dialog.tsx
Adds useBanner/getApiErrorMessage, initializes showBanner, shows a delayed scoped success banner on recall success (with display name fallback), and shows a scoped error banner on failure.
useDevices Hook Notification Cleanup
src/vertex/core/hooks/useDevices.ts
Removes in-hook ReusableToast success/error handlers from multiple mutation callbacks and preserves query invalidations so components control user-facing banners.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • #3496: Similar migration of toasts → banners; overlaps with hook and component notification changes.
  • #3497: Migration from toasts to useBanner across device UIs — shares the same refactor objective.

Possibly related PRs

Suggested labels

ready for review

Suggested reviewers

  • Baalmart
  • OchiengPaul442
  • Codebmk

Poem

Banners rise where toasts once flew,
Scoped inside the modal view,
Mutations quiet, queries stay,
showBanner speaks the error way,
A gentler alert now guides the crew.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 'feat(vertex/devices): migrate device management toasts to InfoBanner' accurately captures the main change across all modified files.
Linked Issues check ✅ Passed The PR implements all coding requirements from issue #3451: replaces ReusableToast with useBanner across specified components and removes toast handlers from useDevices.ts hooks.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #3451 objectives—migrating device management notifications to InfoBanner system with no extraneous modifications.

✏️ 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.

@Codebmk
Codebmk self-requested a review May 18, 2026 12:28

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

Great work @BwanikaRobert .

Also migrate the toasts for RecallDeviceDialog, DeviceDetailsModal, DeviceAssignmentModal. Move their toasts from the hook side to the UI side. If you have any further queries on this, don't hesitate to ask.

@BwanikaRobert
BwanikaRobert requested a review from Codebmk May 18, 2026 16:53

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@src/vertex/components/features/devices/recall-device-dialog.tsx`:
- Around line 53-55: The success banner is created with showBanner(..., scoped:
true) then the dialog is immediately closed via onOpenChange(false), causing the
scoped banner to be hidden before the user can see it; change the banner to
global by passing scoped: false (or omitting scoped if default is global) in the
showBanner call that uses deviceDisplayName/deviceName, then keep the existing
setRecallType("") and onOpenChange(false) behavior so the dialog can close while
the success message remains visible to the user.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b9c4c63d-35cb-4a41-bf8c-e46b3cc3a7f2

📥 Commits

Reviewing files that changed from the base of the PR and between 0eb4933 and 92e71f8.

📒 Files selected for processing (4)
  • src/vertex/components/features/devices/device-assignment-modal.tsx
  • src/vertex/components/features/devices/device-details-modal.tsx
  • src/vertex/components/features/devices/recall-device-dialog.tsx
  • src/vertex/core/hooks/useDevices.ts

Comment thread src/vertex/components/features/devices/recall-device-dialog.tsx Outdated

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.

@BwanikaRobert this error is still being shown using toast, check the useAddMaintenanceLog hook and move the toasts to the UI side
Image

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.

After device is deployed, toast is still being used. Move toast from useDeployDevice hook to UI component

Image

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 In useDevices.ts should i replace all the ReusableToast components or only those you have so far mentioned?

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.

We shall do this following a separate issue and pull request. For now do these and just ensure that for all you've worked on so far they are working as expected @BwanikaRobert

…system

Replaces ReusableToast with useBanner across device management components.
ReusableDialog now natively includes BannerSlot so no manual slot placement
is needed for dialog-based components
…s to UI

Remove onSuccess/onError ReusableToast callbacks from useDeployDevice and
useAddMaintenanceLog hooks.
@BwanikaRobert
BwanikaRobert force-pushed the Update-Device-Management-Module-to-use-InfoBanners branch from 92e71f8 to 0e78435 Compare May 18, 2026 18:56
@BwanikaRobert
BwanikaRobert requested a review from Codebmk May 18, 2026 18:59

@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/devices/create-device-modal.tsx (1)

53-86: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Complete create-device submit feedback migration to banners.

This flow is only partially migrated: missing-network now uses showBanner, but create mutation success/error still depends on hook toasts (catch only logs). That keeps mixed UX in the same modal and conflicts with the banner migration objective.

Suggested direction
// src/vertex/components/features/devices/create-device-modal.tsx
+import { getApiErrorMessage } from "`@/core/utils/getApiErrorMessage`";

...
    } catch (error) {
-      // Error handling is done in the hook
-      console.error("Create device failed:", error);
+      showBanner({
+        severity: "error",
+        message: `Creation Failed: ${getApiErrorMessage(error)}`,
+        scoped: true,
+      });
    }
// src/vertex/core/hooks/useDevices.ts (useCreateDevice)
// Remove ReusableToast side-effects and keep cache invalidation only;
// let caller components own user-facing banners.
🤖 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/devices/create-device-modal.tsx` around lines
53 - 86, The submit flow in handleSubmit still relies on the hook's toasts (only
logs errors) causing mixed UX; update the try/catch around
createDevice.mutateAsync to call showBanner on success and on failure (include
the error message/details), remove the console.error, and keep the current form
reset/onOpenChange behavior on success; reference handleSubmit,
createDevice.mutateAsync, showBanner, onOpenChange, setFormData and setErrors so
you place the banners in the same modal flow and pass scoped: true (and a clear
severity/message) for both success and error cases.
🤖 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/devices/create-device-modal.tsx`:
- Around line 53-86: The submit flow in handleSubmit still relies on the hook's
toasts (only logs errors) causing mixed UX; update the try/catch around
createDevice.mutateAsync to call showBanner on success and on failure (include
the error message/details), remove the console.error, and keep the current form
reset/onOpenChange behavior on success; reference handleSubmit,
createDevice.mutateAsync, showBanner, onOpenChange, setFormData and setErrors so
you place the banners in the same modal flow and pass scoped: true (and a clear
severity/message) for both success and error cases.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 286ebad3-b1ac-4a3c-995f-f2cc71e34288

📥 Commits

Reviewing files that changed from the base of the PR and between 92e71f8 and 0e78435.

📒 Files selected for processing (8)
  • src/vertex/components/features/devices/add-maintenance-log-modal.tsx
  • src/vertex/components/features/devices/create-device-modal.tsx
  • src/vertex/components/features/devices/deploy-device-component.tsx
  • src/vertex/components/features/devices/device-assignment-modal.tsx
  • src/vertex/components/features/devices/device-details-modal.tsx
  • src/vertex/components/features/devices/import-device-modal.tsx
  • src/vertex/components/features/devices/recall-device-dialog.tsx
  • src/vertex/core/hooks/useDevices.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/vertex/components/features/devices/import-device-modal.tsx
  • src/vertex/components/features/devices/device-assignment-modal.tsx
  • src/vertex/components/features/devices/recall-device-dialog.tsx
  • src/vertex/components/features/devices/device-details-modal.tsx

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

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@src/vertex/components/features/devices/create-device-modal.tsx`:
- Around line 75-81: The success banner is shown inside the setTimeout using
showBanner with message interpolating formData.long_name but the dialog closes
immediately, so update the showBanner call (inside the existing setTimeout) to
explicitly set scoped: false (global) so the banner remains visible after the
modal is closed; modify the showBanner invocation in create-device-modal.tsx
(the setTimeout callback that currently builds the success message) to include
scoped: false before the modal-close call.

In `@src/vertex/components/features/devices/import-device-modal.tsx`:
- Around line 128-134: The success banner shown after closing the dialog via
showBanner should be explicitly global so it isn't hidden by scoped defaults;
update the callback that calls showBanner (the setTimeout block that builds the
message using variables.long_name) to include scoped: false in the banner
payload so the success message is visible application-wide after the modal
closes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3dd86293-5ee6-47c1-999b-415a62f1b3d0

📥 Commits

Reviewing files that changed from the base of the PR and between 0e78435 and 47160d9.

📒 Files selected for processing (7)
  • src/vertex/components/features/devices/add-maintenance-log-modal.tsx
  • src/vertex/components/features/devices/create-device-modal.tsx
  • src/vertex/components/features/devices/deploy-device-component.tsx
  • src/vertex/components/features/devices/device-assignment-modal.tsx
  • src/vertex/components/features/devices/import-device-modal.tsx
  • src/vertex/components/features/devices/recall-device-dialog.tsx
  • src/vertex/core/hooks/useDevices.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/vertex/components/features/devices/deploy-device-component.tsx
  • src/vertex/components/features/devices/device-assignment-modal.tsx
  • src/vertex/components/features/devices/add-maintenance-log-modal.tsx

Comment thread src/vertex/components/features/devices/create-device-modal.tsx Outdated
Comment thread src/vertex/components/features/devices/import-device-modal.tsx

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

I have resolved the remaining issues. Brilliant work @BwanikaRobert!
Image

Image Image Image

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 Device Management Module to use InfoBanners

3 participants