Skip to content

Commit

Permalink
Merge branch 'main' into fix-flaky-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine committed Mar 17, 2022
2 parents 7d0cc59 + 3cc429d commit 1ef6411
Show file tree
Hide file tree
Showing 206 changed files with 2,992 additions and 1,849 deletions.
6 changes: 3 additions & 3 deletions docs/developer/contributing/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Please make sure you have signed the [Contributor License Agreement](http://www.

Read <<kibana-localization-best-practices>> for details on our localization practices.

Note that we cannot support accepting contributions to the translations from any source other than the translators we have engaged to do the work.
We are still to develop a proper process to accept any contributed translations. We certainly appreciate that people care enough about the localization effort to want to help improve the quality. We aim to build out a more comprehensive localization process for the future and will notify you once contributions can be supported, but for the time being, we are not able to incorporate suggestions.
Note that we cannot support accepting contributions to the translations from any source other than the translators we have engaged in doing the work.
We are yet to develop a proper process to accept any contributed translations. We certainly appreciate that people care enough about the localization effort to want to help improve the quality. We aim to build out a more comprehensive localization process for the future and will notify you once Kibana supports external contributions. Still, for the time being, we cannot incorporate suggestions.

[discrete]
[[kibana-release-notes-process]]
Expand Down Expand Up @@ -73,7 +73,7 @@ To make sure that your PR is included in the Release Notes, add the right label.
* `release_note:fix` — Fixes for bugs that existed in the previous release.
* `release_note:deprecation` — Deprecates functionality that existed in previous releases.
* `release_note:breaking` — Breaking changes that weren't present in previous releases.
* `release_note:skip` — Changes that should not appear in the Release Notes. For example, docs, build, and test fixes, or unreleased issues that are only in `master`.
* `release_note:skip` — Changes that should not appear in the Release Notes. For example, docs, build, and test fixes, or unreleased issues that are only in `main`.


include::development-github.asciidoc[leveloffset=+1]
Expand Down
24 changes: 9 additions & 15 deletions docs/developer/plugin/external-plugin-localization.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,12 @@ node scripts/i18n_check --fix --include-config ../kibana-extra/myPlugin/.i18nrc.
[discrete]
=== Implementing i18n in the UI

{kib} relies on several UI frameworks (ReactJS and AngularJS) and
requires localization in different environments (browser and NodeJS).
{kib} relies on ReactJS and requires localization in different environments (browser and NodeJS).
The internationalization engine is framework agnostic and consumable in
all parts of {kib} (ReactJS, AngularJS and NodeJS).
all parts of {kib} (ReactJS, and NodeJS).

To simplify
internationalization in UI frameworks, additional abstractions are
built around the I18n engine: `react-intl` for React and custom
components for AngularJS. https://github.com/yahoo/react-intl[React-intl]
is built around https://github.com/yahoo/intl-messageformat[intl-messageformat],
so both React and AngularJS frameworks use the same engine and the same
message syntax.
To simplify internationalization in React, an additional abstraction is
built around the I18n engine using https://github.com/yahoo/react-intl[React-intl] for React.


[discrete]
Expand All @@ -109,7 +103,7 @@ export const HELLO_WORLD = i18n.translate('hello.wonderful.world', {
});
-----------

Full details are {kib-repo}tree/master/packages/kbn-i18n#vanilla-js[here].
Full details are {kib-repo}tree/main/packages/kbn-i18n#vanilla-js[here].

[discrete]
==== i18n for React
Expand All @@ -133,14 +127,14 @@ export const Component = () => {
};
-----------

Full details are {kib-repo}tree/master/packages/kbn-i18n#react[here].
Full details are {kib-repo}tree/main/packages/kbn-i18n#react[here].

[discrete]
=== Resources

To learn more about i18n tooling, see {blob}src/dev/i18n/README.md[i18n dev tooling].
To learn more about i18n tooling, see {kib-repo}blob/{branch}src/dev/i18n/README.md[i18n dev tooling].

To learn more about implementing i18n in the UI, use the following links:

* {blob}packages/kbn-i18n/README.md[i18n plugin]
* {blob}packages/kbn-i18n/GUIDELINE.md[i18n guidelines]
* {kib-repo}blob/{branch}packages/kbn-i18n/README.md[i18n plugin]
* {kib-repo}blob/{branch}packages/kbn-i18n/GUIDELINE.md[i18n guidelines]
1 change: 1 addition & 0 deletions docs/settings/i18n-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ You do not need to configure any settings to run Kibana in English.
* English - `en` (default)
* Chinese - `zh-CN`
* Japanese - `ja-JP`
* French - `fr-FR`
12 changes: 6 additions & 6 deletions src/dev/precommit_hook/casing_check_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ export const TEMPORARILY_IGNORED_PATHS = [
'x-pack/plugins/monitoring/public/icons/health-green.svg',
'x-pack/plugins/monitoring/public/icons/health-red.svg',
'x-pack/plugins/monitoring/public/icons/health-yellow.svg',
'x-pack/plugins/reporting/server/export_types/common/assets/fonts/noto/NotoSansCJKtc-Medium.ttf',
'x-pack/plugins/reporting/server/export_types/common/assets/fonts/noto/NotoSansCJKtc-Regular.ttf',
'x-pack/plugins/reporting/server/export_types/common/assets/fonts/roboto/Roboto-Italic.ttf',
'x-pack/plugins/reporting/server/export_types/common/assets/fonts/roboto/Roboto-Medium.ttf',
'x-pack/plugins/reporting/server/export_types/common/assets/fonts/roboto/Roboto-Regular.ttf',
'x-pack/plugins/reporting/server/export_types/common/assets/img/logo-grey.png',
'x-pack/plugins/screenshotting/server/formats/pdf/pdf_maker/assets/fonts/noto/NotoSansCJKtc-Medium.ttf',
'x-pack/plugins/screenshotting/server/formats/pdf/pdf_maker/assets/fonts/noto/NotoSansCJKtc-Regular.ttf',
'x-pack/plugins/screenshotting/server/formats/pdf/pdf_maker/assets/fonts/roboto/Roboto-Italic.ttf',
'x-pack/plugins/screenshotting/server/formats/pdf/pdf_maker/assets/fonts/roboto/Roboto-Medium.ttf',
'x-pack/plugins/screenshotting/server/formats/pdf/pdf_maker/assets/fonts/roboto/Roboto-Regular.ttf',
'x-pack/plugins/screenshotting/server/formats/pdf/pdf_maker/assets/img/logo-grey.png',
];
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ import { RouteDependencies } from '../../../';
import { Body, Query } from './validation_config';

function toURL(base: string, path: string) {
const [p, query = ''] = path.split('?');

// if there is a '+' sign in query e.g. ?q=create_date:[2020-05-10T08:00:00.000+08:00 TO *]
// node url encodes it as a whitespace which results in a faulty request
// we need to replace '+' with '%2b' to encode it correctly
if (/\+/g.test(query)) {
path = `${p}?${query.replace(/\+/g, '%2b')}`;
}
const urlResult = new url.URL(`${trimEnd(base, '/')}/${trimStart(path, '/')}`);
// Appending pretty here to have Elasticsearch do the JSON formatting, as doing
// in JS can lead to data loss (7.0 will get munged into 7, thus losing indication of
Expand Down Expand Up @@ -116,7 +124,7 @@ export const createHandler =
}: RouteDependencies): RequestHandler<unknown, Query, Body> =>
async (ctx, request, response) => {
const { body, query } = request;
const { path, method, withProductOrigin } = query;
const { method, path, withProductOrigin } = query;

if (kibanaVersion.major < 8) {
// The "console.proxyFilter" setting in kibana.yaml has been deprecated in 8.x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { createHandler } from './create_handler';

describe('Console Proxy Route', () => {
let request: (method: string, path: string) => Promise<IKibanaResponse> | IKibanaResponse;
const proxyRequestMock = requestModule.proxyRequest as jest.Mock;

beforeEach(() => {
(requestModule.proxyRequest as jest.Mock).mockResolvedValue(createResponseStub('foo'));

Expand All @@ -39,27 +41,40 @@ describe('Console Proxy Route', () => {
describe('contains full url', () => {
it('treats the url as a path', async () => {
await request('GET', 'http://evil.com/test');
expect((requestModule.proxyRequest as jest.Mock).mock.calls.length).toBe(1);
expect(proxyRequestMock.mock.calls.length).toBe(1);
const [[args]] = (requestModule.proxyRequest as jest.Mock).mock.calls;
expect(args.uri.href).toBe('http://localhost:9200/http://evil.com/test?pretty=true');
});
});
describe('starts with a slash', () => {
it('combines well with the base url', async () => {
await request('GET', '/index/id');
expect((requestModule.proxyRequest as jest.Mock).mock.calls.length).toBe(1);
expect(proxyRequestMock.mock.calls.length).toBe(1);
const [[args]] = (requestModule.proxyRequest as jest.Mock).mock.calls;
expect(args.uri.href).toBe('http://localhost:9200/index/id?pretty=true');
});
});
describe(`doesn't start with a slash`, () => {
it('combines well with the base url', async () => {
await request('GET', 'index/id');
expect((requestModule.proxyRequest as jest.Mock).mock.calls.length).toBe(1);
expect(proxyRequestMock.mock.calls.length).toBe(1);
const [[args]] = (requestModule.proxyRequest as jest.Mock).mock.calls;
expect(args.uri.href).toBe('http://localhost:9200/index/id?pretty=true');
});
});
describe('contains special characters', () => {
it('correctly encodes plus sign', async () => {
const path = '/_search?q=create_date:[2022-03-10T08:00:00.000+08:00 TO *]';

const { status } = await request('GET', path);
expect(status).toBe(200);
expect(proxyRequestMock.mock.calls.length).toBe(1);
const [[args]] = proxyRequestMock.mock.calls;
expect(args.uri.search).toEqual(
'?q=create_date%3A%5B2022-03-10T08%3A00%3A00.000%2B08%3A00+TO+*%5D&pretty=true'
);
});
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from '../../../../common/tutorial/instructions/apm_agent_instructions';
import { AgentName } from '../../../../typings/es_schemas/ui/fields/agent';
// TODO: Uncomment once https://github.com/elastic/beats/issues/29631 has been closed
// import { JavaRuntimeAttachment } from './runtime_attachment/supported_agents/java_runtime_attachment';
import { JavaRuntimeAttachment } from './runtime_attachment/supported_agents/java_runtime_attachment';
import {
NewPackagePolicy,
PackagePolicy,
Expand Down Expand Up @@ -56,8 +56,7 @@ export const ApmAgentInstructionsMappings: Array<{
title: 'Java',
variantId: 'java',
createAgentInstructions: createJavaAgentInstructions,
// TODO: Uncomment once https://github.com/elastic/beats/issues/29631 has been closed
// AgentRuntimeAttachment: JavaRuntimeAttachment,
AgentRuntimeAttachment: JavaRuntimeAttachment,
},
{
agentName: 'rum-js',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.lnsVisToolbarAxis__popover {
width: 500px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { EuiIconAxisLeft } from '../assets/axis_left';
import { EuiIconAxisBottom } from '../assets/axis_bottom';
import type { HeatmapVisualizationState } from './types';
import { getDefaultVisualValuesForLayer } from '../shared_components/datasource_default_values';
import './toolbar_component.scss';

const legendOptions: Array<{ id: string; value: 'auto' | 'show' | 'hide'; label: string }> = [
{
Expand Down Expand Up @@ -139,6 +140,7 @@ export const HeatmapToolbar = memo(
groupPosition="left"
isDisabled={!Boolean(state?.yAccessor)}
buttonDataTestSubj="lnsHeatmapVerticalAxisButton"
panelClassName="lnsVisToolbarAxis__popover"
>
<AxisTitleSettings
axis="yLeft"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
*/

import React from 'react';
import { shallowWithIntl as shallow } from '@kbn/test-jest-helpers';
import { act } from 'react-dom/test-utils';
import { mountWithIntl as mount } from '@kbn/test-jest-helpers';
import { AxisTitleSettings, AxisTitleSettingsProps } from './axis_title_settings';
import { Label, VisLabel } from './vis_label';

describe('Axes Title settings', () => {
let props: AxisTitleSettingsProps;
Expand All @@ -21,14 +23,41 @@ describe('Axes Title settings', () => {
};
});
it('should show the axes title on the corresponding input text', () => {
const component = shallow(<AxisTitleSettings {...props} />);
expect(component.find('[data-test-subj="lnsxAxisTitle"]').prop('value')).toBe(
const component = mount(<AxisTitleSettings {...props} />);
expect(component.find('[data-test-subj="lnsxAxisTitle"]').last().prop('value')).toBe(
'My custom X axis title'
);
});

it('should set the mode to Auto if no title is passed over', () => {
const component = mount(<AxisTitleSettings {...props} axisTitle={undefined} />);
expect(component.find('[data-test-subj="lnsxAxisTitle"]').last().prop('value')).toBe('');
});

it('should set the mode to Auto if empty title is passed over', () => {
const component = mount(<AxisTitleSettings {...props} axisTitle={''} />);
expect(component.find('[data-test-subj="lnsxAxisTitle"]').last().prop('value')).toBe('');
});

it('should disable the input text if the switch is off', () => {
const component = shallow(<AxisTitleSettings {...props} isAxisTitleVisible={false} />);
expect(component.find('[data-test-subj="lnsxAxisTitle"]').prop('disabled')).toBe(true);
const component = mount(<AxisTitleSettings {...props} isAxisTitleVisible={false} />);
expect(component.find('[data-test-subj="lnsxAxisTitle"]').last().prop('disabled')).toBe(true);
});

it('should allow custom mode on user input even with empty string', () => {
let component = mount(<AxisTitleSettings {...props} axisTitle={''} />);

// switch mode
act(() => {
component.find(VisLabel).prop('handleChange')!({
label: '',
mode: 'custom',
} as Label);
});
component = component.update();
expect(component.find('[data-test-subj="lnsxAxisTitle-select"]').last().prop('value')).toBe(
'custom'
);
expect(component.find('[data-test-subj="lnsxAxisTitle"]').last().prop('value')).toBe('');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,11 @@
* 2.0.
*/

import React from 'react';
import {
EuiFlexGroup,
EuiFlexItem,
EuiText,
EuiSwitch,
EuiSpacer,
EuiFieldText,
} from '@elastic/eui';
import React, { useCallback, useState } from 'react';
import { EuiSpacer, EuiFormRow } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { AxesSettingsConfig } from '../../common/expressions';
import { useDebouncedValue } from './';
import { LabelMode, useDebouncedValue, VisLabel } from './';
type AxesSettingsConfigKeys = keyof AxesSettingsConfig;

export interface AxisTitleSettingsProps {
Expand Down Expand Up @@ -56,45 +49,50 @@ export const AxisTitleSettings: React.FunctionComponent<AxisTitleSettingsProps>
},
{ allowFalsyValue: true }
);
const [titleMode, setTitleMode] = useState<LabelMode>(
!title ? 'auto' : isAxisTitleVisible ? 'custom' : 'none'
);

const updateVisibility = useCallback(
(mode: LabelMode) => {
const visible = mode !== 'none';
if (visible !== isAxisTitleVisible) {
toggleAxisTitleVisibility(axis, visible);
}
setTitleMode(mode);
},
[axis, isAxisTitleVisible, toggleAxisTitleVisibility]
);

return (
<>
<EuiFlexGroup gutterSize="s" justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiText size="xs">
<h4>
{i18n.translate('xpack.lens.shared.axisNameLabel', {
defaultMessage: 'Axis title',
})}
</h4>
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiSwitch
compressed
data-test-subj={`lnsShowAxisTitleSwitch__${axis}`}
label={i18n.translate('xpack.lens.shared.ShowAxisTitleLabel', {
defaultMessage: 'Show',
})}
onChange={({ target }) => toggleAxisTitleVisibility(axis, target.checked)}
checked={isAxisTitleVisible}
/>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="xs" />
<EuiFieldText
data-test-subj={`lns${axis}AxisTitle`}
compressed
placeholder={i18n.translate('xpack.lens.shared.overwriteAxisTitle', {
defaultMessage: 'Overwrite axis title',
})}
value={title || ''}
disabled={!isAxisTitleVisible || false}
onChange={({ target }) => onTitleChange(target.value)}
aria-label={i18n.translate('xpack.lens.shared.overwriteAxisTitle', {
defaultMessage: 'Overwrite axis title',
<EuiFormRow
display="columnCompressed"
label={i18n.translate('xpack.lens.label.shared.axisHeader', {
defaultMessage: 'Axis title',
})}
/>
<EuiSpacer size="m" />
fullWidth
>
<VisLabel
header={i18n.translate('xpack.lens.shared.axisNameLabel', {
defaultMessage: 'Axis title',
})}
dataTestSubj={`lns${axis}AxisTitle`}
label={title || ''}
mode={titleMode}
placeholder={i18n.translate('xpack.lens.shared.overwriteAxisTitle', {
defaultMessage: 'Overwrite axis title',
})}
hasAutoOption={true}
handleChange={({ mode, label }) => {
if (title !== label) {
onTitleChange(label);
}
updateVisibility(mode);
}}
/>
</EuiFormRow>
<EuiSpacer size="s" />
</>
);
};
Loading

0 comments on commit 1ef6411

Please sign in to comment.