-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…194256) # Backport This will backport the following commits from `main` to `8.x`: - [[Discover] Dismiss flyouts when opening another one (#193865)](#193865) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Julia Rechkunova","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-27T07:35:31Z","message":"[Discover] Dismiss flyouts when opening another one (#193865)\n\n- Closes https://github.com/elastic/kibana/issues/193452\r\n\r\n## Summary\r\n\r\nThis PR makes sure that only one flyout is open at a time and\r\nautomatically dismisses all others.\r\n\r\n\r\n### Checklist\r\n\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)","sha":"6fc017a597fc34158313b8537f6b6a2536833cba","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:DataDiscovery","backport:prev-minor","Feature:ES|QL"],"title":"[Discover] Dismiss flyouts when opening another one","number":193865,"url":"https://github.com/elastic/kibana/pull/193865","mergeCommit":{"message":"[Discover] Dismiss flyouts when opening another one (#193865)\n\n- Closes https://github.com/elastic/kibana/issues/193452\r\n\r\n## Summary\r\n\r\nThis PR makes sure that only one flyout is open at a time and\r\nautomatically dismisses all others.\r\n\r\n\r\n### Checklist\r\n\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)","sha":"6fc017a597fc34158313b8537f6b6a2536833cba"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193865","number":193865,"mergeCommit":{"message":"[Discover] Dismiss flyouts when opening another one (#193865)\n\n- Closes https://github.com/elastic/kibana/issues/193452\r\n\r\n## Summary\r\n\r\nThis PR makes sure that only one flyout is open at a time and\r\nautomatically dismisses all others.\r\n\r\n\r\n### Checklist\r\n\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)","sha":"6fc017a597fc34158313b8537f6b6a2536833cba"}}]}] BACKPORT--> Co-authored-by: Julia Rechkunova <[email protected]>
- Loading branch information
1 parent
7cefd3c
commit a3b2bb2
Showing
15 changed files
with
230 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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". | ||
*/ | ||
|
||
export enum DiscoverFlyouts { | ||
lensEdit = 'lensEdit', | ||
docViewer = 'docViewer', | ||
esqlDocs = 'esqlDocs', | ||
} | ||
|
||
const AllDiscoverFlyouts = Object.values(DiscoverFlyouts); | ||
|
||
const getFlyoutCloseButton = (flyout: DiscoverFlyouts): HTMLElement | null => { | ||
switch (flyout) { | ||
case DiscoverFlyouts.lensEdit: | ||
return document.getElementById('lnsCancelEditOnFlyFlyout'); | ||
case DiscoverFlyouts.docViewer: | ||
return document.querySelector('[data-test-subj="docViewerFlyoutCloseButton"]'); | ||
case DiscoverFlyouts.esqlDocs: | ||
return document.querySelector( | ||
'[data-test-subj="esqlInlineDocumentationFlyout"] [data-test-subj="euiFlyoutCloseButton"]' | ||
); | ||
} | ||
}; | ||
|
||
export const dismissFlyouts = ( | ||
selectedFlyouts: DiscoverFlyouts[] = AllDiscoverFlyouts, | ||
excludedFlyout?: DiscoverFlyouts | ||
) => { | ||
selectedFlyouts.forEach((flyout) => { | ||
if (flyout === excludedFlyout) { | ||
return; | ||
} | ||
const closeButton = getFlyoutCloseButton(flyout); | ||
if (closeButton) { | ||
closeButton.click?.(); | ||
} | ||
}); | ||
}; | ||
|
||
export const dismissAllFlyoutsExceptFor = (excludedFlyout: DiscoverFlyouts) => { | ||
dismissFlyouts(AllDiscoverFlyouts, excludedFlyout); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* 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 { FtrProviderContext } from '../ftr_provider_context'; | ||
|
||
export default function ({ getService, getPageObjects }: FtrProviderContext) { | ||
const esArchiver = getService('esArchiver'); | ||
const { common, discover, timePicker, header } = getPageObjects([ | ||
'common', | ||
'discover', | ||
'timePicker', | ||
'header', | ||
]); | ||
const kibanaServer = getService('kibanaServer'); | ||
const security = getService('security'); | ||
const retry = getService('retry'); | ||
const dataGrid = getService('dataGrid'); | ||
const esql = getService('esql'); | ||
const testSubjects = getService('testSubjects'); | ||
|
||
describe('discover flyouts', function () { | ||
async function isLensEditFlyoutOpen() { | ||
return await testSubjects.exists('lnsChartSwitchPopover'); | ||
} | ||
|
||
async function openLensEditFlyout() { | ||
await testSubjects.click('unifiedHistogramEditFlyoutVisualization'); | ||
await retry.waitFor('flyout', async () => { | ||
return await isLensEditFlyoutOpen(); | ||
}); | ||
} | ||
|
||
before(async function () { | ||
await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader']); | ||
await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); | ||
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); | ||
await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); | ||
await timePicker.setDefaultAbsoluteRangeViaUiSettings(); | ||
}); | ||
|
||
beforeEach(async function () { | ||
await common.navigateToApp('discover'); | ||
await header.waitUntilLoadingHasFinished(); | ||
await discover.waitUntilSearchingHasFinished(); | ||
await discover.selectTextBaseLang(); | ||
await header.waitUntilLoadingHasFinished(); | ||
await discover.waitUntilSearchingHasFinished(); | ||
}); | ||
|
||
after(async () => { | ||
await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover'); | ||
await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); | ||
await kibanaServer.uiSettings.replace({}); | ||
await kibanaServer.savedObjects.cleanStandardList(); | ||
}); | ||
|
||
it('doc viewer flyout should get dismissed on opening ESQL docs flyout', async function () { | ||
await dataGrid.clickRowToggle({ rowIndex: 0 }); | ||
expect(await dataGrid.isShowingDocViewer()).to.be(true); | ||
await esql.openQuickReferenceFlyout(); | ||
expect(await dataGrid.isShowingDocViewer()).to.be(false); | ||
expect(await esql.isOpenQuickReferenceFlyout()).to.be(true); | ||
}); | ||
|
||
it('doc viewer flyout should get dismissed on opening Lens Edit flyout', async function () { | ||
await dataGrid.clickRowToggle({ rowIndex: 0 }); | ||
expect(await dataGrid.isShowingDocViewer()).to.be(true); | ||
await openLensEditFlyout(); | ||
expect(await dataGrid.isShowingDocViewer()).to.be(false); | ||
expect(await isLensEditFlyoutOpen()).to.be(true); | ||
}); | ||
|
||
it('ESQL docs flyout should get dismissed on opening doc viewer flyout', async function () { | ||
await esql.openQuickReferenceFlyout(); | ||
expect(await esql.isOpenQuickReferenceFlyout()).to.be(true); | ||
await dataGrid.clickRowToggle({ rowIndex: 0 }); | ||
expect(await dataGrid.isShowingDocViewer()).to.be(true); | ||
expect(await esql.isOpenQuickReferenceFlyout()).to.be(false); | ||
}); | ||
|
||
it('ESQL docs flyout should get dismissed on opening Lens Edit flyout', async function () { | ||
await esql.openQuickReferenceFlyout(); | ||
expect(await esql.isOpenQuickReferenceFlyout()).to.be(true); | ||
await openLensEditFlyout(); | ||
expect(await isLensEditFlyoutOpen()).to.be(true); | ||
expect(await esql.isOpenQuickReferenceFlyout()).to.be(false); | ||
}); | ||
|
||
it('Lens Edit flyout should get dismissed on opening doc viewer flyout', async function () { | ||
await openLensEditFlyout(); | ||
expect(await isLensEditFlyoutOpen()).to.be(true); | ||
await dataGrid.clickRowToggle({ rowIndex: 0 }); | ||
expect(await dataGrid.isShowingDocViewer()).to.be(true); | ||
expect(await isLensEditFlyoutOpen()).to.be(false); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.