-
-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathrelease-notes-manager.ts
More file actions
77 lines (68 loc) · 2.6 KB
/
release-notes-manager.ts
File metadata and controls
77 lines (68 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import * as vscode from 'vscode';
/**
* ReleaseNotesManager class handles release notes functionality
*/
export class ReleaseNotesManager implements vscode.Disposable {
private extensionContext: vscode.ExtensionContext;
private readonly zmodelPreviewReleaseNoteKey = 'zmodel-preview-release-note-shown';
constructor(context: vscode.ExtensionContext) {
this.extensionContext = context;
this.initialize();
}
/**
* Initialize and register commands, show release notes if first time
*/
initialize(): void {
this.showReleaseNotesIfFirstTime();
}
/**
* Show release notes on first activation of this version
*/
async showReleaseNotesIfFirstTime(): Promise<void> {
// Show release notes if this is the first time activating this version
if (!this.extensionContext.globalState.get(this.zmodelPreviewReleaseNoteKey)) {
await this.showReleaseNotes();
// Update the stored version to prevent showing again
await this.extensionContext.globalState.update(this.zmodelPreviewReleaseNoteKey, true);
// Add this key to sync keys for cross-machine synchronization
this.extensionContext.globalState.setKeysForSync([this.zmodelPreviewReleaseNoteKey]);
}
}
/**
* Show release notes (can be called manually)
*/
async showReleaseNotes(): Promise<void> {
try {
// Read the release notes HTML file
const releaseNotesPath = vscode.Uri.joinPath(
this.extensionContext.extensionUri,
'bundle/res/zmodel-preview-release-notes.html'
);
const htmlBytes = await vscode.workspace.fs.readFile(releaseNotesPath);
const htmlContent = Buffer.from(htmlBytes).toString('utf8');
// Create and show the release notes webview
const panel = vscode.window.createWebviewPanel(
'ZenstackReleaseNotes',
'ZenStack - New Feature Announcement!',
vscode.ViewColumn.One,
{
enableScripts: true,
retainContextWhenHidden: true,
}
);
panel.webview.html = htmlContent;
// Optional: Close the panel when user clicks outside or after some time
panel.onDidDispose(() => {
// Panel disposed
});
} catch (error) {
console.error('Error showing release notes:', error);
}
}
/**
* Dispose of resources
*/
dispose(): void {
// Any cleanup if needed
}
}