Chatwoot/app/javascript/dashboard/components/widgets/ChannelItem.vue

100 lines
2.2 KiB
Vue
Raw Normal View History

<template>
<div
class="small-6 medium-4 large-3 columns channel"
:class="{ inactive: !isActive }"
@click="onItemClick"
>
<img
v-if="channel.key === 'facebook'"
2021-10-05 09:05:32 +00:00
src="~dashboard/assets/images/channels/messenger.png"
/>
<img
v-if="channel.key === 'twitter'"
src="~dashboard/assets/images/channels/twitter.png"
/>
<img
v-if="channel.key === 'telegram'"
src="~dashboard/assets/images/channels/telegram.png"
/>
2020-07-21 06:45:24 +00:00
<img
v-if="channel.key === 'api' && !channel.thumbnail"
2020-07-21 06:45:24 +00:00
src="~dashboard/assets/images/channels/api.png"
/>
<img
v-if="channel.key === 'api' && channel.thumbnail"
:src="channel.thumbnail"
/>
2020-07-21 06:45:24 +00:00
<img
v-if="channel.key === 'email'"
2020-07-21 06:45:24 +00:00
src="~dashboard/assets/images/channels/email.png"
/>
<img
v-if="channel.key === 'line'"
src="~dashboard/assets/images/channels/line.png"
/>
<img
v-if="channel.key === 'website'"
src="~dashboard/assets/images/channels/website.png"
/>
<img
v-if="channel.key === 'sms'"
src="~dashboard/assets/images/channels/sms.png"
/>
<img
v-if="channel.key === 'whatsapp'"
src="~dashboard/assets/images/channels/whatsapp.png"
/>
<h3 class="channel__title">
{{ channel.name }}
</h3>
</div>
</template>
<script>
export default {
props: {
channel: {
type: Object,
required: true,
},
enabledFeatures: {
type: Object,
required: true,
},
},
computed: {
isActive() {
const { key } = this.channel;
2020-10-03 08:37:50 +00:00
if (Object.keys(this.enabledFeatures).length === 0) {
return false;
}
if (key === 'facebook') {
return this.enabledFeatures.channel_facebook;
}
if (key === 'twitter') {
return this.enabledFeatures.channel_twitter;
}
if (key === 'email') {
2020-07-21 06:45:24 +00:00
return this.enabledFeatures.channel_email;
}
return [
'website',
'twilio',
'api',
'whatsapp',
'sms',
'telegram',
'line',
].includes(key);
},
},
methods: {
onItemClick() {
if (this.isActive) {
this.$emit('channel-item-click', this.channel.key);
}
},
},
};
</script>