Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/core/server/ui_settings/settings/announcements.test.ts
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]"`
);
});
});
});
26 changes: 26 additions & 0 deletions src/core/server/ui_settings/settings/announcements.ts
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(),
},
};
};
2 changes: 2 additions & 0 deletions src/core/server/ui_settings/settings/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 2 additions & 0 deletions src/core/server/ui_settings/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,6 +25,7 @@ export const getCoreSettings = (
): Record<string, UiSettingsParams> => {
return {
...getAccessibilitySettings(),
...getAnnouncementsSettings(),
...getDateFormatSettings(),
...getMiscUiSettings(),
...getNavigationSettings(),
Expand Down
1 change: 1 addition & 0 deletions src/plugins/discover/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
3 changes: 3 additions & 0 deletions src/plugins/discover/public/__mocks__/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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]);

Expand Down Expand Up @@ -137,7 +138,7 @@ function DiscoverDocumentsComponent({
</EuiScreenReaderOnly>
{isLegacy && rows && rows.length && (
<>
<DocumentExplorerCallout />
{!hideAnnouncements && <DocumentExplorerCallout />}
<DocTableInfiniteMemoized
columns={columns}
indexPattern={indexPattern}
Expand All @@ -158,9 +159,11 @@ function DiscoverDocumentsComponent({
)}
{!isLegacy && (
<>
<DiscoverTourProvider>
<DocumentExplorerUpdateCallout />
</DiscoverTourProvider>
{!hideAnnouncements && (
<DiscoverTourProvider>
<DocumentExplorerUpdateCallout />
</DiscoverTourProvider>
)}
<div className="dscDiscoverGrid">
<DataGridMemoized
ariaLabelledBy="documentsAriaLabel"
Expand Down
45 changes: 45 additions & 0 deletions test/functional/apps/discover/_hide_announcements.ts
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();
Comment thread
gsoldevila marked this conversation as resolved.
const tourButtonExists = await testSubjects.exists('discoverTakeTourButton');
expect(tourButtonExists).to.be(false);
});
});
}
48 changes: 48 additions & 0 deletions test/functional/apps/discover/classic/_hide_announcements.ts
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);
});
});
}
2 changes: 2 additions & 0 deletions test/functional/apps/discover/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,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'));
}
});
}