This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +43
-5
lines changed Expand file tree Collapse file tree 4 files changed +43
-5
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ import Promise from 'bluebird';
21
21
import MatrixClientPeg from '../../MatrixClientPeg' ;
22
22
import sdk from '../../index' ;
23
23
import dis from '../../dispatcher' ;
24
- import SdkConfig from '../../SdkConfig ' ;
24
+ import { getHostingLink } from '../../utils/HostingLink ' ;
25
25
import { sanitizedHtmlNode } from '../../HtmlUtils' ;
26
26
import { _t , _td } from '../../languageHandler' ;
27
27
import AccessibleButton from '../views/elements/AccessibleButton' ;
@@ -818,7 +818,7 @@ export default React.createClass({
818
818
819
819
const header = this . state . editing ? < h2 > { _t ( 'Community Settings' ) } </ h2 > : < div /> ;
820
820
821
- const hostingSignupLink = SdkConfig . get ( ) . hosting_signup_link ;
821
+ const hostingSignupLink = getHostingLink ( 'community-settings' ) ;
822
822
let hostingSignup = null ;
823
823
if ( hostingSignupLink ) {
824
824
hostingSignup = < div className = "mx_GroupView_hostingSignup" >
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import { _t } from '../../../languageHandler';
21
21
import LogoutDialog from "../dialogs/LogoutDialog" ;
22
22
import Modal from "../../../Modal" ;
23
23
import SdkConfig from '../../../SdkConfig' ;
24
+ import { getHostingLink } from '../../../utils/HostingLink' ;
24
25
import MatrixClientPeg from '../../../MatrixClientPeg' ;
25
26
26
27
export class TopLeftMenu extends React . Component {
@@ -53,7 +54,7 @@ export class TopLeftMenu extends React.Component {
53
54
render ( ) {
54
55
const isGuest = MatrixClientPeg . get ( ) . isGuest ( ) ;
55
56
56
- const hostingSignupLink = SdkConfig . get ( ) . hosting_signup_link ;
57
+ const hostingSignupLink = getHostingLink ( 'user-context-menu' ) ;
57
58
let hostingSignup = null ;
58
59
if ( hostingSignupLink ) {
59
60
hostingSignup = < div className = "mx_TopLeftMenu_upgradeLink" >
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ import Field from "../elements/Field";
21
21
import AccessibleButton from "../elements/AccessibleButton" ;
22
22
import classNames from 'classnames' ;
23
23
import { User } from "matrix-js-sdk" ;
24
- import SdkConfig from '../../../SdkConfig ' ;
24
+ import { getHostingLink } from '../../../utils/HostingLink ' ;
25
25
26
26
export default class ProfileSettings extends React . Component {
27
27
constructor ( ) {
@@ -131,7 +131,7 @@ export default class ProfileSettings extends React.Component {
131
131
</ div >
132
132
) ;
133
133
134
- const hostingSignupLink = SdkConfig . get ( ) . hosting_signup_link ;
134
+ const hostingSignupLink = getHostingLink ( 'user-settings' ) ;
135
135
let hostingSignup = null ;
136
136
if ( hostingSignupLink ) {
137
137
hostingSignup = < span className = "mx_ProfileSettings_hostingSignup" >
Original file line number Diff line number Diff line change
1
+ /*
2
+ Copyright 2019 New Vector Ltd.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import url from 'url' ;
18
+ import qs from 'qs' ;
19
+
20
+ import SdkConfig from '../SdkConfig' ;
21
+
22
+ export function getHostingLink ( campaign ) {
23
+ const hostingLink = SdkConfig . get ( ) . hosting_signup_link ;
24
+ if ( ! hostingLink ) return null ;
25
+ if ( ! campaign ) return hostingLink ;
26
+
27
+ try {
28
+ const hostingUrl = url . parse ( hostingLink ) ;
29
+ const params = qs . parse ( hostingUrl . query ) ;
30
+ params . utm_campaign = campaign ;
31
+ hostingUrl . search = undefined ;
32
+ hostingUrl . query = params ;
33
+ return hostingUrl . format ( ) ;
34
+ } catch ( e ) {
35
+ return hostingLink ;
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments