Skip to content

Commit

Permalink
Merge branch 'master' into fix-date-histogram
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Mar 4, 2020
2 parents 22c82f0 + 5a21805 commit 20be343
Show file tree
Hide file tree
Showing 100 changed files with 656 additions and 831 deletions.
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/public/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module.exports = {
{
basePath: path.resolve(__dirname, '../../../../../'),
zones: topLevelRestricedZones.concat(
buildRestrictedPaths(['visualize', 'discover', 'dashboard', 'devTools', 'home'])
buildRestrictedPaths(['visualize', 'discover', 'dashboard', 'devTools'])
),
},
],
Expand Down
1 change: 0 additions & 1 deletion src/legacy/core_plugins/kibana/public/home/_index.scss

This file was deleted.

This file was deleted.

105 changes: 0 additions & 105 deletions src/legacy/core_plugins/kibana/public/home/plugin.ts

This file was deleted.

6 changes: 3 additions & 3 deletions src/legacy/core_plugins/kibana/public/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
// Discover styles
@import 'discover/index';

// Home styles
@import './home/index';

// Visualize styles
@import './visualize/index';
// Has to come after visualize because of some
// bad cascading in the Editor layout
@import 'src/legacy/ui/public/vis/index';

// Home styles
@import '../../../../plugins/home/public/application/index';

// Management styles
@import './management/index';

Expand Down
1 change: 0 additions & 1 deletion src/legacy/core_plugins/kibana/public/kibana.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import 'uiExports/shareContextMenuExtensions';
import 'uiExports/interpreter';

import 'ui/autoload/all';
import './home';
import './discover/legacy';
import './visualize/legacy';
import './dashboard/legacy';
Expand Down
1 change: 0 additions & 1 deletion src/legacy/core_plugins/kibana_react/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export default function DataPlugin(kibana: any) {
const config: Legacy.PluginSpecOptions = {
id: 'kibana_react',
require: [],
publicDir: resolve(__dirname, 'public'),
config: (Joi: any) => {
return Joi.object({
enabled: Joi.boolean().default(true),
Expand Down
8 changes: 1 addition & 7 deletions src/legacy/core_plugins/kibana_react/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,4 @@
* under the License.
*/

// TODO these are imports from the old plugin world.
// Once the new platform is ready, they can get removed
// and handled by the platform itself in the setup method
// of the ExpressionExectorService

/** @public types */
export { Markdown, MarkdownSimple } from './markdown';
export { Markdown, MarkdownSimple } from '../../../../plugins/kibana_react/public';
15 changes: 3 additions & 12 deletions src/legacy/ui/public/new_platform/new_platform.karma_mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ export const npSetup = {
config: {
disableWelcomeScreen: false,
},
tutorials: {
setVariable: sinon.fake(),
},
},
charts: {
theme: {
Expand Down Expand Up @@ -381,18 +384,6 @@ export const npStart = {
getTriggerActions: sinon.fake(),
getTriggerCompatibleActions: sinon.fake(),
},
home: {
featureCatalogue: {
get: sinon.fake(),
register: sinon.fake(),
},
environment: {
get: sinon.fake(),
},
config: {
disableWelcomeScreen: false,
},
},
navigation: {
ui: {
TopNavMenu: mockComponent,
Expand Down
3 changes: 1 addition & 2 deletions src/legacy/ui/public/new_platform/new_platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
import { ChartsPluginSetup, ChartsPluginStart } from '../../../../plugins/charts/public';
import { DevToolsSetup, DevToolsStart } from '../../../../plugins/dev_tools/public';
import { KibanaLegacySetup, KibanaLegacyStart } from '../../../../plugins/kibana_legacy/public';
import { HomePublicPluginSetup, HomePublicPluginStart } from '../../../../plugins/home/public';
import { HomePublicPluginSetup } from '../../../../plugins/home/public';
import { SharePluginSetup, SharePluginStart } from '../../../../plugins/share/public';
import {
AdvancedSettingsSetup,
Expand Down Expand Up @@ -79,7 +79,6 @@ export interface PluginsStart {
data: ReturnType<DataPlugin['start']>;
embeddable: IEmbeddableStart;
expressions: ReturnType<ExpressionsPlugin['start']>;
home: HomePublicPluginStart;
inspector: InspectorStart;
uiActions: UiActionsStart;
navigation: NavigationPublicPluginStart;
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/url/redirect_when_missing.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import React from 'react';
import { i18n } from '@kbn/i18n';
import { MarkdownSimple } from '../../../core_plugins/kibana_react/public/markdown';
import { MarkdownSimple } from '../../../../plugins/kibana_react/public';
import { toastNotifications } from 'ui/notify';
import { SavedObjectNotFound } from '../../../../plugins/kibana_utils/public';
import { uiModules } from '../modules';
Expand Down
61 changes: 56 additions & 5 deletions src/plugins/console/server/lib/proxy_request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ describe(`Console's send request`, () => {
beforeEach(() => {
sandbox = sinon.createSandbox();
stub = sandbox.stub(http, 'request').callsFake(() => {
fakeRequest = {
abort: sinon.stub(),
on() {},
once() {},
} as any;
return fakeRequest;
});
});
Expand All @@ -45,6 +40,11 @@ describe(`Console's send request`, () => {
});

it('correctly implements timeout and abort mechanism', async () => {
fakeRequest = {
abort: sinon.stub(),
on() {},
once() {},
} as any;
try {
await proxyRequest({
agent: null as any,
Expand All @@ -60,4 +60,55 @@ describe(`Console's send request`, () => {
expect((fakeRequest.abort as sinon.SinonStub).calledOnce).toBe(true);
}
});

it('correctly sets the "host" header entry', async () => {
fakeRequest = {
abort: sinon.stub(),
on() {},
once(event: string, fn: any) {
if (event === 'response') {
return fn('done');
}
},
} as any;

// Don't set a host header this time
const result1 = await proxyRequest({
agent: null as any,
headers: {},
method: 'get',
payload: null as any,
timeout: 30000,
uri: new URL('http://noone.nowhere.none'),
});

expect(result1).toEqual('done');

const [httpRequestOptions1] = stub.firstCall.args;

expect((httpRequestOptions1 as any).headers).toEqual({
'content-type': 'application/json',
host: 'noone.nowhere.none', // Defaults to the provided host name
'transfer-encoding': 'chunked',
});

// Set a host header
const result2 = await proxyRequest({
agent: null as any,
headers: { Host: 'myhost' },
method: 'get',
payload: null as any,
timeout: 30000,
uri: new URL('http://noone.nowhere.none'),
});

expect(result2).toEqual('done');

const [httpRequestOptions2] = stub.secondCall.args;
expect((httpRequestOptions2 as any).headers).toEqual({
'content-type': 'application/json',
Host: 'myhost', // Uses provided host name
'transfer-encoding': 'chunked',
});
});
});
11 changes: 8 additions & 3 deletions src/plugins/console/server/lib/proxy_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,24 @@ export const proxyRequest = ({
reject = rej;
});

const finalUserHeaders = { ...headers };
const hasHostHeader = Object.keys(finalUserHeaders).some(key => key.toLowerCase() === 'host');
if (!hasHostHeader) {
finalUserHeaders.host = hostname;
}

const req = client.request({
method: method.toUpperCase(),
// We support overriding this on a per request basis to support legacy proxy config. See ./proxy_config.
rejectUnauthorized: typeof rejectUnauthorized === 'boolean' ? rejectUnauthorized : undefined,
host: hostname,
port: port === '' ? undefined : Number(port),
port: port === '' ? undefined : parseInt(port, 10),
protocol,
path: `${pathname}${search || ''}`,
headers: {
...headers,
...finalUserHeaders,
'content-type': 'application/json',
'transfer-encoding': 'chunked',
host: hostname,
},
agent,
});
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/home/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "kibana",
"server": true,
"ui": true,
"optionalPlugins": ["usage_collection"]
"requiredPlugins": ["data", "kibanaLegacy"],
"optionalPlugins": ["usage_collection", "telemetry"]
}
1 change: 1 addition & 0 deletions src/plugins/home/public/application/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'components/index';
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import { render, unmountComponentAtNode } from 'react-dom';
import { i18n } from '@kbn/i18n';
// @ts-ignore
import { HomeApp } from './components/home_app';
import { getServices } from '../kibana_services';
import { getServices } from './kibana_services';

export const renderApp = async (element: HTMLElement) => {
const homeTitle = i18n.translate('kbn.home.breadcrumbs.homeTitle', { defaultMessage: 'Home' });
const homeTitle = i18n.translate('home.breadcrumbs.homeTitle', { defaultMessage: 'Home' });
const { featureCatalogue, chrome } = getServices();

// all the directories could be get in "start" phase of plugin after all of the legacy plugins will be moved to a NP
Expand Down
Loading

0 comments on commit 20be343

Please sign in to comment.