Skip to content

Commit ad7d66e

Browse files
committed
ScmModule: wrong permission check fixed
1 parent 15d7183 commit ad7d66e

File tree

2 files changed

+37
-27
lines changed

2 files changed

+37
-27
lines changed

src/app/modules/scm_module/pages/resources/resources-index/resources-index.component.html

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,13 @@ <h5>
292292
@for (resource of resources.all_resources; track $index) {
293293
<tr>
294294
<td class="text-center">
295-
<oitc-item-select
296-
*oitcPermission="['scmmodule','resources', 'delete']"
297-
[disabled]="!resource.allow_edit"
298-
[item]="resource"></oitc-item-select>
295+
@if (( PermissionsService.hasModuleObservable('ScmModule')|async ) &&
296+
( ( PermissionsService.hasPermissionObservable(['ScmModule', 'resources', 'setStatus']) | async ) ||
297+
( PermissionsService.hasPermissionObservable(['ScmModule', 'resources', 'delete']) | async ) )) {
298+
<oitc-item-select
299+
[disabled]="!resource.allow_edit"
300+
[item]="resource"></oitc-item-select>
301+
}
299302
</td>
300303
<td>
301304
@switch (resource.status) {
@@ -408,15 +411,17 @@ <h5>
408411
<fa-icon [icon]="['fas', 'timeline']" [rotate]="90"></fa-icon>
409412
{{ t('Changelog') }}
410413
</oitc-actions-button-element>
411-
<li cDropdownDivider></li>
412-
<oitc-actions-button-element (click)="toggleDeleteAllModal(resource)"
413-
*ngIf="resource.allow_edit"
414-
[permission]="'ScmModule.resources.delete'">
415-
<span class="text-danger">
416-
<fa-icon [icon]="['fas', 'trash']"></fa-icon>
417-
{{ t('Delete') }}
418-
</span>
419-
</oitc-actions-button-element>
414+
@if (( PermissionsService.hasModuleObservable('ScmModule')|async ) && ( PermissionsService.hasPermissionObservable(['ScmModule', 'resources', 'delete']) | async )) {
415+
<li cDropdownDivider></li>
416+
<oitc-actions-button-element (click)="toggleDeleteAllModal(resource)"
417+
*ngIf="resource.allow_edit"
418+
[permission]="'ScmModule.resources.delete'">
419+
<span class="text-danger">
420+
<fa-icon [icon]="['fas', 'trash']"></fa-icon>
421+
{{ t('Delete') }}
422+
</span>
423+
</oitc-actions-button-element>
424+
}
420425
</oitc-actions-button>
421426
</td>
422427
</tr>
@@ -436,18 +441,22 @@ <h5>
436441
</c-col>
437442
<c-col [sm]="8" [md]="5" [lg]="4" [xs]="3">
438443
<div class="btn-group d-flex flex-row" role="group">
439-
<button (click)="toggleSetStatusModal()"
440-
class="btn btn-outline-info col-3 border-0"
441-
type="button">
442-
<fa-icon [icon]="['fas', 'person-chalkboard']"></fa-icon>
443-
{{ t('Set status for selected') }}
444-
</button>
445-
<button (click)="toggleDeleteAllModal()"
446-
class="btn btn-outline-danger col-3 border-0"
447-
type="button">
448-
<fa-icon [icon]="['fas', 'trash']"></fa-icon>
449-
{{ t('Delete selected') }}
450-
</button>
444+
@if (( PermissionsService.hasModuleObservable('ScmModule')|async ) && ( PermissionsService.hasPermissionObservable(['ScmModule', 'resources', 'setStatus']) | async )) {
445+
<button (click)="toggleSetStatusModal()"
446+
class="btn btn-outline-info col-3 border-0"
447+
type="button">
448+
<fa-icon [icon]="['fas', 'person-chalkboard']"></fa-icon>
449+
{{ t('Set status for selected') }}
450+
</button>
451+
}
452+
@if (( PermissionsService.hasModuleObservable('ScmModule')|async ) && ( PermissionsService.hasPermissionObservable(['ScmModule', 'resources', 'delete']) | async )) {
453+
<button (click)="toggleDeleteAllModal()"
454+
class="btn btn-outline-danger col-3 border-0"
455+
type="button">
456+
<fa-icon [icon]="['fas', 'trash']"></fa-icon>
457+
{{ t('Delete selected') }}
458+
</button>
459+
}
451460
</div>
452461
</c-col>
453462
</c-row>

src/app/modules/scm_module/pages/resources/resources-index/resources-index.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { DeleteAllModalComponent } from '../../../../../layouts/coreui/delete-al
4747
import { FaIconComponent, FaStackComponent, FaStackItemSizeDirective } from '@fortawesome/angular-fontawesome';
4848
import { FormsModule } from '@angular/forms';
4949
import { ItemSelectComponent } from '../../../../../layouts/coreui/select-all/item-select/item-select.component';
50-
import { NgIf } from '@angular/common';
50+
import { AsyncPipe, NgIf } from '@angular/common';
5151
import { NoRecordsComponent } from '../../../../../layouts/coreui/no-records/no-records.component';
5252
import {
5353
PaginateOrScrollComponent
@@ -111,7 +111,8 @@ import {
111111
MultiSelectComponent,
112112
FormCheckInputDirective,
113113
FormCheckLabelDirective,
114-
ResourcesSetStatusModalComponent
114+
ResourcesSetStatusModalComponent,
115+
AsyncPipe
115116
],
116117
providers: [
117118
{provide: DELETE_SERVICE_TOKEN, useClass: ResourcesService} // Inject the ResourcesService into the DeleteAllModalComponent

0 commit comments

Comments
 (0)