-
Notifications
You must be signed in to change notification settings - Fork 45
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
Conversation
There was a problem hiding this 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 || ""; |
There was a problem hiding this comment.
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.
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)}; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
oracleJdk: { | ||
id: "oracleJdk", | ||
label: l10n.value("jdk.downloader.label.openJdk") | ||
}, | ||
openJdk: { | ||
id: "openJdk", | ||
label: l10n.value("jdk.downloader.label.oracleJdk") | ||
}, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 . Thanks.
While fixing the label in the downloader in #379, a bug was introduced where all the download messages were showing
id
of thejdkType
instead of the label. So, this PR aims to fix that.