mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Discover] Add hideAnnouncements
advanced setting (#135030)
* [Discover] add hide announcements setting * [Discover] add missed import * [Discover] fix test
This commit is contained in:
parent
f9706ae135
commit
f89efc7f30
11 changed files with 170 additions and 5 deletions
32
src/core/server/ui_settings/settings/announcements.test.ts
Normal file
32
src/core/server/ui_settings/settings/announcements.test.ts
Normal file
|
@ -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]"`
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
26
src/core/server/ui_settings/settings/announcements.ts
Normal file
26
src/core/server/ui_settings/settings/announcements.ts
Normal file
|
@ -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(),
|
||||
},
|
||||
};
|
||||
};
|
|
@ -14,12 +14,14 @@ import { getNotificationsSettings } from './notifications';
|
|||
import { getThemeSettings } from './theme';
|
||||
import { getCoreSettings } from '.';
|
||||
import { getStateSettings } from './state';
|
||||
import { getAnnouncementsSettings } from './announcements';
|
||||
|
||||
describe('getCoreSettings', () => {
|
||||
it('should not have setting overlaps', () => {
|
||||
const coreSettingsLength = Object.keys(getCoreSettings()).length;
|
||||
const summedLength = [
|
||||
getAccessibilitySettings(),
|
||||
getAnnouncementsSettings(),
|
||||
getDateFormatSettings(),
|
||||
getMiscUiSettings(),
|
||||
getNavigationSettings(),
|
||||
|
|
|
@ -14,6 +14,7 @@ import { getNavigationSettings } from './navigation';
|
|||
import { getNotificationsSettings } from './notifications';
|
||||
import { getThemeSettings } from './theme';
|
||||
import { getStateSettings } from './state';
|
||||
import { getAnnouncementsSettings } from './announcements';
|
||||
|
||||
interface GetCoreSettingsOptions {
|
||||
isDist?: boolean;
|
||||
|
@ -24,6 +25,7 @@ export const getCoreSettings = (
|
|||
): Record<string, UiSettingsParams> => {
|
||||
return {
|
||||
...getAccessibilitySettings(),
|
||||
...getAnnouncementsSettings(),
|
||||
...getDateFormatSettings(),
|
||||
...getMiscUiSettings(),
|
||||
...getNavigationSettings(),
|
||||
|
|
|
@ -26,3 +26,4 @@ export const SHOW_MULTIFIELDS = 'discover:showMultiFields';
|
|||
export const TRUNCATE_MAX_HEIGHT = 'truncate:maxHeight';
|
||||
export const ROW_HEIGHT_OPTION = 'discover:rowHeightOption';
|
||||
export const SEARCH_EMBEDDABLE_TYPE = 'search';
|
||||
export const HIDE_ANNOUNCEMENTS = 'hideAnnouncements';
|
||||
|
|
|
@ -16,6 +16,7 @@ import {
|
|||
MAX_DOC_FIELDS_DISPLAYED,
|
||||
SAMPLE_SIZE_SETTING,
|
||||
SORT_DEFAULT_ORDER_SETTING,
|
||||
HIDE_ANNOUNCEMENTS,
|
||||
} from '../../common';
|
||||
import { UI_SETTINGS } from '@kbn/data-plugin/public';
|
||||
import { TopNavMenu } from '@kbn/navigation-plugin/public';
|
||||
|
@ -68,6 +69,8 @@ export const discoverServiceMock = {
|
|||
return 250;
|
||||
} else if (key === MAX_DOC_FIELDS_DISPLAYED) {
|
||||
return 50;
|
||||
} else if (key === HIDE_ANNOUNCEMENTS) {
|
||||
return false;
|
||||
}
|
||||
}),
|
||||
isDefault: (key: string) => {
|
||||
|
|
|
@ -88,6 +88,7 @@ export const DocumentExplorerCallout = () => {
|
|||
>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiButton
|
||||
data-test-subj="tryDocumentExplorerButton"
|
||||
iconType="tableDensityNormal"
|
||||
size="s"
|
||||
href={addBasePath(`/app/management/kibana/settings?query=${DOC_TABLE_LEGACY}`)}
|
||||
|
|
|
@ -24,6 +24,7 @@ import {
|
|||
DOC_TABLE_LEGACY,
|
||||
SAMPLE_SIZE_SETTING,
|
||||
SEARCH_FIELDS_FROM_SOURCE,
|
||||
HIDE_ANNOUNCEMENTS,
|
||||
} from '../../../../../common';
|
||||
import { useColumns } from '../../../../hooks/use_data_grid_columns';
|
||||
import { SavedSearch } from '../../../../services/saved_searches';
|
||||
|
@ -62,7 +63,7 @@ function DiscoverDocumentsComponent({
|
|||
}) {
|
||||
const { capabilities, indexPatterns, uiSettings } = useDiscoverServices();
|
||||
const useNewFieldsApi = useMemo(() => !uiSettings.get(SEARCH_FIELDS_FROM_SOURCE), [uiSettings]);
|
||||
|
||||
const hideAnnouncements = useMemo(() => uiSettings.get(HIDE_ANNOUNCEMENTS), [uiSettings]);
|
||||
const isLegacy = useMemo(() => uiSettings.get(DOC_TABLE_LEGACY), [uiSettings]);
|
||||
const sampleSize = useMemo(() => uiSettings.get(SAMPLE_SIZE_SETTING), [uiSettings]);
|
||||
|
||||
|
@ -137,7 +138,7 @@ function DiscoverDocumentsComponent({
|
|||
</EuiScreenReaderOnly>
|
||||
{isLegacy && rows && rows.length && (
|
||||
<>
|
||||
<DocumentExplorerCallout />
|
||||
{!hideAnnouncements && <DocumentExplorerCallout />}
|
||||
<DocTableInfiniteMemoized
|
||||
columns={columns}
|
||||
indexPattern={indexPattern}
|
||||
|
@ -158,9 +159,11 @@ function DiscoverDocumentsComponent({
|
|||
)}
|
||||
{!isLegacy && (
|
||||
<>
|
||||
<DiscoverTourProvider>
|
||||
<DocumentExplorerUpdateCallout />
|
||||
</DiscoverTourProvider>
|
||||
{!hideAnnouncements && (
|
||||
<DiscoverTourProvider>
|
||||
<DocumentExplorerUpdateCallout />
|
||||
</DiscoverTourProvider>
|
||||
)}
|
||||
<div className="dscDiscoverGrid">
|
||||
<DataGridMemoized
|
||||
ariaLabelledBy="documentsAriaLabel"
|
||||
|
|
45
test/functional/apps/discover/_hide_announcements.ts
Normal file
45
test/functional/apps/discover/_hide_announcements.ts
Normal file
|
@ -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
test/functional/apps/discover/classic/_hide_announcements.ts
Normal file
48
test/functional/apps/discover/classic/_hide_announcements.ts
Normal file
|
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
|
@ -66,6 +66,8 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
|
|||
loadTestFile(require.resolve('./_chart_hidden'));
|
||||
loadTestFile(require.resolve('./_context_encoded_url_params'));
|
||||
loadTestFile(require.resolve('./_data_view_editor'));
|
||||
loadTestFile(require.resolve('./_hide_announcements'));
|
||||
loadTestFile(require.resolve('./classic/_hide_announcements'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue