Skip to content

Fixed ids coming up as label issue in JDK Downloader #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

Achal1607
Copy link
Member

While fixing the label in the downloader in #379, a bug was introduced where all the download messages were showing id of the jdkType instead of the label. So, this PR aims to fix that.

@Achal1607 Achal1607 requested a review from sid-srini March 17, 2025 19:02
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Mar 17, 2025
Copy link
Member

@sid-srini sid-srini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Achal1607.

},
};

public static getJdkLabel = (id: string) => Object.values(this.JDK_TYPE).find(el=>el.id === id)?.label || "";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be better to return the id as is if not found.

Suggested change
public static getJdkLabel = (id: string) => Object.values(this.JDK_TYPE).find(el=>el.id === id)?.label || "";
public static getJdkLabel = (id: string) => Object.values(this.JDK_TYPE).find(el=>el.id === id)?.label || id;

@@ -281,7 +287,7 @@ export class JdkDownloaderView {

const triggerJDKDownload = (e) => {
const { id } = e.target;
const jdkType = id === openJdkButtonId+'DownloadButton' ? "${JdkDownloaderView.JDK_TYPE.openJdk}" : "${JdkDownloaderView.JDK_TYPE.oracleJdk}";
const jdkType = id === openJdkButtonId+'DownloadButton' ? ${JSON.stringify(JdkDownloaderView.JDK_TYPE.openJdk.id)} : ${JSON.stringify(JdkDownloaderView.JDK_TYPE.oracleJdk.id)};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is JSON.stringify required here for a string value in the id field?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No note required, it was required for the earlier object. Thanks for pointing this out.

Comment on lines 28 to 35
oracleJdk: {
id: "oracleJdk",
label: l10n.value("jdk.downloader.label.openJdk")
},
openJdk: {
id: "openJdk",
label: l10n.value("jdk.downloader.label.oracleJdk")
},
Copy link
Member

@sid-srini sid-srini Mar 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The labels have got swapped.

I think it may be better to use a programmatic approach like l10n.value("jdk.downloader.label."+id) which would be computed in the getJdkLabel(id) method and avoid storing the labels altogether.
The returned value from l10n.value(key) could be compared with the key and return id if not localised, i.e. return l10nValue !== key ? l10nValue : id

Copy link
Member

@sid-srini sid-srini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 . Thanks.

@Achal1607 Achal1607 merged commit a63ef81 into oracle:telemetry Mar 19, 2025
2 checks passed
@Achal1607 Achal1607 added this to the JVSC 24.1.0 milestone Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants