Skip to content

Commit d34d759

Browse files
committed
feat(yasgui): What's new in the help menu
Lists the changes of each version since 5.0.0 as New, Improved or Fixed, with a filter per kind and a link to the GitHub release notes. A dot on the help button marks a release the user hasn't opened yet (not on a first visit); the newest seen version is persisted as whatsNewSeen. Also in the Ctrl+K search, and showWhatsNew: false switches it off.
1 parent 1f156c6 commit d34d759

12 files changed

Lines changed: 1018 additions & 4 deletions

File tree

‎.changeset/whats-new.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@matdata/yasgui": minor
3+
---
4+
5+
**What's new**: the help button of the top bar now opens a menu with **What's new** and the **Documentation**. What's new lists the changes of each version since 5.0.0 as New, Improved or Fixed, with a filter per kind and a link to the full release notes. After an update a dot on the help button points to it until it is opened; first-time users get no dot. Also in the Ctrl+K search. Embedders can switch it off with `showWhatsNew: false` and add their own entries with `yasgui.helpMenu.addItem()`. `helpUrl: false` now only leaves out the documentation entry.

‎docs/developer-guide.md‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,9 +718,14 @@ interface Config {
718718
// Look up IRIs the endpoint doesn't describe in LOV (lov.linkeddata.es)
719719
iriHoverLovFallback?: boolean; // default: true
720720

721-
// Page opened by the help button of the top bar; false hides the button
721+
// Documentation link in the menu of the help button of the top bar; false leaves it out.
722+
// The help button hides when its menu has no entries left
722723
helpUrl?: string | false; // default: 'https://matgui-doc.matdata.eu/docs/user-guide'
723724

725+
// "What's new" in the help menu: the changes per version, with a dot on the help button
726+
// until the user has seen the latest release. Also in the Ctrl+K search
727+
showWhatsNew?: boolean; // default: true
728+
724729
// AI assistant (see AI Assistant Configuration); { enabled: false } removes it
725730
ai: Partial<AiConfig>;
726731
/**
@@ -2547,6 +2552,24 @@ The older entry points keep working and now drive the side panel:
25472552
25482553
A pinned describe panel saved by an earlier version is restored as the pinned Endpoint view.
25492554
2555+
#### Help menu and What's new
2556+
2557+
The help button of the top bar opens `yasgui.helpMenu`. Add your own entries, for example a link to your site's documentation; entries are sorted on `order` (built-in: quick start 10, What's new 20, Documentation 90, default 100). With a single entry the button runs it directly, and without entries it is hidden.
2558+
2559+
```javascript
2560+
yasgui.helpMenu.addItem({
2561+
id: "contact", // an existing id is replaced
2562+
label: "Contact support",
2563+
icon: "externalLink", // optional, a MatGUI icon name
2564+
order: 95,
2565+
onClick: () => window.open("https://example.org/support", "_blank"),
2566+
});
2567+
yasgui.helpMenu.setBadge("contact", true); // dot on the entry and the help button
2568+
yasgui.helpMenu.removeItem("contact");
2569+
```
2570+
2571+
`yasgui.whatsNew` (unless `showWhatsNew: false`) has `open()`, `close()`, `hasUnseen()` and `getLatestVersion()`. The release entries live in `packages/yasgui/src/whatsNew/releases.ts`, newest first; add the next version there when preparing a release. The newest version a user has opened is stored as `whatsNewSeen` in the persisted config.
2572+
25502573
### Tab Class
25512574
25522575
Represents a query tab.

‎docs/user-guide.md‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- [The Interface](#the-interface)
2626
- [Top Bar](#top-bar)
2727
- [Search](#search)
28+
- [Help Menu and What's New](#help-menu-and-whats-new)
2829
- [Query Card](#query-card)
2930
- [Endpoint Picker](#endpoint-picker)
3031
- [Run and Stop](#run-and-stop)
@@ -352,7 +353,7 @@ From left to right:
352353
- **MatGUI**: the name of the application (sites that embed MatGUI can hide it)
353354
- **Query tabs**: one tab per query. The active tab is raised. Tabs that hold a saved (managed) query show a small dot before their name; the dot turns amber when the query has unsaved changes. Hover a tab to show its close button (×), click **+** to add a tab
354355
- **Search queries and commands** (`Ctrl+K`, or `⌘K` on a Mac): see [Search](#search)
355-
- **Help** (?): opens the MatGUI user guide in a new browser tab
356+
- **Help** (?): opens the help menu with **What's new** and the **Documentation** (see [Help Menu and What's New](#help-menu-and-whats-new)). A blue dot on the button means there is a release you haven't seen yet
356357
- **Theme** (sun / moon): switches between the light and dark theme
357358
- **Settings** (gear): opens the settings of the active tab
358359

@@ -362,11 +363,22 @@ Click **Search queries and commands** in the top bar, or press `Ctrl+K` (`⌘K`
362363

363364
- **Queries**: the saved queries of all your workspaces, with the workspace and folder they are in. Pick one to open it in a new tab, or to go to the tab that already has it open
364365
- **Snippets**: the code snippets of the [Insert menu](#insert-menu), found by name, group or the code they write (`filter` finds the comparison snippets). Pick one to insert it at the cursor
365-
- **Commands**: Run query, New tab, Insert snippet, Insert PREFIX declarations, Switch endpoint, Explore endpoint, Show saved queries, Toggle side panel, Toggle side-by-side layout, Format, Share, Save, Download, full screen editor, dark mode and the documentation. Commands with a shortcut show it at the right
366+
- **Commands**: Run query, New tab, Insert snippet, Insert PREFIX declarations, Switch endpoint, Explore endpoint, Show saved queries, Toggle side panel, Toggle side-by-side layout, Format, Share, Save, Download, full screen editor, dark mode, What's new and the documentation. Commands with a shortcut show it at the right
366367
- **Settings**: every page of the settings (General, SPARQL endpoints, Workspaces, Prefixes, Editor, AI, Import / export, Keyboard shortcuts, About), for example type `prefixes` and pick **Settings: Prefixes**
367368

368369
Type `>` first to search commands and settings only. Snippets and settings show up once you type something. Use `↑` and `↓` to move, `Enter` to open and `Esc` to close.
369370

371+
### Help Menu and What's New
372+
373+
Click **Help** (?) in the top bar to open the help menu:
374+
375+
- **What's new**: what changed in each version of MatGUI since 5.0.0, newest first. Every change is marked **New**, **Improved** or **Fixed**; use the buttons at the top to show only one kind. Releases you haven't seen yet are marked **New to you**. **Full release notes on GitHub** opens the complete notes, including the changes for developers
376+
- **Documentation**: opens this user guide in a new browser tab
377+
378+
After MatGUI is updated, a blue dot on the Help button and next to **What's new** tells you there is something new. The dot goes away once you open What's new. On your first visit there is no dot. You can also open it from the [search](#search) (`Ctrl+K`, then type `what's new`). Press `Esc` to close it.
379+
380+
Sites that embed MatGUI can leave out What's new (`showWhatsNew: false`) or the documentation link (`helpUrl: false`).
381+
370382
### Query Card
371383

372384
The head of the card shows:

‎packages/yasgui/src/CommandPalette.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,15 @@ export default class CommandPalette {
386386
},
387387
});
388388
}
389+
if (yasgui.whatsNew) {
390+
commands.push({
391+
section: "commands",
392+
label: "What's new",
393+
icon: "sparkles",
394+
keywords: "release notes changelog changes version update",
395+
run: () => yasgui.whatsNew?.open(),
396+
});
397+
}
389398
if (yasgui.config.helpUrl) {
390399
const helpUrl = yasgui.config.helpUrl;
391400
commands.push({

‎packages/yasgui/src/PersistentConfig.ts‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface PersistedJson {
2525
sidePanel?: SidePanelState; // Left side panel (Queries / Endpoint / AI)
2626
requestSettings?: RequestSettings; // Request settings of Settings → General, shared by all tabs
2727
editorSettings?: EditorSettings; // Formatter and checks of Settings → General and Editor, shared by all tabs
28+
whatsNewSeen?: string; // Newest version the user has seen in What's new
2829
}
2930
/** Settings of the query editor that apply to every tab */
3031
export interface EditorSettings {
@@ -67,6 +68,8 @@ export default class PersistentConfig {
6768
private storageId: string | undefined;
6869
private yasgui: Yasgui;
6970
private storage: YStorage;
71+
/** Whether a configuration was stored before this page load (false on a first visit) */
72+
private hadStoredConfig = false;
7073
constructor(yasgui: Yasgui) {
7174
this.yasgui = yasgui;
7275
this.storageId = this.yasgui.getStorageId(this.yasgui.config.persistenceLabelConfig);
@@ -139,7 +142,9 @@ export default class PersistentConfig {
139142
);
140143
}
141144
private fromStorage(): PersistedJson {
142-
this.persistedJson = this.storage.get<PersistedJson>(this.storageId) || getDefaults();
145+
const stored = this.storage.get<PersistedJson>(this.storageId);
146+
this.hadStoredConfig = !!stored;
147+
this.persistedJson = stored || getDefaults();
143148
/**
144149
* Modify some settings for backwards compatability
145150
*/
@@ -154,6 +159,18 @@ export default class PersistentConfig {
154159
PersistentConfig.clear();
155160
}
156161

162+
/** False on a first visit, before anything was stored */
163+
public hasStoredConfig(): boolean {
164+
return this.hadStoredConfig;
165+
}
166+
public getWhatsNewSeen(): string | undefined {
167+
return this.persistedJson.whatsNewSeen;
168+
}
169+
public setWhatsNewSeen(version: string) {
170+
this.persistedJson.whatsNewSeen = version;
171+
this.toStorage();
172+
}
173+
157174
public getTabs() {
158175
return this.persistedJson.tabs;
159176
}

‎packages/yasgui/src/defaults.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default function initialize(): Config<CatalogueItem> {
3737
iriHover: true,
3838
iriHoverLovFallback: true,
3939
helpUrl: "https://matgui-doc.matdata.eu/docs/user-guide",
40+
showWhatsNew: true,
4041
endpointDescribe: {
4142
enabled: true,
4243
timeoutMs: 60000,

‎packages/yasgui/src/index.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import SparqlAnythingSupport from "./sparqlAnything/SparqlAnythingSupport";
2727
import SidePanel from "./sidePanel/SidePanel";
2828
import CommandPalette from "./CommandPalette";
2929
import HelpMenu from "./HelpMenu";
30+
import WhatsNew from "./whatsNew/WhatsNew";
3031
import AiAssistant from "./ai/AiAssistant";
3132
import type { AiConfig } from "./ai/types";
3233
import "./index.scss";
@@ -135,6 +136,10 @@ export interface Config<EndpointObject extends CatalogueItem = CatalogueItem> {
135136
* hides when its menu has no other entries, such as the quick start tour or what's new).
136137
*/
137138
helpUrl?: string | false;
139+
/**
140+
* Show "What's new" in the help menu, with a dot on the help button after an update (default: true)
141+
*/
142+
showWhatsNew?: boolean;
138143
/**
139144
* Show the label, description and type of an IRI when hovering it in the query editor, fetched from the
140145
* endpoint of the tab (default: true). Users can switch it off in the editor settings.
@@ -216,6 +221,8 @@ export class Yasgui extends EventEmitter {
216221
public commandPalette: CommandPalette | undefined;
217222
/** Menu of the help button in the top bar; add entries with `helpMenu.addItem()` */
218223
public helpMenu: HelpMenu;
224+
/** What's new dialog (help menu and Ctrl+K search), unless `showWhatsNew` is false */
225+
public whatsNew: WhatsNew | undefined;
219226
/** AI assistant (the "AI" view of the side panel), unless `ai.enabled` is false */
220227
public aiAssistant: AiAssistant | undefined;
221228
/** SPARQL Anything support (the "Source" view of the side panel), unless `sparqlAnything` is false */
@@ -254,6 +261,7 @@ export class Yasgui extends EventEmitter {
254261
}
255262

256263
this.helpMenu = new HelpMenu(this);
264+
if (this.config.showWhatsNew) this.whatsNew = new WhatsNew(this);
257265
this.tabElements = new TabElements(this);
258266
this.tabPanelsEl = document.createElement("div");
259267
addClass(this.tabPanelsEl, "yasgui-tabPanels");
@@ -605,6 +613,7 @@ export class Yasgui extends EventEmitter {
605613
this.sparqlAnything?.destroy();
606614
this.aiAssistant?.destroy();
607615
this.commandPalette?.destroy();
616+
this.whatsNew?.destroy();
608617
this.helpMenu.destroy();
609618
this.sidePanel.destroy();
610619
this.tabElements.destroy();

0 commit comments

Comments
 (0)