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
[chore] extracted URN constants to separate file
Eric Schubert9e6d9f090ec3
diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex ca4e8867753..ef7d3fc9922 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -399,7 +399,7 @@ en:label_expand_project_menu: "Expand project menu"label_export: "Export"label_export_preparing: "The export is being prepared and will be downloaded shortly."- label_file_link_no_permission: "No permission to see this file."+ label_file_link_no_permission: "You have no permission to see this file."label_file_link_error: "Error fetching view permissions."label_filename: "File"label_filesize: "Size"diff --git a/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.html b/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.htmlindex 61f7e934e87..a6660e8f08a 100644--- a/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.html+++ b/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.html@@ -26,9 +26,11 @@class="op-files-tab--file-list-item-avatar"></div></a>- <div class="spot-list--item-floating-actions op-files-tab--file-list-item-floating-actions">+ <div+ *ngIf="!!this.attachment._links.delete"+ class="spot-list--item-floating-actions op-files-tab--file-list-item-floating-actions"+ ><button- *ngIf="!!this.attachment._links.delete"class="spot-link"[title]="deleteIconTitle"(click)="confirmRemoveAttachment($event)"diff --git a/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.component.ts b/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.component.tsindex 28b1d9d620c..42b64913e72 100644--- a/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.component.ts+++ b/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.component.ts@@ -46,6 +46,11 @@ import { TimezoneService } from 'core-app/core/datetime/timezone.service';import { I18nService } from 'core-app/core/i18n/i18n.service';import { PrincipalRendererService } from 'core-app/shared/components/principal/principal-renderer.service';import { IFileIcon } from 'core-app/shared/components/file-links/file-link-icons/icon-mappings';+import {+ fileLinkViewAllowed,+ fileLinkViewError,+ fileLinkViewNotAllowed,+} from 'core-app/shared/components/file-links/file-links-constants.const';@Component({// eslint-disable-next-line @angular-eslint/component-selector@@ -72,13 +77,18 @@ export class FileLinkListItemComponent implements OnInit, AfterViewInit {public showFloatingActions:boolean;+ public floatingText:string;+public text = {title: {openFile: this.i18n.t('js.label_open_file_link'),openFileLocation: this.i18n.t('js.label_open_file_link_location'),removeFileLink: this.i18n.t('js.label_remove_file_link'),},- floatingText: '',+ floatingText: {+ noViewPermission: this.i18n.t('js.label_file_link_no_permission'),+ error: this.i18n.t('js.label_file_link_error'),+ },};constructor(@@ -114,21 +124,21 @@ export class FileLinkListItemComponent implements OnInit, AfterViewInit {private derivePermissionState():void {switch (this.fileLink._links.permission.href) {- case 'urn:openproject-org:api:v3:file-links:permission:View':+ case fileLinkViewAllowed:this.showFloatingActions = true;- this.text.floatingText = '';+ this.floatingText = '';break;- case 'urn:openproject-org:api:v3:file-links:permission:NotAllowed':+ case fileLinkViewNotAllowed:this.showFloatingActions = false;- this.text.floatingText = this.i18n.t('js.label_file_link_no_permission');+ this.floatingText = this.text.floatingText.noViewPermission;break;- case 'urn:openproject-org:api:v3:file-links:permission:Error':+ case fileLinkViewError:this.showFloatingActions = false;- this.text.floatingText = this.i18n.t('js.label_file_link_error');+ this.floatingText = this.text.floatingText.error;break;default:this.showFloatingActions = true;- this.text.floatingText = '';+ this.floatingText = '';}}}diff --git a/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.html b/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.htmlindex bb9bd972228..e2ae259650c 100644--- a/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.html+++ b/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.html@@ -51,6 +51,6 @@class="spot-list--item-floating-actions op-files-tab--file-list-item-floating-text"><span class="spot-icon spot-icon_info2"></span>- <span [textContent]="text.floatingText"></span>+ <span [textContent]="floatingText"></span></div></div>diff --git a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.ts b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.tsindex 8ff69422caa..332e5722adb 100644--- a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.ts+++ b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.ts@@ -34,6 +34,12 @@ import { HalResource } from 'core-app/features/hal/resources/hal-resource';import { IFileLink } from 'core-app/core/state/file-links/file-link.model';import { IStorage } from 'core-app/core/state/storages/storage.model';import { FileLinksResourceService } from 'core-app/core/state/file-links/file-links.service';+import {+ fileLinkViewAllowed,+ storageAuthorizationError,+ storageConnected,+ storageFailedAuthorization,+} from 'core-app/shared/components/file-links/file-links-constants.const';import { CurrentUserService } from 'core-app/core/current-user/current-user.service';import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';import { I18nService } from 'core-app/core/i18n/i18n.service';@@ -127,6 +133,10 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInitwindow.open(this.storage._links.origin.href);}+ public isDisabled(fileLink:IFileLink):boolean {+ return fileLink._links.permission.href !== fileLinkViewAllowed;+ }+private get collectionKey():string {return isNewResource(this.resource) ? 'new' : this.fileLinkSelfLink;}@@ -138,13 +148,13 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInitprivate deriveStorageInformation(fileLinkCount:number):void {switch (this.storage._links.authorizationState.href) {- case 'urn:openproject-org:api:v3:storages:authorization:FailedAuthentication':+ case storageFailedAuthorization:this.setAuthenticationFailureState(fileLinkCount);break;- case 'urn:openproject-org:api:v3:storages:authorization:Error':+ case storageAuthorizationError:this.setConnectionErrorState();break;- case 'urn:openproject-org:api:v3:storages:authorization:Connected':+ case storageConnected:if (fileLinkCount === 0) {this.setEmptyFileLinkListState();} else {diff --git a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.html b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.htmlindex cfbcd5ddef9..106f885e2ef 100644--- a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.html+++ b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.html@@ -19,7 +19,7 @@<li*ngFor="let fileLink of fileLinks$ | async; let i = index;"class="spot-list--item op-files-tab--file-list-item"- [ngClass]="{ 'disabled': fileLink._links.permission.href !== 'urn:openproject-org:api:v3:file-links:permission:View' }"+ [ngClass]="{ 'disabled': isDisabled(fileLink) }"data-qa-selector="op-files-tab--file-list-item"op-file-link-list-item[fileLink]="fileLink"diff --git a/frontend/src/app/shared/components/file-links/file-links-constants.const.ts b/frontend/src/app/shared/components/file-links/file-links-constants.const.tsnew file mode 100644index 00000000000..cdb675c5840--- /dev/null+++ b/frontend/src/app/shared/components/file-links/file-links-constants.const.ts@@ -0,0 +1,9 @@+// Storage authorization state+export const storageConnected = 'urn:openproject-org:api:v3:storages:authorization:Connected';+export const storageFailedAuthorization = 'urn:openproject-org:api:v3:storages:authorization:FailedAuthorization';+export const storageAuthorizationError = 'urn:openproject-org:api:v3:storages:authorization:Error';++// File link view permission flags+export const fileLinkViewAllowed = 'urn:openproject-org:api:v3:file-links:permission:View';+export const fileLinkViewNotAllowed = 'urn:openproject-org:api:v3:file-links:permission:NotAllowed';+export const fileLinkViewError = 'urn:openproject-org:api:v3:file-links:permission:Error';diff --git a/frontend/src/global_styles/content/work_packages/tabs/_files.sass b/frontend/src/global_styles/content/work_packages/tabs/_files.sassindex f716b7b3f73..21c747a7589 100644--- a/frontend/src/global_styles/content/work_packages/tabs/_files.sass+++ b/frontend/src/global_styles/content/work_packages/tabs/_files.sass@@ -75,7 +75,7 @@@include spot-body-small()padding-right: $spot-spacing-0-25- color: #1A67A3+ color: var(--primary-color).spot-icon:first-child:not(:last-child)width: $spot-spacing-1-5