Skip to content

feat: implement bulk edit functionality for devices with multi-select support (vertex app) - #3555

Merged
Baalmart merged 11 commits into
stagingfrom
add-auth-required
May 28, 2026
Merged

feat: implement bulk edit functionality for devices with multi-select support (vertex app)#3555
Baalmart merged 11 commits into
stagingfrom
add-auth-required

Conversation

@Codebmk

@Codebmk Codebmk commented May 28, 2026

Copy link
Copy Markdown
Member

Description

Implemented comprehensive bulk edit capabilities for device management, allowing users to efficiently update multiple devices at once.

Key Features

  • New Bulk Edit Modal (BulkEditDevicesModal):

    • Two-step workflow (select field → confirm)
    • Supports editing: Category, Network, Visibility, Auth Required, and Tags
    • Clean confirmation step with summary
  • Multi-Select Support:

    • Enhanced ReusableTable to support multi-selection
    • Updated DevicesTable, ClientPaginatedDevicesTable, and NetworkDevicesTable
  • API & Hook Support:

    • Added useUpdateDeviceBulk hook
    • Refactored device update API to support bulk operations
    • Improved error handling and success notifications

Changes Summary

  • Added bulk edit action to device tables
  • Improved action handling and state management for selected devices
  • Maintained backward compatibility with existing single device updates

Related Tickets

  • Bulk device management improvements

Files Changed: 8

  • src/vertex/components/features/devices/bulk-edit-device-details-modal.tsx (New)
  • src/vertex/components/features/devices/device-list-table.tsx
  • src/vertex/components/features/devices/client-paginated-devices-table.tsx
  • src/vertex/components/features/networks/network-device-list-table.tsx
  • src/vertex/components/shared/table/ReusableTable.tsx
  • src/vertex/core/hooks/useDevices.ts
  • src/vertex/core/apis/devices.ts
  • src/vertex/app/(authenticated)/devices/my-devices/page.tsx

Screenshots (optional)

image image

Summary by CodeRabbit

Release Notes

  • New Features

    • Added bulk edit functionality to simultaneously update multiple devices' properties, including network, category, visibility, and tags.
    • Enabled multi-select capability in device tables for streamlined device management workflows.
  • Documentation

    • Updated changelog with details on new bulk edit and multi-select device features.

Review Change Stack

Codebmk added 6 commits May 28, 2026 18:29
…ableTable actions

Add multi-select capability to the DevicesTable component, allowing users to select multiple devices for actions such as adding or removing from cohorts. Update the ReusableTable to support dynamic action handling based on selected items, improving user interaction and functionality. Additionally, clean up the action handling logic for better maintainability.
Change the updateDeviceGroup function to bulkUpdateDeviceDetails, allowing multiple device IDs and update data to be processed in a single API call. Update related hooks to accommodate the new bulk update functionality, enhancing efficiency and user experience. Additionally, improve error handling and success notifications in the useCreateDevice hook.
… hook

Enhance the DevicesTable component by introducing a bulk edit option, allowing users to select multiple devices for editing. Implement a new useUpdateDeviceBulk hook to handle bulk updates, including success and error notifications. This update improves user experience by streamlining device management processes and ensuring efficient handling of multiple device updates.
…sTable and NetworkDevicesTable

Enhance the ClientPaginatedDevicesTable and NetworkDevicesTable components by adding bulk action capabilities, allowing users to assign devices to cohorts, unassign them, and perform bulk edits. Introduce modals for assigning and unassigning devices, improving user experience and streamlining device management processes. Update action handling logic to support multi-select functionality and ensure proper state management for selected devices.
Enhance the BulkEditDevicesModal component by streamlining the submission logic and updating the dialog structure. Simplify the updateData object creation and improve the handling of the primary and secondary actions. Adjust the layout and spacing for better user experience, ensuring clear visibility of the selected field and confirmation details. This update also includes minor adjustments to input value handling for consistency.
@Codebmk Codebmk self-assigned this May 28, 2026
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Codebmk, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 31 minutes and 32 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 09e9df19-1318-48f2-9a7a-7b8d7af3ff7c

📥 Commits

Reviewing files that changed from the base of the PR and between a0776b1 and 608164d.

📒 Files selected for processing (3)
  • src/vertex/components/features/devices/bulk-edit-device-details-modal.tsx
  • src/vertex/core/apis/devices.ts
  • src/vertex/core/hooks/useDevices.ts
📝 Walkthrough

Walkthrough

This PR adds bulk edit and multi-select functionality to device management. It introduces a two-step bulk edit modal, refactors the shared table action system from dropdowns to direct buttons, and integrates multi-select workflows across device and network tables with cohort and bulk edit actions.

Changes

Bulk Edit & Multi-Select for Devices

Layer / File(s) Summary
Core API and bulk update hook support
src/vertex/core/apis/devices.ts, src/vertex/core/hooks/useDevices.ts
Removes redundant tokenApiClient, adds bulkUpdateDeviceDetails() API method accepting deviceIds and generic updateData, introduces useUpdateDeviceBulk hook with success/error toasts and cache invalidation, and refactors useUpdateDeviceGroup and useCreateDevice to use the new bulk API.
Shared table multi-select action system
src/vertex/components/shared/table/ReusableTable.tsx
Extends TableAction interface with optional icon field, replaces dropdown-based multi-select bar with direct action buttons that invoke handlers immediately, removes selectedAction state and associated dropdown handlers.
Bulk edit modal component
src/vertex/components/features/devices/bulk-edit-device-details-modal.tsx
New two-step modal for bulk device field updates. Users select a field (category, network, visibility, authRequired, tags), enter a value via type-appropriate inputs, confirm the change with a count summary, and submit via useUpdateDeviceBulk.
Device table multi-select integration
src/vertex/components/features/devices/device-list-table.tsx
Adds multi-select state and memoized actions for "Add to Cohort", "Bulk Edit Devices", and "Remove from Cohort"; wires table selection callbacks and renders cohort assignment and bulk edit dialogs.
Client-paginated device table multi-select
src/vertex/components/features/devices/client-paginated-devices-table.tsx
Manages selected device state with success callbacks, constructs memoized actions, passes selection changes to table, and renders cohort and bulk edit dialogs.
Network device table multi-select
src/vertex/components/features/networks/network-device-list-table.tsx
Adds multi-select state and memoized actions for "Add to Cohort", "Bulk Edit Devices", and "Remove from Cohort"; refactors action handlers to accept selected IDs with empty-selection guards and renders bulk edit modal.
Feature enablement
src/vertex/app/(authenticated)/devices/my-devices/page.tsx
Activates multi-select on the "My Devices" page by passing multiSelect={true} to ClientPaginatedDevicesTable.
Release notes
src/vertex/app/changelog.md
Documents Version 1.23.55 release with bulk edit and multi-select feature details and affected component list.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

ready for review

Suggested reviewers

  • Baalmart
  • NicholasTurner23

Poem

🎨 Multi-select meets the modal's dance,

bulk edits get their shining chance,

buttons replace dropdowns with flair,

devices refresh with table-wide care. ✨

🚥 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 accurately describes the main feature introduced: bulk edit functionality for devices with multi-select support, which is the core objective of this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-auth-required

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.

@github-actions

Copy link
Copy Markdown
Contributor

New azure vertex changes available for preview here

@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: 5

🤖 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/bulk-edit-device-details-modal.tsx`:
- Around line 150-161: The modal allows submitting a stale or null `value` when
`selectedField` changes; update the `onChange` for `ReusableSelectInput` (where
`setSelectedField` is called) to also reset the edit `value` (e.g.,
setValue(null/"" or appropriate empty type) so previous field values are
cleared), add a small validator (isValidValueForField(selectedField, value)) and
update the button disabled logic (currently in the `disabled: step ===
"choose_field" ? !selectedField : bulkUpdate.isPending` expression) to also
require a valid value when on the active edit/confirm step (e.g., for
choose_field/confirm steps require selectedField && isValidValueForField(...));
apply same reset/validation changes to other branching points that set
selectedField (lines ~61-65, 74-122) so no null/stale value can be submitted.
- Around line 61-68: The handleSubmit function currently proceeds to call
bulkUpdate.mutate even when no devices are selected; add an early return guard
that checks deviceIds (e.g., if (!deviceIds || deviceIds.length === 0) return)
before building updateData and calling bulkUpdate.mutate to no-op when there are
no selected devices, leaving existing selectedField/value checks and bulkUpdate
usage intact.

In `@src/vertex/core/apis/devices.ts`:
- Around line 549-557: The bulkUpdateDeviceDetails function is forwarding
deviceIds as-is; add client-side validation in bulkUpdateDeviceDetails to reject
empty arrays or any blank/whitespace-only IDs before building requestBody—check
that deviceIds.length > 0 and that every id is a non-empty trimmed string, and
throw or return a clear validation error (e.g., BadRequest / Error) early so the
request is not sent to the server.

In `@src/vertex/core/hooks/useDevices.ts`:
- Around line 466-469: The bulk-update success handler currently invalidates
"devices", "network-devices", and "deviceActivities" but misses "myDevices",
causing stale UI; update the success invalidation block in useDevices (where
queryClient.invalidateQueries is called) to also call
queryClient.invalidateQueries({ queryKey: ["myDevices"] }) so My Devices cache
is refreshed after bulk edits.
- Around line 540-553: The code currently falls back to an empty deviceId when
calling updateDeviceGroup.mutateAsync and only invalidates caches inside the try
block; change the logic so you only call updateDeviceGroup.mutateAsync when
data.created_device._id (or activeGroup?.grp_title) is truthy to avoid sending
an empty deviceId to updateDeviceGroup.mutateAsync, and move the
queryClient.invalidateQueries calls for ["devices"], ["network-devices"], and
["deviceActivities"] into a finally block (or otherwise ensure they run
regardless of success) so caches are always refreshed even if group assignment
fails.
🪄 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: 9e754633-1c36-458c-9e37-bef8305375b5

📥 Commits

Reviewing files that changed from the base of the PR and between eedc4d0 and a0776b1.

📒 Files selected for processing (9)
  • src/vertex/app/(authenticated)/devices/my-devices/page.tsx
  • src/vertex/app/changelog.md
  • src/vertex/components/features/devices/bulk-edit-device-details-modal.tsx
  • src/vertex/components/features/devices/client-paginated-devices-table.tsx
  • src/vertex/components/features/devices/device-list-table.tsx
  • src/vertex/components/features/networks/network-device-list-table.tsx
  • src/vertex/components/shared/table/ReusableTable.tsx
  • src/vertex/core/apis/devices.ts
  • src/vertex/core/hooks/useDevices.ts

Comment thread src/vertex/components/features/devices/bulk-edit-device-details-modal.tsx Outdated
Comment thread src/vertex/core/apis/devices.ts
Comment thread src/vertex/core/hooks/useDevices.ts
Comment thread src/vertex/core/hooks/useDevices.ts Outdated
Codebmk added 4 commits May 28, 2026 20:07
Refactor the BulkEditDevicesModal component to include validation for selected fields and their corresponding values before proceeding with updates. Introduce a new `hasValidValue` check to ensure that the input meets the required criteria for 'network' and 'tags'. Update the submission logic to prevent actions when validation fails, improving user experience and data integrity.
Sanitize device IDs by trimming whitespace and filtering out empty values. Introduce an error throw if no valid device IDs are provided, ensuring that at least one device ID is required for the update operation. This change enhances input validation and prevents unnecessary API calls.
Enhance the useUpdateDeviceBulk hook by adding cache invalidation for the myDevices query key alongside existing cache invalidations. This ensures that the device list remains up-to-date after bulk updates, improving data consistency and user experience.
@github-actions

Copy link
Copy Markdown
Contributor

New azure vertex changes available for preview here

…ateDevice hook

Refactor the useCreateDevice hook to enhance error handling when assigning newly created devices to groups. Introduce a more robust check for created device IDs and log errors appropriately. This change improves reliability and provides clearer feedback in case of failures during the device assignment process.
@github-actions

Copy link
Copy Markdown
Contributor

New azure vertex changes available for preview here

@Baalmart
Baalmart merged commit 512e725 into staging May 28, 2026
21 checks passed
@Baalmart
Baalmart deleted the add-auth-required branch May 28, 2026 17:59
@Baalmart Baalmart mentioned this pull request May 28, 2026
1 task
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.

2 participants