Skip to content

Commit c715830

Browse files
authored
Show past release note entries (#121)
1 parent 375b883 commit c715830

File tree

5 files changed

+95
-34
lines changed

5 files changed

+95
-34
lines changed

package-lock.json

Lines changed: 58 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"workspaceContains:build.gradle",
3737
"workspaceContains:mnvw",
3838
"onCommand:java.overview",
39-
"onCommand:java.showLatestReleaseNotes",
39+
"onCommand:java.showReleaseNotes",
4040
"onWebviewPanel:java.overview"
4141
],
4242
"contributes": {
@@ -46,7 +46,7 @@
4646
"title": "Java: Overview"
4747
},
4848
{
49-
"command": "java.showLatestReleaseNotes",
49+
"command": "java.showReleaseNotes",
5050
"title": "Java: Show Release Notes"
5151
}
5252
]

src/commands/handler.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as vscode from "vscode";
66
import { validateAndRecommendExtension } from "../recommendation";
77
import { sendInfo } from "vscode-extension-telemetry-wrapper";
88
import { getReleaseNotesEntries, findLatestReleaseNotes } from "../utils";
9+
import { gt, eq } from "semver";
910

1011
export async function createMavenProjectCmdHanlder(context: vscode.ExtensionContext) {
1112
if (!await validateAndRecommendExtension("vscjava.vscode-maven", "Maven extension is recommended to help create Java projects and work with custom goals.", true)) {
@@ -43,8 +44,37 @@ export async function showReleaseNotes(context: vscode.ExtensionContext, operati
4344
});
4445
}
4546

46-
export async function showLatestReleaseNotesHandler(context: vscode.ExtensionContext, operationId: string) {
47+
export async function showReleaseNotesHandler(context: vscode.ExtensionContext, operationId: string, version: string | undefined) {
4748
const entries = await getReleaseNotesEntries(context);
4849
const latest = findLatestReleaseNotes(entries);
49-
await showReleaseNotes(context, operationId, latest.version);
50+
51+
if (version === "latest") {
52+
version = latest.version;
53+
}
54+
55+
if (version === undefined) {
56+
const versions = entries.map((entry) => entry.version).sort((a, b) => {
57+
if (gt(a, b)) {
58+
return -1;
59+
} else if (eq(a, b)) {
60+
return 0;
61+
}
62+
63+
return 1;
64+
});
65+
66+
version = await vscode.window.showQuickPick(versions, {
67+
ignoreFocusOut: true
68+
});
69+
70+
if (!version) {
71+
return;
72+
}
73+
}
74+
75+
sendInfo(operationId, {
76+
version: version
77+
});
78+
79+
return await showReleaseNotes(context, operationId, version);
5080
}

src/commands/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import * as vscode from "vscode";
55

66
import { instrumentCommand } from "../utils";
7-
import { createMavenProjectCmdHanlder, createSpringBootProjectCmdHandler, showExtensionCmdHandler, openUrlCmdHandler, showLatestReleaseNotesHandler } from "./handler";
7+
import { createMavenProjectCmdHanlder, createSpringBootProjectCmdHandler, showExtensionCmdHandler, openUrlCmdHandler, showReleaseNotesHandler } from "./handler";
88
import { overviewCmdHandler } from "../overview";
99

1010
export function initialize(context: vscode.ExtensionContext) {
@@ -13,5 +13,5 @@ export function initialize(context: vscode.ExtensionContext) {
1313
context.subscriptions.push(vscode.commands.registerCommand("java.helper.createSpringBootProject", instrumentCommand(context, "java.helper.createSpringBootProject", createSpringBootProjectCmdHandler)));
1414
context.subscriptions.push(vscode.commands.registerCommand("java.helper.showExtension", instrumentCommand(context, "java.helper.showExtension", showExtensionCmdHandler)));
1515
context.subscriptions.push(vscode.commands.registerCommand("java.helper.openUrl", instrumentCommand(context, "java.helper.openUrl", openUrlCmdHandler)));
16-
context.subscriptions.push(vscode.commands.registerCommand("java.showLatestReleaseNotes", instrumentCommand(context, "java.showLatestReleaseNotes", showLatestReleaseNotesHandler)));
16+
context.subscriptions.push(vscode.commands.registerCommand("java.showReleaseNotes", instrumentCommand(context, "java.showReleaseNotes", showReleaseNotesHandler)));
1717
}

src/misc/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export async function showReleaseNotesOnStart(context: vscode.ExtensionContext)
2424
return;
2525
}
2626

27-
await vscode.commands.executeCommand("java.showLatestReleaseNotes");
27+
await vscode.commands.executeCommand("java.showReleaseNotes", "latest");
2828

2929
history.push({
3030
version: latest.version,

0 commit comments

Comments
 (0)