diff --git a/CHANGELOG.md b/CHANGELOG.md index 0431aaf9..31df5ffe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - [#798](https://github.com/estruyf/vscode-front-matter/issues/798): Changed dialog to slide-over for the snippet forms - [#799](https://github.com/estruyf/vscode-front-matter/issues/799): Added `frontMatter.logging` setting to define the logging output. Options are `info`, `warn`, `error`, and `verbose`. Default is `info`. - [#800](https://github.com/estruyf/vscode-front-matter/issues/800): Add colors for the Front Matter CMS output +- [#810](https://github.com/estruyf/vscode-front-matter/issues/810): Update the tab title based on the view ### ⚡️ Optimizations diff --git a/src/commands/Dashboard.ts b/src/commands/Dashboard.ts index 80d9f9cf..aaf2443b 100644 --- a/src/commands/Dashboard.ts +++ b/src/commands/Dashboard.ts @@ -45,6 +45,13 @@ export class Dashboard { return Dashboard._viewData; } + public static setTitle(title: string) { + if (title && Dashboard.webview) { + Dashboard.webview.title = + title || `Front Matter ${l10n.t(LocalizationKey.commandsDashboardTitle)}`; + } + } + /** * Init the dashboard */ diff --git a/src/constants/TelemetryEvent.ts b/src/constants/TelemetryEvent.ts index f717da6f..6047f5f8 100644 --- a/src/constants/TelemetryEvent.ts +++ b/src/constants/TelemetryEvent.ts @@ -47,6 +47,8 @@ export const TelemetryEvent = { webviewContentsView: 'webviewContentsView', webviewSnippetsView: 'webviewSnippetsView', webviewTaxonomyDashboard: 'webviewTaxonomyDashboard', + webviewSettings: 'webviewSettings', + webviewUnknown: 'webviewUnknown', // Git gitSync: 'gitSync', diff --git a/src/dashboardWebView/DashboardMessage.ts b/src/dashboardWebView/DashboardMessage.ts index 73a2fe97..84b38185 100644 --- a/src/dashboardWebView/DashboardMessage.ts +++ b/src/dashboardWebView/DashboardMessage.ts @@ -76,6 +76,7 @@ export enum DashboardMessage { runCustomScript = 'runCustomScript', sendTelemetry = 'sendTelemetry', showNotification = 'showNotification', + setTitle = 'setTitle', // Settings getSettings = 'getSettings', diff --git a/src/dashboardWebView/components/Contents/Contents.tsx b/src/dashboardWebView/components/Contents/Contents.tsx index d3b7b618..23e30bd9 100644 --- a/src/dashboardWebView/components/Contents/Contents.tsx +++ b/src/dashboardWebView/components/Contents/Contents.tsx @@ -70,6 +70,8 @@ export const Contents: React.FunctionComponent = ({ Messenger.send(DashboardMessage.sendTelemetry, { event: TelemetryEvent.webviewContentsView }); + + Messenger.send(DashboardMessage.setTitle, l10n.t(LocalizationKey.dashboardHeaderTabsContents)); }, []); return ( diff --git a/src/dashboardWebView/components/DataView/DataView.tsx b/src/dashboardWebView/components/DataView/DataView.tsx index ba752919..4ce2e7b0 100644 --- a/src/dashboardWebView/components/DataView/DataView.tsx +++ b/src/dashboardWebView/components/DataView/DataView.tsx @@ -125,6 +125,8 @@ export const DataView: React.FunctionComponent = ( useEffect(() => { Messenger.listen(messageListener); + Messenger.send(DashboardMessage.setTitle, l10n.t(LocalizationKey.dashboardHeaderTabsData)); + Messenger.send(DashboardMessage.sendTelemetry, { event: TelemetryEvent.webviewDataView }); diff --git a/src/dashboardWebView/components/Media/Media.tsx b/src/dashboardWebView/components/Media/Media.tsx index f5b399aa..12dbbc0c 100644 --- a/src/dashboardWebView/components/Media/Media.tsx +++ b/src/dashboardWebView/components/Media/Media.tsx @@ -150,6 +150,8 @@ export const Media: React.FunctionComponent = ( ); useEffect(() => { + Messenger.send(DashboardMessage.setTitle, l10n.t(LocalizationKey.dashboardHeaderTabsMedia)); + Messenger.send(DashboardMessage.sendTelemetry, { event: TelemetryEvent.webviewMediaView }); diff --git a/src/dashboardWebView/components/SettingsView/SettingsView.tsx b/src/dashboardWebView/components/SettingsView/SettingsView.tsx index 7c316d70..e04d91d6 100644 --- a/src/dashboardWebView/components/SettingsView/SettingsView.tsx +++ b/src/dashboardWebView/components/SettingsView/SettingsView.tsx @@ -8,11 +8,14 @@ import { AstroContentTypes } from '../Configuration/Astro/AstroContentTypes'; import { ContentFolders } from '../Configuration/Common/ContentFolders'; import * as l10n from '@vscode/l10n'; import { LocalizationKey } from '../../../localization'; -import { COMMAND_NAME } from '../../../constants'; +import { COMMAND_NAME, TelemetryEvent } from '../../../constants'; import { ArrowPathIcon } from '@heroicons/react/24/outline'; import { VSCodePanelTab, VSCodePanelView, VSCodePanels } from '@vscode/webview-ui-toolkit/react'; import { CommonSettings } from './CommonSettings'; import { IntegrationsView } from './IntegrationsView'; +import { useEffect } from 'react'; +import { Messenger } from '@estruyf/vscode/dist/client'; +import { DashboardMessage } from '../../DashboardMessage'; export interface ISettingsViewProps { } @@ -20,6 +23,14 @@ export const SettingsView: React.FunctionComponent = (_: Rea const [loading, setLoading] = React.useState(false); const settings = useRecoilValue(SettingsSelector); + useEffect(() => { + Messenger.send(DashboardMessage.setTitle, l10n.t(LocalizationKey.commonSettings)); + + Messenger.send(DashboardMessage.sendTelemetry, { + event: TelemetryEvent.webviewSettings + }); + }, []); + return ( { diff --git a/src/dashboardWebView/components/SnippetsView/Snippets.tsx b/src/dashboardWebView/components/SnippetsView/Snippets.tsx index 7ff20304..f6dc876a 100644 --- a/src/dashboardWebView/components/SnippetsView/Snippets.tsx +++ b/src/dashboardWebView/components/SnippetsView/Snippets.tsx @@ -81,6 +81,8 @@ export const Snippets: React.FunctionComponent = ( }; useEffect(() => { + Messenger.send(DashboardMessage.setTitle, l10n.t(LocalizationKey.dashboardHeaderTabsSnippets)); + Messenger.send(DashboardMessage.sendTelemetry, { event: TelemetryEvent.webviewSnippetsView }); diff --git a/src/dashboardWebView/components/TaxonomyView/TaxonomyView.tsx b/src/dashboardWebView/components/TaxonomyView/TaxonomyView.tsx index 9ba266a6..81ddca32 100644 --- a/src/dashboardWebView/components/TaxonomyView/TaxonomyView.tsx +++ b/src/dashboardWebView/components/TaxonomyView/TaxonomyView.tsx @@ -53,6 +53,8 @@ export const TaxonomyView: React.FunctionComponent = ({ }, [settings?.tags, settings?.categories, settings?.customTaxonomy]); useEffect(() => { + Messenger.send(DashboardMessage.setTitle, l10n.t(LocalizationKey.dashboardHeaderTabsTaxonomies)); + Messenger.send(DashboardMessage.sendTelemetry, { event: TelemetryEvent.webviewTaxonomyDashboard }); diff --git a/src/dashboardWebView/components/UnknownView/UnknownView.tsx b/src/dashboardWebView/components/UnknownView/UnknownView.tsx index db71c7ca..c9d72126 100644 --- a/src/dashboardWebView/components/UnknownView/UnknownView.tsx +++ b/src/dashboardWebView/components/UnknownView/UnknownView.tsx @@ -2,12 +2,24 @@ import { StopIcon } from '@heroicons/react/24/outline'; import * as React from 'react'; import * as l10n from '@vscode/l10n'; import { LocalizationKey } from '../../../localization'; +import { useEffect } from 'react'; +import { Messenger } from '@estruyf/vscode/dist/client'; +import { DashboardMessage } from '../../DashboardMessage'; +import { TelemetryEvent } from '../../../constants'; export interface IUnknownViewProps { } export const UnknownView: React.FunctionComponent = ( _: React.PropsWithChildren ) => { + useEffect(() => { + Messenger.send(DashboardMessage.setTitle, "Unknown View"); + + Messenger.send(DashboardMessage.sendTelemetry, { + event: TelemetryEvent.webviewUnknown + }); + }, []); + return (
diff --git a/src/dashboardWebView/components/WelcomeView/WelcomeScreen.tsx b/src/dashboardWebView/components/WelcomeView/WelcomeScreen.tsx index f8f86c0f..65a5f0c6 100644 --- a/src/dashboardWebView/components/WelcomeView/WelcomeScreen.tsx +++ b/src/dashboardWebView/components/WelcomeView/WelcomeScreen.tsx @@ -34,6 +34,8 @@ export const WelcomeScreen: React.FunctionComponent = ({ location: "DASHBOARD" }); + Messenger.send(DashboardMessage.setTitle, "Welcome to Front Matter"); + const crntState: any = Messenger.getState() || {}; Messenger.setState({ ...crntState, diff --git a/src/listeners/dashboard/DashboardListener.ts b/src/listeners/dashboard/DashboardListener.ts index bccd7b23..1dc6664d 100644 --- a/src/listeners/dashboard/DashboardListener.ts +++ b/src/listeners/dashboard/DashboardListener.ts @@ -20,6 +20,9 @@ export class DashboardListener extends BaseListener { super.process(msg); switch (msg.command) { + case DashboardMessage.setTitle: + Dashboard.setTitle(msg.payload); + break; case DashboardMessage.getViewType: if (Dashboard.viewData) { this.sendMsg(DashboardCommand.viewData, Dashboard.viewData);