From 4c408a0e4f9f5486270469a1cbd648efdaae96ac Mon Sep 17 00:00:00 2001 From: Court Ewing Date: Thu, 31 Jan 2019 21:05:42 -0500 Subject: [PATCH] timelion: disable app by default Timelion sheets will continue to work in visualize, but the application will no longer appear in the app switcher by default. The timelion.ui.enabled configuration in kibana.yml will toggle the app on. --- src/legacy/core_plugins/timelion/index.js | 15 +++++++++++ .../public/hacks/toggle_app_link_in_nav.js | 25 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/legacy/core_plugins/timelion/public/hacks/toggle_app_link_in_nav.js diff --git a/src/legacy/core_plugins/timelion/index.js b/src/legacy/core_plugins/timelion/index.js index fff2d4c4408f6e..f9f0777c541c4e 100644 --- a/src/legacy/core_plugins/timelion/index.js +++ b/src/legacy/core_plugins/timelion/index.js @@ -27,6 +27,15 @@ const experimentalLabel = i18n.translate('timelion.uiSettings.experimentalLabel' export default function (kibana) { return new kibana.Plugin({ require: ['kibana', 'elasticsearch'], + + config(Joi) { + return Joi.object({ + ui: Joi.object({ + enabled: Joi.boolean().default(false), + }).default(), + }).default(); + }, + uiExports: { app: { title: 'Timelion', @@ -39,7 +48,13 @@ export default function (kibana) { main: 'plugins/timelion/app', }, styleSheetPaths: resolve(__dirname, 'public/index.scss'), + injectDefaultVars(server) { + return { + timelionUiEnabled: server.config().get('timelion.ui.enabled'), + }; + }, hacks: [ + 'plugins/timelion/hacks/toggle_app_link_in_nav', 'plugins/timelion/lib/panel_registry', 'plugins/timelion/panels/timechart/timechart' ], diff --git a/src/legacy/core_plugins/timelion/public/hacks/toggle_app_link_in_nav.js b/src/legacy/core_plugins/timelion/public/hacks/toggle_app_link_in_nav.js new file mode 100644 index 00000000000000..e3b68ddf022825 --- /dev/null +++ b/src/legacy/core_plugins/timelion/public/hacks/toggle_app_link_in_nav.js @@ -0,0 +1,25 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import chrome from 'ui/chrome'; + +const timelionUiEnabled = chrome.getInjected('timelionUiEnabled'); +if (timelionUiEnabled === false && chrome.navLinkExists('timelion')) { + chrome.getNavLinkById('timelion').hidden = true; +}