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

Kertal pr 2020 01 13 painless playground suggestions #4

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions x-pack/legacy/plugins/painless_playground/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
export const PLUGIN_ID = 'painless_playground';

export const API_ROUTE_EXECUTE = '/api/painless_playground/execute';

export const ADVANCED_SETTINGS_FLAG_NAME = 'devTools:enablePainlessPlayground';
24 changes: 21 additions & 3 deletions x-pack/legacy/plugins/painless_playground/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { i18n } from '@kbn/i18n';
import { resolve } from 'path';
import { PLUGIN_ID } from './common/constants';
import { PLUGIN_ID, ADVANCED_SETTINGS_FLAG_NAME } from './common/constants';

import { registerLicenseChecker } from './server/register_license_checker';
import { registerExecuteRoute } from './server/register_execute_route';
import { Legacy } from '../../../../kibana';

export const painlessPlayground = (kibana: any) =>
new kibana.Plugin({
Expand All @@ -24,7 +25,24 @@ export const painlessPlayground = (kibana: any) =>
uiExports: {
devTools: [resolve(__dirname, 'public/register')],
},
init: (server: any) => {
init: (server: Legacy.Server) => {
// Register feature flag
server.newPlatform.setup.core.uiSettings.register({
[ADVANCED_SETTINGS_FLAG_NAME]: {
name: i18n.translate('kbn.advancedSettings.devTools.painlessPlaygroundTitle', {
defaultMessage: 'Painless Playground',
}),
description: i18n.translate(
'kbn.advancedSettings.devTools.painlessPlaygroundDescription',
{
defaultMessage: 'Enable experimental Painless Playground.',
}
),
value: false,
category: ['Dev Tools'],
},
});

registerLicenseChecker(server);
registerExecuteRoute(server);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,16 @@ export function formatJson(json: any): string {
return `Invalid JSON ${String(json)}`;
}
}

export function formatExecutionError(json: object) {
if (json.script_stack && json.caused_by) {
return `Unhandled Exception ${json.caused_by.type}

${json.caused_by.reason}

Located at:
${formatJson(json.script_stack)}
`;
}
return formatJson(json);
}
Loading