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>
|
2019-10-16 09:06:17 +00:00
|
|
|
<img src="~dashboard/assets/images/woot-logo.svg" alt="Woot-logo" />
|
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"
|
|
|
|
/>
|
|
|
|
</transition-group>
|
|
|
|
</div>
|
2019-11-24 13:39:17 +00:00
|
|
|
|
|
|
|
<!-- this block is only required in the hosted version with billing enabled -->
|
2019-08-14 09:48:44 +00:00
|
|
|
<transition name="fade" mode="out-in">
|
|
|
|
<woot-status-bar
|
2019-08-25 14:29:28 +00:00
|
|
|
v-if="shouldShowStatusBox"
|
2019-08-14 09:48:44 +00:00
|
|
|
:message="trialMessage"
|
2019-08-25 14:29:28 +00:00
|
|
|
:button-text="$t('APP_GLOBAL.TRAIL_BUTTON')"
|
|
|
|
:button-route="{ name: 'billing' }"
|
2019-08-14 09:48:44 +00:00
|
|
|
:type="statusBarClass"
|
|
|
|
:show-button="isAdmin()"
|
|
|
|
/>
|
|
|
|
</transition>
|
2019-11-24 13:39:17 +00:00
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
<div class="bottom-nav">
|
|
|
|
<transition name="menu-slide">
|
2019-08-25 14:29:28 +00:00
|
|
|
<div
|
|
|
|
v-if="showOptionsMenu"
|
|
|
|
v-on-clickaway="showOptions"
|
|
|
|
class="dropdown-pane top"
|
|
|
|
>
|
2019-08-14 09:48:44 +00:00
|
|
|
<ul class="vertical dropdown menu">
|
|
|
|
<li><a href="#" @click.prevent="logout()">Logout</a></li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
<div class="current-user" @click.prevent="showOptions()">
|
2019-11-24 13:39:17 +00:00
|
|
|
<thumbnail :src="gravatarUrl()" :username="currentUser.name">
|
|
|
|
</thumbnail>
|
2019-08-14 09:48:44 +00:00
|
|
|
<div class="current-user--data">
|
2019-08-25 14:29:28 +00:00
|
|
|
<h3 class="current-user--name">
|
|
|
|
{{ currentUser.name }}
|
|
|
|
</h3>
|
|
|
|
<h5 class="current-user--role">
|
|
|
|
{{ currentUser.role }}
|
|
|
|
</h5>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
2019-08-25 14:29:28 +00:00
|
|
|
<span
|
|
|
|
class="current-user--options icon ion-android-more-vertical"
|
|
|
|
></span>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</aside>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import md5 from 'md5';
|
|
|
|
import { mixin as clickaway } from 'vue-clickaway';
|
|
|
|
|
|
|
|
import adminMixin from '../../mixins/isAdmin';
|
|
|
|
import Auth from '../../api/auth';
|
|
|
|
import SidebarItem from './SidebarItem';
|
|
|
|
import WootStatusBar from '../widgets/StatusBar';
|
2019-08-25 14:29:28 +00:00
|
|
|
import { frontendURL } from '../../helper/URLHelper';
|
2019-11-05 04:45:09 +00:00
|
|
|
import Thumbnail from '../widgets/Thumbnail';
|
2019-08-25 14:29:28 +00:00
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
export default {
|
2019-08-25 14:29:28 +00:00
|
|
|
mixins: [clickaway, adminMixin],
|
2019-08-14 09:48:44 +00:00
|
|
|
props: {
|
2019-08-25 14:29:28 +00:00
|
|
|
route: {
|
|
|
|
type: String,
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
showOptionsMenu: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
// this.$store.dispatch('fetchLabels');
|
|
|
|
this.$store.dispatch('fetchInboxes');
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
sidebarList: 'getMenuItems',
|
|
|
|
daysLeft: 'getTrialLeft',
|
|
|
|
subscriptionData: 'getSubscription',
|
|
|
|
}),
|
2019-08-25 14:29:28 +00:00
|
|
|
accessibleMenuItems() {
|
2019-08-14 09:48:44 +00:00
|
|
|
const currentRoute = this.$store.state.route.name;
|
|
|
|
// get all keys in menuGroup
|
|
|
|
const groupKey = Object.keys(this.sidebarList);
|
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) {
|
|
|
|
const groupItem = this.sidebarList[groupKey[i]];
|
|
|
|
// Check if current route is included
|
|
|
|
const isRouteIncluded = groupItem.routes.indexOf(currentRoute) > -1;
|
|
|
|
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
|
|
|
if (!window.chatwootConfig.billingEnabled) {
|
|
|
|
menuItems = this.filterBillingRoutes(menuItems);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.filterMenuItemsByRole(menuItems);
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
currentUser() {
|
|
|
|
return Auth.getCurrentUser();
|
|
|
|
},
|
2019-11-24 13:39:17 +00:00
|
|
|
dashboardPath() {
|
|
|
|
return frontendURL('dashboard');
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
shouldShowStatusBox() {
|
2019-08-25 14:29:28 +00:00
|
|
|
return (
|
2019-11-24 13:39:17 +00:00
|
|
|
window.chatwootConfig.billingEnabled &&
|
|
|
|
(this.subscriptionData.state === 'trial' ||
|
|
|
|
this.subscriptionData.state === 'cancelled')
|
2019-08-25 14:29:28 +00:00
|
|
|
);
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
statusBarClass() {
|
|
|
|
if (this.subscriptionData.state === 'trial') {
|
|
|
|
return 'warning';
|
2019-08-25 14:29:28 +00:00
|
|
|
}
|
|
|
|
if (this.subscriptionData.state === 'cancelled') {
|
2019-08-14 09:48:44 +00:00
|
|
|
return 'danger';
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
},
|
2019-11-24 13:39:17 +00:00
|
|
|
trialMessage() {
|
|
|
|
return `${this.daysLeft} ${this.$t('APP_GLOBAL.TRIAL_MESSAGE')}`;
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
gravatarUrl() {
|
|
|
|
const hash = md5(this.currentUser.email);
|
2019-11-05 04:45:09 +00:00
|
|
|
return `${window.WootConstants.GRAVATAR_URL}${hash}?default=404`;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2019-11-24 13:39:17 +00:00
|
|
|
filterBillingRoutes(menuItems) {
|
|
|
|
return menuItems.filter(
|
|
|
|
menuItem => !menuItem.toState.includes('billing')
|
|
|
|
);
|
|
|
|
},
|
|
|
|
filterMenuItemsByRole(menuItems) {
|
|
|
|
const { role } = this.currentUser;
|
|
|
|
return menuItems.filter(
|
|
|
|
menuItem =>
|
|
|
|
window.roleWiseRoutes[role].indexOf(menuItem.toStateName) > -1
|
|
|
|
);
|
|
|
|
},
|
|
|
|
logout() {
|
|
|
|
Auth.logout();
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
showOptions() {
|
|
|
|
this.showOptionsMenu = !this.showOptionsMenu;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
components: {
|
|
|
|
SidebarItem,
|
|
|
|
WootStatusBar,
|
2019-11-05 04:45:09 +00:00
|
|
|
Thumbnail,
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|