Chore: Scope URLs with account_id (#601)

* Chore: Enable Users to create multiple accounts

Addresses: #402
- migrations to split roles and other attributes from users table
- make changes in code to accommodate this change

Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
This commit is contained in:
Sojan Jose
2020-03-09 23:27:10 +05:30
committed by GitHub
parent 2a6670f0da
commit 19ab0fe108
105 changed files with 480 additions and 402 deletions

View File

@@ -5,7 +5,7 @@ import { frontendURL } from '../../../helper/URLHelper';
export default {
routes: [
{
path: frontendURL('dashboard'),
path: frontendURL('accounts/:accountId/dashboard'),
name: 'home',
roles: ['administrator', 'agent'],
component: ConversationView,
@@ -14,7 +14,7 @@ export default {
},
},
{
path: frontendURL('inbox/:inbox_id'),
path: frontendURL('accounts/:accountId/inbox/:inbox_id'),
name: 'inbox_dashboard',
roles: ['administrator', 'agent'],
component: ConversationView,
@@ -23,7 +23,7 @@ export default {
},
},
{
path: frontendURL('conversations/:conversation_id'),
path: frontendURL('accounts/:accountId/conversations/:conversation_id'),
name: 'inbox_conversation',
roles: ['administrator', 'agent'],
component: ConversationView,
@@ -32,7 +32,9 @@ export default {
},
},
{
path: frontendURL('inbox/:inbox_id/conversations/:conversation_id'),
path: frontendURL(
'accounts/:accountId/inbox/:inbox_id/conversations/:conversation_id'
),
name: 'conversation_through_inbox',
roles: ['administrator', 'agent'],
component: ConversationView,

View File

@@ -6,7 +6,7 @@ import { frontendURL } from '../../helper/URLHelper';
export default {
routes: [
{
path: frontendURL(''),
path: frontendURL('accounts/:account_id'),
component: AppContainer,
children: [...conversation.routes, ...settings.routes],
},

View File

@@ -5,7 +5,7 @@ import { frontendURL } from '../../../../helper/URLHelper';
export default {
routes: [
{
path: frontendURL('settings/agents'),
path: frontendURL('accounts/:accountId/settings/agents'),
component: SettingsContent,
props: {
headerTitle: 'AGENT_MGMT.HEADER',

View File

@@ -6,7 +6,7 @@ import { frontendURL } from '../../../../helper/URLHelper';
export default {
routes: [
{
path: frontendURL('settings/billing'),
path: frontendURL('accounts/:accountId/settings/billing'),
component: SettingsContent,
props: {
headerTitle: 'BILLING.HEADER',

View File

@@ -5,7 +5,7 @@ import { frontendURL } from '../../../../helper/URLHelper';
export default {
routes: [
{
path: frontendURL('settings/canned-response'),
path: frontendURL('accounts/:accountId/settings/canned-response'),
component: SettingsContent,
props: {
headerTitle: 'CANNED_MGMT.HEADER',

View File

@@ -47,7 +47,11 @@
<!-- Action Buttons -->
<td>
<div class="button-wrapper">
<router-link :to="`/app/settings/inboxes/${item.id}`">
<router-link
:to="
`/app/accounts/${accountId}/settings/inboxes/${item.id}`
"
>
<woot-submit-button
v-if="isAdmin()"
:button-text="$t('INBOX_MGMT.SETTINGS')"
@@ -101,6 +105,7 @@ import Settings from './Settings';
import DeleteInbox from './DeleteInbox';
import adminMixin from '../../../../mixins/isAdmin';
import { frontendURL } from '../../../../helper/URLHelper';
import auth from '../../../../api/auth';
export default {
components: {
@@ -136,6 +141,9 @@ export default {
this.selectedInbox.name
} ?`;
},
accountId() {
return auth.getCurrentUser().account_id;
},
},
methods: {
openSettings(inbox) {

View File

@@ -12,7 +12,7 @@ import { frontendURL } from '../../../../helper/URLHelper';
export default {
routes: [
{
path: frontendURL('settings/inboxes'),
path: frontendURL('accounts/:accountId/settings/inboxes'),
component: SettingsContent,
props: params => {
const showBackButton = params.name !== 'settings_inbox_list';

View File

@@ -17,7 +17,13 @@
</p>
</div>
<div class="small-2 column button-wrap">
<router-link :to="frontendURL('settings/integrations/webhook')">
<router-link
:to="
frontendURL(
`accounts/${accountId}/settings/integrations/webhook`
)
"
>
<button class="button success nice">
{{ $t('INTEGRATION_SETTINGS.WEBHOOK.CONFIGURE') }}
</button>
@@ -34,9 +40,18 @@
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import { frontendURL } from '../../../../helper/URLHelper';
export default {
computed: {
...mapGetters({
currentUser: 'getCurrentUser',
}),
accountId() {
return this.currentUser.account_id;
},
},
methods: {
frontendURL,
},

View File

@@ -6,7 +6,7 @@ import { frontendURL } from '../../../../helper/URLHelper';
export default {
routes: [
{
path: frontendURL('settings/integrations'),
path: frontendURL('accounts/:accountId/settings/integrations'),
component: SettingsContent,
props: params => {
const showBackButton = params.name !== 'settings_integrations';

View File

@@ -5,7 +5,7 @@ import { frontendURL } from '../../../../helper/URLHelper';
export default {
routes: [
{
path: frontendURL('profile'),
path: frontendURL('accounts/:accountId/profile'),
name: 'profile_settings',
roles: ['administrator', 'agent'],
component: SettingsContent,

View File

@@ -5,7 +5,7 @@ import { frontendURL } from '../../../../helper/URLHelper';
export default {
routes: [
{
path: frontendURL('reports'),
path: frontendURL('accounts/:accountId/reports'),
component: SettingsContent,
props: {
headerTitle: 'REPORT.HEADER',

View File

@@ -11,14 +11,14 @@ import integrations from './integrations/integrations.routes';
export default {
routes: [
{
path: frontendURL('settings'),
path: frontendURL('accounts/:accountId/settings'),
name: 'settings_home',
roles: ['administrator', 'agent'],
redirect: () => {
if (Auth.isAdmin()) {
return frontendURL('settings/agents');
return frontendURL('accounts/:accountId/settings/agents');
}
return frontendURL('settings/canned-response');
return frontendURL('accounts/:accountId/settings/canned-response');
},
},
...agent.routes,