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

Rework frontend so that it knows features to be trialled

Oliver Günther3f4bd12c93b9
diff --git a/app/components/enterprise_edition/upsell_buttons_component.rb b/app/components/enterprise_edition/upsell_buttons_component.rb
index 996631ade61..bd520bf670f 100644
--- a/app/components/enterprise_edition/upsell_buttons_component.rb
+++ b/app/components/enterprise_edition/upsell_buttons_component.rb
@@ -66,7 +66,7 @@ module EnterpriseEdition
end
def free_trial_button
- return if EnterpriseToken.active? && EnterpriseToken.trial?
+ return if EnterpriseToken.active?
return unless User.current.admin?
helpers.angular_component_tag(
@@ -76,7 +76,7 @@ module EnterpriseEdition
end
def buy_now_button
- return unless EnterpriseToken.active? && EnterpriseToken.trial?
+ return unless EnterpriseToken.active?
return unless User.current.admin?
render(Primer::Beta::Button.new(
diff --git a/app/models/enterprise_token.rb b/app/models/enterprise_token.rb
index be817e7ba69..e5559fb4a5f 100644
--- a/app/models/enterprise_token.rb
+++ b/app/models/enterprise_token.rb
@@ -45,6 +45,14 @@ class EnterpriseToken < ApplicationRecord
current && !current.expired?
end
+ def available_features
+ EnterpriseToken.current&.available_features || []
+ end
+
+ def trialling_features
+ available_features.select { |feature| trialling?(feature) }
+ end
+
def trialling?(feature)
allows_to?(feature) && EnterpriseToken.current.trial?
end
diff --git a/frontend/src/app/core/config/configuration.service.ts b/frontend/src/app/core/config/configuration.service.ts
index 027a23cc87a..071ac782ae0 100644
--- a/frontend/src/app/core/config/configuration.service.ts
+++ b/frontend/src/app/core/config/configuration.service.ts
@@ -150,6 +150,10 @@ export class ConfigurationService {
return this.systemPreference<string[]>('availableFeatures');
}
+ public get triallingFeatures():string[] {
+ return this.systemPreference<string[]>('triallingFeatures');
+ }
+
private loadConfiguration() {
return this
.apiV3Service
diff --git a/frontend/src/app/core/enterprise/banners.service.ts b/frontend/src/app/core/enterprise/banners.service.ts
index 4a74e35158d..a342b7ab1ff 100644
--- a/frontend/src/app/core/enterprise/banners.service.ts
+++ b/frontend/src/app/core/enterprise/banners.service.ts
@@ -43,7 +43,19 @@ export class BannersService {
}
public showBannerFor(feature:string):boolean {
- return !(this._bannersHidden || this.configuration.availableFeatures.includes(feature));
+ if (this._bannersHidden) {
+ return false;
+ }
+
+ return !this.allowsTo(feature) || this.trialling(feature);
+ }
+
+ public allowsTo(feature:string):boolean {
+ return this.configuration.availableFeatures.includes(feature);
+ }
+
+ public trialling(feature:string):boolean {
+ return this.configuration.triallingFeatures.includes(feature);
}
public getEnterPriseEditionUrl({ referrer, hash }:{ referrer?:string, hash?:string } = {}) {
@@ -59,13 +71,13 @@ export class BannersService {
return url.toString();
}
- public async conditional(feature:string, bannersVisible?:() => void, bannersNotVisible?:() => void) {
+ public async conditional(feature:string, featureAvailable?:() => void, featureNotAvailable?:() => void) {
await this.configuration.initialize();
- if (this.showBannerFor(feature)) {
- this.callMaybe(bannersVisible);
+ if (this.allowsTo(feature)) {
+ this.callMaybe(featureAvailable);
} else {
- this.callMaybe(bannersNotVisible);
+ this.callMaybe(featureNotAvailable);
}
}
diff --git a/frontend/src/app/features/admin/types/type-banner.service.ts b/frontend/src/app/features/admin/types/type-banner.service.ts
index 18a355a5af0..3d5937bf2d7 100644
--- a/frontend/src/app/features/admin/types/type-banner.service.ts
+++ b/frontend/src/app/features/admin/types/type-banner.service.ts
@@ -7,7 +7,7 @@ import { ConfigurationService } from 'core-app/core/config/configuration.service
@Injectable()
export class TypeBannerService extends BannersService {
- showBanners = this.showBannerFor('edit_attribute_groups');
+ eeAvailable = this.allowsTo('edit_attribute_groups');
constructor(
@Inject(DOCUMENT) protected documentElement:Document,
diff --git a/frontend/src/app/features/admin/types/type-form-configuration.html b/frontend/src/app/features/admin/types/type-form-configuration.html
index ef1ca845855..2fd43ea8544 100644
--- a/frontend/src/app/features/admin/types/type-form-configuration.html
+++ b/frontend/src/app/features/admin/types/type-form-configuration.html
@@ -10,7 +10,7 @@
</button>
</li>
<li
- *ngIf="!typeBanner.showBanners"
+ *ngIf="typeBanner.eeAvailable"
class="toolbar-item drop-down">
<a class="form-configuration--add-group button -primary" aria-haspopup="true">
<op-icon icon-classes="button--icon icon-add"></op-icon>
diff --git a/frontend/src/app/features/boards/board/board-actions/board-actions-registry.service.ts b/frontend/src/app/features/boards/board/board-actions/board-actions-registry.service.ts
index fb22c325ef0..c30424c757a 100644
--- a/frontend/src/app/features/boards/board/board-actions/board-actions-registry.service.ts
+++ b/frontend/src/app/features/boards/board/board-actions/board-actions-registry.service.ts
@@ -30,7 +30,7 @@ export class BoardActionsRegistryService {
icon: '',
description: '',
image: '',
- disabled: this.bannersService.showBannerFor('board_view'),
+ disabled: !this.bannersService.allowsTo('board_view'),
}));
}
diff --git a/frontend/src/app/features/boards/board/board-partitioned-page/board-list-container.component.html b/frontend/src/app/features/boards/board/board-partitioned-page/board-list-container.component.html
index 7e2806ea85f..33429b92f95 100644
--- a/frontend/src/app/features/boards/board/board-partitioned-page/board-list-container.component.html
+++ b/frontend/src/app/features/boards/board/board-partitioned-page/board-list-container.component.html
@@ -1,6 +1,11 @@
<ng-container *ngIf="(board$ | async) as board">
+ <op-enterprise-banner-frame
+ class="boards-list--enterprise-banner"
+ feature="board_view"
+ [dismissable]="true"
+ ></op-enterprise-banner-frame>
<div
- *ngIf="!needEnterpriseEdition; else enterpriseBanner"
+ *ngIf="available"
class="boards-list--container"
[ngClass]="{ '-free' : board.isFree }"
#container
@@ -38,12 +43,4 @@
</div>
</div>
</div>
-
- <ng-template #enterpriseBanner>
- <op-enterprise-banner-frame
- class="boards-list--enterprise-banner"
- feature="board_view"
- [dismissable]="true"
- ></op-enterprise-banner-frame>
- </ng-template>
</ng-container>
diff --git a/frontend/src/app/features/boards/board/board-partitioned-page/board-list-container.component.ts b/frontend/src/app/features/boards/board/board-partitioned-page/board-list-container.component.ts
index 94c382b289e..5f16eaf1125 100644
--- a/frontend/src/app/features/boards/board/board-partitioned-page/board-list-container.component.ts
+++ b/frontend/src/app/features/boards/board/board-partitioned-page/board-list-container.component.ts
@@ -88,7 +88,7 @@ export class BoardListContainerComponent extends UntilDestroyedMixin implements
showHiddenListWarning:boolean = false;
- needEnterpriseEdition = this.Banner.showBannerFor('board_view');
+ available = this.Banner.allowsTo('board_view');
private currentQueryUpdatedMonitoring:Subscription;
@@ -126,7 +126,7 @@ readonly I18n:I18nService,
);
this.board$.subscribe((board) => {
- this.needEnterpriseEdition = this.Banner.showBannerFor('board_view') && !board.isFree;
+ this.available = this.Banner.allowsTo('board_view') || board.isFree;
});
this.Boards.currentBoard$.next(id);
diff --git a/frontend/src/app/features/enterprise/enterprise-banner-frame.component.html b/frontend/src/app/features/enterprise/enterprise-banner-frame.component.html
index 7aa8d8d3aff..25e1af41340 100644
--- a/frontend/src/app/features/enterprise/enterprise-banner-frame.component.html
+++ b/frontend/src/app/features/enterprise/enterprise-banner-frame.component.html
@@ -1,5 +1,5 @@
<turbo-frame
- id="enterprise_banner_{{feature}}"
+ [id]="frameID"
*ngIf="visible"
[src]="frameURL"
>
diff --git a/frontend/src/app/features/enterprise/enterprise-banner-frame.component.ts b/frontend/src/app/features/enterprise/enterprise-banner-frame.component.ts
index b3f9cb4b6d8..62aa7175b5c 100644
--- a/frontend/src/app/features/enterprise/enterprise-banner-frame.component.ts
+++ b/frontend/src/app/features/enterprise/enterprise-banner-frame.component.ts
@@ -43,6 +43,7 @@ export class EnterpriseBannerFrameComponent implements OnInit {
visible:boolean;
frameURL:string;
+ frameID:string;
constructor(
protected pathHelper:PathHelperService,
@@ -53,5 +54,8 @@ export class EnterpriseBannerFrameComponent implements OnInit {
ngOnInit() {
this.visible = this.banners.showBannerFor(this.feature);
this.frameURL = this.pathHelper.bannerFramePath(this.feature, this.dismissable);
+
+ const trialSuffix = this.banners.trialling(this.feature) ? '_trial' : '';
+ this.frameID = `enterprise_banner_${this.feature}${trialSuffix}`;
}
}
diff --git a/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts b/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts
index 0c914b367ed..e6cbb6fc963 100644
--- a/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts
+++ b/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts
@@ -119,7 +119,14 @@ export class ProjectSelectionComponent implements OnInit {
}
private setPlaceholderOption():void {
- if (this.bannersService.showBannerFor('placeholder_users')) {
+ if (this.bannersService.allowsTo('placeholder_users')) {
+ this.typeOptions.push({
+ value: PrincipalType.Placeholder,
+ title: this.I18n.t('js.invite_user_modal.type.placeholder.title'),
+ description: this.I18n.t('js.invite_user_modal.type.placeholder.description'),
+ disabled: false,
+ });
+ } else {
this.typeOptions.push({
value: PrincipalType.Placeholder,
title: this.I18n.t('js.invite_user_modal.type.placeholder.title_no_ee'),
@@ -131,13 +138,6 @@ export class ProjectSelectionComponent implements OnInit {
}),
disabled: true,
});
- } else {
- this.typeOptions.push({
- value: PrincipalType.Placeholder,
- title: this.I18n.t('js.invite_user_modal.type.placeholder.title'),
- description: this.I18n.t('js.invite_user_modal.type.placeholder.description'),
- disabled: false,
- });
}
}
diff --git a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.html b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.html
index e5ea4522fbb..c25bab2e653 100644
--- a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.html
+++ b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.html
@@ -71,7 +71,7 @@
<p>{{ text.dateAlerts.description }}</p>
</div>
- <div *ngIf="!eeShowBanners">
+ <div *ngIf="eeAvailable">
<div
class="op-reminder-settings-date-alerts--row"
formGroupName="startDate"
diff --git a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.ts b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.ts
index 21d11713558..6333e0ebb95 100644
--- a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.ts
+++ b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.ts
@@ -54,7 +54,7 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin impl
public availableTimesOverdue = overDueReminderTimes();
- public eeShowBanners = false;
+ public eeAvailable = false;
public form = new UntypedFormGroup({
assignee: new UntypedFormControl(false),
@@ -137,7 +137,7 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin impl
ngOnInit():void {
this.form.disable();
- this.eeShowBanners = this.bannersService.showBannerFor('date_alerts');
+ this.eeAvailable = this.bannersService.allowsTo('date_alerts');
this
.currentUserService
diff --git a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html
index 739bdd7b0e3..826cf8ed54f 100644
--- a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html
+++ b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html
@@ -88,7 +88,7 @@
</ng-container>
</tr>
- <tr *ngIf="!eeShowBanners">
+ <tr *ngIf="eeAvailable">
<th class="op-table--cell op-table--cell_soft-heading">
<h5>{{ text.dateAlerts.title }}</h5>
<p>{{ text.dateAlerts.description }}</p>
@@ -98,7 +98,7 @@
</ng-container>
</tr>
- <tr *ngIf="!eeShowBanners">
+ <tr *ngIf="eeAvailable">
<th class="op-table--cell op-table--cell_soft-heading">
{{ text.startDate }}
</th>
@@ -122,7 +122,7 @@
</ng-container>
</tr>
- <tr *ngIf="!eeShowBanners">
+ <tr *ngIf="eeAvailable">
<th class="op-table--cell op-table--cell_soft-heading">
{{ text.dueDate }}
</th>
@@ -146,7 +146,7 @@
</ng-container>
</tr>
- <tr *ngIf="!eeShowBanners">
+ <tr *ngIf="eeAvailable">
<th class="op-table--cell op-table--cell_soft-heading">
{{ text.overdue }}
</th>
diff --git a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts
index c00ba108824..70bb22ec674 100644
--- a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts
+++ b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts
@@ -21,7 +21,7 @@ export class NotificationSettingsTableComponent implements OnInit {
@Input() settings:UntypedFormArray;
- public eeShowBanners = false;
+ public eeAvailable = false;
public availableTimes = [
{
@@ -81,7 +81,7 @@ export class NotificationSettingsTableComponent implements OnInit {
) {}
ngOnInit():void {
- this.eeShowBanners = this.bannersService.showBannerFor('date_alerts');
+ this.eeAvailable = this.bannersService.allowsTo('date_alerts');
}
projectLink(href:string) {
diff --git a/frontend/src/app/features/work-packages/components/wp-baseline/baseline/baseline.component.ts b/frontend/src/app/features/work-packages/components/wp-baseline/baseline/baseline.component.ts
index 3ddfdcf5b9c..134974f85f9 100644
--- a/frontend/src/app/features/work-packages/components/wp-baseline/baseline/baseline.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-baseline/baseline/baseline.component.ts
@@ -98,7 +98,7 @@ export class OpBaselineComponent extends UntilDestroyedMixin implements OnInit {
public tooltipPosition = SpotDropAlignmentOption.TopRight;
- available = !this.Banner.showBannerFor('baseline_comparison');
+ available = this.Banner.allowsTo('baseline_comparison');
public text = {
toggle_title: this.I18n.t('js.baseline.toggle_title'),
diff --git a/frontend/src/app/features/work-packages/components/wp-buttons/wp-share-button/wp-share-button.component.ts b/frontend/src/app/features/work-packages/components/wp-buttons/wp-share-button/wp-share-button.component.ts
index 85d15a90be9..f739417f7b8 100644
--- a/frontend/src/app/features/work-packages/components/wp-buttons/wp-share-button/wp-share-button.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-buttons/wp-share-button/wp-share-button.component.ts
@@ -52,7 +52,7 @@ import { CollectionResource } from 'core-app/features/hal/resources/collection-r
export class WorkPackageShareButtonComponent extends UntilDestroyedMixin implements OnInit {
@Input() public workPackage:WorkPackageResource;
- showEnterpriseIcon = this.bannersService.showBannerFor('work_package_sharing');
+ showEnterpriseIcon = !this.bannersService.allowsTo('work_package_sharing');
shareCount$:Observable<number>;
diff --git a/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions.component.ts b/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions.component.ts
index 653735e4bb9..95ceb504c89 100644
--- a/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions.component.ts
@@ -48,7 +48,7 @@ export class WpCustomActionsComponent extends UntilDestroyedMixin implements OnI
actions:CustomActionResource[] = [];
- available = !this.bannersService.showBannerFor('custom_actions');
+ available = !this.bannersService.allowsTo('custom_actions');
constructor(
readonly apiV3Service:ApiV3Service,
diff --git a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/highlighting-tab.component.html b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/highlighting-tab.component.html
index cd2a9fc3661..a98b2ee6331 100644
--- a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/highlighting-tab.component.html
+++ b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/highlighting-tab.component.html
@@ -9,7 +9,7 @@
<div class="form--field">
<label class="form--label">
<input type="radio"
- [attr.disabled]="disabledValue(eeShowBanners)"
+ [attr.disabled]="disabledValue(eeAvailable)"
[(ngModel)]="highlightingMode"
(change)="updateMode($event.target.value)"
value="inline"
@@ -41,7 +41,7 @@
<div class="form--field">
<label class="form--label">
<input type="radio"
- [attr.disabled]="disabledValue(eeShowBanners)"
+ [attr.disabled]="disabledValue(eeAvailable)"
[(ngModel)]="entireRowMode"
(change)="updateMode('entire-row')"
[value]="true"
@@ -54,7 +54,7 @@
<ng-select #rowHighlightNgSelect
[items]="availableRowHighlightedAttributes"
[(ngModel)]="lastEntireRowAttribute"
- [disabled]="disabledValue(eeShowBanners)"
+ [disabled]="disabledValue(eeAvailable)"
[clearable]="false"
(open)="onOpen(rowHighlightNgSelect)"
(change)="updateMode($event.value)"
@@ -72,7 +72,7 @@
<div class="form--field">
<label class="form--label">
<input type="radio"
- [attr.disabled]="disabledValue(eeShowBanners)"
+ [attr.disabled]="disabledValue(eeAvailable)"
[(ngModel)]="highlightingMode"
(change)="updateMode($event.target.value)"
value="none"
diff --git a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/highlighting-tab.component.ts b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/highlighting-tab.component.ts
index e352e95cd69..38585a5cc62 100644
--- a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/highlighting-tab.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/highlighting-tab.component.ts
@@ -28,7 +28,7 @@ export class WpTableConfigurationHighlightingTabComponent implements TabComponen
public lastEntireRowAttribute:HighlightingMode = 'status';
- public eeShowBanners = false;
+ public eeAvailable = false;
public availableInlineHighlightedAttributes:HalResource[] = [];
@@ -74,10 +74,10 @@ export class WpTableConfigurationHighlightingTabComponent implements TabComponen
this.setSelectedValues();
- this.eeShowBanners = this.Banners.showBannerFor('conditional_highlighting');
+ this.eeAvailable = this.Banners.allowsTo('conditional_highlighting');
this.updateMode(this.wpTableHighlight.current.mode);
- if (this.eeShowBanners) {
+ if (!this.eeAvailable) {
this.updateMode('none');
}
}
@@ -106,8 +106,8 @@ export class WpTableConfigurationHighlightingTabComponent implements TabComponen
this.selectedAttributes = model;
}
- public disabledValue(value:boolean):string | null {
- return value ? 'disabled' : null;
+ public disabledValue(allowed:boolean):string | null {
+ return allowed ? null : 'disabled';
}
public get availableHighlightedAttributes():HalResource[] {
diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-highlighting.service.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-highlighting.service.ts
index f948d43ce32..858af243b1b 100644
--- a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-highlighting.service.ts
+++ b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-highlighting.service.ts
@@ -32,7 +32,7 @@ export class WorkPackageViewHighlightingService extends WorkPackageQueryStateSer
*/
public shouldHighlightInline(name:string):boolean {
// 1. Are we in inline mode or unable to render?
- if (!this.isInline || this.Banners.showBannerFor('conditional_highlighting')) {
+ if (!this.isInline || !this.Banners.allowsTo('conditional_highlighting')) {
return false;
}
diff --git a/lib/api/v3/configuration/configuration_representer.rb b/lib/api/v3/configuration/configuration_representer.rb
index e1a51d2f7d0..ce33491e3cc 100644
--- a/lib/api/v3/configuration/configuration_representer.rb
+++ b/lib/api/v3/configuration/configuration_representer.rb
@@ -100,7 +100,12 @@ module API
property :available_features,
getter: ->(*) {
- EnterpriseToken.current&.available_features || []
+ EnterpriseToken.available_features
+ }
+
+ property :trialling_features,
+ getter: ->(*) {
+ EnterpriseToken.trialling_features
}
property :allowed_link_protocols,