2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
|
|
|
<aside class="sidebar animated shrink columns">
|
|
|
|
<div class="logo">
|
2019-08-25 14:29:28 +00:00
|
|
|
<router-link :to="dashboardPath" replace>
|
2020-05-11 20:01:40 +00:00
|
|
|
<img :src="globalConfig.logo" :alt="globalConfig.installationName" />
|
2019-08-14 09:48:44 +00:00
|
|
|
</router-link>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="main-nav">
|
|
|
|
<transition-group name="menu-list" tag="ul" class="menu vertical">
|
|
|
|
<sidebar-item
|
2019-08-25 14:29:28 +00:00
|
|
|
v-for="item in accessibleMenuItems"
|
|
|
|
:key="item.toState"
|
2019-08-14 09:48:44 +00:00
|
|
|
:menu-item="item"
|
|
|
|
/>
|
2021-02-13 09:28:05 +00:00
|
|
|
<sidebar-item
|
|
|
|
v-if="shouldShowTeams"
|
|
|
|
:key="teamSection.toState"
|
|
|
|
:menu-item="teamSection"
|
|
|
|
/>
|
2019-12-28 16:26:42 +00:00
|
|
|
<sidebar-item
|
|
|
|
v-if="shouldShowInboxes"
|
|
|
|
:key="inboxSection.toState"
|
|
|
|
:menu-item="inboxSection"
|
|
|
|
/>
|
2020-06-25 15:34:03 +00:00
|
|
|
<sidebar-item
|
|
|
|
v-if="shouldShowInboxes"
|
|
|
|
:key="labelSection.toState"
|
|
|
|
:menu-item="labelSection"
|
|
|
|
/>
|
2019-08-14 09:48:44 +00:00
|
|
|
</transition-group>
|
|
|
|
</div>
|
2019-11-24 13:39:17 +00:00
|
|
|
|
2020-10-02 05:46:12 +00:00
|
|
|
<div class="bottom-nav">
|
|
|
|
<availability-status />
|
|
|
|
</div>
|
|
|
|
|
2021-02-08 11:08:35 +00:00
|
|
|
<div class="bottom-nav app-context-menu" @click="toggleOptions">
|
|
|
|
<agent-details @show-options="toggleOptions" />
|
|
|
|
<notification-bell />
|
|
|
|
<span class="current-user--options icon ion-android-more-vertical" />
|
|
|
|
<options-menu
|
|
|
|
:show="showOptionsMenu"
|
|
|
|
@toggle-accounts="toggleAccountModal"
|
|
|
|
@show-support-chat-window="toggleSupportChatWindow"
|
|
|
|
@close="toggleOptions"
|
2020-05-26 17:08:48 +00:00
|
|
|
/>
|
2021-02-08 11:08:35 +00:00
|
|
|
</div>
|
2020-07-26 07:24:50 +00:00
|
|
|
|
2021-02-08 11:08:35 +00:00
|
|
|
<account-selector
|
|
|
|
:show-account-modal="showAccountModal"
|
|
|
|
@close-account-modal="toggleAccountModal"
|
|
|
|
@show-create-account-modal="openCreateAccountModal"
|
|
|
|
/>
|
2020-07-26 07:24:50 +00:00
|
|
|
|
2021-02-08 11:08:35 +00:00
|
|
|
<add-account-modal
|
|
|
|
:show="showCreateAccountModal"
|
|
|
|
@close-account-create-modal="closeCreateAccountModal"
|
|
|
|
/>
|
2019-08-14 09:48:44 +00:00
|
|
|
</aside>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
|
|
|
|
import adminMixin from '../../mixins/isAdmin';
|
|
|
|
import SidebarItem from './SidebarItem';
|
2020-10-02 05:46:12 +00:00
|
|
|
import AvailabilityStatus from './AvailabilityStatus';
|
2019-08-25 14:29:28 +00:00
|
|
|
import { frontendURL } from '../../helper/URLHelper';
|
2020-05-26 17:08:48 +00:00
|
|
|
import { getSidebarItems } from '../../i18n/default-sidebar';
|
2020-07-26 07:24:50 +00:00
|
|
|
import alertMixin from 'shared/mixins/alertMixin';
|
2021-02-08 11:08:35 +00:00
|
|
|
import NotificationBell from './sidebarComponents/NotificationBell';
|
|
|
|
import AgentDetails from './sidebarComponents/AgentDetails.vue';
|
|
|
|
import OptionsMenu from './sidebarComponents/OptionsMenu.vue';
|
|
|
|
import AccountSelector from './sidebarComponents/AccountSelector.vue';
|
|
|
|
import AddAccountModal from './sidebarComponents/AddAccountModal.vue';
|
2019-08-25 14:29:28 +00:00
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
export default {
|
2019-12-28 16:26:42 +00:00
|
|
|
components: {
|
2021-02-08 11:08:35 +00:00
|
|
|
AgentDetails,
|
2019-12-28 16:26:42 +00:00
|
|
|
SidebarItem,
|
2020-10-02 05:46:12 +00:00
|
|
|
AvailabilityStatus,
|
2021-02-08 11:08:35 +00:00
|
|
|
NotificationBell,
|
|
|
|
OptionsMenu,
|
|
|
|
AccountSelector,
|
|
|
|
AddAccountModal,
|
2019-12-28 16:26:42 +00:00
|
|
|
},
|
2021-02-08 11:08:35 +00:00
|
|
|
mixins: [adminMixin, alertMixin],
|
2019-08-14 09:48:44 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
showOptionsMenu: false,
|
2020-05-26 17:08:48 +00:00
|
|
|
showAccountModal: false,
|
2020-07-26 07:24:50 +00:00
|
|
|
showCreateAccountModal: false,
|
2019-08-14 09:48:44 +00:00
|
|
|
};
|
|
|
|
},
|
2021-02-08 11:08:35 +00:00
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
2020-05-11 20:01:40 +00:00
|
|
|
currentUser: 'getCurrentUser',
|
|
|
|
globalConfig: 'globalConfig/get',
|
2019-12-28 16:26:42 +00:00
|
|
|
inboxes: 'inboxes/getInboxes',
|
2020-05-26 17:08:48 +00:00
|
|
|
accountId: 'getCurrentAccountId',
|
|
|
|
currentRole: 'getCurrentRole',
|
2020-06-25 15:34:03 +00:00
|
|
|
accountLabels: 'labels/getLabelsOnSidebar',
|
2021-02-13 09:28:05 +00:00
|
|
|
teams: 'teams/getMyTeams',
|
2019-08-14 09:48:44 +00:00
|
|
|
}),
|
2021-02-08 11:08:35 +00:00
|
|
|
|
2020-05-26 17:08:48 +00:00
|
|
|
sidemenuItems() {
|
|
|
|
return getSidebarItems(this.accountId);
|
|
|
|
},
|
2019-08-25 14:29:28 +00:00
|
|
|
accessibleMenuItems() {
|
2019-08-14 09:48:44 +00:00
|
|
|
// get all keys in menuGroup
|
2020-05-26 17:08:48 +00:00
|
|
|
const groupKey = Object.keys(this.sidemenuItems);
|
2019-08-25 14:29:28 +00:00
|
|
|
|
|
|
|
let menuItems = [];
|
2019-08-14 09:48:44 +00:00
|
|
|
// Iterate over menuGroup to find the correct group
|
|
|
|
for (let i = 0; i < groupKey.length; i += 1) {
|
2020-05-26 17:08:48 +00:00
|
|
|
const groupItem = this.sidemenuItems[groupKey[i]];
|
2019-08-14 09:48:44 +00:00
|
|
|
// Check if current route is included
|
2019-12-28 16:26:42 +00:00
|
|
|
const isRouteIncluded = groupItem.routes.includes(this.currentRoute);
|
2019-08-14 09:48:44 +00:00
|
|
|
if (isRouteIncluded) {
|
2019-08-25 14:29:28 +00:00
|
|
|
menuItems = Object.values(groupItem.menuItems);
|
2019-08-14 09:48:44 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-25 14:29:28 +00:00
|
|
|
|
2019-11-24 13:39:17 +00:00
|
|
|
return this.filterMenuItemsByRole(menuItems);
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2019-12-28 16:26:42 +00:00
|
|
|
currentRoute() {
|
|
|
|
return this.$store.state.route.name;
|
|
|
|
},
|
|
|
|
shouldShowInboxes() {
|
2020-05-26 17:08:48 +00:00
|
|
|
return this.sidemenuItems.common.routes.includes(this.currentRoute);
|
2019-12-28 16:26:42 +00:00
|
|
|
},
|
2021-02-13 09:28:05 +00:00
|
|
|
shouldShowTeams() {
|
|
|
|
return this.shouldShowInboxes && this.teams.length;
|
|
|
|
},
|
2019-12-28 16:26:42 +00:00
|
|
|
inboxSection() {
|
|
|
|
return {
|
|
|
|
icon: 'ion-folder',
|
2020-04-06 16:47:07 +00:00
|
|
|
label: 'INBOXES',
|
2019-12-28 16:26:42 +00:00
|
|
|
hasSubMenu: true,
|
|
|
|
newLink: true,
|
|
|
|
key: 'inbox',
|
|
|
|
cssClass: 'menu-title align-justify',
|
2020-03-09 17:57:10 +00:00
|
|
|
toState: frontendURL(`accounts/${this.accountId}/settings/inboxes`),
|
2019-12-28 16:26:42 +00:00
|
|
|
toStateName: 'settings_inbox_list',
|
|
|
|
children: this.inboxes.map(inbox => ({
|
|
|
|
id: inbox.id,
|
|
|
|
label: inbox.name,
|
2020-03-09 17:57:10 +00:00
|
|
|
toState: frontendURL(`accounts/${this.accountId}/inbox/${inbox.id}`),
|
2020-02-19 05:00:34 +00:00
|
|
|
type: inbox.channel_type,
|
2020-10-04 17:27:11 +00:00
|
|
|
phoneNumber: inbox.phone_number,
|
2019-12-28 16:26:42 +00:00
|
|
|
})),
|
|
|
|
};
|
|
|
|
},
|
2020-06-25 15:34:03 +00:00
|
|
|
labelSection() {
|
|
|
|
return {
|
|
|
|
icon: 'ion-pound',
|
|
|
|
label: 'LABELS',
|
|
|
|
hasSubMenu: true,
|
|
|
|
key: 'label',
|
|
|
|
cssClass: 'menu-title align-justify',
|
|
|
|
toState: frontendURL(`accounts/${this.accountId}/settings/labels`),
|
|
|
|
toStateName: 'labels_list',
|
|
|
|
children: this.accountLabels.map(label => ({
|
|
|
|
id: label.id,
|
|
|
|
label: label.title,
|
|
|
|
color: label.color,
|
2020-10-10 17:10:11 +00:00
|
|
|
truncateLabel: true,
|
2020-06-25 15:34:03 +00:00
|
|
|
toState: frontendURL(
|
|
|
|
`accounts/${this.accountId}/label/${label.title}`
|
|
|
|
),
|
|
|
|
})),
|
|
|
|
};
|
|
|
|
},
|
2021-02-13 09:28:05 +00:00
|
|
|
teamSection() {
|
|
|
|
return {
|
|
|
|
icon: 'ion-ios-people',
|
|
|
|
label: 'TEAMS',
|
|
|
|
hasSubMenu: true,
|
|
|
|
newLink: true,
|
|
|
|
key: 'team',
|
|
|
|
cssClass: 'menu-title align-justify teams-sidebar-menu',
|
|
|
|
toState: frontendURL(`accounts/${this.accountId}/settings/teams`),
|
|
|
|
toStateName: 'teams_list',
|
|
|
|
children: this.teams.map(team => ({
|
|
|
|
id: team.id,
|
|
|
|
label: team.name,
|
|
|
|
truncateLabel: true,
|
|
|
|
toState: frontendURL(`accounts/${this.accountId}/team/${team.id}`),
|
|
|
|
})),
|
|
|
|
};
|
|
|
|
},
|
2019-11-24 13:39:17 +00:00
|
|
|
dashboardPath() {
|
2020-03-09 17:57:10 +00:00
|
|
|
return frontendURL(`accounts/${this.accountId}/dashboard`);
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2021-02-08 11:08:35 +00:00
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
currentUser(newUserInfo, oldUserInfo) {
|
|
|
|
if (!oldUserInfo.email && newUserInfo.email) {
|
|
|
|
this.setChatwootUser();
|
2021-01-24 19:29:44 +00:00
|
|
|
}
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2019-12-28 16:26:42 +00:00
|
|
|
mounted() {
|
2020-11-11 10:32:14 +00:00
|
|
|
this.$store.dispatch('labels/get');
|
2019-12-28 16:26:42 +00:00
|
|
|
this.$store.dispatch('inboxes/get');
|
2021-01-24 19:29:44 +00:00
|
|
|
this.$store.dispatch('notifications/unReadCount');
|
2021-02-13 09:28:05 +00:00
|
|
|
this.$store.dispatch('teams/get');
|
2021-02-08 11:08:35 +00:00
|
|
|
this.setChatwootUser();
|
2019-12-28 16:26:42 +00:00
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
methods: {
|
2021-02-08 11:08:35 +00:00
|
|
|
toggleSupportChatWindow() {
|
|
|
|
window.$chatwoot.toggle();
|
|
|
|
},
|
|
|
|
setChatwootUser() {
|
|
|
|
if (!this.currentUser.email || !this.globalConfig.chatwootInboxToken) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
window.$chatwoot.setUser(this.currentUser.email, {
|
|
|
|
name: this.currentUser.name,
|
|
|
|
email: this.currentUser.email,
|
|
|
|
avatar_url: this.currentUser.avatar_url,
|
|
|
|
identifier_hash: this.currentUser.hmac_identifier,
|
|
|
|
});
|
|
|
|
},
|
2019-11-24 13:39:17 +00:00
|
|
|
filterMenuItemsByRole(menuItems) {
|
2020-05-26 17:08:48 +00:00
|
|
|
if (!this.currentRole) {
|
2020-02-16 11:50:38 +00:00
|
|
|
return [];
|
|
|
|
}
|
2019-11-24 13:39:17 +00:00
|
|
|
return menuItems.filter(
|
|
|
|
menuItem =>
|
2020-05-26 17:08:48 +00:00
|
|
|
window.roleWiseRoutes[this.currentRole].indexOf(
|
|
|
|
menuItem.toStateName
|
|
|
|
) > -1
|
2019-11-24 13:39:17 +00:00
|
|
|
);
|
|
|
|
},
|
2021-02-08 11:08:35 +00:00
|
|
|
toggleOptions() {
|
2019-08-14 09:48:44 +00:00
|
|
|
this.showOptionsMenu = !this.showOptionsMenu;
|
|
|
|
},
|
2021-02-08 11:08:35 +00:00
|
|
|
toggleAccountModal() {
|
|
|
|
this.showAccountModal = !this.showAccountModal;
|
2020-05-26 17:08:48 +00:00
|
|
|
},
|
2021-02-08 11:08:35 +00:00
|
|
|
openCreateAccountModal() {
|
2020-07-26 07:24:50 +00:00
|
|
|
this.showAccountModal = false;
|
|
|
|
this.showCreateAccountModal = true;
|
|
|
|
},
|
2021-02-08 11:08:35 +00:00
|
|
|
closeCreateAccountModal() {
|
2020-07-26 07:24:50 +00:00
|
|
|
this.showCreateAccountModal = false;
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2020-05-26 17:08:48 +00:00
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
@import '~dashboard/assets/scss/variables';
|
|
|
|
|
|
|
|
.account-selector--modal {
|
|
|
|
.modal-container {
|
|
|
|
width: 40rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.page-top-bar {
|
|
|
|
padding-bottom: $space-two;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.change-accounts--button.button {
|
|
|
|
font-weight: $font-weight-normal;
|
|
|
|
font-size: $font-size-small;
|
|
|
|
padding: $space-small $space-one;
|
|
|
|
}
|
|
|
|
|
|
|
|
.dropdown-pane {
|
|
|
|
li {
|
|
|
|
a {
|
|
|
|
padding: $space-small $space-one !important;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.account-selector {
|
|
|
|
cursor: pointer;
|
|
|
|
padding: $space-small $space-large;
|
|
|
|
|
|
|
|
.ion-ios-checkmark {
|
|
|
|
font-size: $font-size-big;
|
|
|
|
|
|
|
|
& + .account--details {
|
|
|
|
padding-left: $space-normal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.account--details {
|
|
|
|
padding-left: $space-large + $space-smaller;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
margin-bottom: $space-large;
|
|
|
|
}
|
|
|
|
|
|
|
|
a {
|
|
|
|
align-items: center;
|
|
|
|
cursor: pointer;
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
.account--name {
|
|
|
|
cursor: pointer;
|
|
|
|
font-size: $font-size-medium;
|
|
|
|
font-weight: $font-weight-medium;
|
|
|
|
line-height: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
.account--role {
|
|
|
|
cursor: pointer;
|
|
|
|
font-size: $font-size-mini;
|
|
|
|
text-transform: capitalize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-02-08 11:08:35 +00:00
|
|
|
|
2020-11-10 09:55:26 +00:00
|
|
|
.app-context-menu {
|
2021-02-08 11:08:35 +00:00
|
|
|
align-items: center;
|
|
|
|
cursor: pointer;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
2020-11-10 09:55:26 +00:00
|
|
|
height: 6rem;
|
|
|
|
}
|
2021-02-08 11:08:35 +00:00
|
|
|
|
|
|
|
.current-user--options {
|
|
|
|
font-size: $font-size-big;
|
|
|
|
margin-bottom: auto;
|
|
|
|
margin-left: auto;
|
|
|
|
margin-top: auto;
|
|
|
|
}
|
2021-02-13 09:28:05 +00:00
|
|
|
|
|
|
|
.teams-sidebar-menu + .nested.vertical.menu {
|
|
|
|
padding-left: calc(var(--space-medium) - var(--space-one));
|
|
|
|
}
|
2020-05-26 17:08:48 +00:00
|
|
|
</style>
|