diff --git a/src/core_plugins/kibana/public/dashboard/dashboard_app.html b/src/core_plugins/kibana/public/dashboard/dashboard_app.html index 49521b3cc09da..053a4dc5ac579 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard_app.html +++ b/src/core_plugins/kibana/public/dashboard/dashboard_app.html @@ -51,7 +51,7 @@

- Click the Add button in the menu bar above to add a visualization to the dashboard.
If you haven't set up any visualizations yet, visit the Visualize app to create your first visualization. + Click the Add button in the menu bar above to add a visualization to the dashboard.
If you haven't set up any visualizations yet, visit the Visualize app to create your first visualization.

@@ -70,4 +70,4 @@

> - \ No newline at end of file + diff --git a/src/ui/public/kbn_top_nav/kbn_top_nav_controller.js b/src/ui/public/kbn_top_nav/kbn_top_nav_controller.js index d6cc9752315ef..689021980a305 100644 --- a/src/ui/public/kbn_top_nav/kbn_top_nav_controller.js +++ b/src/ui/public/kbn_top_nav/kbn_top_nav_controller.js @@ -17,7 +17,7 @@ * under the License. */ -import { capitalize, isArray, isFunction } from 'lodash'; +import { capitalize, isArray, isFunction, get } from 'lodash'; import chrome from '../chrome'; import filterTemplate from '../chrome/config/filter.html'; @@ -83,7 +83,8 @@ export function KbnTopNavControllerProvider($compile) { if (menuItem.disableButton()) { return false; } - menuItem.run(menuItem, this, event.target); + // event will be undefined when method is called from click + menuItem.run(menuItem, this, get(event, 'target')); }; // apply the defaults to individual options _applyOptDefault(opt = {}) { diff --git a/test/functional/apps/dashboard/_empty_dashboard.js b/test/functional/apps/dashboard/_empty_dashboard.js new file mode 100644 index 0000000000000..36f57d48c5100 --- /dev/null +++ b/test/functional/apps/dashboard/_empty_dashboard.js @@ -0,0 +1,50 @@ +/* + * 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 expect from 'expect.js'; + +export default function ({ getService, getPageObjects }) { + const testSubjects = getService('testSubjects'); + const dashboardAddPanel = getService('dashboardAddPanel'); + const PageObjects = getPageObjects(['dashboard']); + + describe('empty dashboard', async () => { + before(async () => { + await PageObjects.dashboard.clickNewDashboard(); + }); + + after(async () => { + await dashboardAddPanel.closeAddPanel(); + await PageObjects.dashboard.gotoDashboardLandingPage(); + }); + + it('should display add button', async () => { + const addButtonExists = await testSubjects.exists('emptyDashboardAddPanelButton'); + expect(addButtonExists).to.be(true); + }); + + it('should open add panel when add button is clicked', async () => { + await testSubjects.click('emptyDashboardAddPanelButton'); + const isAddPanelOpen = await dashboardAddPanel.isAddPanelOpen(); + expect(isAddPanelOpen).to.be(true); + }); + + }); +} + diff --git a/test/functional/apps/dashboard/index.js b/test/functional/apps/dashboard/index.js index 93b6fc88b1d83..dc4000c96bd94 100644 --- a/test/functional/apps/dashboard/index.js +++ b/test/functional/apps/dashboard/index.js @@ -42,6 +42,7 @@ export default function ({ getService, loadTestFile, getPageObjects }) { // This has to be first since the other tests create some embeddables as side affects and our counting assumes // a fresh index. + loadTestFile(require.resolve('./_empty_dashboard')); loadTestFile(require.resolve('./_embeddable_rendering')); loadTestFile(require.resolve('./_create_and_add_embeddables')); loadTestFile(require.resolve('./_time_zones'));