Skip to content

Commit

Permalink
Merge pull request #2041 from wireapp/staging
Browse files Browse the repository at this point in the history
release 2017-12-07
  • Loading branch information
Gregor Herdmann authored Dec 7, 2017
2 parents df87041 + 621c2ca commit 16bd313
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/script/auth/URLParameter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ z.auth.URLParameter = {
ENVIRONMENT: 'env',
INVITE: 'invite',
LOCALE: 'hl',
MODE: 'mode',
REASON: 'reason',
TRACKING: 'tracking',
};
19 changes: 9 additions & 10 deletions app/script/auth/page/Index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,26 @@ import {injectIntl} from 'react-intl';
import {Logo, COLOR} from '@wireapp/react-ui-kit/Identity';
import {ProfileIcon, RoundContainer, TeamIcon} from '@wireapp/react-ui-kit/Icon';
import {Link, Paragraph, Text, Bold} from '@wireapp/react-ui-kit/Text';
import {pathWithParams} from '../util/urlUtil';

class Index extends Component {
componentDidMount() {
this.props.trackEvent({name: TrackingAction.EVENT_NAME.START.OPENED_START_SCREEN});
}

onRegisterPersonalClick = () =>
this.trackAndNavigate(
TrackingAction.EVENT_NAME.START.OPENED_PERSONAL_REGISTRATION,
`${ROUTE.LOGIN}?hl=${this.props.language}#register`
);
onRegisterPersonalClick = () => {
const locationPath = pathWithParams(ROUTE.LOGIN, 'mode=register');
this.trackAndNavigate(TrackingAction.EVENT_NAME.START.OPENED_PERSONAL_REGISTRATION, locationPath);
};

onRegisterTeamClick = () => {
return Promise.resolve()
.then(() => this.props.trackEvent({name: TrackingAction.EVENT_NAME.START.OPENED_TEAM_REGISTRATION}))
.then(() => this.props.history.push(ROUTE.CREATE_TEAM));
this.props.trackEvent({name: TrackingAction.EVENT_NAME.START.OPENED_TEAM_REGISTRATION});
this.props.history.push(ROUTE.CREATE_TEAM);
};

onLoginClick = () => {
const searchParams = window.location.search;
this.trackAndNavigate(TrackingAction.EVENT_NAME.START.OPENED_LOGIN, `${ROUTE.LOGIN}${searchParams}#login`);
const locationPath = pathWithParams(ROUTE.LOGIN, 'mode=login');
this.trackAndNavigate(TrackingAction.EVENT_NAME.START.OPENED_LOGIN, locationPath);
};

trackAndNavigate = (eventName, url) => {
Expand Down
35 changes: 35 additions & 0 deletions app/script/auth/util/urlUtil.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Wire
* Copyright (C) 2017 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/

export function pathWithParams(path, additionalParam) {
const searchParams = window.location.search
.replace(/^\?/, '')
.split('&')
.filter(searchParam => searchParam);

if (additionalParam) {
searchParams.push(additionalParam);
}
const joinedParams = searchParams.join('&');
return `${path}${joinedParams.length ? `?${joinedParams}` : ''}`;
}

export function getURLParameter(parameterName) {
return (window.location.search.split(`${parameterName}=`)[1] || '').split('&')[0];
}
14 changes: 13 additions & 1 deletion app/script/view_model/AuthViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ z.ViewModel.AuthViewModel = class AuthViewModel {
z.auth.URLParameter.BOT_PROVIDER,
z.auth.URLParameter.BOT_SERVICE,
z.auth.URLParameter.ENVIRONMENT,
z.auth.URLParameter.LOCALE,
z.auth.URLParameter.TRACKING,
],
};
Expand Down Expand Up @@ -314,6 +315,16 @@ z.ViewModel.AuthViewModel = class AuthViewModel {
}

_init_url_parameter() {
const mode = z.util.get_url_parameter(z.auth.URLParameter.MODE);
if (mode) {
const expectedModes = [z.auth.AuthView.MODE.ACCOUNT_LOGIN, z.auth.AuthView.MODE.ACCOUNT_REGISTER];
const isExpectedMode = expectedModes.includes(mode);
if (isExpectedMode) {
this._set_hash(mode);
return;
}
}

const is_connect = z.util.get_url_parameter(z.auth.URLParameter.CONNECT);
if (is_connect) {
this.get_wire(true);
Expand Down Expand Up @@ -1175,7 +1186,8 @@ z.ViewModel.AuthViewModel = class AuthViewModel {
}

clicked_on_navigate_back() {
window.location.replace(`/auth${location.search}`);
const locationPath = this._append_existing_parameters('/auth/');
window.location.replace(locationPath);
}

click_on_remove_device_submit(password, device) {
Expand Down

0 comments on commit 16bd313

Please sign in to comment.