diff --git a/src/commands/Dashboard.ts b/src/commands/Dashboard.ts index 9484bef1..41e7dd5c 100644 --- a/src/commands/Dashboard.ts +++ b/src/commands/Dashboard.ts @@ -3,11 +3,13 @@ import { CONTEXT, ExtensionState, SETTING_EXPERIMENTAL, - SETTING_EXTENSIBILITY_SCRIPTS + SETTING_EXTENSIBILITY_SCRIPTS, + COMMAND_NAME, + TelemetryEvent } from '../constants'; import { join } from 'path'; import { commands, Uri, ViewColumn, Webview, WebviewPanel, window } from 'vscode'; -import { DashboardSettings, Logger, Settings as SettingsHelper } from '../helpers'; +import { DashboardSettings, Logger, Settings as SettingsHelper, Telemetry } from '../helpers'; import { DashboardCommand } from '../dashboardWebView/DashboardCommand'; import { Extension } from '../helpers/Extension'; import { WebviewHelper } from '@estruyf/vscode'; @@ -32,6 +34,7 @@ import { Folders } from './Folders'; import * as l10n from '@vscode/l10n'; import { LocalizationKey } from '../localization'; import { DashboardMessage } from '../dashboardWebView/DashboardMessage'; +import { NavigationType } from '../dashboardWebView/models'; export class Dashboard { private static webview: WebviewPanel | null = null; @@ -52,6 +55,56 @@ export class Dashboard { } } + public static registerCommands() { + const subscriptions = Extension.getInstance().subscriptions; + + subscriptions.push( + commands.registerCommand(COMMAND_NAME.dashboard, (data?: DashboardData) => { + Telemetry.send(TelemetryEvent.openContentDashboard); + if (!data) { + Dashboard.open({ type: NavigationType.Contents }); + } else { + Dashboard.open(data); + } + }) + ); + + subscriptions.push( + commands.registerCommand(COMMAND_NAME.dashboardMedia, () => { + Telemetry.send(TelemetryEvent.openMediaDashboard); + Dashboard.open({ type: NavigationType.Media }); + }) + ); + + subscriptions.push( + commands.registerCommand(COMMAND_NAME.dashboardSnippets, () => { + Telemetry.send(TelemetryEvent.openSnippetsDashboard); + Dashboard.open({ type: NavigationType.Snippets }); + }) + ); + + subscriptions.push( + commands.registerCommand(COMMAND_NAME.dashboardData, () => { + Telemetry.send(TelemetryEvent.openDataDashboard); + Dashboard.open({ type: NavigationType.Data }); + }) + ); + + subscriptions.push( + commands.registerCommand(COMMAND_NAME.dashboardTaxonomy, () => { + Telemetry.send(TelemetryEvent.openTaxonomyDashboard); + Dashboard.open({ type: NavigationType.Taxonomy }); + }) + ); + + subscriptions.push( + commands.registerCommand(COMMAND_NAME.dashboardClose, () => { + Telemetry.send(TelemetryEvent.closeDashboard); + Dashboard.close(); + }) + ); + } + /** * Open or reveal the dashboard */ diff --git a/src/extension.ts b/src/extension.ts index 80c3b6a2..4fe78498 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -87,51 +87,7 @@ export async function activate(context: vscode.ExtensionContext) { // Pages dashboard Dashboard.init(); - subscriptions.push( - vscode.commands.registerCommand(COMMAND_NAME.dashboard, (data?: DashboardData) => { - Telemetry.send(TelemetryEvent.openContentDashboard); - if (!data) { - Dashboard.open({ type: NavigationType.Contents }); - } else { - Dashboard.open(data); - } - }) - ); - - subscriptions.push( - vscode.commands.registerCommand(COMMAND_NAME.dashboardMedia, (data?: DashboardData) => { - Telemetry.send(TelemetryEvent.openMediaDashboard); - Dashboard.open({ type: NavigationType.Media }); - }) - ); - - subscriptions.push( - vscode.commands.registerCommand(COMMAND_NAME.dashboardSnippets, (data?: DashboardData) => { - Telemetry.send(TelemetryEvent.openSnippetsDashboard); - Dashboard.open({ type: NavigationType.Snippets }); - }) - ); - - subscriptions.push( - vscode.commands.registerCommand(COMMAND_NAME.dashboardData, (data?: DashboardData) => { - Telemetry.send(TelemetryEvent.openDataDashboard); - Dashboard.open({ type: NavigationType.Data }); - }) - ); - - subscriptions.push( - vscode.commands.registerCommand(COMMAND_NAME.dashboardTaxonomy, (data?: DashboardData) => { - Telemetry.send(TelemetryEvent.openTaxonomyDashboard); - Dashboard.open({ type: NavigationType.Taxonomy }); - }) - ); - - subscriptions.push( - vscode.commands.registerCommand(COMMAND_NAME.dashboardClose, (data?: DashboardData) => { - Telemetry.send(TelemetryEvent.closeDashboard); - Dashboard.close(); - }) - ); + Dashboard.registerCommands(); if (!extension.getVersion().usedVersion) { vscode.commands.executeCommand(COMMAND_NAME.dashboard);