-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Discover] Add hideAnnouncements advanced setting
#135030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dimaanj
merged 5 commits into
elastic:main
from
dimaanj:add-hide-announcements-advanced-setting
Jun 28, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5e3ace1
[Discover] add hide announcements setting
dimaanj 6b55911
[Discover] add missed import
dimaanj fff994d
[Discover] fix test
dimaanj 1890a09
Merge branch 'main' into add-hide-announcements-advanced-setting
kibanamachine 47162bd
Merge branch 'main' into add-hide-announcements-advanced-setting
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/core/server/ui_settings/settings/announcements.test.ts
This file contains hidden or 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,32 @@ | ||
| /* | ||
| * 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 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 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import { UiSettingsParams } from '../../../types'; | ||
| import { getAnnouncementsSettings } from './announcements'; | ||
|
|
||
| describe('announcements settings', () => { | ||
| const state = getAnnouncementsSettings(); | ||
|
|
||
| const getValidationFn = (setting: UiSettingsParams) => (value: any) => | ||
| setting.schema.validate(value); | ||
|
|
||
| describe('hideAnnouncements', () => { | ||
| const validate = getValidationFn(state.hideAnnouncements); | ||
|
|
||
| it('should only accept boolean values', () => { | ||
| expect(() => validate(true)).not.toThrow(); | ||
| expect(() => validate(false)).not.toThrow(); | ||
| expect(() => validate('foo')).toThrowErrorMatchingInlineSnapshot( | ||
| `"expected value of type [boolean] but got [string]"` | ||
| ); | ||
| expect(() => validate(12)).toThrowErrorMatchingInlineSnapshot( | ||
| `"expected value of type [boolean] but got [number]"` | ||
| ); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or 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,26 @@ | ||
| /* | ||
| * 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 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 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import { schema } from '@kbn/config-schema'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { UiSettingsParams } from '../../../types'; | ||
|
|
||
| export const getAnnouncementsSettings = (): Record<string, UiSettingsParams> => { | ||
| return { | ||
| hideAnnouncements: { | ||
| name: i18n.translate('core.ui_settings.params.hideAnnouncements', { | ||
| defaultMessage: 'Hide announcements', | ||
| }), | ||
| value: false, | ||
| description: i18n.translate('core.ui_settings.params.hideAnnouncementsText', { | ||
| defaultMessage: 'Stop showing messages and tours that highlight new features.', | ||
| }), | ||
| schema: schema.boolean(), | ||
| }, | ||
| }; | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,45 @@ | ||
| /* | ||
| * 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 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 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 PageObjects = getPageObjects(['common', 'home', 'settings', 'discover', 'timePicker']); | ||
| const kibanaServer = getService('kibanaServer'); | ||
| const testSubjects = getService('testSubjects'); | ||
| const browser = getService('browser'); | ||
|
|
||
| describe('test hide announcements', function () { | ||
| before(async function () { | ||
| await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); | ||
| await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); | ||
| await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); | ||
| await PageObjects.common.navigateToApp('discover'); | ||
| await PageObjects.timePicker.setDefaultAbsoluteRange(); | ||
| }); | ||
|
|
||
| after(async () => { | ||
| await kibanaServer.uiSettings.replace({}); | ||
| }); | ||
|
|
||
| it('should display take tour button', async function () { | ||
| await PageObjects.discover.selectIndexPattern('logstash-*'); | ||
| const tourButtonExists = await testSubjects.exists('discoverTakeTourButton'); | ||
| expect(tourButtonExists).to.be(true); | ||
| }); | ||
|
|
||
| it('should not display take tour button', async function () { | ||
| await kibanaServer.uiSettings.update({ hideAnnouncements: true }); | ||
| await browser.refresh(); | ||
| const tourButtonExists = await testSubjects.exists('discoverTakeTourButton'); | ||
| expect(tourButtonExists).to.be(false); | ||
| }); | ||
| }); | ||
| } | ||
48 changes: 48 additions & 0 deletions
48
test/functional/apps/discover/classic/_hide_announcements.ts
This file contains hidden or 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 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 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 PageObjects = getPageObjects(['common', 'home', 'settings', 'discover', 'timePicker']); | ||
| const kibanaServer = getService('kibanaServer'); | ||
| const testSubjects = getService('testSubjects'); | ||
| const browser = getService('browser'); | ||
|
|
||
| describe('test hide announcements', function () { | ||
| before(async function () { | ||
| await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); | ||
| await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); | ||
| await kibanaServer.uiSettings.replace({ | ||
| defaultIndex: 'logstash-*', | ||
| 'doc_table:legacy': true, | ||
| }); | ||
| await PageObjects.common.navigateToApp('discover'); | ||
| await PageObjects.timePicker.setDefaultAbsoluteRange(); | ||
| }); | ||
|
|
||
| after(async () => { | ||
| await kibanaServer.uiSettings.replace({}); | ||
| }); | ||
|
|
||
| it('should display try document explorer button', async function () { | ||
| await PageObjects.discover.selectIndexPattern('logstash-*'); | ||
| const tourButtonExists = await testSubjects.exists('tryDocumentExplorerButton'); | ||
| expect(tourButtonExists).to.be(true); | ||
| }); | ||
|
|
||
| it('should not display try document explorer button', async function () { | ||
| await kibanaServer.uiSettings.update({ hideAnnouncements: true }); | ||
| await browser.refresh(); | ||
| const tourButtonExists = await testSubjects.exists('tryDocumentExplorerButton'); | ||
| expect(tourButtonExists).to.be(false); | ||
| }); | ||
| }); | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.