Skip to content

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

Use different components for active trial

Oliver Günther060d5664cecd
diff --git a/app/views/enterprises/_current.html.erb b/app/views/enterprises/_current.html.erb
index 5514c2f40db..8685e9612c1 100644
--- a/app/views/enterprises/_current.html.erb
+++ b/app/views/enterprises/_current.html.erb
@@ -1,9 +1,9 @@
-<enterprise-active-trial data-subscriber="<%= @current_token.subscriber %>"
+<enterprise-active-saved-trial data-subscriber="<%= @current_token.subscriber %>"
data-email="<%= @current_token.mail %>"
data-user-count="<%= @current_token.restrictions.nil? ? t('js.admin.enterprise.upsale.unlimited') : @current_token.restrictions[:active_user_count] %>"
data-starts-at="<%= format_date @current_token.starts_at %>"
data-expires-at="<%= (!@current_token.will_expire?) ? t('js.admin.enterprise.upsale.unlimited') : (format_date @current_token.expires_at) %>">
-</enterprise-active-trial>
+</enterprise-active-saved-trial>
<%= form_tag({}, method: :delete) do %>
<confirm-form-submit></confirm-form-submit>
diff --git a/frontend/src/app/angular4-modules.ts b/frontend/src/app/angular4-modules.ts
index 98fdcca8bed..a5f5860873a 100644
--- a/frontend/src/app/angular4-modules.ts
+++ b/frontend/src/app/angular4-modules.ts
@@ -40,12 +40,6 @@ import {ConfirmDialogModal} from "core-components/modals/confirm-dialog/confirm-
import {ConfirmDialogService} from "core-components/modals/confirm-dialog/confirm-dialog.service";
import {DynamicContentModal} from "core-components/modals/modal-wrapper/dynamic-content.modal";
import {PasswordConfirmationModal} from "core-components/modals/request-for-confirmation/password-confirmation.modal";
-import {EnterpriseBaseComponent} from "core-components/enterprise/enterprise-base.component";
-import {EnterpriseTrialModal} from "core-components/enterprise/enterprise-modal/enterprise-trial.modal";
-import {EETrialFormComponent} from "core-components/enterprise/enterprise-modal/enterprise-trial-form/ee-trial-form.component";
-import {EETrialWaitingComponent} from "core-components/enterprise/enterprise-trial-waiting/ee-trial-waiting.component";
-import {EEActiveTrialComponent} from "core-components/enterprise/enterprise-active-trial/ee-active-trial.component";
-import {EnterpriseTrialService} from "core-components/enterprise/enterprise-trial.service";
import {OpenprojectFieldsModule} from "core-app/modules/fields/openproject-fields.module";
import {OpenprojectCommonModule} from "core-app/modules/common/openproject-common.module";
import {CommentService} from "core-components/wp-activity/comment-service";
@@ -80,6 +74,7 @@ import {OpenprojectProjectsModule} from "core-app/modules/projects/openproject-p
import {KeyboardShortcutService} from "core-app/modules/a11y/keyboard-shortcut-service";
import {globalDynamicComponents} from "core-app/global-dynamic-components.const";
import {OpenprojectMembersModule} from "core-app/modules/members/members.module";
+import {OpenprojectEnterpriseModule} from "core-components/enterprise/openproject-enterprise.module";
@NgModule({
imports: [
@@ -126,6 +121,7 @@ import {OpenprojectMembersModule} from "core-app/modules/members/members.module"
// Admin module
OpenprojectAdminModule,
+ OpenprojectEnterpriseModule,
// Plugin hooks and modules
OpenprojectPluginsModule,
@@ -139,16 +135,13 @@ import {OpenprojectMembersModule} from "core-app/modules/members/members.module"
ReactiveFormsModule
],
providers: [
- {provide: States, useValue: new States()},
+ { provide: States, useValue: new States() },
{ provide: APP_INITIALIZER, useFactory: initializeServices, deps: [Injector], multi: true },
PaginationService,
OpenProjectFileUploadService,
// Split view
CommentService,
ConfirmDialogService,
-
- // Enterprise Edition
- EnterpriseTrialService
],
declarations: [
OpContextMenuTrigger,
@@ -159,13 +152,6 @@ import {OpenprojectMembersModule} from "core-app/modules/members/members.module"
PasswordConfirmationModal,
WpPreviewModal,
- // Enterprise Edition
- EnterpriseBaseComponent,
- EnterpriseTrialModal,
- EETrialFormComponent,
- EETrialWaitingComponent,
- EEActiveTrialComponent,
-
// Main menu
MainMenuResizerComponent,
MainMenuToggleComponent,
@@ -197,7 +183,7 @@ export class OpenProjectModule {
const hookService = (appRef as any)._injector.get(HookService);
hookService
.call('openProjectAngularBootstrap')
- .forEach((results:{selector:string, cls:any}[]) => {
+ .forEach((results:{ selector:string, cls:any }[]) => {
DynamicBootstrapper.bootstrapOptionalDocument(appRef, document, results);
});
}
diff --git a/frontend/src/app/components/enterprise/enterprise-active-trial/ee-active-saved-trial.component.ts b/frontend/src/app/components/enterprise/enterprise-active-trial/ee-active-saved-trial.component.ts
new file mode 100644
index 00000000000..42d84c33739
--- /dev/null
+++ b/frontend/src/app/components/enterprise/enterprise-active-trial/ee-active-saved-trial.component.ts
@@ -0,0 +1,51 @@
+// -- copyright
+// OpenProject is an open source project management software.
+// Copyright (C) 2012-2020 the OpenProject GmbH
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License version 3.
+//
+// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+// Copyright (C) 2006-2013 Jean-Philippe Lang
+// Copyright (C) 2010-2013 the ChiliProject Team
+//
+// 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 2
+// 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, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See docs/COPYRIGHT.rdoc for more details.
+// ++
+
+import {Component, ElementRef} from "@angular/core";
+import {I18nService} from "app/modules/common/i18n/i18n.service";
+import {EEActiveTrialBase} from "core-components/enterprise/enterprise-active-trial/ee-active-trial.base";
+
+export const enterpriseActiveSavedTrialSelector = 'enterprise-active-saved-trial';
+
+@Component({
+ selector: enterpriseActiveSavedTrialSelector,
+ templateUrl: './ee-active-trial.component.html',
+ styleUrls: ['./ee-active-trial.component.sass']
+})
+export class EEActiveSavedTrialComponent extends EEActiveTrialBase {
+ public subscriber = this.elementRef.nativeElement.dataset['subscriber'];
+ public email = this.elementRef.nativeElement.dataset['email'];
+ public userCount = this.elementRef.nativeElement.dataset['userCount'];
+ public startsAt = this.elementRef.nativeElement.dataset['startsAt'];
+ public expiresAt = this.elementRef.nativeElement.dataset['expiresAt'];
+
+ constructor(readonly elementRef:ElementRef,
+ readonly I18n:I18nService) {
+ super(I18n);
+ }
+}
diff --git a/frontend/src/app/components/enterprise/enterprise-active-trial/ee-active-trial.base.ts b/frontend/src/app/components/enterprise/enterprise-active-trial/ee-active-trial.base.ts
new file mode 100644
index 00000000000..72b8abc351f
--- /dev/null
+++ b/frontend/src/app/components/enterprise/enterprise-active-trial/ee-active-trial.base.ts
@@ -0,0 +1,44 @@
+// -- copyright
+// OpenProject is an open source project management software.
+// Copyright (C) 2012-2020 the OpenProject GmbH
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License version 3.
+//
+// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+// Copyright (C) 2006-2013 Jean-Philippe Lang
+// Copyright (C) 2010-2013 the ChiliProject Team
+//
+// 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 2
+// 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, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See docs/COPYRIGHT.rdoc for more details.
+// ++
+
+import {UntilDestroyedMixin} from "core-app/helpers/angular/until-destroyed.mixin";
+import {I18nService} from "app/modules/common/i18n/i18n.service";
+
+export class EEActiveTrialBase extends UntilDestroyedMixin {
+ 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'),
+ label_maximum_users: this.I18n.t('js.admin.enterprise.trial.form.label_maximum_users'),
+ label_starts_at: this.I18n.t('js.admin.enterprise.trial.form.label_starts_at'),
+ label_subscriber: this.I18n.t('js.admin.enterprise.trial.form.label_subscriber')
+ };
+
+ constructor(readonly I18n:I18nService) {
+ super();
+ }
+}
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.ts
index 50f90ed7dbe..a8b289e0c27 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
@@ -28,39 +28,31 @@
import {ChangeDetectorRef, Component, ElementRef, OnInit} from "@angular/core";
import {distinctUntilChanged} from "rxjs/operators";
-import {UntilDestroyedMixin} from "core-app/helpers/angular/until-destroyed.mixin";
import {I18nService} from "app/modules/common/i18n/i18n.service";
import {EnterpriseTrialService} from "app/components/enterprise/enterprise-trial.service";
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
-
-export const enterpriseActiveTrialSelector = 'enterprise-active-trial';
+import {EEActiveTrialBase} from "core-components/enterprise/enterprise-active-trial/ee-active-trial.base";
+import {GonService} from "core-app/modules/common/gon/gon.service";
@Component({
- selector: enterpriseActiveTrialSelector,
+ selector: 'enterprise-active-trial',
templateUrl: './ee-active-trial.component.html',
styleUrls: ['./ee-active-trial.component.sass']
})
-export class EEActiveTrialComponent extends UntilDestroyedMixin implements OnInit {
- 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'),
- label_maximum_users: this.I18n.t('js.admin.enterprise.trial.form.label_maximum_users'),
- label_starts_at: this.I18n.t('js.admin.enterprise.trial.form.label_starts_at'),
- label_subscriber: this.I18n.t('js.admin.enterprise.trial.form.label_subscriber')
- };
-
- public subscriber = this.elementRef.nativeElement.dataset['subscriber'];
- public email = this.elementRef.nativeElement.dataset['email'];
- public userCount = this.elementRef.nativeElement.dataset['userCount'];
- public startsAt = this.elementRef.nativeElement.dataset['startsAt'];
- public expiresAt = this.elementRef.nativeElement.dataset['expiresAt'];
+export class EEActiveTrialComponent extends EEActiveTrialBase implements OnInit {
+ public subscriber:string;
+ public email:string;
+ public userCount:string;
+ public startsAt:string;
+ public expiresAt:string;
constructor(readonly elementRef:ElementRef,
readonly cdRef:ChangeDetectorRef,
readonly I18n:I18nService,
- protected http:HttpClient,
+ readonly http:HttpClient,
+ readonly Gon:GonService,
public eeTrialService:EnterpriseTrialService) {
- super();
+ super(I18n);
}
ngOnInit() {
@@ -81,7 +73,7 @@ export class EEActiveTrialComponent extends UntilDestroyedMixin implements OnIni
}
private initialize():void {
- let eeTrialKey = this.loadGonData();
+ let eeTrialKey = this.Gon.get('ee_trial_key') as any;
if (eeTrialKey && !this.eeTrialService.userData) {
// after reload: get data from Augur using the trial key saved in gon
@@ -98,7 +90,7 @@ export class EEActiveTrialComponent extends UntilDestroyedMixin implements OnIni
.toPromise()
.then((userData:any) => {
this.subscriber = userData.first_name + ' ' + userData.last_name;
- this.email = userData.email;
+ this.email = userData.email;
this.eeTrialService.retryConfirmation();
})
.catch((error:HttpErrorResponse) => {
@@ -107,8 +99,4 @@ export class EEActiveTrialComponent extends UntilDestroyedMixin implements OnIni
});
}
- 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/openproject-enterprise.module.ts b/frontend/src/app/components/enterprise/openproject-enterprise.module.ts
new file mode 100644
index 00000000000..f67c27bb619
--- /dev/null
+++ b/frontend/src/app/components/enterprise/openproject-enterprise.module.ts
@@ -0,0 +1,59 @@
+// -- copyright
+// OpenProject is an open source project management software.
+// Copyright (C) 2012-2020 the OpenProject GmbH
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License version 3.
+//
+// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+// Copyright (C) 2006-2013 Jean-Philippe Lang
+// Copyright (C) 2010-2013 the ChiliProject Team
+//
+// 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 2
+// 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, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See docs/COPYRIGHT.rdoc for more details.
+// ++
+
+import {NgModule} from '@angular/core';
+import {OpenprojectCommonModule} from "core-app/modules/common/openproject-common.module";
+import {EnterpriseTrialService} from "core-components/enterprise/enterprise-trial.service";
+import {EnterpriseBaseComponent} from "core-components/enterprise/enterprise-base.component";
+import {EnterpriseTrialModal} from "core-components/enterprise/enterprise-modal/enterprise-trial.modal";
+import {EETrialFormComponent} from "core-components/enterprise/enterprise-modal/enterprise-trial-form/ee-trial-form.component";
+import {EETrialWaitingComponent} from "core-components/enterprise/enterprise-trial-waiting/ee-trial-waiting.component";
+import {EEActiveTrialComponent} from "core-components/enterprise/enterprise-active-trial/ee-active-trial.component";
+import {EEActiveSavedTrialComponent} from "core-components/enterprise/enterprise-active-trial/ee-active-saved-trial.component";
+import {FormsModule, ReactiveFormsModule} from "@angular/forms";
+
+@NgModule({
+ imports: [
+ OpenprojectCommonModule,
+ FormsModule,
+ ReactiveFormsModule
+ ],
+ providers: [
+ EnterpriseTrialService
+ ],
+ declarations: [
+ EnterpriseBaseComponent,
+ EnterpriseTrialModal,
+ EETrialFormComponent,
+ EETrialWaitingComponent,
+ EEActiveTrialComponent,
+ EEActiveSavedTrialComponent,
+ ]
+})
+export class OpenprojectEnterpriseModule {
+}
diff --git a/frontend/src/app/global-dynamic-components.const.ts b/frontend/src/app/global-dynamic-components.const.ts
index 449bfba8e1b..381b9f48e96 100644
--- a/frontend/src/app/global-dynamic-components.const.ts
+++ b/frontend/src/app/global-dynamic-components.const.ts
@@ -126,14 +126,11 @@ import {
MembersAutocompleterComponent,
membersAutocompleterSelector
} from "core-app/modules/members/members-autocompleter.component";
+import {EnterpriseBaseComponent, enterpriseBaseSelector} from "core-components/enterprise/enterprise-base.component";
import {
- EnterpriseBaseComponent,
- enterpriseBaseSelector
-} from "core-components/enterprise/enterprise-base.component";
-import {
- EEActiveTrialComponent,
- enterpriseActiveTrialSelector
-} from "core-components/enterprise/enterprise-active-trial/ee-active-trial.component";
+ EEActiveSavedTrialComponent,
+ enterpriseActiveSavedTrialSelector
+} from "core-components/enterprise/enterprise-active-trial/ee-active-saved-trial.component";
export const globalDynamicComponents:OptionalBootstrapDefinition[] = [
{ selector: appBaseSelector, cls: ApplicationBaseComponent },
@@ -170,7 +167,7 @@ export const globalDynamicComponents:OptionalBootstrapDefinition[] = [
{ selector: collapsibleSectionAugmentSelector, cls: CollapsibleSectionComponent },
{ selector: enterpriseBannerSelector, cls: EnterpriseBannerBootstrapComponent },
{ selector: enterpriseBaseSelector, cls: EnterpriseBaseComponent },
- { selector: enterpriseActiveTrialSelector, cls: EEActiveTrialComponent },
+ { selector: enterpriseActiveSavedTrialSelector, cls: EEActiveSavedTrialComponent },
{ selector: projectMenuAutocompleteSelector, cls: ProjectMenuAutocompleteComponent },
{ selector: remoteFieldUpdaterSelector, cls: RemoteFieldUpdaterComponent },
{ selector: wpEmbeddedTableEntrySelector, cls: WorkPackageEmbeddedTableEntryComponent },