From 9e6ff3c3587cf42c9a677e94e0d5fdb06dd96435 Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 2 Nov 2016 16:45:36 -0600 Subject: [PATCH 1/2] show search bar in embedded dashboards and visualizations --- .../kibana/public/dashboard/index.html | 2 +- .../kibana/public/visualize/editor/editor.html | 2 +- src/ui/public/chrome/api/controls.js | 17 +++++++++++++++++ src/ui/public/chrome/directives/kbn_chrome.js | 3 +++ src/ui/public/kbn_top_nav/kbn_top_nav.html | 2 +- .../kbn_top_nav/kbn_top_nav_controller.js | 6 +++++- src/ui/public/share/directives/share.js | 4 +++- src/ui/public/share/views/share.html | 14 ++++++++++++++ 8 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/core_plugins/kibana/public/dashboard/index.html b/src/core_plugins/kibana/public/dashboard/index.html index e1b29a59c5c7b1..85bbc8b6926035 100644 --- a/src/core_plugins/kibana/public/dashboard/index.html +++ b/src/core_plugins/kibana/public/dashboard/index.html @@ -18,7 +18,7 @@
diff --git a/src/ui/public/chrome/api/controls.js b/src/ui/public/chrome/api/controls.js index 93408b9c682d44..9c8031d2875c6b 100644 --- a/src/ui/public/chrome/api/controls.js +++ b/src/ui/public/chrome/api/controls.js @@ -29,4 +29,21 @@ module.exports = function (chrome, internals) { if (_.isUndefined(internals.visible)) return def; return internals.visible; }; + + /** + * @param {boolean} showSearch - should the chrome Search Bar be displayed + * @return {chrome} + */ + chrome.setShowSearch = function (showSearch) { + internals.showSearch = Boolean(showSearch); + return chrome; + }; + + /** + * @return {boolean} - Show Search Bar state of the chrome + */ + chrome.getShowSearch = function () { + if (_.isUndefined(internals.showSearch)) return true; + return internals.showSearch; + }; }; diff --git a/src/ui/public/chrome/directives/kbn_chrome.js b/src/ui/public/chrome/directives/kbn_chrome.js index 1b191dda6809a1..f37e106ac3da4c 100644 --- a/src/ui/public/chrome/directives/kbn_chrome.js +++ b/src/ui/public/chrome/directives/kbn_chrome.js @@ -37,6 +37,9 @@ export default function (chrome, internals) { // are we showing the embedded version of the chrome? internals.setVisibleDefault(!$location.search().embed); + if ($location.search().embed) { + chrome.setShowSearch($location.search().showSearch); + } // listen for route changes, propogate to tabs const onRouteChange = function () { diff --git a/src/ui/public/kbn_top_nav/kbn_top_nav.html b/src/ui/public/kbn_top_nav/kbn_top_nav.html index 5ec6577c825d65..796aaa66bfd63f 100644 --- a/src/ui/public/kbn_top_nav/kbn_top_nav.html +++ b/src/ui/public/kbn_top_nav/kbn_top_nav.html @@ -4,7 +4,7 @@ data-test-subj="top-nav" > -
+
{ - const embedQueryParam = '?embed=true'; + let embedQueryParam = '?embed=true'; + if (this.showSearch) embedQueryParam += '&showSearch=true'; const urlHasQueryString = url.indexOf('?') !== -1; if (urlHasQueryString) { return url.replace('?', `${embedQueryParam}&`); @@ -115,6 +116,7 @@ app.directive('share', function (Private) { shortSnapshotIframe: false, }; }; + $scope.updateUrls = updateUrls; // When the URL changes, update the links in the UI. $scope.$watch(() => $location.absUrl(), () => { diff --git a/src/ui/public/share/views/share.html b/src/ui/public/share/views/share.html index f43efa2d511a0a..c7bb3801c01466 100644 --- a/src/ui/public/share/views/share.html +++ b/src/ui/public/share/views/share.html @@ -36,6 +36,13 @@
+
+ +
+
+
+ +
+ Date: Wed, 2 Nov 2016 16:50:26 -0600 Subject: [PATCH 2/2] use this instead of for method updateUrls --- src/ui/public/share/directives/share.js | 2 +- src/ui/public/share/views/share.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/public/share/directives/share.js b/src/ui/public/share/directives/share.js index 15e0c16decdd56..4759d1f0b202b2 100644 --- a/src/ui/public/share/directives/share.js +++ b/src/ui/public/share/directives/share.js @@ -116,7 +116,7 @@ app.directive('share', function (Private) { shortSnapshotIframe: false, }; }; - $scope.updateUrls = updateUrls; + this.updateUrls = updateUrls; // When the URL changes, update the links in the UI. $scope.$watch(() => $location.absUrl(), () => { diff --git a/src/ui/public/share/views/share.html b/src/ui/public/share/views/share.html index c7bb3801c01466..31efca77e91035 100644 --- a/src/ui/public/share/views/share.html +++ b/src/ui/public/share/views/share.html @@ -38,7 +38,7 @@
@@ -134,7 +134,7 @@