Skip to content

Commit

Permalink
Merge branch 'master' into alerting/restructure-docs-1
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jun 7, 2021
2 parents 6485936 + 3930749 commit 1a4efd6
Show file tree
Hide file tree
Showing 34 changed files with 862 additions and 147 deletions.
2 changes: 1 addition & 1 deletion docs/user/dashboard/timelion.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
To use *Timelion*, you define a graph by chaining functions together, using the *Timelion*-specific syntax.
The syntax enables some features that classical point series charts don't offer, such as pulling data from different indices or data sources into one graph.

deprecated::[7.0.0,"*Timelion* is still supported. The *Timelion app* is deprecated in 7.0, replaced by dashboard features. In the last 7.x minor version and later, the *Timelion app* is removed from {kib}. To prepare for the removal of *Timelion app*, you must migrate *Timelion app* worksheets to a dashboard. For information on how to migrate *Timelion app* worksheets, refer to the link:https://www.elastic.co/guide/en/kibana/7.10/release-notes-7.10.0.html#deprecation-v7.10.0[7.10.0 Release Notes]."]
deprecated::[7.0.0,"*Timelion* is still supported. The *Timelion app* is deprecated in 7.0, replaced by dashboard features. In 7.16 and later, the *Timelion app* is removed from {kib}. To prepare for the removal of *Timelion app*, you must migrate *Timelion app* worksheets to a dashboard. For information on how to migrate *Timelion app* worksheets, refer to the link:https://www.elastic.co/guide/en/kibana/7.10/release-notes-7.10.0.html#deprecation-v7.10.0[7.10.0 Release Notes]."]

[float]
==== Timelion expressions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@

// We only truncate if the cell is not a control column.
.euiDataGridHeader {
// This display property is temporary until https://github.com/elastic/eui/issues/4729 is resolved.
display: flex;

.euiDataGridHeaderCell__content {
@include euiTextTruncate;
overflow: hidden;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,21 @@ import ReactDOM from 'react-dom';
import { I18nStart } from 'kibana/public';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiSpacer, EuiButton, EuiText, EuiWrappingPopover, EuiCode } from '@elastic/eui';
import {
EuiSpacer,
EuiButton,
EuiText,
EuiWrappingPopover,
EuiCode,
EuiHorizontalRule,
EuiButtonEmpty,
EuiTextAlign,
} from '@elastic/eui';
import { getServices } from '../../../kibana_services';
import './open_options_popover.scss';
import { DOC_TABLE_LEGACY } from '../../../../common';

const container = document.createElement('div');
let isOpen = false;

interface OptionsPopoverProps {
Expand Down Expand Up @@ -77,11 +87,29 @@ export function OptionsPopover(props: OptionsPopoverProps) {
defaultMessage: 'Get started',
})}
</EuiButton>
<EuiHorizontalRule margin="s" />
<EuiTextAlign textAlign="center">
<EuiButtonEmpty
iconType="gear"
size="s"
href={addBasePath(`/app/management/kibana/settings?query=category:(discover)`)}
>
{i18n.translate('discover.openOptionsPopover.gotToAllSettings', {
defaultMessage: 'All Discover options',
})}
</EuiButtonEmpty>
</EuiTextAlign>
</div>
</EuiWrappingPopover>
);
}

function onClose() {
ReactDOM.unmountComponentAtNode(container);
document.body.removeChild(container);
isOpen = false;
}

export function openOptionsPopover({
I18nContext,
anchorElement,
Expand All @@ -90,17 +118,11 @@ export function openOptionsPopover({
anchorElement: HTMLElement;
}) {
if (isOpen) {
onClose();
return;
}

isOpen = true;
const container = document.createElement('div');
const onClose = () => {
ReactDOM.unmountComponentAtNode(container);
document.body.removeChild(container);
isOpen = false;
};

document.body.appendChild(container);

const element = (
Expand Down
14 changes: 5 additions & 9 deletions src/plugins/discover/public/url_generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@
* Side Public License, v 1.
*/

import {
TimeRange,
Filter,
Query,
esFilters,
QueryState,
RefreshInterval,
} from '../../data/public';
import type { UrlGeneratorsDefinition } from '../../share/public';
import type { TimeRange, Filter, Query, QueryState, RefreshInterval } from '../../data/public';
import { esFilters } from '../../data/public';
import { setStateToKbnUrl } from '../../kibana_utils/public';
import { UrlGeneratorsDefinition } from '../../share/public';

export const DISCOVER_APP_URL_GENERATOR = 'DISCOVER_APP_URL_GENERATOR';

Expand Down Expand Up @@ -71,10 +65,12 @@ export interface DiscoverUrlGeneratorState {
* Used interval of the histogram
*/
interval?: string;

/**
* Array of the used sorting [[field,direction],...]
*/
sort?: string[][];

/**
* id of the used saved query
*/
Expand Down
165 changes: 165 additions & 0 deletions src/plugins/share/common/url_service/__tests__/locators.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
/*
* 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 { of } from 'src/plugins/kibana_utils/common';
import { testLocator, TestLocatorState, urlServiceTestSetup } from './setup';

describe('locators', () => {
test('can start locators service', () => {
const {
service: { locators },
} = urlServiceTestSetup();

expect(typeof locators).toBe('object');
expect(typeof locators.create).toBe('function');
expect(typeof locators.get).toBe('function');
});

test('returns "undefined" for unregistered locator', () => {
const {
service: { locators },
} = urlServiceTestSetup();

expect(locators.get(testLocator.id)).toBe(undefined);
});

test('can register a locator', () => {
const {
service: { locators },
} = urlServiceTestSetup();

locators.create(testLocator);
expect(typeof locators.get(testLocator.id)).toBe('object');
});

test('getLocation() returns KibanaLocation generated by the locator', async () => {
const {
service: { locators },
} = urlServiceTestSetup();

locators.create(testLocator);

const locator = locators.get<TestLocatorState>(testLocator.id);
const location = await locator?.getLocation({
savedObjectId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
pageNumber: 21,
showFlyout: true,
});

expect(location).toEqual({
app: 'test_app',
route: '/my-object/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx?page=21',
state: { isFlyoutOpen: true },
});
});

describe('.navigate()', () => {
test('throws if navigation method is not implemented', async () => {
const {
service: { locators },
} = urlServiceTestSetup();
const locator = locators.create(testLocator);
const [, error] = await of(
locator.navigate({
pageNumber: 1,
savedObjectId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
showFlyout: false,
})
);

expect(error).toBeInstanceOf(Error);
expect(error.message).toBe('not implemented');
});

test('navigates user when .navigate() method is called', async () => {
const {
service: { locators },
deps,
} = urlServiceTestSetup({
navigate: jest.fn(async () => {}),
});
const locator = locators.create(testLocator);
const [, error] = await of(
locator.navigate({
pageNumber: 1,
savedObjectId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
showFlyout: false,
})
);

expect(error).toBe(undefined);
expect(deps.navigate).toHaveBeenCalledTimes(1);
expect(deps.navigate).toHaveBeenCalledWith(
{
app: 'test_app',
route: '/my-object/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx?page=1',
state: {
isFlyoutOpen: false,
},
},
{ replace: false }
);
});

test('can specify "replace" navigation parameter', async () => {
const {
service: { locators },
deps,
} = urlServiceTestSetup({
navigate: jest.fn(async () => {}),
});
const locator = locators.create(testLocator);

await locator.navigate(
{
pageNumber: 1,
savedObjectId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
showFlyout: false,
},
{
replace: false,
}
);

expect(deps.navigate).toHaveBeenCalledTimes(1);
expect(deps.navigate).toHaveBeenCalledWith(
{
app: 'test_app',
route: '/my-object/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx?page=1',
state: {
isFlyoutOpen: false,
},
},
{ replace: false }
);

await locator.navigate(
{
pageNumber: 2,
savedObjectId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
showFlyout: false,
},
{
replace: true,
}
);

expect(deps.navigate).toHaveBeenCalledTimes(2);
expect(deps.navigate).toHaveBeenCalledWith(
{
app: 'test_app',
route: '/my-object/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx?page=2',
state: {
isFlyoutOpen: false,
},
},
{ replace: true }
);
});
});
});
42 changes: 42 additions & 0 deletions src/plugins/share/common/url_service/__tests__/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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 type { SerializableState } from 'src/plugins/kibana_utils/common';
import { LocatorDefinition } from '../locators';
import { UrlService, UrlServiceDependencies } from '../url_service';

export interface TestLocatorState extends SerializableState {
savedObjectId: string;
showFlyout: boolean;
pageNumber: number;
}

export const testLocator: LocatorDefinition<TestLocatorState> = {
id: 'TEST_LOCATOR',
getLocation: async ({ savedObjectId, pageNumber, showFlyout }) => {
return {
app: 'test_app',
route: `/my-object/${savedObjectId}?page=${pageNumber}`,
state: {
isFlyoutOpen: showFlyout,
},
};
},
};

export const urlServiceTestSetup = (partialDeps: Partial<UrlServiceDependencies> = {}) => {
const deps: UrlServiceDependencies = {
navigate: async () => {
throw new Error('not implemented');
},
...partialDeps,
};
const service = new UrlService(deps);

return { service, deps };
};
10 changes: 10 additions & 0 deletions src/plugins/share/common/url_service/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* 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.
*/

export * from './url_service';
export * from './locators';
11 changes: 11 additions & 0 deletions src/plugins/share/common/url_service/locators/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* 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.
*/

export * from './types';
export * from './locator';
export * from './locator_client';
Loading

0 comments on commit 1a4efd6

Please sign in to comment.