Skip to content

Conversation

@lucas-a-pelegrino
Copy link
Contributor

@lucas-a-pelegrino lucas-a-pelegrino commented Oct 8, 2025

Proposed changes (including videos or screenshots)

This PR adds a deprecation warning for livechat:removeUnit legacy meteor method. Updates client to use the endpoint instead.

Issue(s)

CORE-1406

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Improvements

    • Delete Omnichannel units directly from the Units table row.
    • Streamlined deletion flow in the Unit edit view with consistent confirmation and post-delete updates.
  • Deprecations

    • The legacy server method for removing units is deprecated. Please migrate integrations to the REST API for unit deletion.
  • Refactor

    • Units table rows were componentized for a more consistent UI and maintainability.

@lucas-a-pelegrino lucas-a-pelegrino added this to the 7.12.0 milestone Oct 8, 2025
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Oct 8, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is targeting the wrong base branch. It should target 7.12.0, but it targets 7.11.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Oct 8, 2025

🦋 Changeset detected

Latest commit: df59b13

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 42 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/federation-service Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 8, 2025

Walkthrough

Adds a deprecation warning to the legacy Meteor method livechat:removeUnit, refactors client deletion to use a REST DELETE endpoint via a revised useRemoveUnit hook, threads an onDelete callback through UnitEdit/UnitEditWithData, and extracts Units table row UI into a new UnitTableRow component.

Changes

Cohort / File(s) Summary of changes
Changeset metadata
\.changeset/many-moons-wonder.md
Adds a patch-level changeset noting deprecation of livechat:removeUnit.
Unit edit wiring
apps/meteor/client/omnichannel/units/UnitEdit.tsx, apps/meteor/client/omnichannel/units/UnitEditWithData.tsx
UnitEdit accepts optional onDelete prop; internal delete handler removed. UnitEditWithData uses useRemoveUnit(unitId) and passes onDelete={removeUnit} to UnitEdit.
Units table row extraction
apps/meteor/client/omnichannel/units/UnitTableRow.tsx, apps/meteor/client/omnichannel/units/UnitsTable.tsx
Introduces UnitTableRow component handling row click and delete. UnitsTable refactored to render UnitTableRow; removes inline row markup and delete logic.
Delete hook → REST endpoint
apps/meteor/client/omnichannel/units/useRemoveUnit.tsx
Changes signature to useRemoveUnit(id: string). Switches from Meteor method to useEndpoint('DELETE', '/v1/livechat/units/:id'). Deletes now use a parameterless handler bound to provided id; keeps modal, navigation, and cache invalidation.
Server method deprecation log
apps/meteor/ee/app/livechat-enterprise/server/methods/removeUnit.ts
Adds methodDeprecationLogger call marking deprecation in favor of DELETE /v1/livechat/units/:id. No functional behavior changes.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant UI as UnitsTable/UnitEdit UI
  participant Row as UnitTableRow
  participant Hook as useRemoveUnit(id)
  participant API as REST /v1/livechat/units/:id (DELETE)
  participant S as Server
  participant DB as Database

  U->>UI: Click Delete
  UI->>Row: onDelete()
  Row->>Hook: invoke delete handler
  Hook->>API: DELETE /v1/livechat/units/:id
  API->>S: Route request
  S->>DB: Remove unit by id
  DB-->>S: Result
  S-->>API: 200/4xx
  API-->>Hook: Response
  Hook->>UI: Invalidate queries, navigate
  Note over S: Legacy Meteor method logs deprecation when used
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • MartinSchoeler
  • KevLehman
  • dougfabris

Poem

A nibble of code, a hop to REST,
I twitch my nose—DELETE works best.
The meteor fades, a warning chimes,
New rows sprout green in tidy lines.
With carrot clicks and cache anew,
I bounce—unit gone—clean burrow view! 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly denotes the addition of a deprecation warning for livechat:removeUnit, which is a real aspect of the changeset, though it omits mention of the client-side refactoring to use the new HTTP endpoint. It is clear, concise, and avoids noise, so it meets the acceptance criteria.
Linked Issues Check ✅ Passed The pull request implements the primary coding objectives of CORE-1406 by adding a deprecation warning for the legacy livechat:removeUnit Meteor method and fully migrating client-side calls to the new DELETE /v1/livechat/units/:id endpoint through the updated useRemoveUnit hook and component integrations. This alignment satisfies the issue requirements.
Out of Scope Changes Check ✅ Passed All modifications in this pull request are directly related to deprecating the legacy livechat:removeUnit method and migrating client-side unit removal flows to the new HTTP endpoint, and no unrelated or out-of-scope code changes have been introduced.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/v7/CORE-1406

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between beebaf0 and 6681f86.

📒 Files selected for processing (7)
  • .changeset/many-moons-wonder.md (1 hunks)
  • apps/meteor/client/omnichannel/units/UnitEdit.tsx (2 hunks)
  • apps/meteor/client/omnichannel/units/UnitEditWithData.tsx (3 hunks)
  • apps/meteor/client/omnichannel/units/UnitTableRow.tsx (1 hunks)
  • apps/meteor/client/omnichannel/units/UnitsTable.tsx (2 hunks)
  • apps/meteor/client/omnichannel/units/useRemoveUnit.tsx (1 hunks)
  • apps/meteor/ee/app/livechat-enterprise/server/methods/removeUnit.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
apps/meteor/client/omnichannel/units/UnitTableRow.tsx (1)
apps/meteor/client/omnichannel/units/useRemoveUnit.tsx (1)
  • useRemoveUnit (6-43)
apps/meteor/client/omnichannel/units/UnitEditWithData.tsx (2)
apps/meteor/ee/app/livechat-enterprise/server/lib/LivechatEnterprise.ts (1)
  • removeUnit (53-64)
apps/meteor/client/omnichannel/units/useRemoveUnit.tsx (1)
  • useRemoveUnit (6-43)
apps/meteor/client/omnichannel/units/UnitEdit.tsx (1)
packages/livechat/src/components/Button/index.tsx (1)
  • Button (34-99)
apps/meteor/client/omnichannel/units/useRemoveUnit.tsx (1)
apps/meteor/ee/app/livechat-enterprise/server/lib/LivechatEnterprise.ts (1)
  • removeUnit (53-64)
🔇 Additional comments (9)
.changeset/many-moons-wonder.md (1)

1-5: LGTM!

The changeset correctly documents the deprecation warning as a patch-level change with a clear description.

apps/meteor/ee/app/livechat-enterprise/server/methods/removeUnit.ts (1)

6-6: LGTM!

The deprecation warning is correctly implemented:

  • Import added for methodDeprecationLogger
  • Logging placed at method entry before any logic
  • Version 8.0.0 and replacement endpoint DELETE /v1/livechat/units/:id are clearly specified
  • Existing functionality unchanged

Also applies to: 18-18

apps/meteor/client/omnichannel/units/UnitEditWithData.tsx (1)

8-8: LGTM!

The integration of useRemoveUnit is correct:

  • Hook invoked with unitId matching the updated signature
  • onDelete callback properly passed to UnitEdit component
  • Maintains existing data fetching logic
  • No changes to public API

Also applies to: 17-17, 60-66

apps/meteor/client/omnichannel/units/UnitEdit.tsx (1)

38-38: LGTM!

The refactor to delegate deletion is well-structured:

  • onDelete prop correctly typed as optional
  • Delete button uses optional chaining onDelete?.()
  • Internal delete logic removed, delegated to parent component
  • Good separation of concerns

Also applies to: 41-41, 251-251

apps/meteor/client/omnichannel/units/UnitsTable.tsx (1)

1-1: LGTM!

The refactoring to use UnitTableRow component improves modularity:

  • Delegates row rendering and delete logic to dedicated component
  • Simplifies UnitsTable by removing row-level concerns
  • Maintains table structure, headers, and pagination
  • Import cleanup correctly removes unused components

Also applies to: 8-8, 102-102

apps/meteor/client/omnichannel/units/UnitTableRow.tsx (3)

26-29: LGTM!

The delete button correctly uses stopPropagation() to prevent triggering the row click navigation when deleting.


9-14: LGTM!

The component properly:

  • Uses useRemoveUnit hook with the unit _id
  • Sets up navigation handler with onRowClick
  • Maintains clean separation between navigation and deletion actions

17-17: Verify keyboard interaction support on GenericTableRow. The GenericTableRow spreads role='link' and tabIndex={0} to TableRow; confirm that TableRow renders a focusable element and handles Enter/Space activation correctly.

apps/meteor/client/omnichannel/units/useRemoveUnit.tsx (1)

3-3: Approve endpoint migration.

The DELETE /v1/livechat/units/:id endpoint is defined in apps/meteor/ee/app/livechat-enterprise/server/api/units.ts; the hook migration and error handling are correct.


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.

@codecov
Copy link

codecov bot commented Oct 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.40%. Comparing base (6b9b1d1) to head (df59b13).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #37171      +/-   ##
===========================================
+ Coverage    67.38%   67.40%   +0.02%     
===========================================
  Files         3287     3288       +1     
  Lines       111684   111688       +4     
  Branches     20409    20415       +6     
===========================================
+ Hits         75258    75288      +30     
+ Misses       33738    33716      -22     
+ Partials      2688     2684       -4     
Flag Coverage Δ
e2e 57.30% <100.00%> (+0.02%) ⬆️
unit 71.44% <ø> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lucas-a-pelegrino lucas-a-pelegrino marked this pull request as ready for review October 8, 2025 20:28
@lucas-a-pelegrino lucas-a-pelegrino requested a review from a team as a code owner October 8, 2025 20:28
@lucas-a-pelegrino lucas-a-pelegrino added the stat: QA assured Means it has been tested and approved by a company insider label Oct 9, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Oct 9, 2025
@kodiakhq kodiakhq bot merged commit c8f1354 into develop Oct 10, 2025
80 of 83 checks passed
@kodiakhq kodiakhq bot deleted the chore/v7/CORE-1406 branch October 10, 2025 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants