diff --git a/packages/admin-ui/src/lib/core/src/providers/job-queue/job-queue.service.ts b/packages/admin-ui/src/lib/core/src/providers/job-queue/job-queue.service.ts index 4426e6c0c0..03006b6337 100644 --- a/packages/admin-ui/src/lib/core/src/providers/job-queue/job-queue.service.ts +++ b/packages/admin-ui/src/lib/core/src/providers/job-queue/job-queue.service.ts @@ -2,7 +2,7 @@ import { Injectable, OnDestroy } from '@angular/core'; import { EMPTY, interval, Observable, of, Subject, Subscription, timer } from 'rxjs'; import { debounceTime, map, mapTo, scan, shareReplay, switchMap } from 'rxjs/operators'; -import { JobInfoFragment, JobState } from '../../common/generated-types'; +import { JobInfoFragment, JobState, Permission } from '../../common/generated-types'; import { DataService } from '../../data/providers/data.service'; @Injectable({ @@ -61,12 +61,14 @@ export class JobQueueService implements OnDestroy { checkForJobs(delay: number = 1000) { timer(delay) .pipe( - switchMap(() => - this.dataService.client.userStatus().mapSingle((data) => data.userStatus.isLoggedIn), - ), - switchMap((isLoggedIn) => - isLoggedIn ? this.dataService.settings.getRunningJobs().single$ : EMPTY, - ), + switchMap(() => this.dataService.client.userStatus().mapSingle((data) => data.userStatus)), + switchMap((userStatus) => { + if (userStatus.permissions.includes(Permission.ReadSettings) && userStatus.isLoggedIn) { + return this.dataService.settings.getRunningJobs().single$; + } else { + return EMPTY; + } + }), ) .subscribe((data) => data.jobs.items.forEach((job) => this.updateJob$.next(job))); } diff --git a/packages/admin-ui/src/lib/settings/src/components/role-detail/role-detail.component.ts b/packages/admin-ui/src/lib/settings/src/components/role-detail/role-detail.component.ts index 867912f674..87ab9e0012 100644 --- a/packages/admin-ui/src/lib/settings/src/components/role-detail/role-detail.component.ts +++ b/packages/admin-ui/src/lib/settings/src/components/role-detail/role-detail.component.ts @@ -2,11 +2,17 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnIni import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; -import { BaseDetailComponent } from '@vendure/admin-ui/core'; -import { CreateRoleInput, LanguageCode, Permission, Role, UpdateRoleInput } from '@vendure/admin-ui/core'; -import { NotificationService } from '@vendure/admin-ui/core'; -import { DataService } from '@vendure/admin-ui/core'; -import { ServerConfigService } from '@vendure/admin-ui/core'; +import { + BaseDetailComponent, + CreateRoleInput, + DataService, + LanguageCode, + NotificationService, + Permission, + Role, + ServerConfigService, + UpdateRoleInput, +} from '@vendure/admin-ui/core'; import { normalizeString } from '@vendure/common/lib/normalize-string'; import { Observable } from 'rxjs'; import { mergeMap, take } from 'rxjs/operators';