handle redirect params for create org/premium

This commit is contained in:
Kyle Spearrin 2018-07-20 10:29:40 -04:00
parent a5246df3ed
commit b99df5905f
6 changed files with 54 additions and 8 deletions

View File

@ -32,6 +32,12 @@ export class LoginComponent extends BaseLoginComponent {
if (qParams.email != null && qParams.email.indexOf('@') > -1) {
this.email = qParams.email;
}
if (qParams.premium != null) {
this.stateService.save('loginRedirect', { route: '/settings/premium' });
} else if (qParams.org != null) {
this.stateService.save('loginRedirect',
{ route: '/settings/create-organization', qParams: { plan: qParams.org } });
}
await super.ngOnInit();
});
}
@ -41,7 +47,13 @@ export class LoginComponent extends BaseLoginComponent {
if (invite != null) {
this.router.navigate(['accept-organization'], { queryParams: invite });
} else {
this.router.navigate([this.successRoute]);
const loginRedirect = await this.stateService.get<any>('loginRedirect');
if (loginRedirect != null) {
this.router.navigate([loginRedirect.route], { queryParams: loginRedirect.qParams });
await this.stateService.remove('loginRedirect');
} else {
this.router.navigate([this.successRoute]);
}
}
}
}

View File

@ -4,6 +4,9 @@
<p class="lead text-center mb-4">{{'createAccount' | i18n}}</p>
<div class="card">
<div class="card-body">
<app-callout title="{{'createOrganizationStep1' | i18n}}" type="info" icon="fa-thumb-tack" *ngIf="showCreateOrgMessage">
{{'createOrganizationCreatePersonalAccount' | i18n}}
</app-callout>
<div class="form-group">
<label for="email">{{'emailAddress' | i18n}}</label>
<input id="email" class="form-control" type="text" name="Email" [(ngModel)]="email" required [appAutofocus]="email === ''"

View File

@ -20,6 +20,8 @@ import { RegisterComponent as BaseRegisterComponent } from 'jslib/angular/compon
templateUrl: 'register.component.html',
})
export class RegisterComponent extends BaseRegisterComponent {
showCreateOrgMessage = false;
constructor(authService: AuthService, router: Router,
analytics: Angulartics2, toasterService: ToasterService,
i18nService: I18nService, cryptoService: CryptoService,
@ -33,6 +35,13 @@ export class RegisterComponent extends BaseRegisterComponent {
if (qParams.email != null && qParams.email.indexOf('@') > -1) {
this.email = qParams.email;
}
if (qParams.premium != null) {
this.stateService.save('loginRedirect', { route: '/settings/premium' });
} else if (qParams.org != null) {
this.showCreateOrgMessage = true;
this.stateService.save('loginRedirect',
{ route: '/settings/create-organization', qParams: { plan: qParams.org } });
}
});
}
}

View File

@ -63,7 +63,13 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
if (invite != null) {
this.router.navigate(['accept-organization'], { queryParams: invite });
} else {
this.router.navigate([this.successRoute]);
const loginRedirect = await this.stateService.get<any>('loginRedirect');
if (loginRedirect != null) {
this.router.navigate([loginRedirect.route], { queryParams: loginRedirect.qParams });
await this.stateService.remove('loginRedirect');
} else {
this.router.navigate([this.successRoute]);
}
}
}
}

View File

@ -1,11 +1,12 @@
import {
Component,
EventEmitter,
Output,
OnInit,
ViewChild,
} from '@angular/core';
import { Router } from '@angular/router';
import {
ActivatedRoute,
Router,
} from '@angular/router';
import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2';
@ -25,7 +26,7 @@ import { OrganizationCreateRequest } from 'jslib/models/request/organizationCrea
selector: 'app-create-organization',
templateUrl: 'create-organization.component.html',
})
export class CreateOrganizationComponent {
export class CreateOrganizationComponent implements OnInit {
@ViewChild(PaymentComponent) paymentComponent: PaymentComponent;
selfHosted = false;
@ -83,10 +84,19 @@ export class CreateOrganizationComponent {
constructor(private apiService: ApiService, private i18nService: I18nService,
private analytics: Angulartics2, private toasterService: ToasterService,
platformUtilsService: PlatformUtilsService, private cryptoService: CryptoService,
private router: Router, private syncService: SyncService) {
private router: Router, private syncService: SyncService,
private route: ActivatedRoute) {
this.selfHosted = platformUtilsService.isSelfHost();
}
ngOnInit() {
this.route.queryParams.subscribe(async (qParams) => {
if (qParams.plan === 'families' || qParams.plan === 'teams' || qParams.plan === 'enterprise') {
this.plan = qParams.plan;
}
});
}
async submit() {
let files: FileList = null;
if (this.selfHosted) {

View File

@ -2325,5 +2325,11 @@
},
"upgradeOrganizationDesc": {
"message": "This feature is not available for free organizations. Switch to a paid plan to unlock more features."
},
"createOrganizationStep1": {
"message": "Create Organization: Step 1"
},
"createOrganizationCreatePersonalAccount": {
"message": "Before creating your organization, you first need to create a free personal account."
}
}