Bug: Add account scoping in CTA (#754)
This commit is contained in:
parent
645d53db1c
commit
7d41b7a5dc
4 changed files with 56 additions and 10 deletions
|
@ -40,10 +40,10 @@
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
import adminMixin from '../../../mixins/isAdmin';
|
import adminMixin from '../../../mixins/isAdmin';
|
||||||
import { frontendURL } from '../../../helper/URLHelper';
|
import accountMixin from '../../../mixins/account';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [adminMixin],
|
mixins: [accountMixin, adminMixin],
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
|
@ -60,7 +60,7 @@ export default {
|
||||||
return this.$t('CONVERSATION.LOADING_CONVERSATIONS');
|
return this.$t('CONVERSATION.LOADING_CONVERSATIONS');
|
||||||
},
|
},
|
||||||
newInboxURL() {
|
newInboxURL() {
|
||||||
return frontendURL('settings/inboxes/new');
|
return this.addAccountScoping('settings/inboxes/new');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
14
app/javascript/dashboard/mixins/account.js
Normal file
14
app/javascript/dashboard/mixins/account.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import auth from '../api/auth';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
computed: {
|
||||||
|
accountId() {
|
||||||
|
return auth.getCurrentUser().account_id;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
addAccountScoping(url) {
|
||||||
|
return `/app/accounts/${this.accountId}/${url}`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
35
app/javascript/dashboard/mixins/specs/account.spec.js
Normal file
35
app/javascript/dashboard/mixins/specs/account.spec.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import { createWrapper } from '@vue/test-utils';
|
||||||
|
import accountMixin from '../account';
|
||||||
|
import Vue from 'vue';
|
||||||
|
|
||||||
|
jest.mock('../../api/auth', () => ({
|
||||||
|
getCurrentUser: () => ({ account_id: 1 }),
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('accountMixin', () => {
|
||||||
|
test('set accountId properly', () => {
|
||||||
|
const Component = {
|
||||||
|
render() {},
|
||||||
|
title: 'TestComponent',
|
||||||
|
mixins: [accountMixin],
|
||||||
|
};
|
||||||
|
const Constructor = Vue.extend(Component);
|
||||||
|
const vm = new Constructor().$mount();
|
||||||
|
const wrapper = createWrapper(vm);
|
||||||
|
expect(wrapper.vm.accountId).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns current url', () => {
|
||||||
|
const Component = {
|
||||||
|
render() {},
|
||||||
|
title: 'TestComponent',
|
||||||
|
mixins: [accountMixin],
|
||||||
|
};
|
||||||
|
const Constructor = Vue.extend(Component);
|
||||||
|
const vm = new Constructor().$mount();
|
||||||
|
const wrapper = createWrapper(vm);
|
||||||
|
expect(wrapper.vm.addAccountScoping('settings/inboxes/new')).toBe(
|
||||||
|
'/app/accounts/1/settings/inboxes/new'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
|
@ -7,7 +7,7 @@
|
||||||
{{ $t('INBOX_MGMT.LIST.404') }}
|
{{ $t('INBOX_MGMT.LIST.404') }}
|
||||||
<router-link
|
<router-link
|
||||||
v-if="isAdmin()"
|
v-if="isAdmin()"
|
||||||
:to="frontendURL('settings/inboxes/new')"
|
:to="addAccountScoping('settings/inboxes/new')"
|
||||||
>
|
>
|
||||||
{{ $t('SETTINGS.INBOXES.NEW_INBOX') }}
|
{{ $t('SETTINGS.INBOXES.NEW_INBOX') }}
|
||||||
</router-link>
|
</router-link>
|
||||||
|
@ -51,9 +51,7 @@
|
||||||
<td>
|
<td>
|
||||||
<div class="button-wrapper">
|
<div class="button-wrapper">
|
||||||
<router-link
|
<router-link
|
||||||
:to="
|
:to="addAccountScoping(`settings/inboxes/${item.id}`)"
|
||||||
`/app/accounts/${accountId}/settings/inboxes/${item.id}`
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<woot-submit-button
|
<woot-submit-button
|
||||||
v-if="isAdmin()"
|
v-if="isAdmin()"
|
||||||
|
@ -107,15 +105,15 @@ import { mapGetters } from 'vuex';
|
||||||
import Settings from './Settings';
|
import Settings from './Settings';
|
||||||
import DeleteInbox from './DeleteInbox';
|
import DeleteInbox from './DeleteInbox';
|
||||||
import adminMixin from '../../../../mixins/isAdmin';
|
import adminMixin from '../../../../mixins/isAdmin';
|
||||||
import { frontendURL } from '../../../../helper/URLHelper';
|
|
||||||
import auth from '../../../../api/auth';
|
import auth from '../../../../api/auth';
|
||||||
|
import accountMixin from '../../../../mixins/account';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Settings,
|
Settings,
|
||||||
DeleteInbox,
|
DeleteInbox,
|
||||||
},
|
},
|
||||||
mixins: [adminMixin],
|
mixins: [adminMixin, accountMixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loading: {},
|
loading: {},
|
||||||
|
@ -184,7 +182,6 @@ export default {
|
||||||
this.showDeletePopup = false;
|
this.showDeletePopup = false;
|
||||||
this.selectedInbox = {};
|
this.selectedInbox = {};
|
||||||
},
|
},
|
||||||
frontendURL,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue