Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Replace eventBus with mitt.js [CW-3275] #9539

Merged
merged 12 commits into from
May 31, 2024
Merged

Conversation

fayazara
Copy link
Contributor

Replace the deprecated eventBus with mitt.js

Description

Since eventBus and it's respective methods are deprecated and removed from all future releases of vue, this was blocking us from migrating. This PR replaces eventBus with mitt. I have created a wrapper mitt.js to simulate the same old event names so it's backwards compatible, without making a lot of changes.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality not to work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  1. Made sure all the places we're listening to bus events are working as expected.
  2. Respective specsf or the events from mitt.

Checklist:

  • My code follows the style guidelines of this project
  • 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
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Refactor code to replace usages of the deprecated `bus.$emit` with the new `this.$emitter.emit` method for better event handling and consistency across the codebase.
Copy link

linear bot commented May 24, 2024

@fayazara fayazara marked this pull request as ready for review May 24, 2024 11:24
@fayazara fayazara requested review from scmmishra and muhsin-k May 24, 2024 11:25
@vishnu-narayanan vishnu-narayanan temporarily deployed to chatwoot-pr-9539 May 24, 2024 11:27 Inactive
Copy link
Member

@pranavrajs pranavrajs left a comment

Choose a reason for hiding this comment

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

Nice work. Can you please replace all the 'newToastMessage' with the alert mixin?

@fayazara
Copy link
Contributor Author

fayazara commented May 28, 2024

@scmmishra, @muhsin-k

I am replacing showing toasts with alertMixin instead of bus emits, however skipped these two files, added comments

  1. app/javascript/dashboard/components/ui/DatePicker/DatePicker.vue - Has Vue 3 script syntax

  2. app/javascript/v3/components/SnackBar/Container.vue - Ha

Copy link
Member

@scmmishra scmmishra left a comment

Choose a reason for hiding this comment

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

One tiny change, the rest is good to go.

@fayazara fayazara requested a review from scmmishra May 28, 2024 10:46
scmmishra
scmmishra previously approved these changes May 28, 2024
@scmmishra scmmishra dismissed their stale review May 30, 2024 04:56

Some issues with showAlert running in loops

Copy link
Member

@scmmishra scmmishra left a comment

Choose a reason for hiding this comment

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

@fayazara there are instances where we have potential infintie loops, where showAlert is already a function defined in the component, and then the mixin is added which calls showAlert again. PTAL

CleanShot 2024-05-30 at 10 26 50@2x

@fayazara
Copy link
Contributor Author

@scmmishra this was a really good catch. Some of these methods were doing more than just showing alerts, hence renamed them to showAlertMessage.

CleanShot 2024-05-31 at 00 32 36@2x

@fayazara fayazara requested review from scmmishra and pranavrajs May 30, 2024 19:04
@fayazara fayazara dismissed pranavrajs’s stale review May 31, 2024 10:20

Finished changes

@fayazara fayazara merged commit b474929 into develop May 31, 2024
14 of 16 checks passed
@fayazara fayazara deleted the feat-replace-event-bus branch May 31, 2024 10:20
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants