mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 20:18:08 +00:00
# Pull Request Template ## Description This PR adds new eslint rules to the code base. **Error rules** | Rule name | Type | Files updated | | ----------------- | --- | - | | `vue/block-order` | error | ✅ | | `vue/component-name-in-template-casing` | error | ✅ | | `vue/component-options-name-casing` | error | ✅ | | `vue/custom-event-name-casing` | error | ✅ | | `vue/define-emits-declaration` | error | ✅ | | `vue/no-unused-properties` | error | ✅ | | `vue/define-macros-order` | error | ✅ | | `vue/define-props-declaration` | error | ✅ | | `vue/match-component-import-name` | error | ✅ | | `vue/next-tick-style` | error | ✅ | | `vue/no-bare-strings-in-template` | error | ✅ | | `vue/no-empty-component-block` | error | ✅ | | `vue/no-multiple-objects-in-class` | error | ✅ | | `vue/no-required-prop-with-default` | error | ✅ | | `vue/no-static-inline-styles` | error | ✅ | | `vue/no-template-target-blank` | error | ✅ | | `vue/no-this-in-before-route-enter` | error | ✅ | | `vue/no-undef-components` | error | ✅ | | `vue/no-unused-emit-declarations` | error | ✅ | | `vue/no-unused-refs` | error | ✅ | | `vue/no-use-v-else-with-v-for` | error | ✅ | | `vue/no-useless-v-bind` | error | ✅ | | `vue/no-v-text` | error | ✅ | | `vue/padding-line-between-blocks` | error | ✅ | | ~`vue/prefer-prop-type-boolean-first`~ | ~error~ | ❌ (removed this rule, cause a bug in displaying custom attributes) | | `vue/prefer-separate-static-class` | error | ✅ | | `vue/prefer-true-attribute-shorthand` | error | ✅ | | `vue/require-explicit-slots` | error | ✅ | | `vue/require-macro-variable-name` | error | ✅ | **Warn rules** | Rule name | Type | Files updated | | ---- | ------------- | ------------- | | `vue/no-root-v-if` | warn | ❎ | Fixes https://linear.app/chatwoot/issue/CW-3492/vue-eslint-rules ## Type of change - [x] New feature (non-breaking change which adds functionality) ## 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 --------- Co-authored-by: Fayaz Ahmed <fayazara@gmail.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com> Co-authored-by: Shivam Mishra <scm.mymail@gmail.com> Co-authored-by: Pranav <pranav@chatwoot.com>
151 lines
4.4 KiB
Vue
151 lines
4.4 KiB
Vue
<script>
|
|
import { mapGetters } from 'vuex';
|
|
import router from '../dashboard/routes';
|
|
import AddAccountModal from '../dashboard/components/layout/sidebarComponents/AddAccountModal.vue';
|
|
import LoadingState from './components/widgets/LoadingState.vue';
|
|
import NetworkNotification from './components/NetworkNotification.vue';
|
|
import UpdateBanner from './components/app/UpdateBanner.vue';
|
|
import UpgradeBanner from './components/app/UpgradeBanner.vue';
|
|
import PaymentPendingBanner from './components/app/PaymentPendingBanner.vue';
|
|
import PendingEmailVerificationBanner from './components/app/PendingEmailVerificationBanner.vue';
|
|
import vueActionCable from './helper/actionCable';
|
|
import WootSnackbarBox from './components/SnackbarContainer.vue';
|
|
import rtlMixin from 'shared/mixins/rtlMixin';
|
|
import { setColorTheme } from './helper/themeHelper';
|
|
import { isOnOnboardingView } from 'v3/helpers/RouteHelper';
|
|
import {
|
|
registerSubscription,
|
|
verifyServiceWorkerExistence,
|
|
} from './helper/pushHelper';
|
|
import ReconnectService from 'dashboard/helper/ReconnectService';
|
|
|
|
export default {
|
|
name: 'App',
|
|
|
|
components: {
|
|
AddAccountModal,
|
|
LoadingState,
|
|
NetworkNotification,
|
|
UpdateBanner,
|
|
PaymentPendingBanner,
|
|
WootSnackbarBox,
|
|
UpgradeBanner,
|
|
PendingEmailVerificationBanner,
|
|
},
|
|
|
|
mixins: [rtlMixin],
|
|
|
|
data() {
|
|
return {
|
|
showAddAccountModal: false,
|
|
latestChatwootVersion: null,
|
|
reconnectService: null,
|
|
};
|
|
},
|
|
|
|
computed: {
|
|
...mapGetters({
|
|
getAccount: 'accounts/getAccount',
|
|
currentUser: 'getCurrentUser',
|
|
authUIFlags: 'getAuthUIFlags',
|
|
accountUIFlags: 'accounts/getUIFlags',
|
|
currentAccountId: 'getCurrentAccountId',
|
|
}),
|
|
hasAccounts() {
|
|
const { accounts = [] } = this.currentUser || {};
|
|
return accounts.length > 0;
|
|
},
|
|
hideOnOnboardingView() {
|
|
return !isOnOnboardingView(this.$route);
|
|
},
|
|
},
|
|
|
|
watch: {
|
|
currentUser() {
|
|
if (!this.hasAccounts) {
|
|
this.showAddAccountModal = true;
|
|
}
|
|
},
|
|
currentAccountId() {
|
|
if (this.currentAccountId) {
|
|
this.initializeAccount();
|
|
}
|
|
},
|
|
},
|
|
mounted() {
|
|
this.initializeColorTheme();
|
|
this.listenToThemeChanges();
|
|
this.setLocale(window.chatwootConfig.selectedLocale);
|
|
},
|
|
beforeDestroy() {
|
|
if (this.reconnectService) {
|
|
this.reconnectService.disconnect();
|
|
}
|
|
},
|
|
methods: {
|
|
initializeColorTheme() {
|
|
setColorTheme(window.matchMedia('(prefers-color-scheme: dark)').matches);
|
|
},
|
|
listenToThemeChanges() {
|
|
const mql = window.matchMedia('(prefers-color-scheme: dark)');
|
|
mql.onchange = e => setColorTheme(e.matches);
|
|
},
|
|
setLocale(locale) {
|
|
this.$root.$i18n.locale = locale;
|
|
},
|
|
async initializeAccount() {
|
|
await this.$store.dispatch('accounts/get');
|
|
this.$store.dispatch('setActiveAccount', {
|
|
accountId: this.currentAccountId,
|
|
});
|
|
const { locale, latest_chatwoot_version: latestChatwootVersion } =
|
|
this.getAccount(this.currentAccountId);
|
|
const { pubsub_token: pubsubToken } = this.currentUser || {};
|
|
this.setLocale(locale);
|
|
this.updateRTLDirectionView(locale);
|
|
this.latestChatwootVersion = latestChatwootVersion;
|
|
vueActionCable.init(pubsubToken);
|
|
this.reconnectService = new ReconnectService(this.$store, router);
|
|
|
|
verifyServiceWorkerExistence(registration =>
|
|
registration.pushManager.getSubscription().then(subscription => {
|
|
if (subscription) {
|
|
registerSubscription();
|
|
}
|
|
})
|
|
);
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<div
|
|
v-if="!authUIFlags.isFetching && !accountUIFlags.isFetchingItem"
|
|
id="app"
|
|
class="flex-grow-0 w-full h-full min-h-0 app-wrapper"
|
|
:class="{ 'app-rtl--wrapper': isRTLView }"
|
|
:dir="isRTLView ? 'rtl' : 'ltr'"
|
|
>
|
|
<UpdateBanner :latest-chatwoot-version="latestChatwootVersion" />
|
|
<template v-if="currentAccountId">
|
|
<PendingEmailVerificationBanner v-if="hideOnOnboardingView" />
|
|
<PaymentPendingBanner v-if="hideOnOnboardingView" />
|
|
<UpgradeBanner />
|
|
</template>
|
|
<transition name="fade" mode="out-in">
|
|
<router-view />
|
|
</transition>
|
|
<AddAccountModal :show="showAddAccountModal" :has-accounts="hasAccounts" />
|
|
<WootSnackbarBox />
|
|
<NetworkNotification />
|
|
</div>
|
|
<LoadingState v-else />
|
|
</template>
|
|
|
|
<style lang="scss">
|
|
@import './assets/scss/app';
|
|
</style>
|
|
|
|
<style src="vue-multiselect/dist/vue-multiselect.min.css"></style>
|