mirror of
https://github.com/lingble/chatwoot.git
synced 2025-12-27 08:05:00 +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>
133 lines
3.3 KiB
Vue
133 lines
3.3 KiB
Vue
<script>
|
|
import messageFormatterMixin from 'shared/mixins/messageFormatterMixin';
|
|
import Thumbnail from 'dashboard/components/widgets/Thumbnail.vue';
|
|
import configMixin from '../mixins/configMixin';
|
|
import { isEmptyObject } from 'widget/helpers/utils';
|
|
import {
|
|
ON_CAMPAIGN_MESSAGE_CLICK,
|
|
ON_UNREAD_MESSAGE_CLICK,
|
|
} from '../constants/widgetBusEvents';
|
|
import darkModeMixin from 'widget/mixins/darkModeMixin';
|
|
export default {
|
|
name: 'UnreadMessage',
|
|
components: { Thumbnail },
|
|
mixins: [messageFormatterMixin, configMixin, darkModeMixin],
|
|
props: {
|
|
message: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
showSender: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
sender: {
|
|
type: Object,
|
|
default: () => {},
|
|
},
|
|
campaignId: {
|
|
type: Number,
|
|
default: null,
|
|
},
|
|
},
|
|
computed: {
|
|
companyName() {
|
|
return `${this.$t('UNREAD_VIEW.COMPANY_FROM')} ${
|
|
this.channelConfig.websiteName
|
|
}`;
|
|
},
|
|
avatarUrl() {
|
|
// eslint-disable-next-line
|
|
const BotImage = require('dashboard/assets/images/chatwoot_bot.png');
|
|
const displayImage = this.useInboxAvatarForBot
|
|
? this.inboxAvatarUrl
|
|
: BotImage;
|
|
if (this.isSenderExist(this.sender)) {
|
|
const { avatar_url: avatarUrl } = this.sender;
|
|
return avatarUrl;
|
|
}
|
|
return displayImage;
|
|
},
|
|
agentName() {
|
|
if (this.isSenderExist(this.sender)) {
|
|
const { available_name: availableName } = this.sender;
|
|
return availableName;
|
|
}
|
|
if (this.useInboxAvatarForBot) {
|
|
return this.channelConfig.websiteName;
|
|
}
|
|
return this.$t('UNREAD_VIEW.BOT');
|
|
},
|
|
availabilityStatus() {
|
|
if (this.isSenderExist(this.sender)) {
|
|
const { availability_status: availabilityStatus } = this.sender;
|
|
return availabilityStatus;
|
|
}
|
|
return null;
|
|
},
|
|
},
|
|
methods: {
|
|
isSenderExist(sender) {
|
|
return sender && !isEmptyObject(sender);
|
|
},
|
|
onClickMessage() {
|
|
if (this.campaignId) {
|
|
this.$emitter.emit(ON_CAMPAIGN_MESSAGE_CLICK, this.campaignId);
|
|
} else {
|
|
this.$emitter.emit(ON_UNREAD_MESSAGE_CLICK);
|
|
}
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<div class="chat-bubble-wrap">
|
|
<button
|
|
class="chat-bubble agent"
|
|
:class="$dm('bg-white', 'dark:bg-slate-50')"
|
|
@click="onClickMessage"
|
|
>
|
|
<div v-if="showSender" class="row--agent-block">
|
|
<Thumbnail
|
|
:src="avatarUrl"
|
|
size="20px"
|
|
:username="agentName"
|
|
:status="availabilityStatus"
|
|
/>
|
|
<span v-dompurify-html="agentName" class="agent--name" />
|
|
<span v-dompurify-html="companyName" class="company--name" />
|
|
</div>
|
|
<div
|
|
v-dompurify-html="formatMessage(message, false)"
|
|
class="message-content"
|
|
/>
|
|
</button>
|
|
</div>
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
@import '~widget/assets/scss/variables.scss';
|
|
.chat-bubble {
|
|
max-width: 85%;
|
|
padding: $space-normal;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.row--agent-block {
|
|
align-items: center;
|
|
display: flex;
|
|
text-align: left;
|
|
padding-bottom: $space-small;
|
|
font-size: $font-size-small;
|
|
.agent--name {
|
|
font-weight: $font-weight-medium;
|
|
margin-left: $space-smaller;
|
|
}
|
|
.company--name {
|
|
color: $color-light-gray;
|
|
margin-left: $space-smaller;
|
|
}
|
|
}
|
|
</style>
|