Skip to content

Commit

Permalink
Merge feedback PR by jloysenes
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal authored Jan 20, 2020
2 parents 02b37ef + 4640b4d commit 6a4e8ca
Show file tree
Hide file tree
Showing 6 changed files with 271 additions and 174 deletions.
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

0 comments on commit 6a4e8ca

Please sign in to comment.