Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console to NP ready #43346

Merged
merged 42 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
34ae77d
General structure of Public w/ legacy brace + autocomplete 🤔
jloleysens Aug 15, 2019
a6c4045
First refactor of kbn ace keyboard mode to TS+React
jloleysens Aug 28, 2019
bc36ca0
clean up unused props
jloleysens Aug 28, 2019
8983ae8
console_menu.js -> console_menu.tsx
jloleysens Aug 28, 2019
b99749d
Remove unused file from quarantine and added fixed ui ace keyboard mo…
jloleysens Aug 28, 2019
7cf1417
- Refactored history and storage to app-wide services
jloleysens Aug 28, 2019
8ff783a
A lot of cleanup, re-introduced editor resize checker, re-introduced …
jloleysens Aug 29, 2019
32c4633
First iteration of tap nav menu, with history toggle working
jloleysens Aug 29, 2019
1969e66
Lots of fixes
jloleysens Aug 29, 2019
d819528
Moved a lot of files around again, tidied up NP set up
jloleysens Aug 30, 2019
45382c3
Replace angular directive
jloleysens Aug 30, 2019
18f84a2
Remove used code
jloleysens Aug 30, 2019
51daf28
Re-order imports and move all ace dependencies to same location
jloleysens Aug 30, 2019
6bccd55
Remove more unused code
jloleysens Aug 30, 2019
6a5f082
Revise quarantined setup mocks
jloleysens Sep 2, 2019
a6b8750
Merge branch 'master' of github.com:elastic/kibana into chore/console…
jloleysens Sep 2, 2019
c5b2841
Don't suggest 'undefined' or other null-like values in autocomplete
jloleysens Sep 2, 2019
605f16a
Clean up api_server folder
jloleysens Sep 2, 2019
21c9168
Re-add missing style
jloleysens Sep 2, 2019
d5b2702
Updated karma spec mock
jloleysens Sep 2, 2019
b59a2b2
Fix editors cutting of at bottom of screen
jloleysens Sep 2, 2019
8764ab0
Refactor console editors into single components
jloleysens Sep 3, 2019
012d760
Updated use of contexts with better error message
jloleysens Sep 3, 2019
2b2509c
Updated test mocks
jloleysens Sep 3, 2019
758064d
Update to be more in line with NP conventions https://github.com/elas…
jloleysens Sep 4, 2019
3130343
Update console history when making new requests
jloleysens Sep 4, 2019
213bbdc
Merge branch 'master' of github.com:elastic/kibana into chore/console…
jloleysens Sep 4, 2019
0a8648b
Merge branch 'chore/console-to-np-ready' of github.com:jloleysens/kib…
jloleysens Sep 4, 2019
477e8f2
Clean up git merge conflict artifact
jloleysens Sep 4, 2019
60f23cb
Use updated NP interfaces
jloleysens Sep 4, 2019
322569f
More typings fixed after updating local project dependencies
jloleysens Sep 4, 2019
384f4de
Removing some dependencies on KUI and font awesome from legacy editor
jloleysens Sep 5, 2019
683a04e
Fix clear history not re-rendering
jloleysens Sep 5, 2019
e143c64
Simplify split_panel and add tests
jloleysens Sep 5, 2019
e0fcb29
Fix accessibility tabbing behaviour for ace editor
jloleysens Sep 10, 2019
0939758
Refactor ConsoleEditor into two separate components
jloleysens Sep 10, 2019
d1824b3
Merge branch 'master' of github.com:elastic/kibana into chore/console…
jloleysens Sep 10, 2019
2e531e9
Merge branch 'master' of github.com:elastic/kibana into chore/console…
jloleysens Sep 10, 2019
e351ba2
Major a11y fix when tabbing
jloleysens Sep 11, 2019
c82003c
Merge branch 'master' of github.com:elastic/kibana into chore/console…
jloleysens Sep 11, 2019
7f65525
Merge branch 'master' of github.com:elastic/kibana into chore/console…
jloleysens Sep 11, 2019
08a9df0
Update comment
jloleysens Sep 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rfcs/text/0004_application_service_mounting.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MyPlugin {
id: 'my-app',
title: 'My Application',
async mount(context, targetDomElement) {
const { renderApp } = await import('./applcation');
const { renderApp } = await import('./application');
return renderApp(context, targetDomElement);
}
});
Expand Down Expand Up @@ -260,7 +260,7 @@ export class MyPlugin {
application.register({
id: 'my-app',
async mount(context, targetDomElem) {
const { renderApp } = await import('./applcation');
const { renderApp } = await import('./application');
return renderApp(context, targetDomElement);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@ import { resolve, join, sep } from 'path';
import url from 'url';
import { has, isEmpty, head, pick } from 'lodash';

import { resolveApi } from './api_server/server';
import { addExtensionSpecFilePath } from './api_server/spec';
// @ts-ignore
import { resolveApi } from './server/api_server/server';
// @ts-ignore
import { addExtensionSpecFilePath } from './server/api_server/spec';
// @ts-ignore
import { setHeaders } from './server/set_headers';
// @ts-ignore
import { ProxyConfigCollection, getElasticsearchProxyConfig, createProxyRoute } from './server';

import {
ProxyConfigCollection,
getElasticsearchProxyConfig,
createProxyRoute
} from './server';

function filterHeaders(originalHeaders, headersToKeep) {
const normalizeHeader = function (header) {
function filterHeaders(originalHeaders: any, headersToKeep: any) {
const normalizeHeader = function(header: any) {
if (!header) {
return '';
}
Expand All @@ -48,51 +47,64 @@ function filterHeaders(originalHeaders, headersToKeep) {
return pick(originalHeaders, headersToKeepNormalized);
}

export default function (kibana) {
// eslint-disable-next-line
export default function(kibana: any) {
const modules = resolve(__dirname, 'public/webpackShims/');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this point to anything? I am not seeing the webpackShims folder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, @cjcenizal do you know anything more about this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. Can we double-check with the Platform and Operations teams? I see webpackShims in the root, but clearly the path here doesn't make sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with how this works or what it does. @spalger do you have more info on webpackShims and the noParse uiExport?

const src = resolve(__dirname, 'public/src/');
const quarantinedSrc = resolve(__dirname, 'public/quarantined/src/');
const src = resolve(__dirname, 'public/np_ready/public');

let defaultVars;
const apps = [];
let defaultVars: any;
const apps: any[] = [];
return new kibana.Plugin({
id: 'console',
require: ['elasticsearch'],

config: function (Joi) {
config(Joi: any) {
return Joi.object({
enabled: Joi.boolean().default(true),
proxyFilter: Joi.array().items(Joi.string()).single().default(['.*']),
proxyFilter: Joi.array()
.items(Joi.string())
.single()
.default(['.*']),
ssl: Joi.object({
verify: Joi.boolean(),
}).default(),
proxyConfig: Joi.array().items(
Joi.object().keys({
match: Joi.object().keys({
protocol: Joi.string().default('*'),
host: Joi.string().default('*'),
port: Joi.string().default('*'),
path: Joi.string().default('*')
}),

timeout: Joi.number(),
ssl: Joi.object().keys({
verify: Joi.boolean(),
ca: Joi.array().single().items(Joi.string()),
cert: Joi.string(),
key: Joi.string()
}).default()
})
).default()
proxyConfig: Joi.array()
.items(
Joi.object().keys({
match: Joi.object().keys({
protocol: Joi.string().default('*'),
host: Joi.string().default('*'),
port: Joi.string().default('*'),
path: Joi.string().default('*'),
}),

timeout: Joi.number(),
ssl: Joi.object()
.keys({
verify: Joi.boolean(),
ca: Joi.array()
.single()
.items(Joi.string()),
cert: Joi.string(),
key: Joi.string(),
})
.default(),
})
)
.default(),
}).default();
},

deprecations: function () {
deprecations() {
return [
(settings, log) => {
(settings: any, log: any) => {
if (has(settings, 'proxyConfig')) {
log('Config key "proxyConfig" is deprecated. Configuration can be inferred from the "elasticsearch" settings');
log(
'Config key "proxyConfig" is deprecated. Configuration can be inferred from the "elasticsearch" settings'
);
}
}
},
];
},

Expand All @@ -105,71 +117,78 @@ export default function (kibana) {
};
},

async init(server, options) {
async init(server: any, options: any) {
server.expose('addExtensionSpecFilePath', addExtensionSpecFilePath);
if (options.ssl && options.ssl.verify) {
throw new Error('sense.ssl.verify is no longer supported.');
}

const config = server.config();
const legacyEsConfig = await server.newPlatform.setup.core.elasticsearch.legacy.config$.pipe(first()).toPromise();
const legacyEsConfig = await server.newPlatform.setup.core.elasticsearch.legacy.config$
.pipe(first())
.toPromise();
const proxyConfigCollection = new ProxyConfigCollection(options.proxyConfig);
const proxyPathFilters = options.proxyFilter.map(str => new RegExp(str));
const proxyPathFilters = options.proxyFilter.map((str: string) => new RegExp(str));

defaultVars = {
elasticsearchUrl: url.format(
Object.assign(url.parse(head(legacyEsConfig.hosts)), { auth: false })
),
};

server.route(createProxyRoute({
baseUrl: head(legacyEsConfig.hosts),
pathFilters: proxyPathFilters,
getConfigForReq(req, uri) {
const filteredHeaders = filterHeaders(req.headers, legacyEsConfig.requestHeadersWhitelist);
const headers = setHeaders(filteredHeaders, legacyEsConfig.customHeaders);
server.route(
createProxyRoute({
baseUrl: head(legacyEsConfig.hosts),
pathFilters: proxyPathFilters,
getConfigForReq(req: any, uri: any) {
const filteredHeaders = filterHeaders(
req.headers,
legacyEsConfig.requestHeadersWhitelist
);
const headers = setHeaders(filteredHeaders, legacyEsConfig.customHeaders);

if (!isEmpty(config.get('console.proxyConfig'))) {
return {
...proxyConfigCollection.configForUri(uri),
headers,
};
}

if (!isEmpty(config.get('console.proxyConfig'))) {
return {
...proxyConfigCollection.configForUri(uri),
...getElasticsearchProxyConfig(legacyEsConfig),
headers,
};
}

return {
...getElasticsearchProxyConfig(legacyEsConfig),
headers,
};
}
}));
},
})
);

server.route({
path: '/api/console/api_server',
method: ['GET', 'POST'],
handler: function (req, h) {
handler(req: any, h: any) {
const { sense_version: version, apis } = req.query;
if (!apis) {
throw Boom.badRequest('"apis" is a required param.');
}

return resolveApi(version, apis.split(','), h);
}
},
});
},

uiExports: {
apps: apps,
hacks: ['plugins/console/hacks/register'],
devTools: ['plugins/console/console'],
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
apps,
hacks: ['plugins/console/quarantined/hacks/register'],
jloleysens marked this conversation as resolved.
Show resolved Hide resolved
devTools: [`${src}/legacy`],
styleSheetPaths: resolve(__dirname, 'public/quarantined/index.scss'),

injectDefaultVars: () => defaultVars,

noParse: [
join(modules, 'ace' + sep),
join(modules, 'moment_src/moment' + sep),
join(src, 'sense_editor/mode/worker.js')
]
}
});
join(quarantinedSrc, 'sense_editor/mode/worker.js'),
],
},
} as any);
}
20 changes: 20 additions & 0 deletions src/legacy/core_plugins/console/public/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## New Platform (NP) Ready vs Quarantined

We want to move toward more modularised code in the Console app.
Part of the effort means separating out different console compoonents
like:

- The language parser
- The editor rendering component
- Autocomplete
- The UI container components

In addition to this effort we want to bring Console in line with NP
requirements and ensure that we are not using NG in this app anymore.

The quarantined folder contains all of the code that has been cleared
for living in the new platform as it has not been properly refactored
or has dependencies on, for example, UI public.

Over time, the quarantined part of the code should shrink to nothing
jloleysens marked this conversation as resolved.
Show resolved Hide resolved
and we should only have NP ready code.
42 changes: 0 additions & 42 deletions src/legacy/core_plugins/console/public/index.html

This file was deleted.

6 changes: 6 additions & 0 deletions src/legacy/core_plugins/console/public/np_ready/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"id": "console",
"version": "kibana",
"server": true,
jloleysens marked this conversation as resolved.
Show resolved Hide resolved
"ui": true
}
Loading