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 <sojan@pepalo.com>
This commit is contained in:
Sivin Varghese
2024-07-23 16:41:11 +05:30
committed by GitHub
parent 10ee773aac
commit 79aa5a5d7f
163 changed files with 868 additions and 850 deletions

View File

@@ -1,13 +1,13 @@
<template>
<div
class="flex flex-col bg-woot-25 min-h-full w-full py-12 sm:px-6 lg:px-8 justify-center dark:bg-slate-900"
class="flex flex-col justify-center w-full min-h-full py-12 bg-woot-25 sm:px-6 lg:px-8 dark:bg-slate-900"
>
<form
class="sm:mx-auto sm:w-full sm:max-w-lg bg-white dark:bg-slate-800 p-11 shadow sm:shadow-lg sm:rounded-lg"
class="bg-white shadow sm:mx-auto sm:w-full sm:max-w-lg dark:bg-slate-800 p-11 sm:shadow-lg sm:rounded-lg"
@submit.prevent="submitForm"
>
<h1
class="mb-1 text-left text-2xl font-medium tracking-tight text-slate-900 dark:text-white"
class="mb-1 text-2xl font-medium tracking-tight text-left text-slate-900 dark:text-white"
>
{{ $t('SET_NEW_PASSWORD.TITLE') }}
</h1>
@@ -49,18 +49,17 @@
<script>
import { required, minLength } from 'vuelidate/lib/validators';
import { useAlert } from 'dashboard/composables';
import FormInput from '../../../components/Form/Input.vue';
import SubmitButton from '../../../components/Button/SubmitButton.vue';
import { DEFAULT_REDIRECT_URL } from 'dashboard/constants/globals';
import { setNewPassword } from '../../../api/auth';
import alertMixin from 'shared/mixins/alertMixin';
export default {
components: {
FormInput,
SubmitButton,
},
mixins: [alertMixin],
props: {
resetPasswordToken: { type: String, default: '' },
redirectUrl: { type: String, default: '' },
@@ -110,7 +109,7 @@ export default {
showAlertMessage(message) {
// Reset loading, current selected agent
this.newPasswordAPI.showLoading = false;
this.showAlert(message);
useAlert(message);
},
submitForm() {
this.newPasswordAPI.showLoading = true;

View File

@@ -47,17 +47,17 @@
</template>
<script>
import { mapGetters } from 'vuex';
import { useAlert } from 'dashboard/composables';
import { required, minLength, email } from 'vuelidate/lib/validators';
import globalConfigMixin from 'shared/mixins/globalConfigMixin';
import { mapGetters } from 'vuex';
import FormInput from '../../../../components/Form/Input.vue';
import { resetPassword } from '../../../../api/auth';
import SubmitButton from '../../../../components/Button/SubmitButton.vue';
import alertMixin from 'shared/mixins/alertMixin';
export default {
components: { FormInput, SubmitButton },
mixins: [globalConfigMixin, alertMixin],
mixins: [globalConfigMixin],
data() {
return {
credentials: { email: '' },
@@ -84,7 +84,7 @@ export default {
showAlertMessage(message) {
// Reset loading, current selected agent
this.resetPassword.showLoading = false;
this.showAlert(message);
useAlert(message);
},
submit() {
this.resetPassword.showLoading = true;

View File

@@ -1,5 +1,5 @@
<template>
<div class="flex-1 overflow-auto px-1">
<div class="flex-1 px-1 overflow-auto">
<form class="space-y-3" @submit.prevent="submit">
<div class="flex">
<form-input
@@ -81,8 +81,8 @@
<script>
import { required, minLength, email } from 'vuelidate/lib/validators';
import { mapGetters } from 'vuex';
import { useAlert } from 'dashboard/composables';
import globalConfigMixin from 'shared/mixins/globalConfigMixin';
import alertMixin from 'shared/mixins/alertMixin';
import { DEFAULT_REDIRECT_URL } from 'dashboard/constants/globals';
import VueHcaptcha from '@hcaptcha/vue-hcaptcha';
import FormInput from '../../../../../components/Form/Input.vue';
@@ -99,7 +99,7 @@ export default {
SubmitButton,
VueHcaptcha,
},
mixins: [globalConfigMixin, alertMixin],
mixins: [globalConfigMixin],
data() {
return {
credentials: {
@@ -186,7 +186,7 @@ export default {
let errorMessage =
error?.message || this.$t('REGISTER.API.ERROR_MESSAGE');
this.resetCaptcha();
this.showAlert(errorMessage);
useAlert(errorMessage);
} finally {
this.isSignupInProgress = false;
}

View File

@@ -91,6 +91,7 @@
</template>
<script>
import { useAlert } from 'dashboard/composables';
import { required, email } from 'vuelidate/lib/validators';
import globalConfigMixin from 'shared/mixins/globalConfigMixin';
import SubmitButton from '../../components/Button/SubmitButton.vue';
@@ -104,7 +105,6 @@ const ERROR_MESSAGES = {
'no-account-found': 'LOGIN.OAUTH.NO_ACCOUNT_FOUND',
'business-account-only': 'LOGIN.OAUTH.BUSINESS_ACCOUNTS_ONLY',
};
import alertMixin from 'shared/mixins/alertMixin';
export default {
components: {
@@ -113,7 +113,7 @@ export default {
Spinner,
SubmitButton,
},
mixins: [globalConfigMixin, alertMixin],
mixins: [globalConfigMixin],
props: {
ssoAuthToken: { type: String, default: '' },
ssoAccountId: { type: String, default: '' },
@@ -164,7 +164,7 @@ export default {
}
if (this.authError) {
const message = ERROR_MESSAGES[this.authError] ?? 'LOGIN.API.UNAUTH';
this.showAlert(this.$t(message));
useAlert(this.$t(message));
// wait for idle state
this.requestIdleCallbackPolyfill(() => {
// Remove the error query param from the url
@@ -191,7 +191,7 @@ export default {
// Reset loading, current selected agent
this.loginApi.showLoading = false;
this.loginApi.message = message;
this.showAlert(this.loginApi.message);
useAlert(this.loginApi.message);
},
submitLogin() {
if (this.$v.credentials.email.$invalid && !this.email) {