2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
2021-12-02 05:32:43 +00:00
|
|
|
<aside class="woot-sidebar">
|
2021-12-01 07:15:39 +00:00
|
|
|
<primary-sidebar
|
2022-01-06 23:09:01 +00:00
|
|
|
:logo-source="globalConfig.logoThumbnail"
|
2021-12-01 07:15:39 +00:00
|
|
|
:installation-name="globalConfig.installationName"
|
|
|
|
:account-id="accountId"
|
|
|
|
:menu-items="primaryMenuItems"
|
2021-12-02 05:32:43 +00:00
|
|
|
:active-menu-item="activePrimaryMenu.key"
|
2021-12-01 07:15:39 +00:00
|
|
|
@toggle-accounts="toggleAccountModal"
|
|
|
|
@key-shortcut-modal="toggleKeyShortcutModal"
|
2022-03-25 13:32:45 +00:00
|
|
|
@open-notification-panel="openNotificationPanel"
|
2021-12-01 07:15:39 +00:00
|
|
|
/>
|
|
|
|
<secondary-sidebar
|
2022-07-14 03:31:36 +00:00
|
|
|
v-if="showSecondarySidebar"
|
2021-12-01 07:15:39 +00:00
|
|
|
:account-id="accountId"
|
|
|
|
:inboxes="inboxes"
|
2021-12-02 05:32:43 +00:00
|
|
|
:labels="labels"
|
2021-12-01 07:15:39 +00:00
|
|
|
:teams="teams"
|
2022-01-17 03:48:54 +00:00
|
|
|
:custom-views="customViews"
|
2021-12-02 05:32:43 +00:00
|
|
|
:menu-config="activeSecondaryMenu"
|
|
|
|
:current-role="currentRole"
|
2021-12-01 07:15:39 +00:00
|
|
|
@add-label="showAddLabelPopup"
|
2022-05-06 09:25:38 +00:00
|
|
|
@toggle-accounts="toggleAccountModal"
|
2021-12-01 07:15:39 +00:00
|
|
|
/>
|
2019-08-14 09:48:44 +00:00
|
|
|
</aside>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
|
|
|
|
import adminMixin from '../../mixins/isAdmin';
|
2021-12-02 05:32:43 +00:00
|
|
|
import { getSidebarItems } from './config/default-sidebar';
|
2020-07-26 07:24:50 +00:00
|
|
|
import alertMixin from 'shared/mixins/alertMixin';
|
2021-12-01 07:15:39 +00:00
|
|
|
|
2021-12-02 05:32:43 +00:00
|
|
|
import PrimarySidebar from './sidebarComponents/Primary';
|
|
|
|
import SecondarySidebar from './sidebarComponents/Secondary';
|
2021-08-26 10:25:58 +00:00
|
|
|
import {
|
2021-09-15 14:45:06 +00:00
|
|
|
hasPressedAltAndCKey,
|
|
|
|
hasPressedAltAndRKey,
|
|
|
|
hasPressedAltAndSKey,
|
|
|
|
hasPressedAltAndVKey,
|
2021-08-26 10:25:58 +00:00
|
|
|
hasPressedCommandAndForwardSlash,
|
|
|
|
isEscape,
|
|
|
|
} from 'shared/helpers/KeyboardHelpers';
|
2021-08-10 04:23:40 +00:00
|
|
|
import eventListenerMixins from 'shared/mixins/eventListenerMixins';
|
2021-09-15 14:45:06 +00:00
|
|
|
import router from '../../routes';
|
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-12-01 07:15:39 +00:00
|
|
|
PrimarySidebar,
|
|
|
|
SecondarySidebar,
|
2019-12-28 16:26:42 +00:00
|
|
|
},
|
2021-08-10 04:23:40 +00:00
|
|
|
mixins: [adminMixin, alertMixin, eventListenerMixins],
|
2022-07-14 03:31:36 +00:00
|
|
|
props: {
|
|
|
|
showSecondarySidebar: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
showOptionsMenu: false,
|
|
|
|
};
|
|
|
|
},
|
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',
|
2021-12-02 05:32:43 +00:00
|
|
|
labels: 'labels/getLabelsOnSidebar',
|
2021-02-13 09:28:05 +00:00
|
|
|
teams: 'teams/getMyTeams',
|
2019-08-14 09:48:44 +00:00
|
|
|
}),
|
2022-01-21 22:11:59 +00:00
|
|
|
activeCustomView() {
|
|
|
|
if (this.activePrimaryMenu.key === 'contacts') {
|
|
|
|
return 'contact';
|
|
|
|
}
|
|
|
|
if (this.activePrimaryMenu.key === 'conversations') {
|
|
|
|
return 'conversation';
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
},
|
|
|
|
customViews() {
|
|
|
|
return this.$store.getters['customViews/getCustomViewsByFilterType'](
|
|
|
|
this.activeCustomView
|
|
|
|
);
|
|
|
|
},
|
|
|
|
isConversationOrContactActive() {
|
|
|
|
return (
|
|
|
|
this.activePrimaryMenu.key === 'contacts' ||
|
|
|
|
this.activePrimaryMenu.key === 'conversations'
|
|
|
|
);
|
|
|
|
},
|
2021-12-02 05:32:43 +00:00
|
|
|
sideMenuConfig() {
|
2020-05-26 17:08:48 +00:00
|
|
|
return getSidebarItems(this.accountId);
|
|
|
|
},
|
2021-12-01 07:15:39 +00:00
|
|
|
primaryMenuItems() {
|
2021-12-02 05:32:43 +00:00
|
|
|
const menuItems = this.sideMenuConfig.primaryMenu;
|
|
|
|
return menuItems.filter(menuItem =>
|
|
|
|
menuItem.roles.includes(this.currentRole)
|
2021-12-01 07:15:39 +00:00
|
|
|
);
|
2021-06-18 14:38:58 +00:00
|
|
|
},
|
2021-12-02 05:32:43 +00:00
|
|
|
activeSecondaryMenu() {
|
|
|
|
const { secondaryMenu } = this.sideMenuConfig;
|
|
|
|
const { name: currentRoute } = this.$route;
|
|
|
|
|
|
|
|
const activeSecondaryMenu =
|
|
|
|
secondaryMenu.find(menuItem =>
|
|
|
|
menuItem.routes.includes(currentRoute)
|
|
|
|
) || {};
|
|
|
|
return activeSecondaryMenu;
|
2021-02-13 09:28:05 +00:00
|
|
|
},
|
2021-12-02 05:32:43 +00:00
|
|
|
activePrimaryMenu() {
|
|
|
|
const activePrimaryMenu =
|
|
|
|
this.primaryMenuItems.find(
|
|
|
|
menuItem => menuItem.key === this.activeSecondaryMenu.parentNav
|
|
|
|
) || {};
|
|
|
|
return activePrimaryMenu;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2021-02-08 11:08:35 +00:00
|
|
|
},
|
2022-01-21 22:11:59 +00:00
|
|
|
|
|
|
|
watch: {
|
|
|
|
activeCustomView() {
|
|
|
|
this.fetchCustomViews();
|
|
|
|
},
|
|
|
|
},
|
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-11-11 09:53:33 +00:00
|
|
|
this.$store.dispatch('attributes/get');
|
2022-01-21 22:11:59 +00:00
|
|
|
this.fetchCustomViews();
|
2019-12-28 16:26:42 +00:00
|
|
|
},
|
2021-08-10 04:23:40 +00:00
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
methods: {
|
2022-01-21 22:11:59 +00:00
|
|
|
fetchCustomViews() {
|
|
|
|
if (this.isConversationOrContactActive) {
|
|
|
|
this.$store.dispatch('customViews/get', this.activeCustomView);
|
|
|
|
}
|
|
|
|
},
|
2021-08-10 04:23:40 +00:00
|
|
|
toggleKeyShortcutModal() {
|
2022-03-14 12:44:16 +00:00
|
|
|
this.$emit('open-key-shortcut-modal');
|
2021-08-10 04:23:40 +00:00
|
|
|
},
|
|
|
|
closeKeyShortcutModal() {
|
2022-03-14 12:44:16 +00:00
|
|
|
this.$emit('close-key-shortcut-modal');
|
2021-08-10 04:23:40 +00:00
|
|
|
},
|
|
|
|
handleKeyEvents(e) {
|
|
|
|
if (hasPressedCommandAndForwardSlash(e)) {
|
|
|
|
this.toggleKeyShortcutModal();
|
|
|
|
}
|
2021-08-26 10:25:58 +00:00
|
|
|
if (isEscape(e)) {
|
|
|
|
this.closeKeyShortcutModal();
|
|
|
|
}
|
2021-09-15 14:45:06 +00:00
|
|
|
|
|
|
|
if (hasPressedAltAndCKey(e)) {
|
|
|
|
if (!this.isCurrentRouteSameAsNavigation('home')) {
|
|
|
|
router.push({ name: 'home' });
|
|
|
|
}
|
|
|
|
} else if (hasPressedAltAndVKey(e)) {
|
|
|
|
if (!this.isCurrentRouteSameAsNavigation('contacts_dashboard')) {
|
|
|
|
router.push({ name: 'contacts_dashboard' });
|
|
|
|
}
|
|
|
|
} else if (hasPressedAltAndRKey(e)) {
|
|
|
|
if (!this.isCurrentRouteSameAsNavigation('settings_account_reports')) {
|
|
|
|
router.push({ name: 'settings_account_reports' });
|
|
|
|
}
|
|
|
|
} else if (hasPressedAltAndSKey(e)) {
|
|
|
|
if (!this.isCurrentRouteSameAsNavigation('agent_list')) {
|
|
|
|
router.push({ name: 'agent_list' });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
isCurrentRouteSameAsNavigation(routeName) {
|
2021-12-02 05:32:43 +00:00
|
|
|
return this.$route.name === routeName;
|
2021-08-10 04:23:40 +00:00
|
|
|
},
|
2021-02-08 11:08:35 +00:00
|
|
|
toggleSupportChatWindow() {
|
|
|
|
window.$chatwoot.toggle();
|
|
|
|
},
|
|
|
|
toggleAccountModal() {
|
2022-03-14 12:44:16 +00:00
|
|
|
this.$emit('toggle-account-modal');
|
2020-07-26 07:24:50 +00:00
|
|
|
},
|
2021-06-18 14:38:58 +00:00
|
|
|
showAddLabelPopup() {
|
2022-03-14 12:44:16 +00:00
|
|
|
this.$emit('show-add-label-popup');
|
2021-06-18 14:38:58 +00:00
|
|
|
},
|
2022-03-25 13:32:45 +00:00
|
|
|
openNotificationPanel() {
|
|
|
|
this.$emit('open-notification-panel');
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2020-05-26 17:08:48 +00:00
|
|
|
|
2021-12-01 07:15:39 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.woot-sidebar {
|
2021-12-02 05:32:43 +00:00
|
|
|
background: var(--white);
|
2021-12-01 07:15:39 +00:00
|
|
|
display: flex;
|
2022-03-15 15:39:14 +00:00
|
|
|
min-height: 0;
|
|
|
|
height: 100%;
|
2022-06-24 17:42:53 +00:00
|
|
|
width: fit-content;
|
2021-12-01 07:15:39 +00:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
2020-05-26 17:08:48 +00:00
|
|
|
<style lang="scss">
|
|
|
|
@import '~dashboard/assets/scss/variables';
|
|
|
|
|
|
|
|
.account-selector--modal {
|
|
|
|
.modal-container {
|
|
|
|
width: 40rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.account-selector {
|
|
|
|
cursor: pointer;
|
|
|
|
padding: $space-small $space-large;
|
|
|
|
|
2021-12-01 05:03:18 +00:00
|
|
|
.selected--account {
|
|
|
|
margin-top: -$space-smaller;
|
2020-05-26 17:08:48 +00:00
|
|
|
|
|
|
|
& + .account--details {
|
2021-12-01 05:03:18 +00:00
|
|
|
padding-left: $space-normal - $space-micro;
|
2020-05-26 17:08:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.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
|
|
|
|
2021-12-01 07:15:39 +00:00
|
|
|
.secondary-menu .nested.vertical.menu {
|
|
|
|
margin-left: var(--space-small);
|
2021-02-13 09:28:05 +00:00
|
|
|
}
|
2020-05-26 17:08:48 +00:00
|
|
|
</style>
|