mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Hide UI tour steps if user doesnt have permissions
This commit is contained in:
		| @@ -155,6 +155,7 @@ export class AppComponent implements OnInit, OnDestroy { | |||||||
|         content: $localize`Drag-and-drop documents here to start uploading or place them in the consume folder. You can also drag-and-drop documents anywhere on all other pages of the web app. Once you do, Paperless-ngx will start training its machine learning algorithms.`, |         content: $localize`Drag-and-drop documents here to start uploading or place them in the consume folder. You can also drag-and-drop documents anywhere on all other pages of the web app. Once you do, Paperless-ngx will start training its machine learning algorithms.`, | ||||||
|         route: '/dashboard', |         route: '/dashboard', | ||||||
|         enableBackdrop: true, |         enableBackdrop: true, | ||||||
|  |         isOptional: true, | ||||||
|         prevBtnTitle, |         prevBtnTitle, | ||||||
|         nextBtnTitle, |         nextBtnTitle, | ||||||
|         endBtnTitle, |         endBtnTitle, | ||||||
| @@ -167,6 +168,7 @@ export class AppComponent implements OnInit, OnDestroy { | |||||||
|         placement: 'bottom', |         placement: 'bottom', | ||||||
|         enableBackdrop: true, |         enableBackdrop: true, | ||||||
|         disableScrollToAnchor: true, |         disableScrollToAnchor: true, | ||||||
|  |         isOptional: true, | ||||||
|         prevBtnTitle, |         prevBtnTitle, | ||||||
|         nextBtnTitle, |         nextBtnTitle, | ||||||
|         endBtnTitle, |         endBtnTitle, | ||||||
| @@ -177,6 +179,7 @@ export class AppComponent implements OnInit, OnDestroy { | |||||||
|         route: '/documents?sort=created&reverse=1&page=1', |         route: '/documents?sort=created&reverse=1&page=1', | ||||||
|         placement: 'bottom', |         placement: 'bottom', | ||||||
|         enableBackdrop: true, |         enableBackdrop: true, | ||||||
|  |         isOptional: true, | ||||||
|         prevBtnTitle, |         prevBtnTitle, | ||||||
|         nextBtnTitle, |         nextBtnTitle, | ||||||
|         endBtnTitle, |         endBtnTitle, | ||||||
| @@ -186,6 +189,7 @@ export class AppComponent implements OnInit, OnDestroy { | |||||||
|         content: $localize`Any combination of filters can be saved as a 'view' which can then be displayed on the dashboard and / or sidebar.`, |         content: $localize`Any combination of filters can be saved as a 'view' which can then be displayed on the dashboard and / or sidebar.`, | ||||||
|         route: '/documents?sort=created&reverse=1&page=1', |         route: '/documents?sort=created&reverse=1&page=1', | ||||||
|         enableBackdrop: true, |         enableBackdrop: true, | ||||||
|  |         isOptional: true, | ||||||
|         prevBtnTitle, |         prevBtnTitle, | ||||||
|         nextBtnTitle, |         nextBtnTitle, | ||||||
|         endBtnTitle, |         endBtnTitle, | ||||||
| @@ -195,6 +199,7 @@ export class AppComponent implements OnInit, OnDestroy { | |||||||
|         content: $localize`Tags, correspondents, document types and storage paths can all be managed using these pages. They can also be created from the document edit view.`, |         content: $localize`Tags, correspondents, document types and storage paths can all be managed using these pages. They can also be created from the document edit view.`, | ||||||
|         route: '/tags', |         route: '/tags', | ||||||
|         enableBackdrop: true, |         enableBackdrop: true, | ||||||
|  |         isOptional: true, | ||||||
|         prevBtnTitle, |         prevBtnTitle, | ||||||
|         nextBtnTitle, |         nextBtnTitle, | ||||||
|         endBtnTitle, |         endBtnTitle, | ||||||
| @@ -204,6 +209,7 @@ export class AppComponent implements OnInit, OnDestroy { | |||||||
|         content: $localize`File Tasks shows you documents that have been consumed, are waiting to be, or may have failed during the process.`, |         content: $localize`File Tasks shows you documents that have been consumed, are waiting to be, or may have failed during the process.`, | ||||||
|         route: '/tasks', |         route: '/tasks', | ||||||
|         enableBackdrop: true, |         enableBackdrop: true, | ||||||
|  |         isOptional: true, | ||||||
|         prevBtnTitle, |         prevBtnTitle, | ||||||
|         nextBtnTitle, |         nextBtnTitle, | ||||||
|         endBtnTitle, |         endBtnTitle, | ||||||
| @@ -213,6 +219,7 @@ export class AppComponent implements OnInit, OnDestroy { | |||||||
|         content: $localize`Check out the settings for various tweaks to the web app, toggle settings for saved views or setup e-mail checking.`, |         content: $localize`Check out the settings for various tweaks to the web app, toggle settings for saved views or setup e-mail checking.`, | ||||||
|         route: '/settings', |         route: '/settings', | ||||||
|         enableBackdrop: true, |         enableBackdrop: true, | ||||||
|  |         isOptional: true, | ||||||
|         prevBtnTitle, |         prevBtnTitle, | ||||||
|         nextBtnTitle, |         nextBtnTitle, | ||||||
|         endBtnTitle, |         endBtnTitle, | ||||||
|   | |||||||
| @@ -8,13 +8,15 @@ import { | |||||||
| import { Injectable } from '@angular/core' | import { Injectable } from '@angular/core' | ||||||
| import { PermissionsService } from '../services/permissions.service' | import { PermissionsService } from '../services/permissions.service' | ||||||
| import { ToastService } from '../services/toast.service' | import { ToastService } from '../services/toast.service' | ||||||
|  | import { TourService } from 'ngx-ui-tour-ng-bootstrap' | ||||||
|  |  | ||||||
| @Injectable() | @Injectable() | ||||||
| export class PermissionsGuard implements CanActivate { | export class PermissionsGuard implements CanActivate { | ||||||
|   constructor( |   constructor( | ||||||
|     private permissionsService: PermissionsService, |     private permissionsService: PermissionsService, | ||||||
|     private router: Router, |     private router: Router, | ||||||
|     private toastService: ToastService |     private toastService: ToastService, | ||||||
|  |     private tourService: TourService | ||||||
|   ) {} |   ) {} | ||||||
|  |  | ||||||
|   canActivate( |   canActivate( | ||||||
| @@ -27,9 +29,12 @@ export class PermissionsGuard implements CanActivate { | |||||||
|         route.data.requiredPermission.type |         route.data.requiredPermission.type | ||||||
|       ) |       ) | ||||||
|     ) { |     ) { | ||||||
|  |       // Check if tour is running 1 = TourState.ON | ||||||
|  |       if (this.tourService.getStatus() !== 1) { | ||||||
|         this.toastService.showError( |         this.toastService.showError( | ||||||
|           $localize`You don't have permissions to do that` |           $localize`You don't have permissions to do that` | ||||||
|         ) |         ) | ||||||
|  |       } | ||||||
|       return this.router.parseUrl('/dashboard') |       return this.router.parseUrl('/dashboard') | ||||||
|     } else { |     } else { | ||||||
|       return true |       return true | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 shamoon
					shamoon