OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Code cleanup
Henriette Dingerb9a2fbb3d753
diff --git a/frontend/src/app/components/enterprise/enterprise-active-trial/ee-active-trial.component.ts b/frontend/src/app/components/enterprise/enterprise-active-trial/ee-active-trial.component.tsindex f8c30683eb0..129fc962c7f 100644--- a/frontend/src/app/components/enterprise/enterprise-active-trial/ee-active-trial.component.ts+++ b/frontend/src/app/components/enterprise/enterprise-active-trial/ee-active-trial.component.ts@@ -38,8 +38,6 @@ import {HttpClient, HttpErrorResponse} from "@angular/common/http";styleUrls: ['./ee-active-trial.component.sass']})export class EEActiveTrialComponent implements OnInit {- public initialData:any;-public text = {label_email: this.I18n.t('js.admin.enterprise.trial.form.label_email'),label_expires_at: this.I18n.t('js.admin.enterprise.trial.form.label_expires_at'),@@ -61,22 +59,21 @@ export class EEActiveTrialComponent implements OnInit {}ngOnInit() {- // trial is not active yetif (!this.subscriber) {this.initialize();}}- // initialize attributes with submitted user dataprivate initialize():void {- this.initialData = this.loadGonData();+ let eeTrialKey = this.loadGonData();- if (!this.initialData) { // get data from service+ if (eeTrialKey) {+ // after reload: get data from Augur using the trial key saved in gon+ this.eeTrialService.trialLink = baseUrlAugur + '/public/v1/trials/' + eeTrialKey.value;+ this.getUserDataFromAugur();+ } else {this.subscriber = this.eeTrialService.userData.subscriber;this.email = this.eeTrialService.userData.email;- } else { // after reload: get data from Augur using the trial key saved in gon- this.eeTrialService.trialLink = baseUrlAugur + '/public/v1/trials/' + this.initialData.value;- this.getUserDataFromAugur();}}@@ -96,12 +93,9 @@ export class EEActiveTrialComponent implements OnInit {});}- private loadGonData():{value:string}|null {- try {- return (window as any).gon.ee_trial_key;- } catch (e) {- return null;- }+ private loadGonData():{value:string}|undefined {+ let gon = (window as any).gon;+ return gon ? gon.ee_trial_key : undefined;}}diff --git a/frontend/src/app/components/enterprise/enterprise-trial.service.ts b/frontend/src/app/components/enterprise/enterprise-trial.service.tsindex e76712203db..cf0480b9331 100644--- a/frontend/src/app/components/enterprise/enterprise-trial.service.ts+++ b/frontend/src/app/components/enterprise/enterprise-trial.service.ts@@ -3,7 +3,7 @@ import {I18nService} from "core-app/modules/common/i18n/i18n.service";import {HttpClient, HttpErrorResponse} from "@angular/common/http";import {PathHelperService} from "core-app/modules/common/path-helper/path-helper.service";import {NotificationsService} from "core-app/modules/common/notifications/notifications.service";-import {FormBuilder, FormGroup} from "@angular/forms";+import {FormGroup} from "@angular/forms";export const baseUrlAugur = 'https://augur.openproject-edge.com';@@ -27,10 +27,9 @@ export class EnterpriseTrialService {constructor(readonly I18n:I18nService,protected http:HttpClient,readonly pathHelper:PathHelperService,- protected notificationsService:NotificationsService,- readonly formBuilder:FormBuilder) {+ protected notificationsService:NotificationsService) {if ((window as any).gon) {- this.status = 'mailSubmitted';+ this.setMailSubmittedStatus();}}@@ -42,7 +41,6 @@ export class EnterpriseTrialService {email: form.value.email};this.cancelled = false;- // POST /public/v1/trials/this.http.post(baseUrlAugur + '/public/v1/trials', form.value).toPromise().then((enterpriseTrial:any) => {@@ -55,7 +53,6 @@ export class EnterpriseTrialService {if (error.status === 422 || error.status === 400) {this.errorMsg = error.error.description;} else {- // 500 -> internal error occuredthis.notificationsService.addWarning(error.error.description || I18n.t('js.error.internal'));}});@@ -94,7 +91,7 @@ export class EnterpriseTrialService {this.saveTrialKey(this.resendLink);}// open next modal window -> status waiting- this.status = 'mailSubmitted';+ this.setMailSubmittedStatus();this.confirmed = false;} else if (_.get(error, 'error._type') === 'Error') {this.notificationsService.addError(error.error.message);@@ -111,7 +108,6 @@ export class EnterpriseTrialService {private saveTrialKey(resendlink:string) {// extract token from resend linklet trialKey = resendlink.split('/')[6];- // save requested tokenreturn this.http.post(this.pathHelper.api.v3.appBasePath + '/admin/enterprise/save_trial_key',{ trial_key: trialKey },@@ -125,7 +121,6 @@ export class EnterpriseTrialService {// save received token in controllerprivate saveToken(token:string) {- // POST /admin/enterprise (params[:enterprise_token][:encoded_token])this.http.post(this.pathHelper.api.v3.appBasePath + '/admin/enterprise',{ enterprise_token: { encoded_token: token } },@@ -140,13 +135,10 @@ export class EnterpriseTrialService {// retry request while waiting for mail confirmationpublic retryConfirmation(delay:number, retries:number) {if (this.cancelled || this.confirmed) {- // stop if action was cancelled or confirmation link was clickedreturn;} else if (retries === 0) {- // action timed out -> show messagethis.cancelled = true;} else {- // retry as long as limit isn't reachedthis.getToken();setTimeout( () => {this.retryConfirmation(delay, retries - 1);@@ -158,6 +150,10 @@ export class EnterpriseTrialService {this.status = 'startTrial';}+ public setMailSubmittedStatus() {+ this.status = 'mailSubmitted';+ }+public get trialStarted():boolean {return this.status === 'startTrial';}