Prevent unauthorized users from creating library from the dashboad

This commit is contained in:
aditya.chandel
2025-03-09 16:53:25 -06:00
parent 5728d45b31
commit 9745b99962
2 changed files with 13 additions and 9 deletions
@@ -1,15 +1,17 @@
<div class="dashboard">
<div class="dashboard-no-library" *ngIf="isLibrariesEmpty$ | async; else dashboardScroller">
<h1 class="no-library-header">
Looks like you haven't added a library yet. Let's add one!
</h1>
<p-button
label="Add a Library"
icon="pi pi-plus"
styleClass="p-button-rounded p-button-outlined"
(click)="createNewLibrary()">
</p-button>
<div *ngIf="(userService.userData$ | async)?.permissions as permissions">
<div *ngIf="permissions.admin || permissions.canManipulateLibrary">
<h1 class="no-library-header">Looks like you haven't added a library yet. Let's add one!</h1>
<p-button
label="Add a Library"
icon="pi pi-plus"
styleClass="p-button-rounded p-button-outlined"
(click)="createNewLibrary()">
</p-button>
</div>
</div>
</div>
<ng-template #dashboardScroller>
@@ -11,6 +11,7 @@ import {BookService} from '../../../book/service/book.service';
import {BookState} from '../../../book/model/state/book-state.model';
import {Book} from '../../../book/model/book.model';
import {Divider} from 'primeng/divider';
import {UserService} from '../../../user.service';
@Component({
selector: 'app-main-dashboard',
@@ -31,6 +32,7 @@ export class MainDashboardComponent implements OnInit {
private bookService = inject(BookService);
private dialogService = inject(DialogService);
protected userService = inject(UserService);
lastReadBooks$: Observable<Book[]> | undefined;
latestAddedBooks$: Observable<Book[]> | undefined;