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

finalized frontend code removal

Jonas Jabari052f2d030a60
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.ts
index 6f77ddbc86f..76711600c94 100644
--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.ts
+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.ts
@@ -28,17 +28,7 @@
import { ChangeDetectorRef, Directive, OnInit } from '@angular/core';
import { UIRouterGlobals } from '@uirouter/core';
-import { Observable } from 'rxjs';
-import { distinctUntilChanged, map } from 'rxjs/operators';
-import { take } from 'rxjs/internal/operators/take';
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
-import { HalResource } from 'core-app/features/hal/resources/hal-resource';
-import {
- ActivityEntryInfo,
-} from 'core-app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-entry-info';
-import {
- WorkPackagesActivityService,
-} from 'core-app/features/work-packages/components/wp-single-view-tabs/activity-panel/wp-activity.service';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
@@ -53,177 +43,22 @@ export class ActivityPanelBaseController extends UntilDestroyedMixin implements
public workPackageId:string;
- // All activities retrieved for the work package
- public unfilteredActivities:HalResource[] = [];
-
- // Visible activities
- public visibleActivities:ActivityEntryInfo[] = [];
-
- public reverse:boolean;
-
- public showToggler:boolean;
-
- public onlyComments = false;
-
- public togglerText:string;
-
- public text = {
- commentsOnly: this.I18n.t('js.label_activity_show_only_comments'),
- showAll: this.I18n.t('js.label_activity_show_all'),
- };
-
public turboFrameSrc:string;
- private additionalScrollMargin = 200;
-
- private initialized = false;
-
- private comingFromNotifications = false;
-
constructor(
readonly apiV3Service:ApiV3Service,
readonly I18n:I18nService,
readonly cdRef:ChangeDetectorRef,
readonly uiRouterGlobals:UIRouterGlobals,
- readonly wpActivity:WorkPackagesActivityService,
readonly storeService:WpSingleViewService,
readonly browserDetector:BrowserDetector,
- private wpSingleViewService:WpSingleViewService,
readonly deviceService:DeviceService,
readonly pathHelper:PathHelperService,
) {
super();
-
- this.reverse = wpActivity.isReversed;
- this.togglerText = this.text.commentsOnly;
-
- if (window.location.href.includes('/notifications')) {
- this.comingFromNotifications = true;
- }
}
ngOnInit():void {
- this.initialized = false;
- this
- .apiV3Service
- .work_packages
- .id(this.workPackageId)
- .requireAndStream()
- .pipe(this.untilDestroyed())
- .subscribe((wp) => {
- this.workPackage = wp;
- this.reloadActivities();
- });
-
- this
- .wpSingleViewService
- .selectNotificationsCount$
- .pipe(
- this.untilDestroyed(),
- distinctUntilChanged(),
- )
- .subscribe(() => {
- this.reloadActivities();
- });
-
- this.turboFrameSrc = `${this.pathHelper.staticBase}/work_packages/${this.workPackage.id}/activities`;
- }
-
- private scrollIfNotificationPresent() {
- this
- .storeService
- .hasNotifications$
- .pipe(take(1))
- .subscribe((hasNotification) => {
- if (hasNotification) {
- this.scrollToUnreadNotification();
- }
- });
- }
-
- private reloadActivities() {
- void this.wpActivity.require(this.workPackage, true).then((activities:HalResource[]) => {
- this.updateActivities(activities);
- this.cdRef.detectChanges();
-
- if (!this.initialized) {
- this.initialized = true;
- this.scrollIfNotificationPresent();
- }
- });
- }
-
- protected updateActivities(activities:HalResource[]):void {
- this.unfilteredActivities = activities;
-
- const visible = this.getVisibleActivities();
- this.visibleActivities = visible.map((el:HalResource, i:number) => this.info(el, i));
- this.showToggler = this.shouldShowToggler();
- }
-
- protected shouldShowToggler():boolean {
- const countAll = this.unfilteredActivities.length;
- const countWithComments = this.getActivitiesWithComments().length;
-
- return countAll > 1
- && countWithComments > 0
- && countWithComments < this.unfilteredActivities.length;
- }
-
- protected getVisibleActivities():HalResource[] {
- if (!this.onlyComments) {
- return this.unfilteredActivities;
- }
- return this.getActivitiesWithComments();
- }
-
- protected getActivitiesWithComments():HalResource[] {
- return this.unfilteredActivities
- .filter((activity:HalResource) => !!_.get(activity, 'comment.html'));
- }
-
- protected hasUnreadNotification(activityHref:string):Observable<boolean> {
- return this
- .storeService
- .selectNotifications$
- .pipe(
- map((notifications) => (
- !!notifications.find((notification) => notification._links.activity?.href === activityHref)
- )),
- );
- }
-
- protected scrollToUnreadNotification():void {
- const unreadNotifications = document.querySelectorAll("[data-notification-selector='notification-activity']");
- // scroll to the unread notification only if there is no deep link
- if (window.location.href.indexOf('activity#') > -1 || unreadNotifications.length === 0) {
- return;
- }
-
- const notificationElement = unreadNotifications[this.reverse ? unreadNotifications.length - 1 : 0] as HTMLElement;
- const scrollContainer = document.querySelectorAll("[data-notification-selector='notification-scroll-container']")[0];
-
- const scrollOffset = notificationElement.offsetTop - (scrollContainer as HTMLElement).offsetTop - this.additionalScrollMargin;
- scrollContainer.scrollTop = scrollOffset;
-
- // Make sure the scrollContainer is visible on mobile
- if (this.comingFromNotifications && this.deviceService.isMobile) {
- scrollContainer.scrollIntoView(true);
- }
- }
-
- public toggleComments():void {
- this.onlyComments = !this.onlyComments;
- this.updateActivities(this.unfilteredActivities);
-
- if (this.onlyComments) {
- this.togglerText = this.text.showAll;
- } else {
- this.togglerText = this.text.commentsOnly;
- }
- }
-
- public info(activity:HalResource, index:number):ActivityEntryInfo {
- return this.wpActivity.info(this.unfilteredActivities, activity, index);
+ this.turboFrameSrc = `${this.pathHelper.staticBase}/work_packages/${this.workPackageId}/activities`;
}
}
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-entry-info.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-entry-info.ts
deleted file mode 100644
index fbe25692a90..00000000000
--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-entry-info.ts
+++ /dev/null
@@ -1,101 +0,0 @@
-//-- copyright
-// OpenProject is an open source project management software.
-// Copyright (C) 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 { TimezoneService } from 'core-app/core/datetime/timezone.service';
-import { HalResource } from 'core-app/features/hal/resources/hal-resource';
-import * as moment from 'moment-timezone';
-
-export class ActivityEntryInfo {
- public date = this.activityDate(this.activity);
-
- public dateOfPrevious = this.index > 0 ? this.activityDate(this.activities[this.index - 1]) : undefined;
-
- public isNextDate = this.date !== this.dateOfPrevious;
-
- constructor(public timezoneService:TimezoneService,
- public isReversed:boolean,
- public activities:any[],
- public activity:HalResource,
- public index:number) {
- }
-
- public number(forceReverse = false):number {
- return this.orderedIndex(this.index, forceReverse);
- }
-
- public get href():string {
- return this.activity.href as string;
- }
-
- public get identifier():string {
- return `${this.href}-${this.version}-${this.updatedAt}`;
- }
-
- public get version():number {
- return this.activity.version as number;
- }
-
- public get updatedAt():string {
- return this.activity.updatedAt as string;
- }
-
- public isInitial(forceReverse = false) {
- let activityNo = this.number(forceReverse);
-
- if (this.activity._type.indexOf('Activity') !== 0) {
- return false;
- }
-
- if (activityNo === 1) {
- return true;
- }
-
- while (--activityNo > 0) {
- const idx = this.orderedIndex(activityNo, forceReverse) - 1;
- const activity = this.activities[idx];
- if (!_.isNil(activity) && activity._type.indexOf('Activity') === 0) {
- return false;
- }
- }
-
- return true;
- }
-
- protected activityDate(activity:any) {
- // Force long date regardless of current date settings for headers
- return moment(activity.createdAt).format('LL');
- }
-
- protected orderedIndex(activityNo:number, forceReverse = false) {
- if (forceReverse || this.isReversed) {
- return this.activities.length - activityNo;
- }
-
- return activityNo + 1;
- }
-}
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/wp-activity.service.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/wp-activity.service.ts
index 34b967b7645..91d333353b0 100644
--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/wp-activity.service.ts
+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/wp-activity.service.ts
@@ -32,7 +32,6 @@ import { Injectable } from '@angular/core';
import { ConfigurationService } from 'core-app/core/config/configuration.service';
import { WorkPackageLinkedResourceCache } from 'core-app/features/work-packages/components/wp-single-view-tabs/wp-linked-resource-cache.service';
import { TimezoneService } from 'core-app/core/datetime/timezone.service';
-import { ActivityEntryInfo } from './activity-entry-info';
@Injectable()
export class WorkPackagesActivityService extends WorkPackageLinkedResourceCache<HalResource[]> {
@@ -78,8 +77,4 @@ export class WorkPackagesActivityService extends WorkPackageLinkedResourceCache<
}
return sorted;
}
-
- public info(activities:HalResource[], activity:HalResource, index:number) {
- return new ActivityEntryInfo(this.timezoneService, this.isReversed, activities, activity, index);
- }
}