From 597c142f0565a9b051060d60e74085bb08083272 Mon Sep 17 00:00:00 2001 From: Tim Roes Date: Tue, 19 Feb 2019 10:32:21 +0100 Subject: [PATCH] Add documentation links to Visualize/Dashboard (#31406) * Add documentation links to Visualize/Dashboard * Add more targeted links --- .../kibana/public/dashboard/dashboard_app.js | 3 +++ .../dashboard/top_nav/get_top_nav_config.js | 19 +++++++++++++++++-- .../public/dashboard/top_nav/top_nav_ids.js | 1 + .../kibana/public/visualize/editor/editor.js | 9 +++++++++ .../documentation_links.ts | 4 ++++ 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.js b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.js index 78ebc27431b94..18f6974aea281 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.js +++ b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.js @@ -55,6 +55,7 @@ import { ContextMenuActionsRegistryProvider } from 'ui/embeddable'; import { VisTypesRegistryProvider } from 'ui/registry/vis_types'; import { timefilter } from 'ui/timefilter'; import { getUnhashableStatesProvider } from 'ui/state_management/state_hashing'; +import { documentationLinks } from 'ui/documentation_links'; import { DashboardViewportProvider } from './viewport/dashboard_viewport_provider'; @@ -86,6 +87,7 @@ app.directive('dashboardApp', function ($injector) { $rootScope, $route, $routeParams, + $window, getAppState, dashboardConfig, localStorage, @@ -364,6 +366,7 @@ app.directive('dashboardApp', function ($injector) { $scope.kbnTopNav.click('edit'); }; const navActions = {}; + navActions[TopNavIds.DOCUMENTATION] = () => $window.open(documentationLinks.kibana.dashboard); navActions[TopNavIds.FULL_SCREEN] = () => dashboardStateManager.setFullScreenMode(true); navActions[TopNavIds.EXIT_EDIT_MODE] = () => onChangeViewMode(DashboardViewMode.VIEW); diff --git a/src/legacy/core_plugins/kibana/public/dashboard/top_nav/get_top_nav_config.js b/src/legacy/core_plugins/kibana/public/dashboard/top_nav/get_top_nav_config.js index 969ff3f631de5..dffc51ee35bfe 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/top_nav/get_top_nav_config.js +++ b/src/legacy/core_plugins/kibana/public/dashboard/top_nav/get_top_nav_config.js @@ -41,7 +41,8 @@ export function getTopNavConfig(dashboardMode, actions, hideWriteControls) { getFullScreenConfig(actions[TopNavIds.FULL_SCREEN]), getShareConfig(actions[TopNavIds.SHARE]), getCloneConfig(actions[TopNavIds.CLONE]), - getEditConfig(actions[TopNavIds.ENTER_EDIT_MODE]) + getEditConfig(actions[TopNavIds.ENTER_EDIT_MODE]), + getDocumentationConfig(actions[TopNavIds.DOCUMENTATION]), ] ); case DashboardViewMode.EDIT: @@ -50,7 +51,9 @@ export function getTopNavConfig(dashboardMode, actions, hideWriteControls) { getViewConfig(actions[TopNavIds.EXIT_EDIT_MODE]), getAddConfig(actions[TopNavIds.ADD]), getOptionsConfig(actions[TopNavIds.OPTIONS]), - getShareConfig(actions[TopNavIds.SHARE])]; + getShareConfig(actions[TopNavIds.SHARE]), + getDocumentationConfig(actions[TopNavIds.DOCUMENTATION]), + ]; default: return []; } @@ -180,3 +183,15 @@ function getOptionsConfig(action) { run: action, }; } + +function getDocumentationConfig(action) { + return { + key: i18n.translate('kbn.dashboard.topNav.documentationButtonKey', { + defaultMessage: 'documentation', + }), + description: i18n.translate('kbn.dashboard.topNav.documentationButtonDescription', { + defaultMessage: 'Documentation', + }), + run: action, + }; +} diff --git a/src/legacy/core_plugins/kibana/public/dashboard/top_nav/top_nav_ids.js b/src/legacy/core_plugins/kibana/public/dashboard/top_nav/top_nav_ids.js index 9df86f2ca3cce..ec357302d4636 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/top_nav/top_nav_ids.js +++ b/src/legacy/core_plugins/kibana/public/dashboard/top_nav/top_nav_ids.js @@ -20,6 +20,7 @@ export const TopNavIds = { ADD: 'add', SHARE: 'share', + DOCUMENTATION: 'documentation', OPTIONS: 'options', SAVE: 'save', EXIT_EDIT_MODE: 'exitEditMode', diff --git a/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js b/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js index 46ad82cdfa96c..3ea21052299ad 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js +++ b/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js @@ -47,6 +47,7 @@ import { showShareContextMenu, ShareContextMenuExtensionsRegistryProvider } from import { getUnhashableStatesProvider } from 'ui/state_management/state_hashing'; import { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal'; import { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal'; +import { documentationLinks } from 'ui/documentation_links'; uiRoutes .when(VisualizeConstants.CREATE_PATH, { @@ -234,6 +235,14 @@ function VisEditor( vis.forceReload(); }, testId: 'visualizeRefreshButton', + }, { + key: i18n('kbn.topNavManu.documentationLabel', { defaultMessage: 'documentation' }), + description: i18n('kbn.visualize.topNavMenu.documentationButtonDescription', { + defaultMessage: 'Documentation', + }), + run() { + $window.open(documentationLinks.kibana.visualize); + }, }]; let stateMonitor; diff --git a/src/ui/public/documentation_links/documentation_links.ts b/src/ui/public/documentation_links/documentation_links.ts index d9252f7aa2a64..38aa4250ba90d 100644 --- a/src/ui/public/documentation_links/documentation_links.ts +++ b/src/ui/public/documentation_links/documentation_links.ts @@ -85,6 +85,10 @@ export const documentationLinks = { loadingData: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/tutorial-load-dataset.html`, introduction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/index-patterns.html`, }, + kibana: { + visualize: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/visualize.html`, + dashboard: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/dashboard.html`, + }, query: { luceneQuerySyntax: `${ELASTIC_DOCS}query-dsl-query-string-query.html#query-string-syntax`, queryDsl: `${ELASTIC_DOCS}query-dsl.html`,