mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Fix startup without saved view permissions
This commit is contained in:
		| @@ -115,7 +115,7 @@ describe('settings', () => { | |||||||
|     cy.contains('a', 'Dashboard').click() |     cy.contains('a', 'Dashboard').click() | ||||||
|     cy.contains('You have unsaved changes') |     cy.contains('You have unsaved changes') | ||||||
|     cy.contains('button', 'Cancel').click() |     cy.contains('button', 'Cancel').click() | ||||||
|     cy.contains('button', 'Save').click().wait('@savedViews').wait(2000) |     cy.contains('button', 'Save').click().wait(2000) | ||||||
|     cy.contains('a', 'Dashboard').click() |     cy.contains('a', 'Dashboard').click() | ||||||
|     cy.contains('You have unsaved changes').should('not.exist') |     cy.contains('You have unsaved changes').should('not.exist') | ||||||
|   }) |   }) | ||||||
|   | |||||||
| @@ -1,4 +1,9 @@ | |||||||
| import { Component } from '@angular/core' | import { Component } from '@angular/core' | ||||||
|  | import { | ||||||
|  |   PermissionAction, | ||||||
|  |   PermissionsService, | ||||||
|  |   PermissionType, | ||||||
|  | } from 'src/app/services/permissions.service' | ||||||
| import { SavedViewService } from 'src/app/services/rest/saved-view.service' | import { SavedViewService } from 'src/app/services/rest/saved-view.service' | ||||||
| import { SettingsService } from 'src/app/services/settings.service' | import { SettingsService } from 'src/app/services/settings.service' | ||||||
| import { ComponentWithPermissions } from '../with-permissions/with-permissions.component' | import { ComponentWithPermissions } from '../with-permissions/with-permissions.component' | ||||||
| @@ -10,10 +15,20 @@ import { ComponentWithPermissions } from '../with-permissions/with-permissions.c | |||||||
| }) | }) | ||||||
| export class DashboardComponent extends ComponentWithPermissions { | export class DashboardComponent extends ComponentWithPermissions { | ||||||
|   constructor( |   constructor( | ||||||
|     public savedViewService: SavedViewService, |     public settingsService: SettingsService, | ||||||
|     public settingsService: SettingsService |     private permissionsService: PermissionsService, | ||||||
|  |     public savedViewService: SavedViewService | ||||||
|   ) { |   ) { | ||||||
|     super() |     super() | ||||||
|  |  | ||||||
|  |     if ( | ||||||
|  |       permissionsService.currentUserCan( | ||||||
|  |         PermissionAction.View, | ||||||
|  |         PermissionType.SavedView | ||||||
|  |       ) | ||||||
|  |     ) { | ||||||
|  |       savedViewService.initialize() | ||||||
|  |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   get subtitle() { |   get subtitle() { | ||||||
|   | |||||||
| @@ -3,6 +3,7 @@ import { Injectable } from '@angular/core' | |||||||
| import { combineLatest, Observable } from 'rxjs' | import { combineLatest, Observable } from 'rxjs' | ||||||
| import { tap } from 'rxjs/operators' | import { tap } from 'rxjs/operators' | ||||||
| import { PaperlessSavedView } from 'src/app/data/paperless-saved-view' | import { PaperlessSavedView } from 'src/app/data/paperless-saved-view' | ||||||
|  | import { PermissionsService } from '../permissions.service' | ||||||
| import { AbstractPaperlessService } from './abstract-paperless-service' | import { AbstractPaperlessService } from './abstract-paperless-service' | ||||||
|  |  | ||||||
| @Injectable({ | @Injectable({ | ||||||
| @@ -11,8 +12,11 @@ import { AbstractPaperlessService } from './abstract-paperless-service' | |||||||
| export class SavedViewService extends AbstractPaperlessService<PaperlessSavedView> { | export class SavedViewService extends AbstractPaperlessService<PaperlessSavedView> { | ||||||
|   loading: boolean |   loading: boolean | ||||||
|  |  | ||||||
|   constructor(http: HttpClient) { |   constructor(http: HttpClient, permissionService: PermissionsService) { | ||||||
|     super(http, 'saved_views') |     super(http, 'saved_views') | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   public initialize() { | ||||||
|     this.reload() |     this.reload() | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 shamoon
					shamoon