Skip to content

Comments

feat: Allow managing association to business units on departments' creation and update#32682

Merged
kodiakhq[bot] merged 34 commits intodevelopfrom
improve/monitors-manage-departments-units
Sep 18, 2024
Merged

feat: Allow managing association to business units on departments' creation and update#32682
kodiakhq[bot] merged 34 commits intodevelopfrom
improve/monitors-manage-departments-units

Conversation

@matheusbsilva137
Copy link
Contributor

@matheusbsilva137 matheusbsilva137 commented Jun 27, 2024

Proposed changes (including videos or screenshots)

  • Added a new optional departmentUnit object param to livechat:saveDepartment Meteor method, livechat/department (POST) endpoint and livechat/department (PUT) endpoint;
    • Providing an empty object ({}) to this param removes the department from its associated unit (or just doesn't add the department to any unit, if provided on the creation of a new department). Providing { _id: undefined } or null triggers the same effect;
    • If no value is provided to this new param, then the association between the department and its unit (if it exists) won't be changed, nor created or removed;
    • When providing a string _id field in the object ({ _id: "unit-id" }), the department will be associated to the unit with the specified _id IF the user has the permission to do so.
  • In order to use any of the updated endpoints, the user must have the manage-livechat-departments permission (this is already the current behavior), but there are additional conditions to associate a department with a specific unit when the new param is provided:
    • If the user is a monitor (role livechat-monitor), then they must be a supervisor of the specified unit. That is, they must be linked (as monitor) to the specified unit in order to add or remove departments from it;
    • If the user is not a monitor (such as an admin or livechat-manager), any unit can be associated to the department (on creation or update).
  • Providing any value different from a string to the _id field to the new param's object will trigger an error.
  • This is an additional/non-blocking operation. No errors are thrown (yet) even if the user tries to add a department to a unit they don't have the permission to manage.

Issue(s)

Steps to test or reproduce

Example request to the livechat:saveDepartment method (the new param is the last one that should be provided -- {\"_id\":\"unit-id\"} in the example):

curl --request POST \
  --url http://localhost:3000/api/v1/method.call/livechat%3AsaveDepartment \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'X-Auth-Token: f4U57vG-drmhd8hZbKAT_9TTJqW48Y_VB1zle6HWiRf' \
  --header 'X-User-Id: WM8KyWfu6qXDCRZrq' \
  --data '{"message":"{\"msg\":\"method\",\"id\":\"15\",\"method\":\"livechat:saveDepartment\",\"params\":[null,{\"enabled\":false,\"name\":\"My new department5\",\"description\":\"\",\"showOnRegistration\":false,\"showOnOfflineForm\":false,\"requestTagBeforeClosingChat\":false,\"email\":\"my-new-testdep5@example.com\",\"chatClosingTags\":[],\"offlineMessageChannelName\":\"\",\"abandonedRoomsCloseCustomMessage\":\"\",\"waitingQueueMessage\":\"\",\"departmentsAllowedToForward\":[],\"fallbackForwardDepartment\":\"\",\"allowReceiveForwardOffline\":false},[],{\"_id\":\"unit-id\"}]}"}'

The command above triggers the creation of a new department associated with the unit with id unit-id. Change the first null param to a valid department string to edit it.

Example request to the livechat/department POST endpoint (check the new departmentUnit param):

curl --request POST \
  --url http://localhost:3000/api/v1/livechat/department \
  --header 'X-Auth-Token: f4U57vG-drmhd8hZbKAT_9TTJqW48Y_VB1zle6HWiRf' \
  --header 'X-User-Id: WM8KyWfu6qXDCRZrq' \
  --data '{
  "department": {
    "name": "Test23456",
    "enabled": true,
    "showOnOfflineForm": true,
    "showOnRegistration": true,
    "email": "bla@bla"
  },
  "departmentUnit": { "_id": "unit-id" }
}'

Example request to the livechat/department/:id PUT endpoint (check the new departmentUnit param -- providing an empty object to it will remove the department from its associated unit):

curl --request PUT \
  --url http://localhost:3000/api/v1/livechat/department/666cc15cd32e4e47b82332fd \
  --header 'X-Auth-Token: f4U57vG-drmhd8hZbKAT_9TTJqW48Y_VB1zle6HWiRf' \
  --header 'X-User-Id: WM8KyWfu6qXDCRZrq' \
  --data '{
  "department": {
    "name": "Test23456",
    "enabled": true,
    "showOnOfflineForm": true,
    "showOnRegistration": true,
    "email": "bla@bla"
  },
  "departmentUnit": {}
}'

Further comments

SUP-613

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jun 27, 2024

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Jun 27, 2024

🦋 Changeset detected

Latest commit: e625cb2

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

This PR includes changesets to release 32 packages
Name Type
@rocket.chat/meteor Minor
@rocket.chat/model-typings Minor
@rocket.chat/rest-typings Minor
@rocket.chat/apps Patch
@rocket.chat/models 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/omnichannel-services Patch
rocketchat-services Patch
@rocket.chat/api-client Patch
@rocket.chat/core-services Patch
@rocket.chat/ddp-client Patch
@rocket.chat/ui-contexts Major
@rocket.chat/presence Patch
@rocket.chat/cron Patch
@rocket.chat/instance-status Patch
@rocket.chat/livechat Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/fuselage-ui-kit Major
@rocket.chat/gazzodown Major
@rocket.chat/ui-avatar Major
@rocket.chat/ui-client Major
@rocket.chat/ui-video-conf Major
@rocket.chat/web-ui-registration Major
@rocket.chat/core-typings Minor
@rocket.chat/license Patch
@rocket.chat/pdf-worker 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

@codecov
Copy link

codecov bot commented Jun 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.84%. Comparing base (4202d65) to head (e625cb2).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #32682      +/-   ##
===========================================
+ Coverage    59.74%   59.84%   +0.09%     
===========================================
  Files         2552     2554       +2     
  Lines        62869    63020     +151     
  Branches     14123    14133      +10     
===========================================
+ Hits         37562    37713     +151     
  Misses       22900    22900              
  Partials      2407     2407              
Flag Coverage Δ
unit 77.14% <100.00%> (+0.18%) ⬆️

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

@matheusbsilva137 matheusbsilva137 added this to the 6.11 milestone Jun 27, 2024
@matheusbsilva137 matheusbsilva137 marked this pull request as ready for review June 27, 2024 20:50
@matheusbsilva137 matheusbsilva137 requested review from a team as code owners June 27, 2024 20:50
@matheusbsilva137 matheusbsilva137 changed the title feat: Allow monitors to manage departments in units they supervise feat: Allow managing association to business units on departments' creation and update Jun 27, 2024
@kodiakhq kodiakhq bot removed the stat: ready to merge PR tested and approved waiting for merge label Aug 8, 2024
@kodiakhq
Copy link
Contributor

kodiakhq bot commented Aug 8, 2024

This PR currently has a merge conflict. Please resolve this and then re-add the ['stat: ready to merge', 'automerge'] label.

@KevLehman KevLehman added the stat: ready to merge PR tested and approved waiting for merge label Aug 16, 2024
@scuciatto scuciatto modified the milestones: 6.12, 6.13 Aug 23, 2024
@dionisio-bot dionisio-bot bot removed the stat: ready to merge PR tested and approved waiting for merge label Sep 16, 2024
@github-actions
Copy link
Contributor

github-actions bot commented Sep 16, 2024

PR Preview Action v1.4.8
Preview removed because the pull request was closed.
2024-09-18 12:31 UTC

@scuciatto scuciatto added the stat: ready to merge PR tested and approved waiting for merge label Sep 18, 2024
@kodiakhq kodiakhq bot merged commit 9a38c8e into develop Sep 18, 2024
@kodiakhq kodiakhq bot deleted the improve/monitors-manage-departments-units branch September 18, 2024 12:31
KevLehman pushed a commit that referenced this pull request Sep 20, 2024
gabriellsh added a commit that referenced this pull request Sep 23, 2024
…hAvatarById

* 'develop' of github.com:RocketChat/Rocket.Chat:
  feat: Implement proper accessbility for report user modal (#33294)
  chore: update E2EE setting text (#33226)
  fix: conference calls are shown as "not answered" after they end (#33179)
  fix: markdown inconsistency with bold and italics (#33157)
  feat: E2EE messages mentions (#32510)
  refactor: Reactions set/unset (#32994)
  ci: auto candidate releases (#33325)
  feat: `RoomSidepanel` (#33225)
  feat: contextualbar based on chat size (#33321)
  fix: error on sendmessage stub (#33317)
  fix: `LivechatSessionTaken` webhook event called without `agent` param (#33209)
  refactor: Remove old `setreaction` callbacks and use new after/before callbacks (#33309)
  fix: Mark as unread not working (#32939)
  fix: Local avatars prioritized over external avatar provider and remove remnant references on client of `Accounts_AvatarExternalProviderUrl` (#33296)
  feat: Allow managing association to business units on departments' creation and update (#32682)
pierre-lehnen-rc added a commit that referenced this pull request Sep 26, 2024
* Bump 6.12.1

* fix: message parser being slow to process very long messages with too many symbols (#33254)

Co-authored-by: Pierre Lehnen <55164754+pierre-lehnen-rc@users.noreply.github.com>

* fix: Allow to use the token from `room.v` when requesting transcript instead of finding visitor (#33242)

Co-authored-by: Kevin Aleman <11577696+KevLehman@users.noreply.github.com>

* fix: Retention Policy cached settings not updated during upgrade procedure (#33265)

Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com>

* fix: imported fixes (#33268)

Co-authored-by: Julio A. <52619625+julio-cfa@users.noreply.github.com>

* Release 6.12.1

[no ci]

* fix: Federation callback not awaiting model call (#33298)

* fix: correct parameter order in afterSaveMessage to restore outgoing webhooks and related features (#33295)

* feat: New endpoint for listing rooms & discussions from teams (#33177)

* chore: Update typings on callbacks to accept less than a full room object (#33305)

* fix: resolve avatar download issue on setUsername by refining service selection logic (#33193)

* feat: Allow managing association to business units on departments' creation and update (#32682)

* fix: Local avatars prioritized over external avatar provider and remove remnant references on client of `Accounts_AvatarExternalProviderUrl` (#33296)

Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com>

* fix: Mark as unread not working (#32939)

Co-authored-by: Douglas Fabris <27704687+dougfabris@users.noreply.github.com>

* refactor: Remove old `setreaction` callbacks and use new after/before callbacks (#33309)

* fix: `LivechatSessionTaken` webhook event called without `agent` param (#33209)

* fix: error on sendmessage stub (#33317)

* feat: contextualbar based on chat size (#33321)

* feat: `RoomSidepanel` (#33225)

Co-authored-by: Guilherme Gazzo <5263975+ggazzo@users.noreply.github.com>

* ci: auto candidate releases (#33325)

Co-authored-by: Diego Sampaio <chinello@gmail.com>

* refactor: Reactions set/unset (#32994)

* feat: E2EE messages mentions (#32510)

* fix: markdown inconsistency with bold and italics (#33157)

* fix: conference calls are shown as "not answered" after they end (#33179)

* Release 6.13.0-rc.0

* chore: update E2EE setting text (#33226)

* feat: Implement proper accessbility for report user modal (#33294)

Co-authored-by: Tasso Evangelista <2263066+tassoevan@users.noreply.github.com>

* fix: imported fixes (#33330)

* chore: create network broker package (#33338)

* feat: Adds new admin feature preview setting management (#33212)

Co-authored-by: Guilherme Gazzo <guilhermegazzo@gmail.com>

* chore: move common files to core-services (#33341)

* regression: `Sidepanel` color highlight (#33342)

* feat: Adds new admin feature preview setting management (#33212)

Co-authored-by: Guilherme Gazzo <guilhermegazzo@gmail.com>

* fix: Avoid destructuring `connectionData` when value is undefined (#33339)

* Release 6.13.0-rc.1

[no ci]

* chore: replace Meteor._localStorage -> Accounts.storageLocation (#33356)

* Bump rocket.chat to 6.14.0-develop (#33366)

* ci: use node20 for release action (#33343)

---------

Co-authored-by: rocketchat-github-ci <buildmaster@rocket.chat>
Co-authored-by: dionisio-bot[bot] <117394943+dionisio-bot[bot]@users.noreply.github.com>
Co-authored-by: Pierre Lehnen <55164754+pierre-lehnen-rc@users.noreply.github.com>
Co-authored-by: Kevin Aleman <11577696+KevLehman@users.noreply.github.com>
Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com>
Co-authored-by: Julio A. <52619625+julio-cfa@users.noreply.github.com>
Co-authored-by: Guilherme Gazzo <guilhermegazzo@gmail.com>
Co-authored-by: Kevin Aleman <kaleman960@gmail.com>
Co-authored-by: Ricardo Garim <rswarovsky@gmail.com>
Co-authored-by: Matheus Barbosa Silva <36537004+matheusbsilva137@users.noreply.github.com>
Co-authored-by: Tasso Evangelista <tasso.evangelista@rocket.chat>
Co-authored-by: Martin Schoeler <martin.schoeler@rocket.chat>
Co-authored-by: Douglas Fabris <27704687+dougfabris@users.noreply.github.com>
Co-authored-by: Júlia Jaeger Foresti <60678893+juliajforesti@users.noreply.github.com>
Co-authored-by: Guilherme Gazzo <5263975+ggazzo@users.noreply.github.com>
Co-authored-by: Diego Sampaio <chinello@gmail.com>
Co-authored-by: Hugo Costa <hugocarreiracosta@gmail.com>
Co-authored-by: csuadev <72958726+csuadev@users.noreply.github.com>
Co-authored-by: Henrique Guimarães Ribeiro <43561537+rique223@users.noreply.github.com>
Co-authored-by: Tasso Evangelista <2263066+tassoevan@users.noreply.github.com>
Co-authored-by: Lucas Pelegrino <lucas.pelegrino@icloud.com>
Co-authored-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
abhinavkrin pushed a commit that referenced this pull request Oct 25, 2024
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.

5 participants