Skip to content

Commit 8213f22

Browse files
marie-jjleveugle
authored andcommitted
fix(navbar): get links according to region
1 parent 7f2e835 commit 8213f22

File tree

4 files changed

+54
-54
lines changed

4 files changed

+54
-54
lines changed

packages/manager/modules/navbar/src/assistance-menu/constants.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { Environment } from '@ovh-ux/manager-config';
2-
31
const CA = {
42
ticket: 'https://ca.ovh.com/manager/index.html#/ticket',
53
support: {
@@ -114,7 +112,7 @@ const US = {
114112
},
115113
};
116114

117-
const ASSISTANCE_URLS = {
115+
export const ASSISTANCE_URLS = {
118116
CA,
119117
EU,
120118
US,
@@ -128,11 +126,8 @@ export const CHATBOT_SUBSIDIARIES = [
128126
'FR',
129127
];
130128

131-
export const URLS = ASSISTANCE_URLS[Environment.getRegion()];
132-
133-
134129
export default {
135130
CHATBOT_SUBSIDIARIES,
136131
HELP_CENTER_SUBSIDIARIES,
137-
URLS,
132+
ASSISTANCE_URLS,
138133
};

packages/manager/modules/navbar/src/assistance-menu/controller.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import get from 'lodash/get';
33
import has from 'lodash/has';
44
import isFunction from 'lodash/isFunction';
55

6-
import { Environment } from '@ovh-ux/manager-config';
7-
import { CHATBOT_SUBSIDIARIES, HELP_CENTER_SUBSIDIARIES, URLS } from './constants';
6+
import { CHATBOT_SUBSIDIARIES, HELP_CENTER_SUBSIDIARIES, ASSISTANCE_URLS } from './constants';
87

98
export default class {
109
/* @ngInject */
@@ -14,6 +13,7 @@ export default class {
1413
$scope,
1514
$translate,
1615
atInternet,
16+
coreConfig,
1717
OtrsPopupService,
1818
ovhManagerNavbarMenuHeaderBuilder,
1919
) {
@@ -22,10 +22,12 @@ export default class {
2222
this.$scope = $scope;
2323
this.$translate = $translate;
2424
this.atInternet = atInternet;
25+
this.coreConfig = coreConfig;
2526
this.otrsPopupService = OtrsPopupService;
2627
this.NavbarBuilder = ovhManagerNavbarMenuHeaderBuilder;
2728

28-
this.REGION = Environment.getRegion();
29+
this.REGION = this.coreConfig.getRegion();
30+
this.URLS = ASSISTANCE_URLS[this.REGION];
2931
}
3032

3133
$onInit() {
@@ -62,43 +64,43 @@ export default class {
6264
if (useHelpCenterMenu) {
6365
sublinks.push({
6466
title: this.$translate.instant('navbar_assistance_help_center'),
65-
url: get(URLS, `support.${this.subsidiary}`),
67+
url: get(this.URLS, `support.${this.subsidiary}`),
6668
isExternal: true,
6769
click: () => this.atInternet.trackClick({
6870
name: 'assistance::all_guides',
6971
type: 'action',
7072
}),
71-
mustBeKept: has(URLS, `support.${this.subsidiary}`),
73+
mustBeKept: has(this.URLS, `support.${this.subsidiary}`),
7274
},
7375
{
7476
title: this.$translate.instant('navbar_assistance_ask_for_assistance'),
75-
url: URLS.ticket,
77+
url: this.URLS.ticket,
7678
click: () => this.atInternet.trackClick({
7779
name: 'assistance::assistance_requests_created',
7880
type: 'action',
7981
}),
80-
mustBeKept: has(URLS, 'ticket'),
82+
mustBeKept: has(this.URLS, 'ticket'),
8183
});
8284
} else {
8385
sublinks.push({
8486
title: this.$translate.instant('navbar_assistance_guide'),
85-
url: get(URLS, `guides.${this.universe}.${this.subsidiary}`),
87+
url: get(this.HELP_CENTER_SUBSIDIARIESURLS, `guides.${this.universe}.${this.subsidiary}`),
8688
isExternal: true,
8789
click: () => this.atInternet.trackClick({
8890
name: `assistance::all_guides::${this.universe}`,
8991
type: 'action',
9092
}),
91-
mustBeKept: has(URLS, `guides.${this.universe}.${this.subsidiary}`),
93+
mustBeKept: has(this.URLS, `guides.${this.universe}.${this.subsidiary}`),
9294
},
9395
{
9496
title: this.$translate.instant('navbar_assistance_all_guides'),
95-
url: get(URLS, `guides.home.${this.subsidiary}`),
97+
url: get(this.URLS, `guides.home.${this.subsidiary}`),
9698
isExternal: true,
9799
click: () => this.atInternet.trackClick({
98100
name: 'assistance::all_guides',
99101
type: 'action',
100102
}),
101-
mustBeKept: !has(URLS, `guides.${this.universe}.${this.subsidiary}`) && has(URLS, `guides.home.${this.subsidiary}`),
103+
mustBeKept: !has(this.URLS, `guides.${this.universe}.${this.subsidiary}`) && has(this.URLS, `guides.home.${this.subsidiary}`),
102104
}, {
103105
title: this.$translate.instant('navbar_assistance_new_ticket'),
104106
click: (callback) => {
@@ -121,12 +123,12 @@ export default class {
121123
},
122124
{
123125
title: this.$translate.instant('navbar_assistance_list_ticket'),
124-
url: URLS.ticket,
126+
url: this.URLS.ticket,
125127
click: () => this.atInternet.trackClick({
126128
name: 'assistance::assistance_requests_created',
127129
type: 'action',
128130
}),
129-
mustBeKept: has(URLS, 'ticket'),
131+
mustBeKept: has(this.URLS, 'ticket'),
130132
});
131133
}
132134

@@ -135,7 +137,7 @@ export default class {
135137
if (!['US'].includes(this.REGION)) {
136138
sublinks.push({
137139
title: this.$translate.instant('navbar_assistance_telephony_contact'),
138-
url: get(URLS, 'support_contact', {})[this.subsidiary] || get(URLS, 'support_contact.FR'),
140+
url: get(this.URLS, 'support_contact', {})[this.subsidiary] || get(this.URLS, 'support_contact.FR'),
139141
isExternal: true,
140142
click: () => this.atInternet.trackClick({
141143
name: 'assistance::helpline',

packages/manager/modules/navbar/src/user-menu/constants.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { Environment } from '@ovh-ux/manager-config';
2-
31
const CA = {
42
billing: 'https://ca.ovh.com/manager/index.html#/billing/history',
53
billingCredits: 'https://ca.ovh.com/manager/index.html#/billing/credits',
@@ -63,17 +61,15 @@ const US = {
6361
userSSH: 'https://us.ovhcloud.com/manager/dedicated/index.html#/useraccount/ssh',
6462
};
6563

66-
const USER_MENU_URLS = {
64+
export const USER_MENU_URLS = {
6765
CA,
6866
EU,
6967
US,
7068
};
7169

72-
export const URLS = USER_MENU_URLS[Environment.getRegion()];
73-
7470
export const MAX_NAME_LENGTH = 10;
7571

7672
export default {
7773
MAX_NAME_LENGTH,
78-
URLS,
74+
USER_MENU_URLS,
7975
};

packages/manager/modules/navbar/src/user-menu/controller.js

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
import { Environment } from '@ovh-ux/manager-config';
2-
import { MAX_NAME_LENGTH, URLS } from './constants';
1+
import { MAX_NAME_LENGTH, USER_MENU_URLS } from './constants';
32

43
export default class {
54
/* @ngInject */
6-
constructor($q, $translate, atInternet, ovhManagerNavbarMenuHeaderBuilder, ssoAuthentication) {
5+
constructor(
6+
$q,
7+
$translate,
8+
atInternet,
9+
coreconfig,
10+
ovhManagerNavbarMenuHeaderBuilder,
11+
ssoAuthentication,
12+
) {
713
this.$q = $q;
814
this.$translate = $translate;
915
this.atInternet = atInternet;
1016
this.NavbarBuilder = ovhManagerNavbarMenuHeaderBuilder;
1117
this.ssoAuthentication = ssoAuthentication;
1218

13-
this.REGION = Environment.getRegion();
19+
this.REGION = coreconfig.getRegion();
20+
this.URLS = USER_MENU_URLS[this.REGION];
1421
}
1522

1623
$onInit() {
@@ -49,100 +56,100 @@ export default class {
4956
return [{
5057
name: 'user.account',
5158
title: this.$translate.instant('navbar_user_account'),
52-
url: URLS.userInfos,
59+
url: this.URLS.userInfos,
5360
click: () => this.trackUserMenuSection('my_account', 'account'),
5461
subLinks: [{
5562
title: this.$translate.instant('navbar_user_account_infos'),
56-
url: URLS.userInfos,
63+
url: this.URLS.userInfos,
5764
}, {
5865
title: this.$translate.instant('navbar_user_account_security'),
59-
url: URLS.userSecurity,
66+
url: this.URLS.userSecurity,
6067
}, (this.REGION === 'EU' || this.REGION === 'CA') && {
6168
title: this.$translate.instant('navbar_user_account_emails'),
62-
url: URLS.userEmails,
69+
url: this.URLS.userEmails,
6370
}, (this.REGION === 'EU') && {
6471
title: this.$translate.instant('navbar_user_account_subscriptions'),
65-
url: URLS.userSubscriptions,
72+
url: this.URLS.userSubscriptions,
6673
}, {
6774
title: this.$translate.instant('navbar_user_account_ssh'),
68-
url: URLS.userSSH,
75+
url: this.URLS.userSSH,
6976
}, {
7077
title: this.$translate.instant('navbar_user_account_advanced'),
71-
url: URLS.userAdvanced,
78+
url: this.URLS.userAdvanced,
7279
}],
7380
},
7481

7582
// Billing
7683
!this.user.isEnterprise && {
7784
name: 'user.billing',
7885
title: this.$translate.instant('navbar_user_billing'),
79-
url: URLS.billing,
86+
url: this.URLS.billing,
8087
click: () => this.trackUserMenuSection('my_facturation', 'billing'),
8188
subLinks: [{
8289
title: this.$translate.instant('navbar_user_billing_history'),
83-
url: URLS.billing,
90+
url: this.URLS.billing,
8491
}, {
8592
title: this.$translate.instant('navbar_user_billing_payments'),
86-
url: URLS.billingPayments,
93+
url: this.URLS.billingPayments,
8794
}],
8895
},
8996

9097
// Services
9198
(this.REGION === 'EU' || this.REGION === 'CA') && (!this.user.isEnterprise ? {
9299
name: 'user.services',
93100
title: this.$translate.instant('navbar_user_renew'),
94-
url: URLS.services,
101+
url: this.URLS.services,
95102
click: () => this.trackUserMenuSection('my_services', 'services'),
96103
subLinks: [{
97104
title: this.$translate.instant('navbar_user_renew_management'),
98-
url: URLS.services,
105+
url: this.URLS.services,
99106
}, {
100107
title: this.$translate.instant('navbar_user_renew_agreements'),
101-
url: URLS.servicesAgreements,
108+
url: this.URLS.servicesAgreements,
102109
}],
103110
} : {
104111
title: this.$translate.instant('navbar_user_renew_agreements'),
105-
url: URLS.servicesAgreements,
112+
url: this.URLS.servicesAgreements,
106113
}),
107114

108115
// Payment
109116
!this.user.isEnterprise && {
110117
name: 'user.payment',
111118
title: this.$translate.instant('navbar_user_means'),
112-
url: URLS.paymentMeans,
119+
url: this.URLS.paymentMeans,
113120
click: () => this.trackUserMenuSection('my_payment_types', 'payment_types'),
114121
subLinks: [{
115122
title: this.$translate.instant('navbar_user_means_mean'),
116-
url: URLS.paymentMeans,
123+
url: this.URLS.paymentMeans,
117124
}, (this.REGION === 'EU' || this.REGION === 'CA') && {
118125
title: this.$translate.instant('navbar_user_means_ovhaccount'),
119-
url: URLS.ovhAccount,
126+
url: this.URLS.ovhAccount,
120127
}, (this.REGION === 'EU' || this.REGION === 'CA') && {
121128
title: this.$translate.instant('navbar_user_means_vouchers'),
122-
url: URLS.billingVouchers,
129+
url: this.URLS.billingVouchers,
123130
}, {
124131
title: this.$translate.instant('navbar_user_means_refunds'),
125-
url: URLS.billingRefunds,
132+
url: this.URLS.billingRefunds,
126133
}, (this.REGION === 'EU') && {
127134
title: this.$translate.instant('navbar_user_means_fidelity'),
128-
url: URLS.billingFidelity,
135+
url: this.URLS.billingFidelity,
129136
}, {
130137
title: this.$translate.instant('navbar_user_means_credits'),
131-
url: URLS.billingCredits,
138+
url: this.URLS.billingCredits,
132139
}],
133140
},
134141

135142
// Orders
136143
(!this.user.isEnterprise && this.REGION === 'EU' && this.user.ovhSubsidiary === 'FR') && {
137144
title: this.$translate.instant('navbar_user_orders_all'),
138-
url: URLS.orders,
145+
url: this.URLS.orders,
139146
click: () => this.trackUserMenuSection('my_orders', 'orders'),
140147
},
141148

142149
// Contacts
143150
(this.REGION === 'EU') && {
144151
title: this.$translate.instant('navbar_user_contacts'),
145-
url: URLS.contacts,
152+
url: this.URLS.contacts,
146153
click: () => this.trackUserMenuSection('my_contacts', 'contacts'),
147154
},
148155

0 commit comments

Comments
 (0)