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

[36236] Unnecessary requests (3 - 4 times too many) on loading the board (#9457)

Henriette Darge5ab91b004788
diff --git a/frontend/src/app/features/boards/board/board-list/board-list.component.ts b/frontend/src/app/features/boards/board/board-list/board-list.component.ts
index 65a427fa969..17ac4299977 100644
--- a/frontend/src/app/features/boards/board/board-list/board-list.component.ts
+++ b/frontend/src/app/features/boards/board/board-list/board-list.component.ts
@@ -76,6 +76,9 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
/** Output fired upon query removal */
@Output() onRemove = new EventEmitter<void>();
+ /* Output fired after it is assured whether a user has the right to see the list */
+ @Output() visibilityChange = new EventEmitter<boolean>();
+
/** Access to the board resource */
@Input() public board:Board;
@@ -396,10 +399,7 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
let observable = this
.apiv3Service
.queries
- .find(this.columnsQueryProps, this.queryId)
- .pipe(
- retry(3),
- );
+ .find(this.columnsQueryProps, this.queryId);
// Spread arguments on pipe does not work:
// https://github.com/ReactiveX/rxjs/issues/3989
@@ -409,8 +409,14 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
observable
.subscribe(
- (query) => this.wpStatesInitialization.updateQuerySpace(query, query.results),
+ (query) => {
+ this.wpStatesInitialization.updateQuerySpace(query, query.results);
+ },
(error) => {
+ const userIsNotAllowedToSeeSubprojectError = 'urn:openproject-org:api:v3:errors:InvalidQuery';
+ if(error.errorIdentifier === userIsNotAllowedToSeeSubprojectError) {
+ this.visibilityChange.emit(false);
+ }
this.loadingError = this.halNotification.retrieveErrorMessage(error);
this.cdRef.detectChanges();
},
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 e12a60e5f31..e42d7ecf4e5 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
@@ -20,9 +20,15 @@
cdkDragHandle></span>
<board-list [resource]="boardWidget"
[board]="board"
- (onRemove)="removeList(board, boardWidget)">
+ (onRemove)="removeList(board, boardWidget)"
+ (visibilityChange)="changeVisibilityOfList(board, boardWidget, $event)">
</board-list>
</div>
+ <span *ngIf="showHiddenListWarning"
+ class="boards-list--tooltip tooltip--right"
+ [attr.data-tooltip]="text.hiddenListWarning">
+ <i class="icon icon-attention"></i>
+ </span>
<div class="boards-list--add-item -no-text-select"
*ngIf="board.editable"
diff --git a/frontend/src/app/features/boards/board/board-partitioned-page/board-list-container.component.sass b/frontend/src/app/features/boards/board/board-partitioned-page/board-list-container.component.sass
index 8a9024e742f..05673d8049b 100644
--- a/frontend/src/app/features/boards/board/board-partitioned-page/board-list-container.component.sass
+++ b/frontend/src/app/features/boards/board/board-partitioned-page/board-list-container.component.sass
@@ -1,6 +1,7 @@
@import 'src/assets/sass/helpers'
$board-list-max-width: 300px
+$board-list-top-offset: 18px
.boards-list--container
display: flex
@@ -17,7 +18,7 @@ $board-list-max-width: 300px
position: absolute
font-size: 14px
left: 0
- top: 18px
+ top: $board-list-top-offset
z-index: 100
opacity: 0
cursor: grab
@@ -60,3 +61,7 @@ $board-list-max-width: 300px
&.cdk-drag-placeholder
@include modifying--placeholder
+
+.boards-list--tooltip
+ align-self: start
+ margin-top: $board-list-top-offset
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 581ce56097c..f7603972028 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
@@ -1,9 +1,5 @@
-import {
- Component, ElementRef, Injector, OnInit, QueryList, ViewChild, ViewChildren,
-} from '@angular/core';
-import {
- forkJoin, Observable, of, Subscription,
-} from 'rxjs';
+import { Component, ElementRef, Injector, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core';
+import { Observable, Subscription } from 'rxjs';
import { QueryResource } from 'core-app/features/hal/resources/query-resource';
import { BoardListComponent } from 'core-app/features/boards/board/board-list/board-list.component';
import { StateService } from '@uirouter/core';
@@ -23,9 +19,7 @@ import { BoardPartitionedPageComponent } from 'core-app/features/boards/board/bo
import { AddListModalComponent } from 'core-app/features/boards/board/add-list-modal/add-list-modal.component';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { BoardListCrossSelectionService } from 'core-app/features/boards/board/board-list/board-list-cross-selection.service';
-import {
- catchError, filter, map, switchMap, tap,
-} from 'rxjs/operators';
+import { filter, tap } from 'rxjs/operators';
import { BoardActionsRegistryService } from 'core-app/features/boards/board/board-actions/board-actions-registry.service';
import { APIV3Service } from 'core-app/core/apiv3/api-v3.service';
import { WorkPackageStatesInitializationService } from 'core-app/features/work-packages/components/wp-list/wp-states-initialization.service';
@@ -39,7 +33,6 @@ import { WorkPackageStatesInitializationService } from 'core-app/features/work-p
})
export class BoardListContainerComponent extends UntilDestroyedMixin implements OnInit {
text = {
- button_more: this.I18n.t('js.button_more'),
delete: this.I18n.t('js.button_delete'),
areYouSure: this.I18n.t('js.text_are_you_sure'),
deleteSuccessful: this.I18n.t('js.notice_successful_delete'),
@@ -48,7 +41,8 @@ export class BoardListContainerComponent extends UntilDestroyedMixin implements
addList: this.I18n.t('js.boards.add_list'),
upsaleBoards: this.I18n.t('js.boards.upsale.teaser_text'),
upsaleCheckOutLink: this.I18n.t('js.work_packages.table_configuration.upsale.check_out_link'),
- unnamed_list: this.I18n.t('js.boards.label_unnamed_list'),
+ unnamedList: this.I18n.t('js.boards.label_unnamed_list'),
+ hiddenListWarning: this.I18n.t('js.boards.text_hidden_list_warning'),
};
/** Container reference */
@@ -75,6 +69,8 @@ export class BoardListContainerComponent extends UntilDestroyedMixin implements
boardWidgets:GridWidgetResource[] = [];
+ showHiddenListWarning:boolean = false;
+
private currentQueryUpdatedMonitoring:Subscription;
constructor(readonly I18n:I18nService,
@@ -105,7 +101,6 @@ export class BoardListContainerComponent extends UntilDestroyedMixin implements
.id(id)
.requireAndStream()
.pipe(
- this.setAllowedBoardWidgets,
tap((board) => this.setupQueryUpdatedMonitoring(board)),
);
@@ -123,42 +118,6 @@ export class BoardListContainerComponent extends UntilDestroyedMixin implements
});
}
- setAllowedBoardWidgets = (boardObservable:Observable<Board>) =>
- // The grid config could have widgets that the user is not allowed to
- // see, so we filter out those that rise an access error.
- boardObservable
- .pipe(
- switchMap(
- (board) => this.getAllowedBoardWidgets(board).pipe(map((allowedBoardWidgets) => ({ board, allowedBoardWidgets }))),
- ),
- map((result) => {
- this.boardWidgets = result.allowedBoardWidgets;
-
- return result.board;
- }),
- )
- ;
-
- getAllowedBoardWidgets(board:Board) {
- if (board.queries?.length) {
- const queryRequests$ = board.queries.map((query) => this.apiv3Service.queries
- .find({ filters: JSON.stringify(query.options.filters), pageSize: 0 }, query.options.queryId as string)
- .pipe(
- map(() => query),
- catchError((error) => {
- const userIsNotAllowedToSeeSubprojectError = 'urn:openproject-org:api:v3:errors:InvalidQuery';
- const result = error.errorIdentifier === userIsNotAllowedToSeeSubprojectError ? null : query;
-
- return of(result);
- }),
- ));
-
- return forkJoin([...queryRequests$])
- .pipe(map((boardWidgets) => boardWidgets.filter((boardWidget) => !!boardWidget) as GridWidgetResource[]));
- }
- return of([]);
- }
-
moveList(board:Board, event:CdkDragDrop<GridWidgetResource[]>) {
moveItemInArray(board.queries, event.previousIndex, event.currentIndex);
this.saveBoard(board);
@@ -172,7 +131,7 @@ export class BoardListContainerComponent extends UntilDestroyedMixin implements
addList(board:Board):any {
if (board.isFree) {
return this.BoardList
- .addFreeQuery(board, { name: this.text.unnamed_list })
+ .addFreeQuery(board, { name: this.text.unnamedList })
.then((board) => this.Boards.save(board).toPromise())
.catch((error) => this.showError(error));
}
@@ -184,6 +143,13 @@ export class BoardListContainerComponent extends UntilDestroyedMixin implements
);
}
+ changeVisibilityOfList(board:Board, boardWidget:GridWidgetResource, visible:boolean) {
+ if (!visible) {
+ this.showHiddenListWarning = true;
+ this.boardWidgets = this.boardWidgets.filter(widget => widget.id !== boardWidget.id);
+ }
+ }
+
showBoardListView() {
return !this.Banner.eeShowBanners;
}
@@ -201,6 +167,8 @@ export class BoardListContainerComponent extends UntilDestroyedMixin implements
this.currentQueryUpdatedMonitoring.unsubscribe();
}
+ this.boardWidgets = board.queries;
+
this.currentQueryUpdatedMonitoring = this
.QueryUpdated
.monitor(board.queries.map((widget) => widget.options.queryId as string))
diff --git a/modules/boards/config/locales/js-en.yml b/modules/boards/config/locales/js-en.yml
index f29b066d0dc..c73daac4d9f 100644
--- a/modules/boards/config/locales/js-en.yml
+++ b/modules/boards/config/locales/js-en.yml
@@ -33,6 +33,7 @@ en:
error_loading_the_list: "Error loading the list: %{error_message}"
error_permission_missing: "The permission to create public queries is missing"
error_cannot_move_into_self: "You can not move a work package into its own column."
+ text_hidden_list_warning: "Not all lists are displayed because you lack the permission. Contact your admin for more information."
click_to_remove_list: "Click to remove this list"
board_type:
text: 'Board type'