Feature: Ability to switch between multiple accounts (#881)
* Feature: Ability to switch between multiple accounts * Fix rubocop * Fix assigned inboxes * fix auth json * Add account switcher in UI * fix ordering on administrate * Add switch accounts to sidebar * add account id * Fix schema.rb timestamp * Revert "add account id" This reverts commit 27570f50ef584cb9a5f69454f43f630b318c8807. * Add a check for account Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
This commit is contained in:
@@ -15,11 +15,6 @@ export default {
|
||||
components: {
|
||||
Sidebar,
|
||||
},
|
||||
props: {
|
||||
mainViewComponent: String,
|
||||
sidebarMenu: String,
|
||||
page: String,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isSidebarOpen: false,
|
||||
@@ -50,6 +45,7 @@ export default {
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.$store.dispatch('setCurrentAccountId', this.$route.params.accountId);
|
||||
window.addEventListener('resize', this.handleResize);
|
||||
this.handleResize();
|
||||
bus.$on('sidemenu_icon_click', () => {
|
||||
|
||||
@@ -19,11 +19,13 @@
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import BackButton from '../../../components/widgets/BackButton';
|
||||
import adminMixin from '../../../mixins/isAdmin';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
BackButton,
|
||||
},
|
||||
mixins: [adminMixin],
|
||||
props: {
|
||||
headerTitle: {
|
||||
default: '',
|
||||
@@ -51,10 +53,6 @@ export default {
|
||||
iconClass() {
|
||||
return `icon ${this.icon} header--icon`;
|
||||
},
|
||||
isAdmin() {
|
||||
const { role } = this.currentUser;
|
||||
return role === 'administrator';
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -6,7 +6,6 @@ export default {
|
||||
routes: [
|
||||
{
|
||||
path: frontendURL('accounts/:accountId/settings/general'),
|
||||
name: 'general_settings',
|
||||
roles: ['administrator'],
|
||||
component: SettingsContent,
|
||||
props: {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<p v-if="!inboxesList.length" class="no-items-error-message">
|
||||
{{ $t('INBOX_MGMT.LIST.404') }}
|
||||
<router-link
|
||||
v-if="isAdmin()"
|
||||
v-if="isAdmin"
|
||||
:to="addAccountScoping('settings/inboxes/new')"
|
||||
>
|
||||
{{ $t('SETTINGS.INBOXES.NEW_INBOX') }}
|
||||
@@ -54,7 +54,7 @@
|
||||
:to="addAccountScoping(`settings/inboxes/${item.id}`)"
|
||||
>
|
||||
<woot-submit-button
|
||||
v-if="isAdmin()"
|
||||
v-if="isAdmin"
|
||||
:button-text="$t('INBOX_MGMT.SETTINGS')"
|
||||
icon-class="ion-gear-b"
|
||||
button-class="link hollow grey-btn"
|
||||
@@ -62,7 +62,7 @@
|
||||
</router-link>
|
||||
|
||||
<woot-submit-button
|
||||
v-if="isAdmin()"
|
||||
v-if="isAdmin"
|
||||
:button-text="$t('INBOX_MGMT.DELETE.BUTTON_TEXT')"
|
||||
:loading="loading[item.id]"
|
||||
icon-class="ion-close-circled"
|
||||
@@ -111,7 +111,6 @@
|
||||
import { mapGetters } from 'vuex';
|
||||
import Settings from './Settings';
|
||||
import adminMixin from '../../../../mixins/isAdmin';
|
||||
import auth from '../../../../api/auth';
|
||||
import accountMixin from '../../../../mixins/account';
|
||||
import globalConfigMixin from 'shared/mixins/globalConfigMixin';
|
||||
|
||||
@@ -149,9 +148,6 @@ export default {
|
||||
this.selectedInbox.name
|
||||
} ?`;
|
||||
},
|
||||
accountId() {
|
||||
return auth.getCurrentUser().account_id;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
openSettings(inbox) {
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
path: 'list',
|
||||
name: 'settings_inbox_list',
|
||||
component: InboxHome,
|
||||
roles: ['administrator', 'agent'],
|
||||
roles: ['administrator'],
|
||||
},
|
||||
{
|
||||
path: 'new',
|
||||
|
||||
@@ -52,10 +52,8 @@ export default {
|
||||
...mapGetters({
|
||||
currentUser: 'getCurrentUser',
|
||||
globalConfig: 'globalConfig/get',
|
||||
accountId: 'getCurrentAccountId',
|
||||
}),
|
||||
accountId() {
|
||||
return this.currentUser.account_id;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
frontendURL,
|
||||
|
||||
@@ -164,7 +164,6 @@ export default {
|
||||
registration.pushManager
|
||||
.getSubscription()
|
||||
.then(subscription => {
|
||||
console.log(subscription);
|
||||
if (!subscription) {
|
||||
this.hasEnabledPushPermissions = false;
|
||||
} else {
|
||||
|
||||
@@ -17,7 +17,7 @@ export default {
|
||||
children: [
|
||||
{
|
||||
path: 'settings',
|
||||
name: 'general_settings_index',
|
||||
name: 'profile_settings_index',
|
||||
component: Index,
|
||||
roles: ['administrator', 'agent'],
|
||||
},
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { frontendURL } from '../../../helper/URLHelper';
|
||||
import agent from './agents/agent.routes';
|
||||
import Auth from '../../../api/auth';
|
||||
import billing from './billing/billing.routes';
|
||||
import canned from './canned/canned.routes';
|
||||
import inbox from './inbox/inbox.routes';
|
||||
@@ -8,6 +7,7 @@ import profile from './profile/profile.routes';
|
||||
import reports from './reports/reports.routes';
|
||||
import integrations from './integrations/integrations.routes';
|
||||
import account from './account/account.routes';
|
||||
import store from '../../../store';
|
||||
|
||||
export default {
|
||||
routes: [
|
||||
@@ -16,7 +16,7 @@ export default {
|
||||
name: 'settings_home',
|
||||
roles: ['administrator', 'agent'],
|
||||
redirect: () => {
|
||||
if (Auth.isAdmin()) {
|
||||
if (store.getters.getCurrentRole === 'administrator') {
|
||||
return frontendURL('accounts/:accountId/settings/agents');
|
||||
}
|
||||
return frontendURL('accounts/:accountId/settings/canned-response');
|
||||
|
||||
Reference in New Issue
Block a user