Skip to content

Conversation

lucas-a-pelegrino
Copy link
Member

@lucas-a-pelegrino lucas-a-pelegrino commented Sep 24, 2025

Proposed changes (including videos or screenshots)

This PR adds a deprecation warning for removeCannedResponse meteor method, as well as it updates useRemoveCannedResponse to use corresponding endpoint.

Issue(s)

CTZ-72

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Refactor

    • Streamlined canned response deletion: unified delete UI with a dedicated Remove button and updated edit flow.
    • API now deletes canned responses by ID in the URL: DELETE /v1/canned-responses/:_id (path-based deletion).
  • Deprecation

    • Legacy removeCannedResponse method emits a deprecation warning; switch to the new REST endpoint.
  • Chores

    • Patch version bump.

@lucas-a-pelegrino lucas-a-pelegrino added this to the 7.12.0 milestone Sep 24, 2025
Copy link
Contributor

dionisio-bot bot commented Sep 24, 2025

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

  • This PR is missing the 'stat: QA assured' label
  • 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

Copy link

changeset-bot bot commented Sep 24, 2025

🦋 Changeset detected

Latest commit: f71fbf4

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

This PR includes changesets to release 40 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/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service 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

Copy link

coderabbitai bot commented Sep 24, 2025

Walkthrough

Moves canned-response deletion from a body-based Meteor method to a RESTful DELETE /v1/canned-responses/:_id endpoint; refactors client to use a new useRemoveCannedResponse(id) hook, adds RemoveCannedResponseButton, wires onDelete props through edit components, logs deprecation for the old method, and updates E2E tests.

Changes

Cohort / File(s) Summary
Client edit components
apps/meteor/client/omnichannel/cannedResponses/CannedResponseEdit.tsx, apps/meteor/client/omnichannel/cannedResponses/CannedResponseEditWithData.tsx, apps/meteor/client/omnichannel/cannedResponses/CannedResponseEditWithDepartmentData.tsx
CannedResponseEdit now accepts an optional onDelete?: () => void prop and no longer uses an internal delete hook; parent components obtain a delete handler from useRemoveCannedResponse(id) and pass it down.
Client table action
apps/meteor/client/omnichannel/cannedResponses/CannedResponsesTable.tsx
Replaces inline IconButton delete cell with a RemoveCannedResponseButton component, removing prior inline delete handler wiring.
New button component
apps/meteor/client/omnichannel/cannedResponses/RemoveCannedResponseButton.tsx
Adds RemoveCannedResponseButton (default export) that uses useRemoveCannedResponse(id) and invokes the delete handler on click, stopping event propagation.
Client deletion hook
apps/meteor/client/omnichannel/cannedResponses/useRemoveCannedResponse.tsx
Introduces useRemoveCannedResponse(id: IOmnichannelCannedResponse['_id']), switches to useEndpoint for DELETE /v1/canned-responses/:_id, and preserves modal/ toast/ cache invalidation/ navigation side effects; handler no longer expects an id argument.
Server API (EE)
apps/meteor/ee/app/api-enterprise/server/canned-responses.ts
Removes DELETE from /v1/canned-responses (body-based); adds DELETE to /v1/canned-responses/:_id with appropriate permissions/validation and a handler that calls removeCannedResponse(this.userId, _id).
Server method deprecation
apps/meteor/ee/app/canned-responses/server/methods/removeCannedResponse.ts
Adds a methodDeprecationLogger.method('removeCannedResponse', '8.0.0', 'DELETE /v1/canned-responses/:_id') call to log deprecation when the old Meteor method is invoked.
E2E tests
apps/meteor/tests/end-to-end/api/livechat/15-canned-responses.ts
Updates DELETE tests to call DELETE /v1/canned-responses/:_id (path param) instead of sending _id in the body; adjusts expected statuses (e.g., 404 for missing resource).
Changeset
.changeset/late-papayas-swim.md
Adds a patch changeset noting a deprecation warning on removeCannedResponse.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant UI as Client UI (Edit/Table)
  participant Hook as useRemoveCannedResponse(id)
  participant API as DELETE /v1/canned-responses/:_id
  participant S as Server Handler
  participant Store as Client Cache / Router

  U->>UI: Click "Delete"
  UI->>Hook: onDelete()
  Note right of Hook #DDEBF7: confirm modal shown, then proceed
  Hook->>API: DELETE /v1/canned-responses/:_id
  API->>S: validate auth & permissions
  S-->>API: 200 success
  API-->>Hook: success
  Hook->>Store: invalidate getCannedResponses, show toast, navigate list
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • ggazzo
  • dougfabris
  • sampaiodiego

Poem

I nibble paths and hop along the trail,
From body to URL the IDs set sail.
Hooks drum a beat, a button gives a tap,
Old method whispers—soon a gentle nap.
Tests hop by, approval in my tail. 🐇

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 clearly indicates that a deprecation warning was added to the removeCannedResponse method, which aligns with the primary intent of marking that API call as deprecated; it is concise, specific, and free of extraneous details.
Linked Issues Check ✅ Passed The pull request adds a deprecation logger to the removeCannedResponse Meteor method and updates the useRemoveCannedResponse hook and related UI components to call the new REST endpoint, and it updates server routes and tests accordingly, fully addressing the CTZ-72 objective.
Out of Scope Changes Check ✅ Passed All modifications in the pull request relate to deprecating the removeCannedResponse method and migrating deletion functionality to the new REST endpoint, with corresponding updates to hooks, components, server routes, and tests; there are no unrelated or out-of-scope changes.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/v7/CTZ-72

📜 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 4abfe98 and f71fbf4.

📒 Files selected for processing (3)
  • apps/meteor/client/omnichannel/cannedResponses/CannedResponseEditWithData.tsx (2 hunks)
  • apps/meteor/client/omnichannel/cannedResponses/CannedResponseEditWithDepartmentData.tsx (2 hunks)
  • apps/meteor/ee/app/canned-responses/server/methods/removeCannedResponse.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/meteor/client/omnichannel/cannedResponses/CannedResponseEditWithDepartmentData.tsx
  • apps/meteor/client/omnichannel/cannedResponses/CannedResponseEditWithData.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: 🔨 Test Storybook / Test Storybook
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 🔎 Code Check / TypeScript
  • GitHub Check: 📦 Meteor Build - coverage
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (1)
apps/meteor/ee/app/canned-responses/server/methods/removeCannedResponse.ts (1)

40-40: Deprecation notice now points to the correct replacement

Glad to see the guidance updated to the per-id DELETE endpoint; this will steer consumers to the right API.


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.

Copy link

codecov bot commented Sep 24, 2025

Codecov Report

❌ Patch coverage is 23.52941% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.35%. Comparing base (3b2905b) to head (f71fbf4).
⚠️ Report is 11 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #37051      +/-   ##
===========================================
+ Coverage    67.31%   67.35%   +0.03%     
===========================================
  Files         3337     3327      -10     
  Lines       113294   113224      -70     
  Branches     20562    20574      +12     
===========================================
- Hits         76266    76262       -4     
+ Misses       34422    34355      -67     
- Partials      2606     2607       +1     
Flag Coverage Δ
e2e 57.25% <23.52%> (+0.22%) ⬆️
unit 71.13% <ø> (-0.03%) ⬇️

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 September 25, 2025 21:00
@lucas-a-pelegrino lucas-a-pelegrino requested review from a team as code owners September 25, 2025 21:00
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (4)
apps/meteor/client/omnichannel/cannedResponses/useRemoveCannedResponse.tsx (1)

21-26: Also invalidate the detail query to prevent stale caches

When deleting from the edit view, invalidate the per-id cache too.

       await removeCannedResponse();
       queryClient.invalidateQueries({
         queryKey: ['getCannedResponses'],
       });
+      queryClient.invalidateQueries({
+        queryKey: ['getCannedResponseById', id],
+      });
       router.navigate('/omnichannel/canned-responses');
       dispatchToastMessage({ type: 'success', message: t('Canned_Response_Removed') });
apps/meteor/tests/end-to-end/api/livechat/15-canned-responses.ts (1)

255-258: Rename test to reflect path-based 404

The title references body param; now it’s 404 due to missing path param.

-it('should fail if _id is not on the request', async () => {
+it('should 404 when DELETE /canned-responses has no :_id path parameter', async () => {
   await updatePermission('remove-canned-responses', ['livechat-agent', 'livechat-monitor', 'livechat-manager', 'admin']);
   return request.delete(api('canned-responses')).set(credentials).expect(404);
 });
apps/meteor/client/omnichannel/cannedResponses/RemoveCannedResponseButton.tsx (1)

15-23: Add aria-label for accessibility

Provide an explicit accessible name for the icon button.

-      <IconButton
+      <IconButton
         icon='trash'
         small
+        aria-label={t('Remove')}
         title={t('Remove')}
         onClick={(e) => {
           e.stopPropagation();
           handleDelete();
         }}
       />
apps/meteor/client/omnichannel/cannedResponses/CannedResponseEdit.tsx (1)

81-86: Guard Delete button rendering when onDelete is not provided

Prevents a runtime error if a caller omits onDelete.

-        {cannedResponseData?._id && (
+        {cannedResponseData?._id && onDelete && (
           <ButtonGroup>
             <Button danger onClick={onDelete}>
               {t('Delete')}
             </Button>
           </ButtonGroup>
         )}
📜 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 65b57cc and 4abfe98.

📒 Files selected for processing (10)
  • .changeset/late-papayas-swim.md (1 hunks)
  • apps/meteor/client/omnichannel/cannedResponses/CannedResponseEdit.tsx (3 hunks)
  • apps/meteor/client/omnichannel/cannedResponses/CannedResponseEditWithData.tsx (2 hunks)
  • apps/meteor/client/omnichannel/cannedResponses/CannedResponseEditWithDepartmentData.tsx (2 hunks)
  • apps/meteor/client/omnichannel/cannedResponses/CannedResponsesTable.tsx (2 hunks)
  • apps/meteor/client/omnichannel/cannedResponses/RemoveCannedResponseButton.tsx (1 hunks)
  • apps/meteor/client/omnichannel/cannedResponses/useRemoveCannedResponse.tsx (1 hunks)
  • apps/meteor/ee/app/api-enterprise/server/canned-responses.ts (5 hunks)
  • apps/meteor/ee/app/canned-responses/server/methods/removeCannedResponse.ts (2 hunks)
  • apps/meteor/tests/end-to-end/api/livechat/15-canned-responses.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (7)
apps/meteor/client/omnichannel/cannedResponses/RemoveCannedResponseButton.tsx (1)
apps/meteor/client/omnichannel/cannedResponses/useRemoveCannedResponse.tsx (1)
  • useRemoveCannedResponse (8-45)
apps/meteor/client/omnichannel/cannedResponses/CannedResponseEdit.tsx (1)
packages/livechat/src/components/Button/index.tsx (1)
  • Button (34-99)
apps/meteor/tests/end-to-end/api/livechat/15-canned-responses.ts (2)
apps/meteor/tests/data/api-data.ts (2)
  • request (10-10)
  • credentials (39-42)
apps/meteor/tests/data/livechat/canned-responses.ts (1)
  • createCannedResponse (7-25)
apps/meteor/client/omnichannel/cannedResponses/useRemoveCannedResponse.tsx (1)
packages/ui-contexts/src/index.ts (1)
  • useEndpoint (32-32)
apps/meteor/client/omnichannel/cannedResponses/CannedResponseEditWithData.tsx (2)
packages/ui-contexts/src/index.ts (1)
  • useEndpoint (32-32)
apps/meteor/client/omnichannel/cannedResponses/useRemoveCannedResponse.tsx (1)
  • useRemoveCannedResponse (8-45)
apps/meteor/client/omnichannel/cannedResponses/CannedResponseEditWithDepartmentData.tsx (1)
apps/meteor/client/omnichannel/cannedResponses/useRemoveCannedResponse.tsx (1)
  • useRemoveCannedResponse (8-45)
apps/meteor/ee/app/api-enterprise/server/canned-responses.ts (1)
packages/rest-typings/src/v1/omnichannel.ts (2)
  • isPOSTCannedResponsesProps (2883-2883)
  • isCannedResponsesProps (998-998)
🔇 Additional comments (7)
.changeset/late-papayas-swim.md (1)

1-5: Changelog entry looks good.

Patch bump and deprecation note are captured clearly.

apps/meteor/client/omnichannel/cannedResponses/useRemoveCannedResponse.tsx (1)

15-15: LGTM: using DELETE /v1/canned-responses/:_id

Endpoint binding with path params is correct.

apps/meteor/client/omnichannel/cannedResponses/CannedResponsesTable.tsx (1)

171-171: LGTM: centralized delete via RemoveCannedResponseButton

Good consolidation and event propagation stop handled in the button.

apps/meteor/tests/end-to-end/api/livechat/15-canned-responses.ts (2)

253-253: LGTM: unauthorized delete now targets path-based endpoint

403 expectation remains correct.


262-265: LGTM: switched to DELETE /canned-responses/:_id

Matches new API contract and keeps response assertions intact.

apps/meteor/client/omnichannel/cannedResponses/CannedResponseEditWithData.tsx (1)

39-39: LGTM: delegate delete via onDelete

Wires the new hook through props cleanly.

apps/meteor/ee/app/api-enterprise/server/canned-responses.ts (1)

112-135: LGTM!

Splitting the permissions per verb and moving the delete handler onto the id-scoped route aligns with the updated endpoint contract without introducing regressions.

@dougfabris dougfabris requested a review from a team September 25, 2025 21:19
Copy link
Member

@dougfabris dougfabris left a comment

Choose a reason for hiding this comment

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

LGTM!

);
return API.v1.success();
},
async delete() {
Copy link
Member

Choose a reason for hiding this comment

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

you cannot remove this, it would be a breaking change.. what you could do is also deprecate this one in favor of the new one you created.. but I'd recommend you just leave this one here and use it even though it doesn't follow any standards :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants