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

Re-add the view selector button and hide it behind the gantt feature flag

Henriette Darge3976ca566203
diff --git a/frontend/src/app/features/work-packages/components/wp-buttons/wp-view-toggle-button/work-package-view-toggle-button.component.ts b/frontend/src/app/features/work-packages/components/wp-buttons/wp-view-toggle-button/work-package-view-toggle-button.component.ts
new file mode 100644
index 00000000000..35825b1c412
--- /dev/null
+++ b/frontend/src/app/features/work-packages/components/wp-buttons/wp-view-toggle-button/work-package-view-toggle-button.component.ts
@@ -0,0 +1,102 @@
+// -- copyright
+// OpenProject is an open source project management software.
+// Copyright (C) 2012-2024 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 COPYRIGHT and LICENSE files for more details.
+//++
+
+import {
+ ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit,
+} from '@angular/core';
+import { I18nService } from 'core-app/core/i18n/i18n.service';
+import {
+ WorkPackageViewDisplayRepresentationService,
+ wpDisplayCardRepresentation,
+ wpDisplayListRepresentation,
+} from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-display-representation.service';
+import { WorkPackageViewTimelineService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-timeline.service';
+import { combineLatest } from 'rxjs';
+import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
+
+@Component({
+ template: `
+ <button class="button"
+ id="wp-view-toggle-button"
+ wpViewDropdown>
+ <op-icon icon-classes="button--icon icon-view-{{view}}"></op-icon>
+ <span class="button--text"
+ aria-hidden="true"
+ [textContent]="text[view]">
+ </span>
+ <span class="spot-icon spot-icon_dropdown"></span>
+ </button>
+ `,
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ selector: 'wp-view-toggle-button',
+})
+export class WorkPackageViewToggleButtonComponent extends UntilDestroyedMixin implements OnInit {
+ public view:string;
+
+ public text:any = {
+ card: this.I18n.t('js.views.card'),
+ list: this.I18n.t('js.views.list'),
+ timeline: this.I18n.t('js.views.timeline'),
+ };
+
+ constructor(
+ readonly I18n:I18nService,
+ readonly cdRef:ChangeDetectorRef,
+ readonly wpDisplayRepresentationService:WorkPackageViewDisplayRepresentationService,
+ readonly wpTableTimeline:WorkPackageViewTimelineService,
+ ) {
+ super();
+ }
+
+ ngOnInit() {
+ const statesCombined = combineLatest([
+ this.wpDisplayRepresentationService.live$(),
+ this.wpTableTimeline.live$(),
+ ]);
+
+ statesCombined.pipe(
+ this.untilDestroyed(),
+ ).subscribe(([display, timelines]) => {
+ this.detectView(display, timelines.visible);
+ this.cdRef.detectChanges();
+ });
+ }
+
+ public detectView(display:string|null, timelineVisible:boolean) {
+ if (display === wpDisplayCardRepresentation) {
+ this.view = wpDisplayCardRepresentation;
+ return;
+ }
+
+ if (timelineVisible) {
+ this.view = 'timeline';
+ } else {
+ this.view = wpDisplayListRepresentation;
+ }
+ }
+}
diff --git a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.modal.ts b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.modal.ts
index 21ff1abc755..a43974d0183 100644
--- a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.modal.ts
+++ b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.modal.ts
@@ -68,7 +68,7 @@ export class WpTableConfigurationModalComponent extends OpModalComponent impleme
// Try to load an optional provided configuration service, and fall back to the default one
private wpTableConfigurationService:WpTableConfigurationService =
- this.injector.get(WpTableConfigurationService, new WpTableConfigurationService(this.I18n, this.$state));
+ this.injector.get(WpTableConfigurationService, new WpTableConfigurationService(this.I18n, this.$state, this.configurationService));
constructor(
@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,
@@ -87,6 +87,7 @@ export class WpTableConfigurationModalComponent extends OpModalComponent impleme
readonly ConfigurationService:ConfigurationService,
readonly elementRef:ElementRef,
readonly $state:StateService,
+ readonly configurationService:ConfigurationService,
) {
super(locals, cdRef, elementRef);
}
diff --git a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.service.ts b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.service.ts
index be119cedf33..487d2197f19 100644
--- a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.service.ts
+++ b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.service.ts
@@ -9,6 +9,7 @@ import { WpTableConfigurationTimelinesTabComponent } from 'core-app/features/wor
import { WpTableConfigurationHighlightingTabComponent } from 'core-app/features/work-packages/components/wp-table/configuration-modal/tabs/highlighting-tab.component';
import { OpBaselineComponent } from 'core-app/features/work-packages/components/wp-baseline/baseline/baseline.component';
import { StateService } from '@uirouter/angular';
+import { ConfigurationService } from 'core-app/core/config/configuration.service';
@Injectable()
export class WpTableConfigurationService {
@@ -48,11 +49,12 @@ export class WpTableConfigurationService {
constructor(
readonly I18n:I18nService,
readonly $state:StateService,
+ readonly configurationService:ConfigurationService,
) {
}
public get tabs() {
- if (this.$state.current.name?.includes('work-packages') || this.$state.current.name?.includes('bim')) {
+ if (this.configurationService.activeFeatureFlags.includes('showSeparateGanttModule') && (this.$state.current.name?.includes('work-packages') || this.$state.current.name?.includes('bim'))) {
return this._tabs;
}
diff --git a/frontend/src/app/features/work-packages/components/wp-table/external-configuration/restricted-wp-table-configuration.service.ts b/frontend/src/app/features/work-packages/components/wp-table/external-configuration/restricted-wp-table-configuration.service.ts
index d1b91c01a0a..48ac6edfe9c 100644
--- a/frontend/src/app/features/work-packages/components/wp-table/external-configuration/restricted-wp-table-configuration.service.ts
+++ b/frontend/src/app/features/work-packages/components/wp-table/external-configuration/restricted-wp-table-configuration.service.ts
@@ -5,6 +5,7 @@ import { WpTableConfigurationService } from 'core-app/features/work-packages/com
import { QueryConfigurationLocals } from 'core-app/features/work-packages/components/wp-table/external-configuration/external-query-configuration.component';
import { OpQueryConfigurationLocalsToken } from 'core-app/features/work-packages/components/wp-table/external-configuration/external-query-configuration.constants';
import { StateService } from '@uirouter/angular';
+import { ConfigurationService } from 'core-app/core/config/configuration.service';
@Injectable()
export class RestrictedWpTableConfigurationService extends WpTableConfigurationService {
@@ -12,8 +13,9 @@ export class RestrictedWpTableConfigurationService extends WpTableConfigurationS
@Inject(OpQueryConfigurationLocalsToken) readonly locals:QueryConfigurationLocals,
readonly I18n:I18nService,
readonly $state:StateService,
+ readonly configurationService:ConfigurationService,
) {
- super(I18n, $state);
+ super(I18n, $state, configurationService);
}
public get tabs():TabInterface[] {
diff --git a/frontend/src/app/features/work-packages/openproject-work-packages.module.ts b/frontend/src/app/features/work-packages/openproject-work-packages.module.ts
index 433283cc79d..253d67cc613 100644
--- a/frontend/src/app/features/work-packages/openproject-work-packages.module.ts
+++ b/frontend/src/app/features/work-packages/openproject-work-packages.module.ts
@@ -414,6 +414,7 @@ import {
import {
WorkPackageShareModalComponent,
} from 'core-app/features/work-packages/components/wp-share-modal/wp-share.modal';
+import { WorkPackageViewToggleButtonComponent } from 'core-app/features/work-packages/components/wp-buttons/wp-view-toggle-button/work-package-view-toggle-button.component';
@NgModule({
imports: [
@@ -644,6 +645,7 @@ import {
// Card view
WorkPackageCardViewComponent,
WorkPackageSingleCardComponent,
+ WorkPackageViewToggleButtonComponent,
// Notifications
WorkPackageMarkNotificationButtonComponent,
diff --git a/frontend/src/app/features/work-packages/routing/wp-view-page/wp-view-page.component.ts b/frontend/src/app/features/work-packages/routing/wp-view-page/wp-view-page.component.ts
index f24f68304d4..b582e36ee6e 100644
--- a/frontend/src/app/features/work-packages/routing/wp-view-page/wp-view-page.component.ts
+++ b/frontend/src/app/features/work-packages/routing/wp-view-page/wp-view-page.component.ts
@@ -45,6 +45,7 @@ import { of } from 'rxjs';
import { WorkPackageFoldToggleButtonComponent } from 'core-app/features/work-packages/components/wp-buttons/wp-fold-toggle-button/wp-fold-toggle-button.component';
import { OpProjectIncludeComponent } from 'core-app/shared/components/project-include/project-include.component';
import { OpBaselineModalComponent } from 'core-app/features/work-packages/components/wp-baseline/baseline-modal/baseline-modal.component';
+import { WorkPackageViewToggleButtonComponent } from 'core-app/features/work-packages/components/wp-buttons/wp-view-toggle-button/work-package-view-toggle-button.component';
@Component({
selector: 'wp-view-page',
@@ -79,6 +80,11 @@ export class WorkPackageViewPageComponent extends PartitionedQuerySpacePageCompo
{
component: WorkPackageFilterButtonComponent,
},
+ {
+ component: WorkPackageViewToggleButtonComponent,
+ containerClasses: 'hidden-for-tablet',
+ show: () => !this.configuration.activeFeatureFlags.includes('showSeparateGanttModule'),
+ },
{
component: WorkPackageFoldToggleButtonComponent,
show: () => !!(this.currentQuery && this.currentQuery.groupBy),
@@ -120,7 +126,7 @@ export class WorkPackageViewPageComponent extends PartitionedQuerySpacePageCompo
}
private get stateName() {
- if (this.$state.current.name?.includes('gantt')) {
+ if (this.configuration.activeFeatureFlags.includes('showSeparateGanttModule') && this.$state.current.name?.includes('gantt')) {
return 'gantt.partitioned.list.new';
}
diff --git a/spec/features/work_packages/timeline/timeline_navigation_spec.rb b/spec/features/work_packages/timeline/timeline_navigation_spec.rb
index 04641ed86a8..c0ada3d92ef 100644
--- a/spec/features/work_packages/timeline/timeline_navigation_spec.rb
+++ b/spec/features/work_packages/timeline/timeline_navigation_spec.rb
@@ -47,16 +47,11 @@ RSpec.describe 'Work package timeline navigation',
due_date: Date.current + 5.days)
end
- let!(:query_tl) do
+ let!(:query) do
query = build(:query_with_view_gantt, user:, project:)
- query.column_names = ['id', 'type', 'subject']
- query.filters.clear
- query.add_filter('type_id', '=', [type2.id])
query.timeline_visible = true
- query.name = 'Query with Timeline'
query.save!
-
query
end
@@ -97,6 +92,19 @@ RSpec.describe 'Work package timeline navigation',
query
end
+ let!(:query_tl) do
+ query = build(:query_with_view_gantt, user:, project:)
+ query.column_names = ['id', 'type', 'subject']
+ query.filters.clear
+ query.add_filter('type_id', '=', [type2.id])
+ query.timeline_visible = true
+ query.name = 'Query with Timeline'
+
+ query.save!
+
+ query
+ end
+
it 'can move from and to the timeline query (Regression test #26086)' do
# Visit timeline query
wp_timeline.visit_query query_tl
@@ -144,7 +152,7 @@ RSpec.describe 'Work package timeline navigation',
end
it 'can save the open state and zoom of timeline' do
- wp_timeline.visit_query query_tl
+ wp_timeline.visit_query query
wp_timeline.expect_work_package_listed(work_package)
# Should be initially open
@@ -162,7 +170,7 @@ RSpec.describe 'Work package timeline navigation',
wp_timeline.expect_zoom_at :weeks
# Save the query
- settings_menu.open_and_save_query 'foobar'
+ settings_menu.open_and_save_query_as 'foobar'
wp_timeline.expect_title 'foobar'
# Check the query
@@ -201,8 +209,18 @@ RSpec.describe 'Work package timeline navigation',
end
let(:hierarchy) { Components::WorkPackages::Hierarchies.new }
+ let!(:query) do
+ query = build(:query_with_view_gantt, user:, project:)
+ query.show_hierarchies = true
+ query.timeline_visible = true
+
+ query.save!
+ query
+ end
+
it 'toggles the hierarchy in both views' do
- wp_timeline.visit_query query_tl
+ wp_timeline.visit_query query
+ loading_indicator_saveguard
wp_timeline.expect_work_package_listed(work_package)
wp_timeline.expect_work_package_listed(child_work_package)