mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
- Closes https://github.com/elastic/kibana/issues/194269
## Summary
This PR introduces a new extension point `getAppMenu` which allows to:
- add custom App Menu items (as a button or a submenu with more actions)
- extend Alerts menu item with more custom actions
Additionally, this PR rearranges the existing Discover menu items. The
primary actions are rendered as an icon only now.

The example usage of the new extension point can be found in
e7964f08e3/src/plugins/discover/public/context_awareness/profile_providers/example/example_data_source_profile/profile.tsx (L81-L168)
### For testing with the example profile
1. Add `discover.experimental.enabledProfiles: ['example-root-profile',
'example-data-source-profile', 'example-document-profile']` to
`kibana.dev.yml`
2. Run the following in DevTools
```
POST _aliases
{
"actions": [
{
"add": {
"index": "kibana_sample_data_logs",
"alias": "my-example-logs"
}
}
]
}
```
3. Create and use Data View with `my-custom-logs` index pattern
### Checklist
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Davis McPhee <davis.mcphee@elastic.co>
Co-authored-by: Davis McPhee <davismcphee@hotmail.com>
101 lines
4.4 KiB
TypeScript
101 lines
4.4 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the "Elastic License
|
|
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
|
* Public License v 1"; you may not use this file except in compliance with, at
|
|
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
|
* License v3.0 only", or the "Server Side Public License, v 1".
|
|
*/
|
|
|
|
import expect from '@kbn/expect';
|
|
import type { FtrProviderContext } from '../../functional/ftr_provider_context';
|
|
|
|
const TEST_START_TIME = 'Sep 19, 2015 @ 06:31:44.000';
|
|
const TEST_END_TIME = 'Sep 23, 2015 @ 18:31:44.000';
|
|
|
|
// eslint-disable-next-line import/no-default-export
|
|
export default ({ getService, getPageObjects }: FtrProviderContext) => {
|
|
const { common, timePicker, header } = getPageObjects(['common', 'timePicker', 'header']);
|
|
const esArchiver = getService('esArchiver');
|
|
const kibanaServer = getService('kibanaServer');
|
|
const testSubjects = getService('testSubjects');
|
|
const browser = getService('browser');
|
|
const dataGrid = getService('dataGrid');
|
|
const retry = getService('retry');
|
|
const defaultSettings = { defaultIndex: 'logstash-*' };
|
|
|
|
describe('Customizations', () => {
|
|
before(async () => {
|
|
await kibanaServer.savedObjects.cleanStandardList();
|
|
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional');
|
|
await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover');
|
|
await kibanaServer.uiSettings.replace(defaultSettings);
|
|
await common.navigateToApp('home');
|
|
const currentUrl = await browser.getCurrentUrl();
|
|
const customizationUrl =
|
|
currentUrl.substring(0, currentUrl.indexOf('/app/home')) +
|
|
'/app/discoverCustomizationExamples';
|
|
await browser.get(customizationUrl);
|
|
await timePicker.setAbsoluteRange(TEST_START_TIME, TEST_END_TIME);
|
|
await header.waitUntilLoadingHasFinished();
|
|
});
|
|
|
|
after(async () => {
|
|
await kibanaServer.uiSettings.unset('defaultIndex');
|
|
await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover');
|
|
await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional');
|
|
await kibanaServer.savedObjects.cleanStandardList();
|
|
});
|
|
|
|
it('Top nav', async () => {
|
|
await testSubjects.existOrFail('shareTopNavButton');
|
|
await testSubjects.missingOrFail('discoverNewButton');
|
|
await testSubjects.missingOrFail('discoverOpenButton');
|
|
});
|
|
|
|
it('Search bar', async () => {
|
|
await testSubjects.click('logsViewSelectorButton');
|
|
await testSubjects.click('logsViewSelectorOption-ASavedSearch');
|
|
await header.waitUntilLoadingHasFinished();
|
|
await retry.try(async () => {
|
|
const { title, description } = await common.getSharedItemTitleAndDescription();
|
|
const expected = {
|
|
title: 'A Saved Search',
|
|
description: 'A Saved Search Description',
|
|
};
|
|
expect(title).to.eql(expected.title);
|
|
expect(description).to.eql(expected.description);
|
|
});
|
|
await browser.goBack();
|
|
await header.waitUntilLoadingHasFinished();
|
|
});
|
|
|
|
it('Search bar Prepend Filters exists and should apply filter properly', async () => {
|
|
// Validate custom filters are present
|
|
await testSubjects.existOrFail('customPrependedFilter');
|
|
await testSubjects.click('customPrependedFilter');
|
|
await testSubjects.existOrFail('optionsList-control-selection-exists');
|
|
|
|
// Retrieve option list popover
|
|
const optionsListControl = await testSubjects.find('optionsList-control-popover');
|
|
const optionsItems = await optionsListControl.findAllByCssSelector(
|
|
'[data-test-subj*="optionsList-control-selection-"]'
|
|
);
|
|
|
|
// Retrieve second item in the options along with the count of documents
|
|
const item = optionsItems[1];
|
|
const countBadge = await item.findByCssSelector(
|
|
'[data-test-subj="optionsList-document-count-badge"]'
|
|
);
|
|
const documentsCount = parseInt(await countBadge.getVisibleText(), 10);
|
|
|
|
// Click the item to apply filter
|
|
await item.click();
|
|
await header.waitUntilLoadingHasFinished();
|
|
|
|
// Validate that filter is applied
|
|
const rows = await dataGrid.getDocTableRows();
|
|
await expect(documentsCount).to.eql(rows.length);
|
|
});
|
|
});
|
|
};
|