mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
# Pull Request Template ## Changes * Remove unused component `MaskedText.vue` * Remove unused component `ContactIntro.vue` * Remove unused `AddCustomViews.vue` component * Update buttons in help center upgrade page <img width="741" alt="image" src="https://github.com/user-attachments/assets/f46b8ffa-ef74-4b83-95c1-83842844c4b7" /> * Update SLA view details button in reports page <img width="419" alt="image" src="https://github.com/user-attachments/assets/7db6bff6-9ba5-4c13-850f-b9d4dbb55489" /> * Update assign to me conversation action button <img width="152" alt="image" src="https://github.com/user-attachments/assets/587ee1fe-93c9-48e0-910a-390dd4eac1f2" /> * Update button in participants action <img width="365" alt="image" src="https://github.com/user-attachments/assets/50eb386f-882b-4277-ad61-d557893ac490" /> <img width="365" alt="image" src="https://github.com/user-attachments/assets/3c64ed42-0203-43c6-9a26-8ad9465aa394" /> * Update the show more attributes button <img width="365" alt="image" src="https://github.com/user-attachments/assets/f2105a2f-8441-4d8b-b355-dfe97ce2e362" /> * Update SLA empty state <img width="376" alt="image" src="https://github.com/user-attachments/assets/55fd4376-6183-45c9-acb2-6ad5a6a58730" /> * Update create new label button from dropdown <img width="376" alt="image" src="https://github.com/user-attachments/assets/bb8226d0-795f-431f-8fe4-15d15ee1d695" /> * Update add macro button <img width="382" alt="image" src="https://github.com/user-attachments/assets/b6375402-5213-4041-841b-09c2157ed56a" /> * Update copy button <img width="382" alt="image" src="https://github.com/user-attachments/assets/f1929d63-f7ca-4eab-bfa8-716be2aa4be8" /> * Update the buttons in banner component <img width="849" alt="image" src="https://github.com/user-attachments/assets/bb86b498-ab8e-4a92-8c6a-60edcef0fd7b" /> <img width="838" alt="image" src="https://github.com/user-attachments/assets/4bde00de-907e-49ac-9128-f364a90cd3c1" /> * Update table pagination buttons <img width="968" alt="image" src="https://github.com/user-attachments/assets/8d439af6-8126-4fad-a3fe-89b26a56f880" /> <img width="968" alt="image" src="https://github.com/user-attachments/assets/a178b3d7-3385-4a2b-a0d7-35be9a25fd93" /> * Update filter chip buttons and dropdown colors <img width="541" alt="image" src="https://github.com/user-attachments/assets/7be1f418-82df-4db6-b265-4c185fc79f4b" /> <img width="541" alt="image" src="https://github.com/user-attachments/assets/69110d75-85e9-4974-8c2a-e195b23a335c" /> <img width="173" alt="image" src="https://github.com/user-attachments/assets/c8f5bc82-15b4-4f25-b7d4-35a9280ec7c6" /> <img width="565" alt="image" src="https://github.com/user-attachments/assets/7dad1d00-784b-46eb-b823-e6e55d5f9dc8" /> <img width="565" alt="image" src="https://github.com/user-attachments/assets/384a86ed-f45f-488c-b9aa-1f02b16c813d" /> --------- Co-authored-by: Pranav <pranav@chatwoot.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com> Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
285 lines
8.5 KiB
Vue
285 lines
8.5 KiB
Vue
<script>
|
|
import { mapGetters } from 'vuex';
|
|
import { useAdmin } from 'dashboard/composables/useAdmin';
|
|
import { useConfig } from 'dashboard/composables/useConfig';
|
|
import {
|
|
getInboxClassByType,
|
|
getInboxWarningIconClass,
|
|
} from 'dashboard/helper/inbox';
|
|
|
|
import SecondaryChildNavItem from './SecondaryChildNavItem.vue';
|
|
import {
|
|
isOnMentionsView,
|
|
isOnUnattendedView,
|
|
} from '../../../store/modules/conversations/helpers/actionHelpers';
|
|
import Policy from '../../policy.vue';
|
|
import NextButton from 'dashboard/components-next/button/Button.vue';
|
|
|
|
export default {
|
|
components: { SecondaryChildNavItem, Policy, NextButton },
|
|
props: {
|
|
menuItem: {
|
|
type: Object,
|
|
default: () => ({}),
|
|
},
|
|
},
|
|
emits: ['addLabel', 'open'],
|
|
setup() {
|
|
const { isAdmin } = useAdmin();
|
|
const { isEnterprise } = useConfig();
|
|
return {
|
|
isAdmin,
|
|
isEnterprise,
|
|
};
|
|
},
|
|
computed: {
|
|
...mapGetters({
|
|
activeInbox: 'getSelectedInbox',
|
|
accountId: 'getCurrentAccountId',
|
|
isFeatureEnabledonAccount: 'accounts/isFeatureEnabledonAccount',
|
|
globalConfig: 'globalConfig/get',
|
|
}),
|
|
isCountZero() {
|
|
return this.menuItem.count === 0;
|
|
},
|
|
isActiveView() {
|
|
return this.computedClass.includes('active-view');
|
|
},
|
|
hasSubMenu() {
|
|
return !!this.menuItem.children;
|
|
},
|
|
isMenuItemVisible() {
|
|
if (this.menuItem.globalConfigFlag) {
|
|
// this checks for the `csmlEditorHost` flag in the global config
|
|
// if this is present, we toggle the CSML editor menu item
|
|
// TODO: This is very specific, and can be handled better, fix it
|
|
return !!this.globalConfig[this.menuItem.globalConfigFlag];
|
|
}
|
|
|
|
let isFeatureEnabled = true;
|
|
if (this.menuItem.featureFlag) {
|
|
isFeatureEnabled = this.isFeatureEnabledonAccount(
|
|
this.accountId,
|
|
this.menuItem.featureFlag
|
|
);
|
|
}
|
|
|
|
if (this.menuItem.isEnterpriseOnly) {
|
|
if (!this.isEnterprise) return false;
|
|
return isFeatureEnabled || this.globalConfig.displayManifest;
|
|
}
|
|
|
|
if (this.menuItem.featureFlag) {
|
|
return this.isFeatureEnabledonAccount(
|
|
this.accountId,
|
|
this.menuItem.featureFlag
|
|
);
|
|
}
|
|
|
|
return isFeatureEnabled;
|
|
},
|
|
isAllConversations() {
|
|
return (
|
|
this.$store.state.route.name === 'inbox_conversation' &&
|
|
this.menuItem.toStateName === 'home'
|
|
);
|
|
},
|
|
isMentions() {
|
|
return (
|
|
isOnMentionsView({ route: this.$route }) &&
|
|
this.menuItem.toStateName === 'conversation_mentions'
|
|
);
|
|
},
|
|
isUnattended() {
|
|
return (
|
|
isOnUnattendedView({ route: this.$route }) &&
|
|
this.menuItem.toStateName === 'conversation_unattended'
|
|
);
|
|
},
|
|
isTeamsSettings() {
|
|
return (
|
|
this.$store.state.route.name === 'settings_teams_edit' &&
|
|
this.menuItem.toStateName === 'settings_teams_list'
|
|
);
|
|
},
|
|
isInboxSettings() {
|
|
return (
|
|
this.$route.name === 'settings_inbox_show' &&
|
|
this.menuItem.toStateName === 'settings_inbox_list'
|
|
);
|
|
},
|
|
isIntegrationsSettings() {
|
|
return (
|
|
this.$store.state.route.name === 'settings_integrations_webhook' &&
|
|
this.menuItem.toStateName === 'settings_integrations'
|
|
);
|
|
},
|
|
isApplicationsSettings() {
|
|
return (
|
|
this.$store.state.route.name === 'settings_applications_integration' &&
|
|
this.menuItem.toStateName === 'settings_applications'
|
|
);
|
|
},
|
|
isContactsDefaultRoute() {
|
|
return (
|
|
this.menuItem.toStateName === 'contacts_dashboard_index' &&
|
|
(this.$store.state.route.name === 'contacts_dashboard_index' ||
|
|
this.$store.state.route.name === 'contacts_edit')
|
|
);
|
|
},
|
|
isCurrentRoute() {
|
|
return this.$store.state.route.name.includes(this.menuItem.toStateName);
|
|
},
|
|
|
|
computedClass() {
|
|
// If active inbox is present, do not highlight conversations
|
|
if (this.activeInbox) return ' ';
|
|
if (
|
|
this.isAllConversations ||
|
|
this.isMentions ||
|
|
this.isUnattended ||
|
|
this.isContactsDefaultRoute ||
|
|
this.isCurrentRoute
|
|
) {
|
|
return 'bg-woot-25 dark:bg-slate-800 text-woot-500 dark:text-woot-500 hover:text-woot-500 dark:hover:text-woot-500 active-view';
|
|
}
|
|
if (this.hasSubMenu) {
|
|
if (
|
|
this.isTeamsSettings ||
|
|
this.isInboxSettings ||
|
|
this.isIntegrationsSettings ||
|
|
this.isApplicationsSettings
|
|
) {
|
|
return 'bg-woot-25 dark:bg-slate-800 text-woot-500 dark:text-woot-500 hover:text-woot-500 dark:hover:text-woot-500 active-view';
|
|
}
|
|
return 'hover:text-slate-700 dark:hover:text-slate-100';
|
|
}
|
|
|
|
return 'hover:text-slate-700 dark:hover:text-slate-100';
|
|
},
|
|
},
|
|
methods: {
|
|
computedInboxClass(child) {
|
|
const { type, phoneNumber } = child;
|
|
if (!type) return '';
|
|
const classByType = getInboxClassByType(type, phoneNumber);
|
|
return classByType;
|
|
},
|
|
computedInboxErrorClass(child) {
|
|
const { type, reauthorizationRequired } = child;
|
|
if (!type) return '';
|
|
const warningClass = getInboxWarningIconClass(
|
|
type,
|
|
reauthorizationRequired
|
|
);
|
|
return warningClass;
|
|
},
|
|
newLinkClick(e, navigate) {
|
|
if (this.menuItem.newLinkRouteName) {
|
|
navigate(e);
|
|
} else if (this.menuItem.showModalForNewItem) {
|
|
if (this.menuItem.modalName === 'AddLabel') {
|
|
e.preventDefault();
|
|
this.$emit('addLabel');
|
|
}
|
|
}
|
|
},
|
|
showItem(item) {
|
|
return this.isAdmin && !!item.newLink;
|
|
},
|
|
onClickOpen() {
|
|
this.$emit('open');
|
|
},
|
|
showChildCount(count) {
|
|
return Number.isInteger(count);
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<li v-show="isMenuItemVisible" class="mt-1">
|
|
<div v-if="hasSubMenu" class="flex justify-between">
|
|
<span
|
|
class="px-2 pt-1 my-2 text-sm font-semibold text-slate-700 dark:text-slate-200"
|
|
>
|
|
{{ $t(`SIDEBAR.${menuItem.label}`) }}
|
|
</span>
|
|
<div v-if="menuItem.showNewButton" class="flex items-center">
|
|
<NextButton ghost xs slate icon="i-lucide-plus" @click="onClickOpen" />
|
|
</div>
|
|
</div>
|
|
<router-link
|
|
v-else
|
|
class="flex items-center p-2 m-0 text-sm leading-4 rounded-lg text-slate-700 dark:text-slate-100 hover:bg-slate-25 dark:hover:bg-slate-800"
|
|
:class="computedClass"
|
|
:to="menuItem && menuItem.toState"
|
|
>
|
|
<fluent-icon
|
|
:icon="menuItem.icon"
|
|
class="min-w-[1rem] mr-1.5 rtl:mr-0 rtl:ml-1.5"
|
|
size="14"
|
|
/>
|
|
{{ $t(`SIDEBAR.${menuItem.label}`) }}
|
|
<span
|
|
v-if="showChildCount(menuItem.count)"
|
|
class="px-1 py-0 mx-1 rounded-md text-xxs"
|
|
:class="{
|
|
'text-slate-300 dark:text-slate-600': isCountZero && !isActiveView,
|
|
'text-slate-600 dark:text-slate-50': !isCountZero && !isActiveView,
|
|
'bg-woot-75 dark:bg-woot-200 text-woot-600 dark:text-woot-600':
|
|
isActiveView,
|
|
'bg-slate-50 dark:bg-slate-700': !isActiveView,
|
|
}"
|
|
>
|
|
{{ `${menuItem.count}` }}
|
|
</span>
|
|
<span
|
|
v-if="menuItem.beta"
|
|
data-view-component="true"
|
|
label="Beta"
|
|
class="inline-block px-1 mx-1 leading-4 text-green-500 border border-green-400 rounded-lg text-xxs"
|
|
>
|
|
{{ $t('SIDEBAR.BETA') }}
|
|
</span>
|
|
</router-link>
|
|
|
|
<ul v-if="hasSubMenu" class="list-none reset-base">
|
|
<SecondaryChildNavItem
|
|
v-for="child in menuItem.children"
|
|
:key="child.id"
|
|
:to="child.toState"
|
|
:label="child.label"
|
|
:label-color="child.color"
|
|
:should-truncate="child.truncateLabel"
|
|
:icon="computedInboxClass(child)"
|
|
:warning-icon="computedInboxErrorClass(child)"
|
|
:show-child-count="showChildCount(child.count)"
|
|
:child-item-count="child.count"
|
|
/>
|
|
<Policy :permissions="['administrator']">
|
|
<router-link
|
|
v-if="menuItem.newLink"
|
|
v-slot="{ href, navigate }"
|
|
:to="menuItem.toState"
|
|
custom
|
|
>
|
|
<li class="pl-1">
|
|
<a :href="href">
|
|
<NextButton
|
|
ghost
|
|
xs
|
|
slate
|
|
icon="i-lucide-plus"
|
|
:label="$t(`SIDEBAR.${menuItem.newLinkTag}`)"
|
|
:data-testid="menuItem.dataTestid"
|
|
@click="e => newLinkClick(e, navigate)"
|
|
/>
|
|
</a>
|
|
</li>
|
|
</router-link>
|
|
</Policy>
|
|
</ul>
|
|
</li>
|
|
</template>
|