From 901306509606238fa5bf8660f9ecc8fd3b45c5a4 Mon Sep 17 00:00:00 2001 From: Pham Hoang Hung <84316773+phhung-axonivy@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:37:22 +0700 Subject: [PATCH] MARP-1484 Return 204 for externaldocument instead of 404 in details page (#244) --- .../controller/ExternalDocumentController.java | 2 +- .../product-detail-information-tab.component.ts | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/marketplace-service/src/main/java/com/axonivy/market/controller/ExternalDocumentController.java b/marketplace-service/src/main/java/com/axonivy/market/controller/ExternalDocumentController.java index 11671489..978b86d1 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/controller/ExternalDocumentController.java +++ b/marketplace-service/src/main/java/com/axonivy/market/controller/ExternalDocumentController.java @@ -50,7 +50,7 @@ public ResponseEntity findExternalDocument( in = ParameterIn.PATH) String version) { ExternalDocumentMeta externalDocument = externalDocumentService.findExternalDocument(id, version); if (externalDocument == null) { - return new ResponseEntity<>(HttpStatus.NOT_FOUND); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } var model = ExternalDocumentModel.builder().productId(externalDocument.getProductId()) diff --git a/marketplace-ui/src/app/modules/product/product-detail/product-detail-information-tab/product-detail-information-tab.component.ts b/marketplace-ui/src/app/modules/product/product-detail/product-detail-information-tab/product-detail-information-tab.component.ts index 16335a22..9c102cfa 100644 --- a/marketplace-ui/src/app/modules/product/product-detail/product-detail-information-tab/product-detail-information-tab.component.ts +++ b/marketplace-ui/src/app/modules/product/product-detail/product-detail-information-tab/product-detail-information-tab.component.ts @@ -50,19 +50,27 @@ export class ProductDetailInformationTabComponent implements OnChanges { this.productDetailService.getExternalDocumentForProductByVersion(this.productDetail.id, this.extractVersionValue(version)) .subscribe({ next: response => { - this.externalDocumentLink = response.relativeLink; - this.displayExternalDocName = response.artifactName; + if (response) { + this.externalDocumentLink = response.relativeLink; + this.displayExternalDocName = response.artifactName; + } else { + this.resetValues(); + } this.loadingService.hide(); }, error: () => { - this.externalDocumentLink = ''; - this.displayExternalDocName = ''; + this.resetValues(); this.loadingService.hide(); } }); this.displayVersion = this.extractVersionValue(this.selectedVersion); } + resetValues() { + this.externalDocumentLink = ''; + this.displayExternalDocName = ''; + } + extractVersionValue(versionDisplayName: string) { return versionDisplayName.replace(VERSION.displayPrefix, ''); }