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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[38805] Fix notification loading as anonymous user
Oliver Günther0d4d9ad4ffd6
diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/state/wp-single-view.service.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/state/wp-single-view.service.tsindex acb37959462..fcc73b01255 100644--- a/frontend/src/app/features/work-packages/routing/wp-view-base/state/wp-single-view.service.ts+++ b/frontend/src/app/features/work-packages/routing/wp-view-base/state/wp-single-view.service.ts@@ -1,7 +1,11 @@import { Injectable } from '@angular/core';import { WpSingleViewStore } from './wp-single-view.store';import { WpSingleViewQuery } from 'core-app/features/work-packages/routing/wp-view-base/state/wp-single-view.query';-import { take } from 'rxjs/operators';+import {+ filter,+ switchMap,+ take,+} from 'rxjs/operators';import { selectCollectionAsHrefs$ } from 'core-app/core/state/collection-store';import { InAppNotificationsResourceService } from 'core-app/core/state/in-app-notifications/in-app-notifications.service';import { ApiV3ListFilter } from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';@@ -14,6 +18,7 @@ import {EffectCallback,EffectHandler,} from 'core-app/core/state/effects/effect-handler.decorator';+import { CurrentUserService } from 'core-app/core/current-user/current-user.service';@EffectHandler@Injectable()@@ -26,6 +31,7 @@ export class WpSingleViewService {constructor(readonly actions$:ActionsService,+ readonly currentUser$:CurrentUserService,private resourceService:InAppNotificationsResourceService,) {}@@ -63,8 +69,13 @@ export class WpSingleViewService {private reload() {this- .resourceService- .fetchNotifications(this.query.params)+ .currentUser$+ .isLoggedIn$+ .pipe(+ take(1),+ filter((loggedIn) => loggedIn),+ switchMap(() => this.resourceService.fetchNotifications(this.query.params)),+ ).subscribe();}diff --git a/spec/features/work_packages/tabs/activity_notifications_spec.rb b/spec/features/work_packages/tabs/activity_notifications_spec.rbindex c31b29ddd21..8eccb11159f 100644--- a/spec/features/work_packages/tabs/activity_notifications_spec.rb+++ b/spec/features/work_packages/tabs/activity_notifications_spec.rb@@ -90,4 +90,19 @@ describe 'Activity tab notifications', js: true, selenium: true doit_behaves_like 'when there are no notifications for the work package'end++ context 'when visiting as an anonymous user', with_settings: { login_required?: false } do+ let(:full_view) { Pages::FullWorkPackage.new(work_package, project) }+ let!(:anonymous_role) do+ FactoryBot.create :anonymous_role, permissions: [:view_work_packages]+ end++ it 'does not show an error' do+ full_view.visit_tab! 'activity'+ full_view.ensure_page_loaded++ full_view.expect_no_notification type: :error, message: 'Http failure response for'+ full_view.expect_no_notification+ end+ endend