Skip to content

Commit

Permalink
Handle feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
nntthuy-axonivy committed Aug 1, 2024
1 parent bed1afb commit 801a096
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;

import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.time.StopWatch;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PagedResourcesAssembler;
import org.springframework.hateoas.PagedModel;
Expand Down Expand Up @@ -50,6 +52,7 @@
@Tag(name = "Product Controller", description = "API collection to get and search products")
public class ProductController {

public static final int PAGE_SIZE_FOR_REST_CLIENT = 40;
private final ProductService productService;
private final GitHubService gitHubService;
private final ProductModelAssembler assembler;
Expand All @@ -75,6 +78,9 @@ public ResponseEntity<PagedModel<ProductModel>> findProducts(
@RequestParam(name = LANGUAGE) @Parameter(description = "Language of product short description", in = ParameterIn.QUERY, schema = @Schema(allowableValues = {"en", "de"})) String language,
@RequestParam(name = IS_REST_CLIENT) @Parameter(description = "Option to render the website in the REST Client Editor of Designer", in = ParameterIn.QUERY) Boolean isRESTClient,
@ParameterObject Pageable pageable) {
if (BooleanUtils.isTrue(isRESTClient)) {
pageable = PageRequest.ofSize(PAGE_SIZE_FOR_REST_CLIENT);
}
Page<Product> results = productService.findProducts(type, keyword, language, isRESTClient, pageable);
if (results.isEmpty()) {
return generateEmptyPagedModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public Page<Product> findProducts(String type, String keyword, String language,
searchCriteria.setListed(true);
searchCriteria.setKeyword(keyword);
if (BooleanUtils.isTrue(isRESTClient)) {
searchCriteria.setType(TypeOption.CONNECTORS);
searchCriteria.setLanguage(Language.EN);
searchCriteria.setExcludeFields(List.of(SHORT_DESCRIPTIONS));
} else {
searchCriteria.setType(typeOption);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ void testFindProducts() {
void testFindProductsInRESTClientOfDesigner() {
productService.findProducts(TypeOption.CONNECTORS.getOption(), keyword, Language.EN.getValue(), true, PAGEABLE);
verify(productRepository).searchByCriteria(productSearchCriteriaArgumentCaptor.capture(), any(Pageable.class));
assertEquals(TypeOption.CONNECTORS, productSearchCriteriaArgumentCaptor.getValue().getType());
assertEquals(Language.EN, productSearchCriteriaArgumentCaptor.getValue().getLanguage());
assertEquals(List.of(SHORT_DESCRIPTIONS), productSearchCriteriaArgumentCaptor.getValue().getExcludeFields());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe('ProductComponent', () => {

it('should not display marketplace introduction in designer', () => {
component.route.queryParams = of({
[DESIGNER_COOKIE_VARIABLE.restClientParamName]: 'resultsoOnly',
[DESIGNER_COOKIE_VARIABLE.restClientParamName]: 'resultsOnly',
[DESIGNER_COOKIE_VARIABLE.searchParamName]: 'search'
});

Expand Down
2 changes: 0 additions & 2 deletions marketplace-ui/src/app/modules/product/product.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ export class ProductComponent implements AfterViewInit, OnDestroy {
this.criteria.language = this.languageService.selectedLanguage();
if (this.isRestClient()) {
this.criteria.isRESTClientEditor = true;
this.criteria.language = Language.EN;
this.criteria.type = TypeOption.CONNECTORS;
}

this.subscriptions.push(
Expand Down

0 comments on commit 801a096

Please sign in to comment.