Skip to content

Commit

Permalink
Merge branch 'master' into JasonStoltz/hidden-text
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonStoltz committed Oct 19, 2020
2 parents 450205a + 4c81b1a commit 3edef98
Show file tree
Hide file tree
Showing 157 changed files with 6,053 additions and 3,345 deletions.
86 changes: 86 additions & 0 deletions docs/user/dashboard/url-drilldown.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,92 @@ Example:

`{{ date event.from “YYYY MM DD”}}` +
`{{date “now-15”}}`

|formatNumber
a|Format numbers. Numbers can be formatted to look like currency, percentages, times or numbers with decimal places, thousands, and abbreviations.
Refer to the http://numeraljs.com/#format[numeral.js] for different formatting options.

Example:

`{{formatNumber event.value "0.0"}}`

|lowercase
a|Converts a string to lower case.

Example:

`{{lowercase event.value}}`

|uppercase
a|Converts a string to upper case.

Example:

`{{uppercase event.value}}`

|trim
a|Removes leading and trailing spaces from a string.

Example:

`{{trim event.value}}`

|trimLeft
a|Removes leading spaces from a string.

Example:

`{{trimLeft event.value}}`

|trimRight
a|Removes trailing spaces from a string.

Example:

`{{trimRight event.value}}`

|mid
a|Extracts a substring from a string by start position and number of characters to extract.

Example:

`{{mid event.value 3 5}}` - extracts five characters starting from a third character.

|left
a|Extracts a number of characters from a string (starting from left).

Example:

`{{left event.value 3}}`

|right
a|Extracts a number of characters from a string (starting from right).

Example:

`{{right event.value 3}}`

|concat
a|Concatenates two or more strings.

Example:

`{{concat event.value "," event.key}}`

|replace
a|Replaces all substrings within a string.

Example:

`{{replace event.value "stringToReplace" "stringToReplaceWith"}}`

|split
a|Splits a string using a provided splitter.

Example:

`{{split event.value ","}}`

|===


Expand Down
3 changes: 2 additions & 1 deletion docs/user/dashboard/vega-reference.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ a configuration option for changing the tooltip position and padding:
kibana: {
tooltips: {
position: 'top',
padding: 15
padding: 15,
textTruncate: true,
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
extends: [
'config:base',
],
includePaths: [
'package.json',
'x-pack/package.json',
ignorePaths: [
'**/__fixtures__/**',
'**/fixtures/**'
],
baseBranches: [
'master',
Expand Down
2 changes: 1 addition & 1 deletion src/core/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ It means that NP plugin artifacts tend to have a bigger size than the legacy pla
To understand the current size of your plugin artifact, run `@kbn/optimizer` as

```bash
node scripts/build_kibana_platform_plugins.js --dist --no-examples
node scripts/build_kibana_platform_plugins.js --dist --profile --focus=my_plugin
```

and check the output in the `target` sub-folder of your plugin folder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ RUN tar --strip-components=1 -zxf /opt/{{artifactTarball}}
# OpenShift does this, for example.
# REF: https://docs.openshift.org/latest/creating_images/guidelines.html
RUN chmod -R g=u /usr/share/kibana
RUN find /usr/share/kibana -type d -exec chmod g+s {} \;

################################################################################
# Build stage 1 (the actual Kibana image):
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/server/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function i18nMixin(kbnServer: KbnServer, server: Server, config: Ki
const translationPaths = await Promise.all([
getTranslationPaths({
cwd: fromRoot('.'),
glob: I18N_RC,
glob: `*/${I18N_RC}`,
}),
...(config.get('plugins.paths') as string[]).map((cwd) =>
getTranslationPaths({ cwd, glob: I18N_RC })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const CheckBoxField = ({ field, euiFieldProps = {}, ...rest }: Props) =>
error={errorMessage}
isInvalid={isInvalid}
fullWidth
data-test-subj={rest['data-test-subj']}
describedByIds={rest.idAria ? [rest.idAria] : undefined}
{...rest}
>
<EuiCheckbox
label={field.label}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ export const ComboBoxField = ({ field, euiFieldProps = {}, ...rest }: Props) =>
error={errorMessage}
isInvalid={isInvalid}
fullWidth
data-test-subj={rest['data-test-subj']}
describedByIds={rest.idAria ? [rest.idAria] : undefined}
{...rest}
>
<EuiComboBox
noSuggestions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const MultiSelectField = ({ field, euiFieldProps = {}, ...rest }: Props)
error={errorMessage}
isInvalid={isInvalid}
fullWidth
data-test-subj={rest['data-test-subj']}
describedByIds={rest.idAria ? [rest.idAria] : undefined}
{...rest}
>
<EuiSelectable
allowExclusions={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const NumericField = ({ field, euiFieldProps = {}, ...rest }: Props) => {
error={errorMessage}
isInvalid={isInvalid}
fullWidth
data-test-subj={rest['data-test-subj']}
describedByIds={rest.idAria ? [rest.idAria] : undefined}
{...rest}
>
<EuiFieldNumber
isInvalid={isInvalid}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const RadioGroupField = ({ field, euiFieldProps = {}, ...rest }: Props) =
error={errorMessage}
isInvalid={isInvalid}
fullWidth
data-test-subj={rest['data-test-subj']}
describedByIds={rest.idAria ? [rest.idAria] : undefined}
{...rest}
>
<EuiRadioGroup
idSelected={field.value as string}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export const RangeField = ({ field, euiFieldProps = {}, ...rest }: Props) => {
error={errorMessage}
isInvalid={isInvalid}
fullWidth
data-test-subj={rest['data-test-subj']}
describedByIds={rest.idAria ? [rest.idAria] : undefined}
{...rest}
>
<EuiRange
value={field.value as number}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export const SelectField = ({ field, euiFieldProps, ...rest }: Props) => {
error={errorMessage}
isInvalid={isInvalid}
fullWidth
data-test-subj={rest['data-test-subj']}
describedByIds={rest.idAria ? [rest.idAria] : undefined}
{...rest}
>
<EuiSelect
fullWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export const SuperSelectField = ({ field, euiFieldProps = { options: [] }, ...re
error={errorMessage}
isInvalid={isInvalid}
fullWidth
data-test-subj={rest['data-test-subj']}
describedByIds={rest.idAria ? [rest.idAria] : undefined}
{...rest}
>
<EuiSuperSelect
fullWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const TextAreaField = ({ field, euiFieldProps = {}, ...rest }: Props) =>
error={errorMessage}
isInvalid={isInvalid}
fullWidth
data-test-subj={rest['data-test-subj']}
describedByIds={rest.idAria ? [rest.idAria] : undefined}
{...rest}
>
<EuiTextArea
isInvalid={isInvalid}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const TextField = ({ field, euiFieldProps = {}, ...rest }: Props) => {
error={errorMessage}
isInvalid={isInvalid}
fullWidth
data-test-subj={rest['data-test-subj']}
describedByIds={rest.idAria ? [rest.idAria] : undefined}
{...rest}
>
<EuiFieldText
isInvalid={isInvalid}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export const ToggleField = ({ field, euiFieldProps = {}, ...rest }: Props) => {
error={errorMessage}
isInvalid={isInvalid}
fullWidth
data-test-subj={rest['data-test-subj']}
describedByIds={rest.idAria ? [rest.idAria] : undefined}
{...rest}
>
<EuiSwitch
label={field.label}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ const SavedObjectsTablePage = ({
goInspectObject={(savedObject) => {
const { editUrl } = savedObject.meta;
if (editUrl) {
return coreStart.application.navigateToUrl('/app' + editUrl);
return coreStart.application.navigateToUrl(
coreStart.http.basePath.prepend(`/app${editUrl}`)
);
}
}}
canGoInApp={(savedObject) => {
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/telemetry/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ import { TelemetryPluginStart, TelemetryPluginSetup, TelemetryPluginConfig } fro

export interface TelemetryServiceMockOptions {
reportOptInStatusChange?: boolean;
currentKibanaVersion?: string;
config?: Partial<TelemetryPluginConfig>;
}

export function mockTelemetryService({
reportOptInStatusChange,
currentKibanaVersion = 'mockKibanaVersion',
config: configOverride = {},
}: TelemetryServiceMockOptions = {}) {
const config = {
Expand All @@ -56,6 +58,7 @@ export function mockTelemetryService({
config,
http: httpServiceMock.createStartContract(),
notifications: notificationServiceMock.createStartContract(),
currentKibanaVersion,
reportOptInStatusChange,
});

Expand Down
8 changes: 7 additions & 1 deletion src/plugins/telemetry/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ export class TelemetryPlugin implements Plugin<TelemetryPluginSetup, TelemetryPl

public setup({ http, notifications }: CoreSetup): TelemetryPluginSetup {
const config = this.config;
this.telemetryService = new TelemetryService({ config, http, notifications });
const currentKibanaVersion = this.currentKibanaVersion;
this.telemetryService = new TelemetryService({
config,
http,
notifications,
currentKibanaVersion,
});

this.telemetrySender = new TelemetrySender(this.telemetryService);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ describe('TelemetrySender', () => {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Elastic-Stack-Version': telemetryService.currentKibanaVersion,
},
body: mockTelemetryPayload[0],
});
Expand Down
1 change: 1 addition & 0 deletions src/plugins/telemetry/public/services/telemetry_sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class TelemetrySender {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Elastic-Stack-Version': this.telemetryService.currentKibanaVersion,
},
body: cluster,
})
Expand Down
56 changes: 56 additions & 0 deletions src/plugins/telemetry/public/services/telemetry_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,60 @@ describe('TelemetryService', () => {
expect(telemetryService.getUserShouldSeeOptInNotice()).toBe(true);
});
});

describe('reportOptInStatus', () => {
let originalFetch: typeof window['fetch'];
let mockFetch: jest.Mock<typeof window['fetch']>;

beforeAll(() => {
originalFetch = window.fetch;
});

// @ts-ignore
beforeEach(() => (window.fetch = mockFetch = jest.fn()));
// @ts-ignore
afterAll(() => (window.fetch = originalFetch));

it('reports opt-in status to telemetry url', async () => {
const telemetryService = mockTelemetryService({
config: { userCanChangeSettings: undefined },
});
const mockPayload = ['mock_hashed_opt_in_status_payload'];
const mockUrl = 'mock_telemetry_optin_status_url';

const mockGetOptInStatusUrl = jest.fn().mockReturnValue(mockUrl);
telemetryService.getOptInStatusUrl = mockGetOptInStatusUrl;
const result = await telemetryService['reportOptInStatus'](mockPayload);
expect(result).toBeUndefined();
expect(mockGetOptInStatusUrl).toBeCalledTimes(1);
expect(mockFetch).toBeCalledTimes(1);

expect(mockFetch).toBeCalledWith(mockUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Elastic-Stack-Version': 'mockKibanaVersion',
},
body: JSON.stringify(mockPayload),
});
});

it('swallows errors if fetch fails', async () => {
const telemetryService = mockTelemetryService({
config: { userCanChangeSettings: undefined },
});
const mockPayload = ['mock_hashed_opt_in_status_payload'];
const mockUrl = 'mock_telemetry_optin_status_url';

const mockGetOptInStatusUrl = jest.fn().mockReturnValue(mockUrl);
mockFetch.mockImplementation(() => {
throw Error('Error sending usage');
});

telemetryService.getOptInStatusUrl = mockGetOptInStatusUrl;
const result = await telemetryService['reportOptInStatus'](mockPayload);
expect(result).toBeUndefined();
expect(mockFetch).toHaveBeenCalledTimes(1);
});
});
});
Loading

0 comments on commit 3edef98

Please sign in to comment.