Skip to content

Commit

Permalink
MARP-1445 Rate this connector Fix remaining text also (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
phhung-axonivy authored Nov 21, 2024
1 parent 9061409 commit 536ebde
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ <h4 class="analysis-title text-primary text-capitalize mb-0">
alt="Message Star" />
<p class="rate-empty-text">
<span [lang]="languageService.selectedLanguage()">
{{ 'common.feedback.noFeedbackMessage1' | translate }}
{{ productDetailService.noFeedbackLabel() | translate }}
</span>
<br />
<span [lang]="languageService.selectedLanguage()">
{{ 'common.feedback.noFeedbackMessage2' | translate }}
{{ 'common.feedback.noFeedbackSecondLabel' | translate }}
</span>
</p>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { of } from 'rxjs';
import { TypeOption } from '../../../shared/enums/type-option.enum';
import {
MOCK_PRODUCT_DETAIL,
MOCK_PRODUCT_DETAIL_BY_VERSION,
MOCK_CRON_JOB_PRODUCT_DETAIL,
MOCK_PRODUCT_MODULE_CONTENT,
MOCK_PRODUCTS
} from '../../../shared/mocks/mock-data';
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('ProductDetailComponent', () => {
targetVersion
);
component.getProductById(productId, false).subscribe(productDetail => {
expect(productDetail).toEqual(MOCK_PRODUCT_DETAIL_BY_VERSION);
expect(productDetail).toEqual(MOCK_CRON_JOB_PRODUCT_DETAIL);
});
});

Expand Down Expand Up @@ -796,6 +796,18 @@ describe('ProductDetailComponent', () => {

it('should generate right text for the rate connector', () => {
const rateConnector = fixture.debugElement.query(By.css('.rate-connector-btn'));
console.log(rateConnector);
expect(rateConnector.childNodes[0].nativeNode.textContent).toContain("common.feedback.rateFeedbackForConnectorBtnLabel");

const rateConnectorEmptyText = fixture.debugElement.query(By.css('.rate-empty-text'));
console.log(rateConnectorEmptyText);
expect(rateConnectorEmptyText.childNodes[0].nativeNode.textContent).toContain("common.feedback.noFeedbackForConnectorLabel");

component.route.snapshot.params['id'] = 'cronjob';
spyOn(component, 'getProductById').and.returnValue(of(MOCK_CRON_JOB_PRODUCT_DETAIL));
component.ngOnInit();
fixture.detectChanges();
expect(rateConnector.childNodes[0].nativeNode.textContent).toContain("common.feedback.rateFeedbackForUtilityBtnLabel");
expect(rateConnectorEmptyText.childNodes[0].nativeNode.textContent).toContain("common.feedback.noFeedbackForUtilityLabel");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
DEFAULT_IMAGE_URL,
DEFAULT_VENDOR_IMAGE,
DEFAULT_VENDOR_IMAGE_BLACK,
PRODUCT_DETAIL_TABS, RATING_BUTTONS, SHOW_DEV_VERSION,
PRODUCT_DETAIL_TABS, RATING_LABELS_BY_TYPE, SHOW_DEV_VERSION,
VERSION
} from '../../../shared/constants/common.constant';
import { ItemDropdown } from '../../../shared/models/item-dropdown.model';
Expand Down Expand Up @@ -161,9 +161,10 @@ export class ProductDetailComponent {
this.updateProductDetailActionType(productDetail);
this.logoUrl = productDetail.logoUrl;
this.updateWebBrowserTitle();
const ratingBtn = RATING_BUTTONS.find(button => button.type === productDetail.type);
if (ratingBtn !== undefined) {
this.productDetailService.ratingBtnLabel.set(ratingBtn.btnLabel);
const ratingLabels = RATING_LABELS_BY_TYPE.find(button => button.type === productDetail.type);
if (ratingLabels !== undefined) {
this.productDetailService.ratingBtnLabel.set(ratingLabels.btnLabel);
this.productDetailService.noFeedbackLabel.set(ratingLabels.noFeedbackLabel);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class ProductDetailService {
httpClient = inject(HttpClient);
loadingService = inject(LoadingService);
ratingBtnLabel: WritableSignal<string> = signal('');
noFeedbackLabel: WritableSignal<string> = signal('');

getExternalDocumentForProductByVersion(productId: string, version: string): Observable<ExternalDocument> {
return this.httpClient.get<ExternalDocument>(
Expand Down
11 changes: 7 additions & 4 deletions marketplace-ui/src/app/shared/constants/common.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,21 @@ export const LANGUAGES = [
}
];

export const RATING_BUTTONS = [
export const RATING_LABELS_BY_TYPE = [
{
type: 'connector',
btnLabel: 'common.feedback.rateFeedbackForConnectorBtnLabel'
btnLabel: 'common.feedback.rateFeedbackForConnectorBtnLabel',
noFeedbackLabel: 'common.feedback.noFeedbackForConnectorLabel'
},
{
type: 'solution',
btnLabel: 'common.feedback.rateFeedbackForSolutionBtnLabel'
btnLabel: 'common.feedback.rateFeedbackForSolutionBtnLabel',
noFeedbackLabel: 'common.feedback.noFeedbackForSolutionLabel'
},
{
type: 'util',
btnLabel: 'common.feedback.rateFeedbackForUtilityBtnLabel'
btnLabel: 'common.feedback.rateFeedbackForUtilityBtnLabel',
noFeedbackLabel: 'common.feedback.noFeedbackForUtilityLabel'
}
];

Expand Down
2 changes: 1 addition & 1 deletion marketplace-ui/src/app/shared/mocks/mock-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export const MOCK_PRODUCT_MODULE_CONTENT: ProductModuleContent = {
productId: 'jira-connector'
};

export const MOCK_PRODUCT_DETAIL_BY_VERSION: ProductDetail = {
export const MOCK_CRON_JOB_PRODUCT_DETAIL: ProductDetail = {
id: 'cronjob',
names: {
de: 'Cron Job',
Expand Down
6 changes: 3 additions & 3 deletions marketplace-ui/src/app/shared/mocks/mock-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
MOCK_PRODUCTS_FILTER_CONNECTOR,
MOCK_PRODUCTS_NEXT_PAGE,
MOCK_PRODUCT_DETAIL,
MOCK_PRODUCT_DETAIL_BY_VERSION
MOCK_CRON_JOB_PRODUCT_DETAIL
} from './mock-data';
import { ProductApiResponse } from '../models/apis/product-response.model';
import { ProductDetail } from '../models/product-detail.model';
Expand All @@ -30,13 +30,13 @@ export class MockProductService {
productId: string,
version: string
): Observable<ProductDetail> {
return of(MOCK_PRODUCT_DETAIL_BY_VERSION);
return of(MOCK_CRON_JOB_PRODUCT_DETAIL);
}

getBestMatchProductDetailsWithVersion(
productId: string,
version: string
): Observable<ProductDetail> {
return of(MOCK_PRODUCT_DETAIL_BY_VERSION);
return of(MOCK_CRON_JOB_PRODUCT_DETAIL);
}
}
6 changes: 4 additions & 2 deletions marketplace-ui/src/assets/i18n/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ common:
reviewLabel: Überprüfung
detailedReviews: Ausführliche Bewertungen
showMoreBtnLabel: Mehr anzeigen
noFeedbackMessage1: Deine Meinung ist gefragt.
noFeedbackMessage2: ''
noFeedbackForConnectorLabel: Zu diesem Konnektor gibt's noch kein Feedback.
noFeedbackForSolutionLabel: Zu dieser Lösung gibt's noch kein Feedback.
noFeedbackForUtilityLabel: Zu diesem Tool gibt's noch kein Feedback.
noFeedbackSecondLabel: Sag uns was Du denkst.
rateFeedbackForConnectorBtnLabel: Bewerte diesen Konnektor
rateFeedbackForSolutionBtnLabel: Bewerte diese Lösung
rateFeedbackForUtilityBtnLabel: Bewerte dieses Tool
Expand Down
6 changes: 4 additions & 2 deletions marketplace-ui/src/assets/i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ common:
reviewLabel: Review
detailedReviews: Detailed reviews
showMoreBtnLabel: Show more
noFeedbackMessage1: There is no feedback for this connector yet.
noFeedbackMessage2: Be the first to share your opinion.
noFeedbackForConnectorLabel: There is no feedback for this connector yet.
noFeedbackForSolutionLabel: There is no feedback for this solution yet.
noFeedbackForUtilityLabel: There is no feedback for this utility yet.
noFeedbackSecondLabel: Be the first to share your opinion.
rateFeedbackForConnectorBtnLabel: Rate this connector
rateFeedbackForSolutionBtnLabel: Rate this solution
rateFeedbackForUtilityBtnLabel: Rate this utility
Expand Down

0 comments on commit 536ebde

Please sign in to comment.