From 79aa5a5d7fef54f074463c86f98548cec9158fe0 Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Tue, 23 Jul 2024 16:41:11 +0530 Subject: [PATCH] feat: Replace `alertMixin` usage with `useAlert` (#9793) # Pull Request Template ## Description This PR will replace the usage of `alertMixin` from the code base with the `useAlert` composable. Fixes https://linear.app/chatwoot/issue/CW-3462/replace-alertmixin-usage-with-usealert ## Type of change - [x] Breaking change (fix or feature that would cause existing functionality not to work as expected) ## How Has This Been Tested? Please refer this issue description https://linear.app/chatwoot/issue/CW-3462/replace-alertmixin-usage-with-usealert ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [ ] 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 --------- Co-authored-by: Sojan Jose --- .../dashboard/components/ChatList.vue | 31 ++++++----- app/javascript/dashboard/components/Code.vue | 5 +- .../dashboard/components/MaskedText.vue | 5 +- .../components/SnackbarContainer.vue | 4 +- .../components/app/PaymentPendingBanner.vue | 12 +++-- .../app/PendingEmailVerificationBanner.vue | 6 +-- .../dashboard/components/app/UpdateBanner.vue | 9 +++- .../components/app/UpgradeBanner.vue | 3 +- .../components/buttons/ResolveAction.vue | 6 +-- .../components/layout/AvailabilityStatus.vue | 13 ++--- .../dashboard/components/layout/Sidebar.vue | 4 +- .../sidebarComponents/AddAccountModal.vue | 9 ++-- .../sidebarComponents/SecondaryNavItem.vue | 11 ++-- .../components/widgets/AIAssistanceButton.vue | 12 +++-- .../components/widgets/AICTAModal.vue | 8 +-- .../widgets/AutomationFileInput.vue | 5 +- .../components/widgets/LabelSelector.vue | 11 +++- .../components/widgets/VideoCallButton.vue | 5 +- .../widgets/WootWriter/AudioRecorder.vue | 11 ++-- .../components/widgets/WootWriter/Editor.vue | 10 ++-- .../widgets/WootWriter/FullEditor.vue | 14 ++--- .../ConversationAdvancedFilter.vue | 6 +-- .../widgets/conversation/ConversationCard.vue | 4 +- .../conversation/EmailTranscriptModal.vue | 11 ++-- .../conversation/EmptyState/EmptyState.vue | 10 +++- .../widgets/conversation/Message.vue | 3 +- .../widgets/conversation/MoreActions.vue | 9 ++-- .../widgets/conversation/ReplyBox.vue | 7 ++- .../widgets/conversation/bubble/Contact.vue | 11 ++-- .../conversation/bubble/integrations/Dyte.vue | 5 +- .../conversation/specs/MoreActions.spec.js | 19 ++++--- app/javascript/dashboard/composables/index.js | 15 ++++-- .../dashboard/composables/spec/index.spec.js | 51 ++++++++++++++++++ .../composables/spec/useAdmin.spec.js | 52 +++++++++++++++++++ .../dashboard/composables/useAdmin.js | 17 ++++++ app/javascript/dashboard/helper/pushHelper.js | 12 ++--- app/javascript/dashboard/mixins/aiMixin.js | 5 +- .../mixins/automations/methodsMixin.js | 5 +- .../dashboard/mixins/fileUploadMixin.js | 7 +-- app/javascript/dashboard/mixins/isAdmin.js | 12 ----- .../mixins/specs/fileUploadMixin.spec.js | 13 +++-- .../dashboard/mixins/specs/isAdmin.spec.js | 28 ---------- .../modules/contact/ContactMergeModal.vue | 9 ++-- .../contact/components/AddCustomAttribute.vue | 4 +- .../contact/components/MergeContact.vue | 6 +-- .../components/MessageContextMenu.vue | 12 ++--- .../routes/dashboard/commands/commandbar.vue | 2 - .../dashboard/commands/goToCommandHotKeys.js | 7 +++ .../contacts/components/ContactLabels.vue | 5 +- .../components/ContactsAdvancedFilters.vue | 6 +-- .../contacts/components/ContactsView.vue | 9 ++-- .../dashboard/contacts/components/Header.vue | 9 +++- .../contacts/components/ImportContacts.vue | 15 +++--- .../dashboard/conversation/ContactPanel.vue | 3 +- .../conversation/ConversationAction.vue | 10 ++-- .../conversation/ConversationParticipant.vue | 6 +-- .../conversation/ConversationView.vue | 8 +-- .../conversation/Macros/MacroItem.vue | 9 ++-- .../conversation/contact/ContactForm.vue | 21 +++----- .../conversation/contact/ContactInfo.vue | 18 ++++--- .../conversation/contact/ContactInfoRow.vue | 19 ++++--- .../conversation/contact/ConversationForm.vue | 27 +++++----- .../customAttributes/CustomAttributes.vue | 14 ++--- .../conversation/labels/LabelBox.vue | 11 ++-- .../dashboard/customviews/AddCustomViews.vue | 5 +- .../customviews/DeleteCustomViews.vue | 7 ++- .../helpcenter/components/AddLocale.vue | 9 ++-- .../ArticleSearch/ArticleSearchResultItem.vue | 11 ++-- .../ArticleSearch/SearchPopover.vue | 10 ++-- .../components/Header/EditArticleHeader.vue | 5 +- .../helpcenter/components/PortalListItem.vue | 34 ++++++------ .../helpcenter/pages/articles/EditArticle.vue | 16 +++--- .../helpcenter/pages/articles/NewArticle.vue | 10 ++-- .../pages/categories/AddCategory.vue | 9 ++-- .../pages/categories/EditCategory.vue | 9 ++-- .../pages/portals/ListAllPortals.vue | 10 ++-- .../pages/portals/PortalDetails.vue | 5 +- .../routes/dashboard/inbox/InboxList.vue | 14 ++--- .../inbox/components/InboxItemHeader.vue | 9 ++-- .../inbox/components/InboxListHeader.vue | 21 ++++---- .../dashboard/settings/SettingsHeader.vue | 15 ++++-- .../dashboard/settings/account/Index.vue | 10 ++-- .../dashboard/settings/agentBots/Index.vue | 13 +++-- .../settings/agentBots/csml/Edit.vue | 11 ++-- .../dashboard/settings/agentBots/csml/New.vue | 11 ++-- .../dashboard/settings/agents/AddAgent.vue | 7 ++- .../dashboard/settings/agents/EditAgent.vue | 15 +++--- .../dashboard/settings/agents/Index.vue | 10 ++-- .../settings/attributes/AddAttribute.vue | 9 ++-- .../settings/attributes/CustomAttribute.vue | 11 ++-- .../settings/attributes/EditAttribute.vue | 10 ++-- .../dashboard/settings/auditlogs/Index.vue | 9 ++-- .../settings/automation/AddAutomationRule.vue | 9 ++-- .../automation/EditAutomationRule.vue | 9 ++-- .../dashboard/settings/automation/Index.vue | 21 ++++---- .../dashboard/settings/billing/Index.vue | 5 +- .../settings/campaigns/AddCampaign.vue | 10 ++-- .../dashboard/settings/campaigns/Campaign.vue | 8 +-- .../settings/campaigns/EditCampaign.vue | 14 ++--- .../dashboard/settings/canned/AddCanned.vue | 11 ++-- .../dashboard/settings/canned/EditCanned.vue | 11 ++-- .../dashboard/settings/canned/Index.vue | 7 ++- .../dashboard/settings/inbox/AddAgents.vue | 7 ++- .../dashboard/settings/inbox/ImapSettings.vue | 7 ++- .../routes/dashboard/settings/inbox/Index.vue | 20 ++++--- .../settings/inbox/PreChatForm/Settings.vue | 15 +++--- .../dashboard/settings/inbox/Settings.vue | 14 +++-- .../dashboard/settings/inbox/SmtpSettings.vue | 7 ++- .../settings/inbox/WidgetBuilder.vue | 11 ++-- .../inbox/channels/360DialogWhatsapp.vue | 5 +- .../dashboard/settings/inbox/channels/Api.vue | 7 ++- .../settings/inbox/channels/BandwidthSms.vue | 5 +- .../settings/inbox/channels/CloudWhatsapp.vue | 5 +- .../settings/inbox/channels/Facebook.vue | 12 ++--- .../settings/inbox/channels/Line.vue | 9 ++-- .../settings/inbox/channels/Telegram.vue | 7 ++- .../settings/inbox/channels/Twilio.vue | 5 +- .../settings/inbox/channels/Twitter.vue | 5 +- .../settings/inbox/channels/Website.vue | 9 ++-- .../emailChannels/ForwardToOption.vue | 7 ++- .../inbox/components/BotConfiguration.vue | 13 +++-- .../inbox/components/WeeklyAvailability.vue | 10 ++-- .../settings/inbox/facebook/Reauthorize.vue | 19 +++---- .../inbox/settingsPage/CollaboratorsPage.vue | 12 ++--- .../inbox/settingsPage/ConfigurationPage.vue | 12 ++--- .../integrationapps/IntegrationHooks.vue | 6 +-- .../settings/integrationapps/NewHook.vue | 6 +-- .../DashboardApps/DashboardAppModal.vue | 7 ++- .../integrations/DashboardApps/Index.vue | 14 ++--- .../settings/integrations/Integration.vue | 10 ++-- .../Slack/SelectChannelWarning.vue | 20 ++++--- .../integrations/Webhooks/EditWebHook.vue | 7 ++- .../settings/integrations/Webhooks/Index.vue | 8 +-- .../integrations/Webhooks/NewWebHook.vue | 8 +-- .../dashboard/settings/labels/AddLabel.vue | 7 ++- .../dashboard/settings/labels/EditLabel.vue | 7 ++- .../dashboard/settings/labels/Index.vue | 11 ++-- .../dashboard/settings/macros/Index.vue | 8 +-- .../dashboard/settings/macros/MacroEditor.vue | 10 ++-- .../settings/profile/AudioNotifications.vue | 10 ++-- .../settings/profile/ChangePassword.vue | 7 ++- .../dashboard/settings/profile/Index.vue | 16 +++--- .../profile/NotificationPreferences.vue | 14 ++--- .../settings/profile/UserBasicDetails.vue | 5 +- .../dashboard/settings/reports/BotReports.vue | 7 +-- .../settings/reports/CsatResponses.vue | 11 ++-- .../dashboard/settings/reports/Index.vue | 10 ++-- .../dashboard/settings/reports/SLAReports.vue | 5 +- .../reports/components/WootReports.vue | 5 +- .../routes/dashboard/settings/sla/AddSLA.vue | 7 ++- .../routes/dashboard/settings/sla/Index.vue | 8 +-- .../settings/teams/Create/AddAgents.vue | 7 ++- .../settings/teams/Create/CreateTeam.vue | 5 +- .../settings/teams/Edit/EditAgents.vue | 9 ++-- .../settings/teams/Edit/EditTeam.vue | 9 ++-- .../routes/dashboard/settings/teams/Index.vue | 20 ++++--- app/javascript/shared/mixins/alertMixin.js | 9 ---- app/javascript/survey/views/Response.vue | 19 +++---- .../v3/components/SnackBar/Container.vue | 2 +- .../v3/views/auth/password/Edit.vue | 11 ++-- .../v3/views/auth/reset/password/Index.vue | 8 +-- .../auth/signup/components/Signup/Form.vue | 8 +-- app/javascript/v3/views/login/Index.vue | 8 +-- 163 files changed, 868 insertions(+), 850 deletions(-) create mode 100644 app/javascript/dashboard/composables/spec/index.spec.js create mode 100644 app/javascript/dashboard/composables/spec/useAdmin.spec.js create mode 100644 app/javascript/dashboard/composables/useAdmin.js delete mode 100644 app/javascript/dashboard/mixins/isAdmin.js delete mode 100644 app/javascript/dashboard/mixins/specs/isAdmin.spec.js delete mode 100644 app/javascript/shared/mixins/alertMixin.js diff --git a/app/javascript/dashboard/components/ChatList.vue b/app/javascript/dashboard/components/ChatList.vue index b25ca4bbb..fc6ac302a 100644 --- a/app/javascript/dashboard/components/ChatList.vue +++ b/app/javascript/dashboard/components/ChatList.vue @@ -116,6 +116,7 @@