From c63a6ed8ec040b779bef5bcfe21fe812bcfa5315 Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Thu, 22 Aug 2024 13:02:11 +0530 Subject: [PATCH] feat: Rewrite `agentMixin` to a helper (#9940) # Pull Request Template ## Description This PR will replace the usage of `agentMixin`with the utility helpers functions. **Files updated** 1. dashboard/components/widgets/conversation/contextMenu/Index.vue 2. dashboard/components/widgets/conversation/ConversationHeader.vue **(Not used)** 3. dashboard/routes/dashboard/commands/commandbar.vue 4. dashboard/routes/dashboard/conversation/ConversationAction.vue 5. dashboard/routes/dashboard/conversation/ConversationParticipant.vue Fixes https://linear.app/chatwoot/issue/CW-3442/rewrite-agentmixin-mixin-to-a-composable ## Type of change - [x] New feature (non-breaking change which adds functionality) ## How Has This Been Tested? **Test cases** 1. See agent list sorting based on availability, if agents are on the same status, then sorted by name. 2. Test actions like assigning/unassigning agent from conversation sidebar, CMD bar, Context menu. 3. Test actions like adding/removing participants from conversation sidebar. 4. See agent list is generated properly, none value. ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules --- .../conversation/ConversationHeader.vue | 3 +- .../conversation/contextMenu/Index.vue | 18 +- .../spec/fixtures/agentFixtures.js | 63 +++++ .../composables/spec/useAgentsList.spec.js | 91 +++++++ .../dashboard/composables/useAgentsList.js | 57 ++++ .../dashboard/helper/agentHelper.js | 83 ++++++ .../helper/specs/agentHelper.spec.js | 131 ++++++++++ .../helper/specs/fixtures/agentFixtures.js | 184 +++++++++++++ app/javascript/dashboard/mixins/agentMixin.js | 69 ----- .../dashboard/mixins/specs/agentFixtures.js | 246 ------------------ .../dashboard/mixins/specs/agentMixin.spec.js | 140 ---------- .../routes/dashboard/commands/commandbar.vue | 7 +- .../conversation/ConversationAction.vue | 16 +- .../conversation/ConversationParticipant.vue | 17 +- 14 files changed, 643 insertions(+), 482 deletions(-) create mode 100644 app/javascript/dashboard/composables/spec/fixtures/agentFixtures.js create mode 100644 app/javascript/dashboard/composables/spec/useAgentsList.spec.js create mode 100644 app/javascript/dashboard/composables/useAgentsList.js create mode 100644 app/javascript/dashboard/helper/agentHelper.js create mode 100644 app/javascript/dashboard/helper/specs/agentHelper.spec.js create mode 100644 app/javascript/dashboard/helper/specs/fixtures/agentFixtures.js delete mode 100644 app/javascript/dashboard/mixins/agentMixin.js delete mode 100644 app/javascript/dashboard/mixins/specs/agentFixtures.js delete mode 100644 app/javascript/dashboard/mixins/specs/agentMixin.spec.js diff --git a/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue b/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue index 428e5549f..8bfc1d314 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue @@ -2,7 +2,6 @@ import { ref } from 'vue'; import { mapGetters } from 'vuex'; import { useKeyboardEvents } from 'dashboard/composables/useKeyboardEvents'; -import agentMixin from '../../../mixins/agentMixin.js'; import BackButton from '../BackButton.vue'; import inboxMixin from 'shared/mixins/inboxMixin'; import InboxName from '../InboxName.vue'; @@ -24,7 +23,7 @@ export default { SLACardLabel, Linear, }, - mixins: [inboxMixin, agentMixin], + mixins: [inboxMixin], props: { chat: { type: Object, diff --git a/app/javascript/dashboard/components/widgets/conversation/contextMenu/Index.vue b/app/javascript/dashboard/components/widgets/conversation/contextMenu/Index.vue index fc9ec29fe..90c14e450 100644 --- a/app/javascript/dashboard/components/widgets/conversation/contextMenu/Index.vue +++ b/app/javascript/dashboard/components/widgets/conversation/contextMenu/Index.vue @@ -1,9 +1,12 @@