From b6a36ebc595d413bcc0c5f58c1905da65dd39298 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Tue, 22 Oct 2019 14:24:26 -0700 Subject: [PATCH] BDC Dashboard context sensitive troubleshoot links (#7895) * Add context awareness to troubleshoot button on dashboard * Remove tests for now * Undo yarn.lock changes * Correct yarn.lock version * Lower case service check --- .../src/bigDataCluster/dialog/bdcDashboard.ts | 12 ++++----- .../dialog/bdcDashboardModel.ts | 25 ++++++++++++++++++- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboard.ts b/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboard.ts index c523759fce..2999b2c1e0 100644 --- a/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboard.ts +++ b/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboard.ts @@ -8,7 +8,7 @@ import * as azdata from 'azdata'; import * as vscode from 'vscode'; import * as nls from 'vscode-nls'; -import { BdcDashboardModel } from './bdcDashboardModel'; +import { BdcDashboardModel, getTroubleshootNotebookUrl } from './bdcDashboardModel'; import { IconPathHelper, cssStyles } from '../constants'; import { BdcServiceStatusPage } from './bdcServiceStatusPage'; import { BdcDashboardOverviewPage } from './bdcDashboardOverviewPage'; @@ -22,7 +22,7 @@ const navWidth = '200px'; const selectedTabCss = { 'font-weight': 'bold' }; const unselectedTabCss = { 'font-weight': '' }; -type NavTab = { div: azdata.DivContainer, dot: azdata.TextComponent, text: azdata.TextComponent }; +type NavTab = { serviceName: string, div: azdata.DivContainer, dot: azdata.TextComponent, text: azdata.TextComponent }; export class BdcDashboard { @@ -83,7 +83,7 @@ export class BdcDashboard { }).component(); openTroubleshootNotebookButton.onDidClick(() => { - vscode.commands.executeCommand('books.sqlserver2019'); + vscode.commands.executeCommand('books.sqlserver2019', getTroubleshootNotebookUrl(this.currentTab.serviceName)); }); const toolbarContainer = modelView.modelBuilder.toolbarContainer() @@ -130,7 +130,7 @@ export class BdcDashboard { overviewNavItemDiv.addItem(overviewNavItemText, { CSSStyles: { 'user-select': 'text' } }); const overviewPage = new BdcDashboardOverviewPage(this, this.model).create(modelView); this.currentPage = overviewPage; - this.currentTab = { div: overviewNavItemDiv, dot: undefined, text: overviewNavItemText }; + this.currentTab = { serviceName: undefined, div: overviewNavItemDiv, dot: undefined, text: overviewNavItemText }; this.mainAreaContainer.addItem(overviewPage, { flex: '0 0 100%', CSSStyles: { 'margin': '0 20px 0 20px' } }); overviewNavItemDiv.onDidClick(() => { @@ -140,7 +140,7 @@ export class BdcDashboard { this.mainAreaContainer.removeItem(this.currentPage); this.mainAreaContainer.addItem(overviewPage, { flex: '0 0 100%', CSSStyles: { 'margin': '0 20px 0 20px' } }); this.currentPage = overviewPage; - this.currentTab = { div: overviewNavItemDiv, dot: undefined, text: overviewNavItemText }; + this.currentTab = { serviceName: undefined, div: overviewNavItemDiv, dot: undefined, text: overviewNavItemText }; this.currentTab.text.updateCssStyles(selectedTabCss); }); this.navContainer.addItem(overviewNavItemDiv, { flex: '0 0 auto' }); @@ -227,5 +227,5 @@ function createServiceNavTab(modelBuilder: azdata.ModelBuilder, serviceStatus: S const text = modelBuilder.text().withProperties({ value: getServiceNameDisplayText(serviceStatus.serviceName), CSSStyles: { ...cssStyles.tabHeaderText } }).component(); innerContainer.addItem(text, { flex: '0 0 auto' }); div.addItem(innerContainer); - return { div: div, dot: dot, text: text }; + return { serviceName: serviceStatus.serviceName, div: div, dot: dot, text: text }; } diff --git a/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardModel.ts b/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardModel.ts index bdb1c0672c..4edbb9d09f 100644 --- a/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardModel.ts +++ b/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardModel.ts @@ -7,7 +7,7 @@ import * as azdata from 'azdata'; import * as vscode from 'vscode'; import { ClusterController } from '../controller/clusterControllerApi'; import { EndpointModel, BdcStatusModel } from '../controller/apiGenerated'; -import { showErrorMessage, Endpoint } from '../utils'; +import { showErrorMessage, Endpoint, Service } from '../utils'; import { AuthType } from '../constants'; export type BdcDashboardOptions = { url: string, auth: AuthType, username: string, password: string }; @@ -94,6 +94,29 @@ export class BdcDashboardModel { } } +/** + * Retrieves the troubleshoot book URL for the specified service, defaulting to the BDC + * troubleshoot notebook if the service name is unknown. + * @param service The service name to get the troubleshoot notebook URL for + */ +export function getTroubleshootNotebookUrl(service: string): string { + switch (service.toLowerCase()) { + case Service.sql: + return 'troubleshooters/tsg101-troubleshoot-sql-server'; + case Service.hdfs: + return 'troubleshooters/tsg102-troubleshoot-hdfs'; + case Service.spark: + return 'troubleshooters/tsg103-troubleshoot-spark'; + case Service.control: + return 'troubleshooters/tsg104-troubleshoot-control'; + case Service.gateway: + return 'troubleshooters/tsg105-troubleshoot-gateway'; + case Service.app: + return 'troubleshooters/tsg106-troubleshoot-app'; + } + return 'troubleshooters/tsg100-troubleshoot-bdc'; +} + /** * Applies fixes to the endpoints received so they are displayed correctly * @param endpoints The endpoints received to modify