Skip to content

Commit

Permalink
Merge branch 'master' into redesign/44541--new-monitor-list-expanded-row
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Nov 18, 2019
2 parents 6b8e052 + e2dc921 commit a2b9427
Show file tree
Hide file tree
Showing 496 changed files with 5,114 additions and 1,395 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ Note that for VSCode, to enable "live" linting of TypeScript (and other) file ty
"eslint.autoFixOnSave": true,
```

It is **not** recommended to use `prettier` plugin on Kibana project. Because settings are in `eslintrc.js` file and it is applied to too many files that shouldn't be prettier-ized.
:warning: It is **not** recommended to use the [`Prettier` extension/IDE plugin](https://prettier.io/) while maintaining the Kibana project. Formatting and styling roles are set in the multiple `.eslintrc.js` files across the project and some of them use the [NPM version of Prettier](https://www.npmjs.com/package/prettier). Using the IDE extension might cause conflicts, applying the formatting to too many files that shouldn't be prettier-ized and/or highlighting errors that are actually OK.

### Internationalization

Expand Down
4 changes: 2 additions & 2 deletions docs/canvas/canvas-share-workpad.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ image::images/canvas-create-URL.gif[Create POST URL]
[[add-workpad-website]]
=== Share the workpad on a website

beta[] Download the workpad and share it on any website, then customize the workpad behavior to autoplay the pages or hide the toolbar.
beta[] Canvas allows you to create _shareables_, which are workpads that you download and securely share on any website. To customize the behavior of the workpad on your website, you can choose to autoplay the pages or hide the workpad toolbar.

. If you are using a Gold or Platinum license, enable reporting in your `config/kibana.yml` file.

Expand All @@ -74,7 +74,7 @@ NOTE: Shareable workpads encode the current state of the workpad in a JSON file.

[float]
[[change-the-workpad-settings]]
=== Change the shareable workpad settings
=== Change the settings

After you've added the workpad to your website, you can change the autoplay and toolbar settings.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Each route can have only one handler function, which is executed when the route

```ts
const router = createRouter();
// handler is called when '${my-plugin-id}/path' resource is requested with `GET` method
// handler is called when '/path' resource is requested with `GET` method
router.get({ path: '/path', validate: false }, (context, req, res) => res.ok({ content: 'ok' }));

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface HttpServiceSetup

## Example

To handle an incoming request in your plugin you should: - Create a `Router` instance. Router is already configured to use `plugin-id` to prefix path segment for your routes.
To handle an incoming request in your plugin you should: - Create a `Router` instance.

```ts
const router = httpSetup.createRouter();
Expand Down Expand Up @@ -61,7 +61,7 @@ const handler = async (context: RequestHandlerContext, request: KibanaRequest, r
}

```
- Register route handler for GET request to 'my-app/path/<!-- -->{<!-- -->id<!-- -->}<!-- -->' path
- Register route handler for GET request to 'path/<!-- -->{<!-- -->id<!-- -->}<!-- -->' path

```ts
import { schema, TypeOf } from '@kbn/config-schema';
Expand Down
2 changes: 1 addition & 1 deletion docs/management/managing-beats.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[role="xpack"]
== Managing {beats}

beta[]
include::{asciidoc-dir}/../../shared/discontinued.asciidoc[tag=cm-discontinued]

Use the Central Management UI under *Management > {beats}* to define and
manage configurations in a central location in {kib} and quickly deploy
Expand Down
9 changes: 6 additions & 3 deletions docs/maps/search.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You can create a layer that requests data from {es} from the following:

** Grid aggregation source

** <<terms-join>>. The search context is applied to both the terms join and the vector source when the vector source is provided by Elasticsearch documents.
** <<terms-join>>

* <<heatmap-layer>> with Grid aggregation source

Expand Down Expand Up @@ -87,8 +87,11 @@ The most common cause for empty layers are searches for a field that exists in o
[[maps-disable-search-for-layer]]
==== Disable search for layer

To prevent the global search bar from applying search context to a layer, clear the *Apply global filter to layer* checkbox in Layer settings.
Disabling the search context applies to the layer source and all <<terms-join, term joins>> configured for the layer.
You can prevent the search bar from applying search context to a layer by configuring the following:

* In *Source settings*, clear the *Apply global filter to source* checkbox to turn off the global search context for the layer source.

* In *Term joins*, clear the *Apply global filter to join* checkbox to turn off the global search context for the <<terms-join, term join>>.

[float]
[[maps-add-index-search]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class Config {
this[$values] = value;
}

public has(key: string) {
public has(key: string | string[]) {
function recursiveHasCheck(
remainingPath: string[],
values: Record<string, any>,
Expand Down Expand Up @@ -109,7 +109,7 @@ export class Config {
return recursiveHasCheck(path, this[$values], schema);
}

public get(key: string, defaultValue?: any) {
public get(key: string | string[], defaultValue?: any) {
if (!this.has(key)) {
throw new Error(`Unknown config key "${key}"`);
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/core/server/elasticsearch/elasticsearch_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,11 @@ test('#ssl.certificateAuthorities accepts both string and array of strings', ()
);
expect(configValue.ssl.certificateAuthorities).toEqual(['some-path', 'another-path']);
});

test('#username throws if equal to "elastic", only while running from source', () => {
const obj = {
username: 'elastic',
};
expect(() => config.schema.validate(obj, { dist: false })).toThrowErrorMatchingSnapshot();
expect(() => config.schema.validate(obj, { dist: true })).not.toThrow();
});
30 changes: 28 additions & 2 deletions src/core/server/elasticsearch/elasticsearch_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import { schema, TypeOf } from '@kbn/config-schema';
import { Duration } from 'moment';
import { Logger } from '../logging';

const hostURISchema = schema.uri({ scheme: ['http', 'https'] });

Expand All @@ -39,7 +40,23 @@ export const config = {
defaultValue: 'http://localhost:9200',
}),
preserveHost: schema.boolean({ defaultValue: true }),
username: schema.maybe(schema.string()),
username: schema.maybe(
schema.conditional(
schema.contextRef('dist'),
false,
schema.string({
validate: rawConfig => {
if (rawConfig === 'elastic') {
return (
'value of "elastic" is forbidden. This is a superuser account that can obfuscate ' +
'privilege-related issues. You should use the "kibana" user instead.'
);
}
},
}),
schema.string()
)
),
password: schema.maybe(schema.string()),
requestHeadersWhitelist: schema.oneOf([schema.string(), schema.arrayOf(schema.string())], {
defaultValue: ['authorization'],
Expand Down Expand Up @@ -166,7 +183,7 @@ export class ElasticsearchConfig {
*/
public readonly customHeaders: ElasticsearchConfigType['customHeaders'];

constructor(rawConfig: ElasticsearchConfigType) {
constructor(rawConfig: ElasticsearchConfigType, log?: Logger) {
this.ignoreVersionMismatch = rawConfig.ignoreVersionMismatch;
this.apiVersion = rawConfig.apiVersion;
this.logQueries = rawConfig.logQueries;
Expand Down Expand Up @@ -195,5 +212,14 @@ export class ElasticsearchConfig {
...rawConfig.ssl,
certificateAuthorities,
};

if (this.username === 'elastic' && log !== undefined) {
// logger is optional / not used during tests
// TODO: logger can be removed when issue #40255 is resolved to support deprecations in NP config service
log.warn(
`Setting the elasticsearch username to "elastic" is deprecated. You should use the "kibana" user instead.`,
{ tags: ['deprecation'] }
);
}
}
}
2 changes: 1 addition & 1 deletion src/core/server/elasticsearch/elasticsearch_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class ElasticsearchService implements CoreService<InternalElasticsearchSe
this.log = coreContext.logger.get('elasticsearch-service');
this.config$ = coreContext.configService
.atPath<ElasticsearchConfigType>('elasticsearch')
.pipe(map(rawConfig => new ElasticsearchConfig(rawConfig)));
.pipe(map(rawConfig => new ElasticsearchConfig(rawConfig, coreContext.logger.get('config'))));
}

public async setup(deps: SetupDeps): Promise<InternalElasticsearchServiceSetup> {
Expand Down
6 changes: 3 additions & 3 deletions src/core/server/http/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export type RequestHandlerContextProvider<
*
* @example
* To handle an incoming request in your plugin you should:
* - Create a `Router` instance. Router is already configured to use `plugin-id` to prefix path segment for your routes.
* - Create a `Router` instance.
* ```ts
* const router = httpSetup.createRouter();
* ```
Expand Down Expand Up @@ -87,7 +87,7 @@ export type RequestHandlerContextProvider<
* }
* ```
*
* - Register route handler for GET request to 'my-app/path/{id}' path
* - Register route handler for GET request to 'path/{id}' path
* ```ts
* import { schema, TypeOf } from '@kbn/config-schema';
* const router = httpSetup.createRouter();
Expand Down Expand Up @@ -184,7 +184,7 @@ export interface HttpServiceSetup {
* @example
* ```ts
* const router = createRouter();
* // handler is called when '${my-plugin-id}/path' resource is requested with `GET` method
* // handler is called when '/path' resource is requested with `GET` method
* router.get({ path: '/path', validate: false }, (context, req, res) => res.ok({ content: 'ok' }));
* ```
* @public
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class Home extends Component {
getServices().getInjected('disableWelcomeScreen') ||
props.localStorage.getItem(KEY_ENABLE_WELCOME) === 'false'
);
const showTelemetryDisclaimer = getServices().getInjected('allowChangingOptInStatus');
const showTelemetryDisclaimer = getServices().getInjected('telemetryNotifyUserAboutOptInDefault');

this.state = {
// If welcome is enabled, we wait for loading to complete
Expand Down Expand Up @@ -231,6 +231,7 @@ export class Home extends Component {
onSkip={this.skipWelcome}
urlBasePath={this.props.urlBasePath}
showTelemetryDisclaimer={this.state.showTelemetryDisclaimer}
onOptInSeen={this.props.onOptInSeen}
/>
);
}
Expand Down Expand Up @@ -269,4 +270,5 @@ Home.propTypes = {
localStorage: PropTypes.object.isRequired,
urlBasePath: PropTypes.string.isRequired,
mlEnabled: PropTypes.bool.isRequired,
onOptInSeen: PropTypes.func.isRequired,
};
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export function HomeApp({ directories }) {
savedObjectsClient,
getBasePath,
addBasePath,
telemetryOptInProvider: {
setOptInNoticeSeen,
},
} = getServices();

const isCloudEnabled = getInjected('isCloudEnabled', false);
Expand Down Expand Up @@ -83,6 +86,7 @@ export function HomeApp({ directories }) {
find={savedObjectsClient.find}
localStorage={localStorage}
urlBasePath={getBasePath()}
onOptInSeen={setOptInNoticeSeen}
/>
</Route>
<Route path="/home">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jest.mock('../kibana_services', () => ({
test('should render a Welcome screen with the telemetry disclaimer', () => {
const component = shallow(
// @ts-ignore
<Welcome urlBase="/" onSkip={() => {}} showTelemetryDisclaimer={true} />
<Welcome urlBase="/" onSkip={() => {}} showTelemetryDisclaimer={true} onOptInSeen={() => {}} />
);

expect(component).toMatchSnapshot();
Expand All @@ -45,8 +45,19 @@ test('should render a Welcome screen with no telemetry disclaimer', () => {
// @ts-ignore
const component = shallow(
// @ts-ignore
<Welcome urlBase="/" onSkip={() => {}} showTelemetryDisclaimer={false} />
<Welcome urlBase="/" onSkip={() => {}} showTelemetryDisclaimer={false} onOptInSeen={() => {}} />
);

expect(component).toMatchSnapshot();
});

test('fires opt-in seen when mounted', () => {
const seen = jest.fn();

shallow(
// @ts-ignore
<Welcome urlBase="/" onSkip={() => {}} showTelemetryDisclaimer={true} onOptInSeen={seen} />
);

expect(seen).toHaveBeenCalled();
});
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { SampleDataCard } from './sample_data';
interface Props {
urlBasePath: string;
onSkip: () => void;
onOptInSeen: () => any;
showTelemetryDisclaimer: boolean;
}

Expand Down Expand Up @@ -75,6 +76,7 @@ export class Welcome extends React.Component<Props> {

componentDidMount() {
this.services.trackUiMetric(this.services.METRIC_TYPE.LOADED, 'welcomeScreenMount');
this.props.onOptInSeen();
document.addEventListener('keydown', this.hideOnEsc);
}

Expand Down Expand Up @@ -132,17 +134,17 @@ export class Welcome extends React.Component<Props> {
>
<FormattedMessage
id="kbn.home.dataManagementDisclaimerPrivacyLink"
defaultMessage="Privacy Policy."
defaultMessage="Privacy Statement."
/>
</EuiLink>
<FormattedMessage
id="kbn.home.dataManagementDisableCollection"
defaultMessage=" To disable collection, "
defaultMessage=" To stop collection, "
/>
<EuiLink href="#/management/kibana/settings">
<FormattedMessage
id="kbn.home.dataManagementDisableCollectionLink"
defaultMessage="click here."
defaultMessage="disable usage data here."
/>
</EuiLink>
</EuiTextColor>
Expand Down
23 changes: 19 additions & 4 deletions src/legacy/core_plugins/kibana/public/home/load_tutorials.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,44 @@ import _ from 'lodash';
import { getServices } from './kibana_services';
import { i18n } from '@kbn/i18n';

const baseUrlLP = getServices().addBasePath('/api/kibana/home/tutorials_LP');
const baseUrl = getServices().addBasePath('/api/kibana/home/tutorials');
const headers = new Headers();
headers.append('Accept', 'application/json');
headers.append('Content-Type', 'application/json');
headers.append('kbn-xsrf', 'kibana');

let tutorials = [];
let tutorialsLegacyPlatform = [];
let tutorialsNewPlatform = [];
let tutorialsLoaded = false;

async function loadTutorials() {
try {
const response = await fetch(baseUrl, {
const responseLegacyPlatform = await fetch(baseUrlLP, {
method: 'get',
credentials: 'include',
headers: headers,
});
if (response.status >= 300) {
if (responseLegacyPlatform.status >= 300) {
throw new Error(i18n.translate('kbn.home.loadTutorials.requestFailedErrorMessage', {
defaultMessage: 'Request failed with status code: {status}', values: { status: response.status } }
defaultMessage: 'Request failed with status code: {status}', values: { status: responseLegacyPlatform.status } }
));
}
const responseNewPlatform = await fetch(baseUrl, {
method: 'get',
credentials: 'include',
headers: headers,
});
if (responseNewPlatform.status >= 300) {
throw new Error(i18n.translate('kbn.home.loadTutorials.requestFailedErrorMessage', {
defaultMessage: 'Request failed with status code: {status}', values: { status: responseNewPlatform.status } }
));
}

tutorials = await response.json();
tutorialsLegacyPlatform = await responseLegacyPlatform.json();
tutorialsNewPlatform = await responseNewPlatform.json();
tutorials = tutorialsLegacyPlatform.concat(tutorialsNewPlatform);
tutorialsLoaded = true;
} catch(err) {
getServices().toastNotifications.addDanger({
Expand Down
Loading

0 comments on commit a2b9427

Please sign in to comment.