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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions vscode/src/webviews/jdkDownloader/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class JdkDownloaderAction {
private readonly DOWNLOAD_DIR = path.join(__dirname, 'jdk_downloads');
private startTimer: number | null = null;

private jdkType?: string;
private jdkType!: string;
private jdkVersion?: string;
private osType?: string;
private machineArch?: string;
Expand Down Expand Up @@ -132,7 +132,7 @@ export class JdkDownloaderAction {

private jdkInstallationManager = async () => {
const startingInstallationMessage = l10n.value("jdk.downloader.message.downloadingAndCompletingSetup", {
jdkType: this.jdkType,
jdkType: JdkDownloaderView.getJdkLabel(this.jdkType),
jdkVersion: this.jdkVersion
});

Expand All @@ -144,7 +144,7 @@ export class JdkDownloaderAction {
}
await this.downloadAndVerify();
const downloadSuccessLabel = l10n.value("jdk.downloader.message.downloadCompleted", {
jdkType: this.jdkType,
jdkType: JdkDownloaderView.getJdkLabel(this.jdkType),
jdkVersion: this.jdkVersion,
osType: this.osType
});
Expand Down Expand Up @@ -187,7 +187,7 @@ export class JdkDownloaderAction {

private downloadAndVerify = async (): Promise<void> => {
const message = l10n.value("jdk.downloader.message.downloadProgressBar", {
jdkType: this.jdkType,
jdkType: JdkDownloaderView.getJdkLabel(this.jdkType),
jdkVersion: this.jdkVersion
});
await downloadFileWithProgressBar(this.downloadUrl!, this.downloadFilePath!, message);
Expand All @@ -196,7 +196,7 @@ export class JdkDownloaderAction {
const doesMatch = await this.checksumMatch();
if (!doesMatch) {
const checksumMatchFailedLabel = l10n.value("jdk.downloader.message.downloadFailed", {
jdkType: this.jdkType,
jdkType: JdkDownloaderView.getJdkLabel(this.jdkType),
jdkVersion: this.jdkVersion,
osType: this.osType
});
Expand Down Expand Up @@ -230,7 +230,7 @@ export class JdkDownloaderAction {
} catch (err) {
LOGGER.error(`Error while extracting JDK: ${(err as Error).message}`);
throw new Error(l10n.value("jdk.downloader.error_message.extractionError", {
jdkType: this.jdkType,
jdkType: JdkDownloaderView.getJdkLabel(this.jdkType),
jdkVersion: this.jdkVersion
}));
}
Expand All @@ -250,11 +250,11 @@ export class JdkDownloaderAction {
const tempDirectoryPath = path.join(this.DOWNLOAD_DIR, matchingJdkDir[0]);

// If directory with same name is present in the user selected download location then ask user if they want to delete it or not?
const newDirName = `${this.jdkType!.split(' ').join('_')}-${this.jdkVersion}`;
const newDirName = `${this.jdkType.split(' ').join('_')}-${this.jdkVersion}`;
const newDirectoryPath = await this.handleJdkPaths(newDirName, this.installationPath!, this.osType!);
if (newDirectoryPath === null) {
throw new Error(l10n.value('jdk.downloader.error_message.jdkNewDirectoryIssueCannotInstall', {
jdkType: this.jdkType,
jdkType: JdkDownloaderView.getJdkLabel(this.jdkType),
jdkVersion: this.jdkVersion,
newDirName
}));
Expand All @@ -278,7 +278,7 @@ export class JdkDownloaderAction {
private installationCleanup = (tempDirPath: string, newDirPath: string) => {
const currentTime = getCurrentUTCDateInSeconds();
const downloadTelemetryEvent: JdkDownloadEventData = {
vendor: this.jdkType!,
vendor: this.jdkType,
version: this.jdkVersion!,
os: this.osType!,
arch: this.machineArch!,
Expand Down
10 changes: 7 additions & 3 deletions vscode/src/webviews/jdkDownloader/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ export class JdkDownloaderView {
public static readonly DOWNLOAD_CMD = 'downloadJDK';
public static readonly JDK_TYPE = {
oracleJdk: "oracleJdk",
openJdk: "openJdk",
openJdk: "openJdk"
}

public static getJdkLabel = (id: string): string => {
const key = "jdk.downloader.label." + id;
const label = l10n.value(key);
return label !== key ? label : id;
}

private static readonly OPEN_JDK_LABEL = l10n.value("jdk.downloader.label.openJdk");
private static readonly ORACLE_JDK_LABEL = l10n.value("jdk.downloader.label.oracleJdk");
private readonly jdkDownloaderTitle = l10n.value("jdk.downloader.heading");

private jdkDownloaderWebView?: WebviewPanel;
Expand Down