OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add capability check for calendar widget
Oliver Günther2c02b58e6bc1
diff --git a/frontend/src/app/shared/components/grids/widgets/wp-calendar/wp-calendar.component.html b/frontend/src/app/shared/components/grids/widgets/wp-calendar/wp-calendar.component.htmlindex afb48aa709d..61802814662 100644--- a/frontend/src/app/shared/components/grids/widgets/wp-calendar/wp-calendar.component.html+++ b/frontend/src/app/shared/components/grids/widgets/wp-calendar/wp-calendar.component.html@@ -8,4 +8,13 @@</widget-menu></widget-header>-<op-wp-calendar [static]="true"></op-wp-calendar>+<ng-container *ngIf="{hasCapability: hasCapability$ | async} as context">+ <div class="op-toast -error" *ngIf="context.hasCapability === false">+ <span [textContent]="text.missing_permission"></span>+ </div>++ <op-wp-calendar+ *ngIf="context.hasCapability === true"+ [static]="true"+ ></op-wp-calendar>+</ng-container>diff --git a/frontend/src/app/shared/components/grids/widgets/wp-calendar/wp-calendar.component.ts b/frontend/src/app/shared/components/grids/widgets/wp-calendar/wp-calendar.component.tsindex 31c9b9f068f..64377300b05 100644--- a/frontend/src/app/shared/components/grids/widgets/wp-calendar/wp-calendar.component.ts+++ b/frontend/src/app/shared/components/grids/widgets/wp-calendar/wp-calendar.component.ts@@ -33,6 +33,7 @@ import { CurrentProjectService } from 'core-app/core/current-project/current-proimport {WorkPackageIsolatedQuerySpaceDirective,} from 'core-app/features/work-packages/directives/query-space/wp-isolated-query-space.directive';+import { CurrentUserService } from 'core-app/core/current-user/current-user.service';@Component({changeDetection: ChangeDetectionStrategy.OnPush,@@ -40,10 +41,19 @@ import {hostDirectives: [WorkPackageIsolatedQuerySpaceDirective],})export class WidgetWpCalendarComponent extends AbstractWidgetComponent {- constructor(protected readonly i18n:I18nService,+ text = {+ missing_permission: this.I18n.t('js.grid.widgets.missing_permission'),+ };++ hasCapability$ = this.currentUser.hasCapabilities$('work_packages/read', this.currentProject.id);++ constructor(+ protected readonly I18n:I18nService,protected readonly injector:Injector,- protected readonly currentProject:CurrentProjectService) {- super(i18n, injector);+ protected readonly currentProject:CurrentProjectService,+ protected readonly currentUser:CurrentUserService,+ ) {+ super(I18n, injector);}public get projectIdentifier() {diff --git a/modules/grids/config/locales/js-en.yml b/modules/grids/config/locales/js-en.ymlindex b4c81602a84..44543cb5754 100644--- a/modules/grids/config/locales/js-en.yml+++ b/modules/grids/config/locales/js-en.yml@@ -8,6 +8,7 @@ en:text: "Some widgets, like the work package graph widget, are only available in the Enterprise edition."link: 'Enterprise edition.'widgets:+ missing_permission: "You don't have the necessary permissions to view this widget."custom_text:title: 'Custom text'documents: