From d367dc2eee8e8b8a059ae3b8f565103242f0ad4c Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Thu, 12 Mar 2020 12:18:24 +0000 Subject: [PATCH 01/18] Move from legacy/plugins to plugins --- x-pack/{legacy => }/plugins/grokdebugger/README.md | 0 .../{legacy => }/plugins/grokdebugger/common/constants/editor.js | 0 .../{legacy => }/plugins/grokdebugger/common/constants/index.js | 0 .../{legacy => }/plugins/grokdebugger/common/constants/plugin.js | 0 .../{legacy => }/plugins/grokdebugger/common/constants/routes.js | 0 x-pack/{legacy => }/plugins/grokdebugger/index.js | 0 .../components/custom_patterns_input/custom_patterns_input.js | 0 .../grokdebugger/public/components/custom_patterns_input/index.js | 0 .../grokdebugger/public/components/event_input/event_input.js | 0 .../plugins/grokdebugger/public/components/event_input/index.js | 0 .../grokdebugger/public/components/event_output/event_output.js | 0 .../plugins/grokdebugger/public/components/event_output/index.js | 0 .../grokdebugger/public/components/grok_debugger/brace_imports.ts | 0 .../grokdebugger/public/components/grok_debugger/grok_debugger.js | 0 .../plugins/grokdebugger/public/components/grok_debugger/index.js | 0 .../plugins/grokdebugger/public/components/pattern_input/index.js | 0 .../grokdebugger/public/components/pattern_input/pattern_input.js | 0 .../plugins/grokdebugger/public/lib/ace/grok_highlight_rules.js | 0 .../{legacy => }/plugins/grokdebugger/public/lib/ace/grok_mode.js | 0 x-pack/{legacy => }/plugins/grokdebugger/public/lib/ace/index.js | 0 .../public/models/grokdebugger_request/grokdebugger_request.js | 0 .../grokdebugger/public/models/grokdebugger_request/index.js | 0 .../public/models/grokdebugger_response/grokdebugger_response.js | 0 .../grokdebugger/public/models/grokdebugger_response/index.js | 0 x-pack/{legacy => }/plugins/grokdebugger/public/register.js | 0 .../{legacy => }/plugins/grokdebugger/public/register_feature.ts | 0 x-pack/{legacy => }/plugins/grokdebugger/public/render_app.js | 0 .../public/services/grokdebugger/grokdebugger_service.js | 0 .../lib/call_with_request_factory/call_with_request_factory.js | 0 .../grokdebugger/server/lib/call_with_request_factory/index.js | 0 .../server/lib/check_license/__tests__/check_license.js | 0 .../grokdebugger/server/lib/check_license/check_license.js | 0 .../plugins/grokdebugger/server/lib/check_license/index.js | 0 .../plugins/grokdebugger/server/lib/error_wrappers/index.js | 0 .../grokdebugger/server/lib/error_wrappers/wrap_es_error.js | 0 .../__tests__/license_pre_routing_factory.js | 0 .../grokdebugger/server/lib/license_pre_routing_factory/index.js | 0 .../license_pre_routing_factory/license_pre_routing_factory.js | 0 .../grokdebugger/server/lib/register_license_checker/index.js | 0 .../lib/register_license_checker/register_license_checker.js | 0 .../models/grokdebugger_request/__tests__/grokdebugger_request.js | 0 .../server/models/grokdebugger_request/grokdebugger_request.js | 0 .../grokdebugger/server/models/grokdebugger_request/index.js | 0 .../grokdebugger_response/__tests__/grokdebugger_response.js | 0 .../server/models/grokdebugger_response/grokdebugger_response.js | 0 .../grokdebugger/server/models/grokdebugger_response/index.js | 0 .../plugins/grokdebugger/server/routes/api/grokdebugger/index.js | 0 .../routes/api/grokdebugger/register_grok_simulate_route.js | 0 .../routes/api/grokdebugger/register_grokdebugger_routes.js | 0 49 files changed, 0 insertions(+), 0 deletions(-) rename x-pack/{legacy => }/plugins/grokdebugger/README.md (100%) rename x-pack/{legacy => }/plugins/grokdebugger/common/constants/editor.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/common/constants/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/common/constants/plugin.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/common/constants/routes.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/components/custom_patterns_input/custom_patterns_input.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/components/custom_patterns_input/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/components/event_input/event_input.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/components/event_input/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/components/event_output/event_output.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/components/event_output/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/components/grok_debugger/brace_imports.ts (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/components/grok_debugger/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/components/pattern_input/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/components/pattern_input/pattern_input.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/lib/ace/grok_highlight_rules.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/lib/ace/grok_mode.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/lib/ace/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/models/grokdebugger_request/grokdebugger_request.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/models/grokdebugger_request/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/models/grokdebugger_response/grokdebugger_response.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/models/grokdebugger_response/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/register.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/register_feature.ts (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/render_app.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/public/services/grokdebugger/grokdebugger_service.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/lib/call_with_request_factory/call_with_request_factory.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/lib/call_with_request_factory/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/lib/check_license/__tests__/check_license.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/lib/check_license/check_license.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/lib/check_license/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/lib/error_wrappers/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/lib/error_wrappers/wrap_es_error.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/lib/license_pre_routing_factory/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/lib/license_pre_routing_factory/license_pre_routing_factory.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/lib/register_license_checker/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/lib/register_license_checker/register_license_checker.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/models/grokdebugger_request/__tests__/grokdebugger_request.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/models/grokdebugger_request/grokdebugger_request.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/models/grokdebugger_request/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/models/grokdebugger_response/__tests__/grokdebugger_response.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/models/grokdebugger_response/grokdebugger_response.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/models/grokdebugger_response/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/routes/api/grokdebugger/index.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js (100%) rename x-pack/{legacy => }/plugins/grokdebugger/server/routes/api/grokdebugger/register_grokdebugger_routes.js (100%) diff --git a/x-pack/legacy/plugins/grokdebugger/README.md b/x-pack/plugins/grokdebugger/README.md similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/README.md rename to x-pack/plugins/grokdebugger/README.md diff --git a/x-pack/legacy/plugins/grokdebugger/common/constants/editor.js b/x-pack/plugins/grokdebugger/common/constants/editor.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/common/constants/editor.js rename to x-pack/plugins/grokdebugger/common/constants/editor.js diff --git a/x-pack/legacy/plugins/grokdebugger/common/constants/index.js b/x-pack/plugins/grokdebugger/common/constants/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/common/constants/index.js rename to x-pack/plugins/grokdebugger/common/constants/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/common/constants/plugin.js b/x-pack/plugins/grokdebugger/common/constants/plugin.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/common/constants/plugin.js rename to x-pack/plugins/grokdebugger/common/constants/plugin.js diff --git a/x-pack/legacy/plugins/grokdebugger/common/constants/routes.js b/x-pack/plugins/grokdebugger/common/constants/routes.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/common/constants/routes.js rename to x-pack/plugins/grokdebugger/common/constants/routes.js diff --git a/x-pack/legacy/plugins/grokdebugger/index.js b/x-pack/plugins/grokdebugger/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/index.js rename to x-pack/plugins/grokdebugger/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/components/custom_patterns_input/custom_patterns_input.js b/x-pack/plugins/grokdebugger/public/components/custom_patterns_input/custom_patterns_input.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/components/custom_patterns_input/custom_patterns_input.js rename to x-pack/plugins/grokdebugger/public/components/custom_patterns_input/custom_patterns_input.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/components/custom_patterns_input/index.js b/x-pack/plugins/grokdebugger/public/components/custom_patterns_input/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/components/custom_patterns_input/index.js rename to x-pack/plugins/grokdebugger/public/components/custom_patterns_input/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/components/event_input/event_input.js b/x-pack/plugins/grokdebugger/public/components/event_input/event_input.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/components/event_input/event_input.js rename to x-pack/plugins/grokdebugger/public/components/event_input/event_input.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/components/event_input/index.js b/x-pack/plugins/grokdebugger/public/components/event_input/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/components/event_input/index.js rename to x-pack/plugins/grokdebugger/public/components/event_input/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/components/event_output/event_output.js b/x-pack/plugins/grokdebugger/public/components/event_output/event_output.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/components/event_output/event_output.js rename to x-pack/plugins/grokdebugger/public/components/event_output/event_output.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/components/event_output/index.js b/x-pack/plugins/grokdebugger/public/components/event_output/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/components/event_output/index.js rename to x-pack/plugins/grokdebugger/public/components/event_output/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/components/grok_debugger/brace_imports.ts b/x-pack/plugins/grokdebugger/public/components/grok_debugger/brace_imports.ts similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/components/grok_debugger/brace_imports.ts rename to x-pack/plugins/grokdebugger/public/components/grok_debugger/brace_imports.ts diff --git a/x-pack/legacy/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js b/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js rename to x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/components/grok_debugger/index.js b/x-pack/plugins/grokdebugger/public/components/grok_debugger/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/components/grok_debugger/index.js rename to x-pack/plugins/grokdebugger/public/components/grok_debugger/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/components/pattern_input/index.js b/x-pack/plugins/grokdebugger/public/components/pattern_input/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/components/pattern_input/index.js rename to x-pack/plugins/grokdebugger/public/components/pattern_input/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/components/pattern_input/pattern_input.js b/x-pack/plugins/grokdebugger/public/components/pattern_input/pattern_input.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/components/pattern_input/pattern_input.js rename to x-pack/plugins/grokdebugger/public/components/pattern_input/pattern_input.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/lib/ace/grok_highlight_rules.js b/x-pack/plugins/grokdebugger/public/lib/ace/grok_highlight_rules.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/lib/ace/grok_highlight_rules.js rename to x-pack/plugins/grokdebugger/public/lib/ace/grok_highlight_rules.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/lib/ace/grok_mode.js b/x-pack/plugins/grokdebugger/public/lib/ace/grok_mode.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/lib/ace/grok_mode.js rename to x-pack/plugins/grokdebugger/public/lib/ace/grok_mode.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/lib/ace/index.js b/x-pack/plugins/grokdebugger/public/lib/ace/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/lib/ace/index.js rename to x-pack/plugins/grokdebugger/public/lib/ace/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/models/grokdebugger_request/grokdebugger_request.js b/x-pack/plugins/grokdebugger/public/models/grokdebugger_request/grokdebugger_request.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/models/grokdebugger_request/grokdebugger_request.js rename to x-pack/plugins/grokdebugger/public/models/grokdebugger_request/grokdebugger_request.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/models/grokdebugger_request/index.js b/x-pack/plugins/grokdebugger/public/models/grokdebugger_request/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/models/grokdebugger_request/index.js rename to x-pack/plugins/grokdebugger/public/models/grokdebugger_request/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/models/grokdebugger_response/grokdebugger_response.js b/x-pack/plugins/grokdebugger/public/models/grokdebugger_response/grokdebugger_response.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/models/grokdebugger_response/grokdebugger_response.js rename to x-pack/plugins/grokdebugger/public/models/grokdebugger_response/grokdebugger_response.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/models/grokdebugger_response/index.js b/x-pack/plugins/grokdebugger/public/models/grokdebugger_response/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/models/grokdebugger_response/index.js rename to x-pack/plugins/grokdebugger/public/models/grokdebugger_response/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/register.js b/x-pack/plugins/grokdebugger/public/register.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/register.js rename to x-pack/plugins/grokdebugger/public/register.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/register_feature.ts b/x-pack/plugins/grokdebugger/public/register_feature.ts similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/register_feature.ts rename to x-pack/plugins/grokdebugger/public/register_feature.ts diff --git a/x-pack/legacy/plugins/grokdebugger/public/render_app.js b/x-pack/plugins/grokdebugger/public/render_app.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/render_app.js rename to x-pack/plugins/grokdebugger/public/render_app.js diff --git a/x-pack/legacy/plugins/grokdebugger/public/services/grokdebugger/grokdebugger_service.js b/x-pack/plugins/grokdebugger/public/services/grokdebugger/grokdebugger_service.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/public/services/grokdebugger/grokdebugger_service.js rename to x-pack/plugins/grokdebugger/public/services/grokdebugger/grokdebugger_service.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/lib/call_with_request_factory/call_with_request_factory.js b/x-pack/plugins/grokdebugger/server/lib/call_with_request_factory/call_with_request_factory.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/lib/call_with_request_factory/call_with_request_factory.js rename to x-pack/plugins/grokdebugger/server/lib/call_with_request_factory/call_with_request_factory.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/lib/call_with_request_factory/index.js b/x-pack/plugins/grokdebugger/server/lib/call_with_request_factory/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/lib/call_with_request_factory/index.js rename to x-pack/plugins/grokdebugger/server/lib/call_with_request_factory/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/lib/check_license/__tests__/check_license.js b/x-pack/plugins/grokdebugger/server/lib/check_license/__tests__/check_license.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/lib/check_license/__tests__/check_license.js rename to x-pack/plugins/grokdebugger/server/lib/check_license/__tests__/check_license.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/lib/check_license/check_license.js b/x-pack/plugins/grokdebugger/server/lib/check_license/check_license.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/lib/check_license/check_license.js rename to x-pack/plugins/grokdebugger/server/lib/check_license/check_license.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/lib/check_license/index.js b/x-pack/plugins/grokdebugger/server/lib/check_license/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/lib/check_license/index.js rename to x-pack/plugins/grokdebugger/server/lib/check_license/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/lib/error_wrappers/index.js b/x-pack/plugins/grokdebugger/server/lib/error_wrappers/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/lib/error_wrappers/index.js rename to x-pack/plugins/grokdebugger/server/lib/error_wrappers/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/lib/error_wrappers/wrap_es_error.js b/x-pack/plugins/grokdebugger/server/lib/error_wrappers/wrap_es_error.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/lib/error_wrappers/wrap_es_error.js rename to x-pack/plugins/grokdebugger/server/lib/error_wrappers/wrap_es_error.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js b/x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js rename to x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/lib/license_pre_routing_factory/index.js b/x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/lib/license_pre_routing_factory/index.js rename to x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/lib/license_pre_routing_factory/license_pre_routing_factory.js b/x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/license_pre_routing_factory.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/lib/license_pre_routing_factory/license_pre_routing_factory.js rename to x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/license_pre_routing_factory.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/lib/register_license_checker/index.js b/x-pack/plugins/grokdebugger/server/lib/register_license_checker/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/lib/register_license_checker/index.js rename to x-pack/plugins/grokdebugger/server/lib/register_license_checker/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/lib/register_license_checker/register_license_checker.js b/x-pack/plugins/grokdebugger/server/lib/register_license_checker/register_license_checker.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/lib/register_license_checker/register_license_checker.js rename to x-pack/plugins/grokdebugger/server/lib/register_license_checker/register_license_checker.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/models/grokdebugger_request/__tests__/grokdebugger_request.js b/x-pack/plugins/grokdebugger/server/models/grokdebugger_request/__tests__/grokdebugger_request.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/models/grokdebugger_request/__tests__/grokdebugger_request.js rename to x-pack/plugins/grokdebugger/server/models/grokdebugger_request/__tests__/grokdebugger_request.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/models/grokdebugger_request/grokdebugger_request.js b/x-pack/plugins/grokdebugger/server/models/grokdebugger_request/grokdebugger_request.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/models/grokdebugger_request/grokdebugger_request.js rename to x-pack/plugins/grokdebugger/server/models/grokdebugger_request/grokdebugger_request.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/models/grokdebugger_request/index.js b/x-pack/plugins/grokdebugger/server/models/grokdebugger_request/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/models/grokdebugger_request/index.js rename to x-pack/plugins/grokdebugger/server/models/grokdebugger_request/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/models/grokdebugger_response/__tests__/grokdebugger_response.js b/x-pack/plugins/grokdebugger/server/models/grokdebugger_response/__tests__/grokdebugger_response.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/models/grokdebugger_response/__tests__/grokdebugger_response.js rename to x-pack/plugins/grokdebugger/server/models/grokdebugger_response/__tests__/grokdebugger_response.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/models/grokdebugger_response/grokdebugger_response.js b/x-pack/plugins/grokdebugger/server/models/grokdebugger_response/grokdebugger_response.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/models/grokdebugger_response/grokdebugger_response.js rename to x-pack/plugins/grokdebugger/server/models/grokdebugger_response/grokdebugger_response.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/models/grokdebugger_response/index.js b/x-pack/plugins/grokdebugger/server/models/grokdebugger_response/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/models/grokdebugger_response/index.js rename to x-pack/plugins/grokdebugger/server/models/grokdebugger_response/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/routes/api/grokdebugger/index.js b/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/index.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/routes/api/grokdebugger/index.js rename to x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/index.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js b/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js rename to x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js diff --git a/x-pack/legacy/plugins/grokdebugger/server/routes/api/grokdebugger/register_grokdebugger_routes.js b/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grokdebugger_routes.js similarity index 100% rename from x-pack/legacy/plugins/grokdebugger/server/routes/api/grokdebugger/register_grokdebugger_routes.js rename to x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grokdebugger_routes.js From b0c70d280b958ac5ec7256938177fb2204601845 Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Thu, 12 Mar 2020 12:45:13 +0000 Subject: [PATCH 02/18] Add kibana.json file --- x-pack/plugins/grokdebugger/kibana.json | 13 +++++++++++++ .../plugins/grokdebugger/public/register_feature.ts | 2 +- .../register_license_checker.js | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 x-pack/plugins/grokdebugger/kibana.json diff --git a/x-pack/plugins/grokdebugger/kibana.json b/x-pack/plugins/grokdebugger/kibana.json new file mode 100644 index 0000000000000..d74a79c315432 --- /dev/null +++ b/x-pack/plugins/grokdebugger/kibana.json @@ -0,0 +1,13 @@ +{ + "id": "grokdebugger", + "version": "8.0.0", + "kibanaVersion": "kibana", + "requiredPlugins": [ + "kibana", + "elasticsearch", + "xpack_main" + ], + "server": true, + "ui": true, + "configPath": ["xpack", "grokdebugger"] +} diff --git a/x-pack/plugins/grokdebugger/public/register_feature.ts b/x-pack/plugins/grokdebugger/public/register_feature.ts index 97d2e53ce7836..e04634a3b751a 100644 --- a/x-pack/plugins/grokdebugger/public/register_feature.ts +++ b/x-pack/plugins/grokdebugger/public/register_feature.ts @@ -6,7 +6,7 @@ import { i18n } from '@kbn/i18n'; import { npSetup } from 'ui/new_platform'; -import { FeatureCatalogueCategory } from '../../../../../src/plugins/home/public'; +import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public'; const { plugins: { home }, diff --git a/x-pack/plugins/grokdebugger/server/lib/register_license_checker/register_license_checker.js b/x-pack/plugins/grokdebugger/server/lib/register_license_checker/register_license_checker.js index ee9a9a3ebdece..489130f819ab3 100644 --- a/x-pack/plugins/grokdebugger/server/lib/register_license_checker/register_license_checker.js +++ b/x-pack/plugins/grokdebugger/server/lib/register_license_checker/register_license_checker.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mirrorPluginStatus } from '../../../../../server/lib/mirror_plugin_status'; +import { mirrorPluginStatus } from '../../../../../legacy/server/lib/mirror_plugin_status'; import { checkLicense } from '../check_license'; import { PLUGIN } from '../../../common/constants'; From 09a522ffc86a28d642921fad4b3ff4d25029913d Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Thu, 12 Mar 2020 12:45:55 +0000 Subject: [PATCH 03/18] Remove index.js file --- x-pack/plugins/grokdebugger/index.js | 31 ---------------------------- 1 file changed, 31 deletions(-) delete mode 100644 x-pack/plugins/grokdebugger/index.js diff --git a/x-pack/plugins/grokdebugger/index.js b/x-pack/plugins/grokdebugger/index.js deleted file mode 100644 index 7803aed739b99..0000000000000 --- a/x-pack/plugins/grokdebugger/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { resolve } from 'path'; -import { PLUGIN } from './common/constants'; -import { registerGrokdebuggerRoutes } from './server/routes/api/grokdebugger'; -import { registerLicenseChecker } from './server/lib/register_license_checker'; - -export const grokdebugger = kibana => - new kibana.Plugin({ - id: PLUGIN.ID, - publicDir: resolve(__dirname, 'public'), - require: ['kibana', 'elasticsearch', 'xpack_main'], - configPrefix: 'xpack.grokdebugger', - config(Joi) { - return Joi.object({ - enabled: Joi.boolean().default(true), - }).default(); - }, - uiExports: { - devTools: ['plugins/grokdebugger/register'], - home: ['plugins/grokdebugger/register_feature'], - }, - init: server => { - registerLicenseChecker(server); - registerGrokdebuggerRoutes(server); - }, - }); From e8c479c048b39c12015d3bb5ec0f9b8312a66231 Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Mon, 16 Mar 2020 15:44:57 +0000 Subject: [PATCH 04/18] Add routing --- x-pack/index.js | 2 - x-pack/plugins/grokdebugger/kibana.json | 7 +- .../call_with_request_factory => }/index.js | 6 +- .../call_with_request_factory.js | 18 ----- .../server/lib/kibana_framework.ts | 77 +++++++++++++++++++ x-pack/plugins/grokdebugger/server/plugin.js | 32 ++++++++ .../register_grok_simulate_route.js | 61 ++++++++------- .../register_grokdebugger_routes.js | 4 +- 8 files changed, 149 insertions(+), 58 deletions(-) rename x-pack/plugins/grokdebugger/server/{lib/call_with_request_factory => }/index.js (66%) delete mode 100644 x-pack/plugins/grokdebugger/server/lib/call_with_request_factory/call_with_request_factory.js create mode 100644 x-pack/plugins/grokdebugger/server/lib/kibana_framework.ts create mode 100644 x-pack/plugins/grokdebugger/server/plugin.js diff --git a/x-pack/index.js b/x-pack/index.js index ab31d40c5d718..fdbaf6df2ef61 100644 --- a/x-pack/index.js +++ b/x-pack/index.js @@ -10,7 +10,6 @@ import { monitoring } from './legacy/plugins/monitoring'; import { reporting } from './legacy/plugins/reporting'; import { security } from './legacy/plugins/security'; import { tilemap } from './legacy/plugins/tilemap'; -import { grokdebugger } from './legacy/plugins/grokdebugger'; import { dashboardMode } from './legacy/plugins/dashboard_mode'; import { logstash } from './legacy/plugins/logstash'; import { beats } from './legacy/plugins/beats_management'; @@ -45,7 +44,6 @@ module.exports = function(kibana) { spaces(kibana), security(kibana), tilemap(kibana), - grokdebugger(kibana), dashboardMode(kibana), logstash(kibana), beats(kibana), diff --git a/x-pack/plugins/grokdebugger/kibana.json b/x-pack/plugins/grokdebugger/kibana.json index d74a79c315432..9f62375b3a905 100644 --- a/x-pack/plugins/grokdebugger/kibana.json +++ b/x-pack/plugins/grokdebugger/kibana.json @@ -2,12 +2,7 @@ "id": "grokdebugger", "version": "8.0.0", "kibanaVersion": "kibana", - "requiredPlugins": [ - "kibana", - "elasticsearch", - "xpack_main" - ], "server": true, - "ui": true, + "ui": false, "configPath": ["xpack", "grokdebugger"] } diff --git a/x-pack/plugins/grokdebugger/server/lib/call_with_request_factory/index.js b/x-pack/plugins/grokdebugger/server/index.js similarity index 66% rename from x-pack/plugins/grokdebugger/server/lib/call_with_request_factory/index.js rename to x-pack/plugins/grokdebugger/server/index.js index 787814d87dff9..960c9d8d58e4a 100644 --- a/x-pack/plugins/grokdebugger/server/lib/call_with_request_factory/index.js +++ b/x-pack/plugins/grokdebugger/server/index.js @@ -4,4 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -export { callWithRequestFactory } from './call_with_request_factory'; +import { Plugin } from './plugin'; + +export function plugin(initializerContext) { + return new Plugin(initializerContext); +} diff --git a/x-pack/plugins/grokdebugger/server/lib/call_with_request_factory/call_with_request_factory.js b/x-pack/plugins/grokdebugger/server/lib/call_with_request_factory/call_with_request_factory.js deleted file mode 100644 index 7359a831994f9..0000000000000 --- a/x-pack/plugins/grokdebugger/server/lib/call_with_request_factory/call_with_request_factory.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { once } from 'lodash'; - -const callWithRequest = once(server => { - const cluster = server.plugins.elasticsearch.getCluster('data'); - return cluster.callWithRequest; -}); - -export const callWithRequestFactory = (server, request) => { - return (...args) => { - return callWithRequest(server)(request, ...args); - }; -}; diff --git a/x-pack/plugins/grokdebugger/server/lib/kibana_framework.ts b/x-pack/plugins/grokdebugger/server/lib/kibana_framework.ts new file mode 100644 index 0000000000000..d3bdd966be29d --- /dev/null +++ b/x-pack/plugins/grokdebugger/server/lib/kibana_framework.ts @@ -0,0 +1,77 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +/* eslint-disable @typescript-eslint/array-type */ + +import { + CoreSetup, + IRouter, + KibanaRequest, + RequestHandlerContext, + KibanaResponseFactory, + RouteMethod, + RouteConfig, + APICaller, + RequestHandler, +} from 'src/core/server'; + +type GrokDebuggerRouteConfig = { + method: RouteMethod; +} & RouteConfig; + +// TODO: type properly +type GrokDebuggerPluginDeps = any; + +export class KibanaFramework { + public router: IRouter; + public plugins: GrokDebuggerPluginDeps; + + constructor(core: CoreSetup, plugins: GrokDebuggerPluginDeps) { + this.router = core.http.createRouter(); + this.plugins = plugins; + } + + public registerRoute( + config: GrokDebuggerRouteConfig, + handler: RequestHandler + ) { + const routeConfig = { + path: config.path, + validate: config.validate, + }; + switch (config.method) { + case 'get': + this.router.get(routeConfig, handler); + break; + case 'post': + this.router.post(routeConfig, handler); + break; + case 'delete': + this.router.delete(routeConfig, handler); + break; + case 'put': + this.router.put(routeConfig, handler); + break; + } + } + + callWithRequest( + requestContext: RequestHandlerContext, + endpoint: 'ingest.simulate', + options?: { + body: any; + } + ): Promise; + + public async callWithRequest( + requestContext: RequestHandlerContext, + endpoint: string, + options?: any + ) { + const { elasticsearch } = requestContext.core; + return elasticsearch.dataClient.callAsCurrentUser(endpoint, options); + } +} diff --git a/x-pack/plugins/grokdebugger/server/plugin.js b/x-pack/plugins/grokdebugger/server/plugin.js new file mode 100644 index 0000000000000..33a0ad99cb0a6 --- /dev/null +++ b/x-pack/plugins/grokdebugger/server/plugin.js @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { schema } from '@kbn/config-schema'; +import { KibanaFramework } from './lib/kibana_framework'; +import { registerGrokdebuggerRoutes } from './routes/api/grokdebugger'; + +export const config = { + schema: schema.object({ + enabled: schema.boolean({ defaultValue: true }), + }), +}; + +export class Plugin { + constructor(initializerContext) { + this.config$ = initializerContext.config.create(); + } + + setup(coreSetup) { + console.log('STARTING: Grok Debugger'); + // TODO: Add license checking setup + const framework = new KibanaFramework(coreSetup); + registerGrokdebuggerRoutes(framework); + } + + start() {} + + stop() {} +} diff --git a/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js b/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js index 14ea1e7acb668..27c7e17808a6b 100644 --- a/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js +++ b/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js @@ -4,38 +4,41 @@ * you may not use this file except in compliance with the Elastic License. */ -import { wrapEsError } from '../../../lib/error_wrappers'; -import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; +import { schema } from '@kbn/config-schema'; import { GrokdebuggerRequest } from '../../../models/grokdebugger_request'; import { GrokdebuggerResponse } from '../../../models/grokdebugger_response'; -import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; -function simulateGrok(callWithRequest, ingestJson) { - return callWithRequest('ingest.simulate', { - body: ingestJson, - }); -} - -export function registerGrokSimulateRoute(server) { - const licensePreRouting = licensePreRoutingFactory(server); +const escapeHatch = schema.object({}, { allowUnknowns: true }); - server.route({ - path: '/api/grokdebugger/simulate', - method: 'POST', - handler: request => { - const callWithRequest = callWithRequestFactory(server, request); - const grokdebuggerRequest = GrokdebuggerRequest.fromDownstreamJSON(request.payload); - return simulateGrok(callWithRequest, grokdebuggerRequest.upstreamJSON) - .then(simulateResponseFromES => { - const grokdebuggerResponse = GrokdebuggerResponse.fromUpstreamJSON( - simulateResponseFromES - ); - return { grokdebuggerResponse }; - }) - .catch(e => wrapEsError(e)); - }, - config: { - pre: [licensePreRouting], +export function registerGrokSimulateRoute(framework) { + // TODO: Handle license check here + //const licensePreRouting = licensePreRoutingFactory(server); + framework.registerRoute( + { + method: 'POST', + path: '/api/grokdebugger/simulate', + validate: { + // TODO: Add real validation here + body: escapeHatch, + }, }, - }); + async (requestContext, request, response) => { + try { + const grokdebuggerRequest = GrokdebuggerRequest.fromDownstreamJSON(request.body); + const simulateResponseFromES = await framework.callWithRequest( + requestContext, + 'ingest.simulate', + { body: grokdebuggerRequest.upstreamJSON } + ); + const grokdebuggerResponse = GrokdebuggerResponse.fromUpstreamJSON(simulateResponseFromES); + return response.ok({ + body: grokdebuggerResponse, + }); + } catch (error) { + return response.internalError({ + body: error.message, + }); + } + } + ); } diff --git a/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grokdebugger_routes.js b/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grokdebugger_routes.js index 6d27ce2ca0545..d7ecd1c360d81 100644 --- a/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grokdebugger_routes.js +++ b/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grokdebugger_routes.js @@ -6,6 +6,6 @@ import { registerGrokSimulateRoute } from './register_grok_simulate_route'; -export function registerGrokdebuggerRoutes(server) { - registerGrokSimulateRoute(server); +export function registerGrokdebuggerRoutes(framework) { + registerGrokSimulateRoute(framework); } From 171bb7ea3bcd43a1f09a49208de0cc8939fc7b86 Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Wed, 18 Mar 2020 13:07:57 +0000 Subject: [PATCH 05/18] Scaffolding and preliminary rendering of UI --- x-pack/plugins/grokdebugger/kibana.json | 7 +++- .../components/grok_debugger/grok_debugger.js | 15 +++++-- x-pack/plugins/grokdebugger/public/index.js | 11 +++++ .../public/lib/ace/grok_highlight_rules.js | 2 +- .../grokdebugger/public/lib/ace/grok_mode.js | 2 +- x-pack/plugins/grokdebugger/public/plugin.js | 41 +++++++++++++++++++ .../plugins/grokdebugger/public/render_app.js | 11 +++-- .../grokdebugger/grokdebugger_service.js | 8 ++-- 8 files changed, 82 insertions(+), 15 deletions(-) create mode 100644 x-pack/plugins/grokdebugger/public/index.js create mode 100644 x-pack/plugins/grokdebugger/public/plugin.js diff --git a/x-pack/plugins/grokdebugger/kibana.json b/x-pack/plugins/grokdebugger/kibana.json index 9f62375b3a905..4d37f9ccdb0de 100644 --- a/x-pack/plugins/grokdebugger/kibana.json +++ b/x-pack/plugins/grokdebugger/kibana.json @@ -2,7 +2,12 @@ "id": "grokdebugger", "version": "8.0.0", "kibanaVersion": "kibana", + "requiredPlugins": [ + "licensing", + "home", + "devTools" + ], "server": true, - "ui": false, + "ui": true, "configPath": ["xpack", "grokdebugger"] } diff --git a/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js b/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js index dfdd524b3d3d4..93aba536bbf69 100644 --- a/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js +++ b/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js @@ -22,10 +22,10 @@ import { PatternInput } from '../pattern_input'; import { CustomPatternsInput } from '../custom_patterns_input'; import { EventOutput } from '../event_output'; import { GrokdebuggerRequest } from '../../models/grokdebugger_request'; -import { toastNotifications } from 'ui/notify'; +import { withKibana } from '../../../../../../src/plugins/kibana_react/public'; import { FormattedMessage } from '@kbn/i18n/react'; -export class GrokDebugger extends React.Component { +export class GrokDebuggerComponent extends React.Component { constructor(props) { super(props); this.state = { @@ -73,6 +73,7 @@ export class GrokDebugger extends React.Component { }; simulateGrok = async () => { + const notifications = this.props.kibana.services.notifications; try { const simulateResponse = await this.props.grokdebuggerService.simulate( this.grokdebuggerRequest @@ -82,10 +83,14 @@ export class GrokDebugger extends React.Component { }); if (!isEmpty(simulateResponse.error)) { - toastNotifications.addDanger(simulateResponse.error); + notifications.toasts.danger({ + body: simulateResponse.error, + }); } } catch (e) { - toastNotifications.addDanger(e); + notifications.toasts.danger({ + body: e, + }); } }; @@ -138,3 +143,5 @@ export class GrokDebugger extends React.Component { ); } } + +export const GrokDebugger = withKibana(GrokDebuggerComponent); diff --git a/x-pack/plugins/grokdebugger/public/index.js b/x-pack/plugins/grokdebugger/public/index.js new file mode 100644 index 0000000000000..960c9d8d58e4a --- /dev/null +++ b/x-pack/plugins/grokdebugger/public/index.js @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Plugin } from './plugin'; + +export function plugin(initializerContext) { + return new Plugin(initializerContext); +} diff --git a/x-pack/plugins/grokdebugger/public/lib/ace/grok_highlight_rules.js b/x-pack/plugins/grokdebugger/public/lib/ace/grok_highlight_rules.js index 3da1afdc0fc00..1851d53ff0ee8 100644 --- a/x-pack/plugins/grokdebugger/public/lib/ace/grok_highlight_rules.js +++ b/x-pack/plugins/grokdebugger/public/lib/ace/grok_highlight_rules.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import ace from 'ace'; +import ace from 'brace'; const { TextHighlightRules } = ace.acequire('ace/mode/text_highlight_rules'); diff --git a/x-pack/plugins/grokdebugger/public/lib/ace/grok_mode.js b/x-pack/plugins/grokdebugger/public/lib/ace/grok_mode.js index 84b2e482673c6..cd82a5b9917e6 100644 --- a/x-pack/plugins/grokdebugger/public/lib/ace/grok_mode.js +++ b/x-pack/plugins/grokdebugger/public/lib/ace/grok_mode.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import ace from 'ace'; +import ace from 'brace'; import { GrokHighlightRules } from './grok_highlight_rules'; const TextMode = ace.acequire('ace/mode/text').Mode; diff --git a/x-pack/plugins/grokdebugger/public/plugin.js b/x-pack/plugins/grokdebugger/public/plugin.js new file mode 100644 index 0000000000000..bf2c42bf4c665 --- /dev/null +++ b/x-pack/plugins/grokdebugger/public/plugin.js @@ -0,0 +1,41 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * 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'; + +export class Plugin { + setup(coreSetup, plugins) { + plugins.devTools.register({ + order: 6, + title: i18n.translate('xpack.grokDebugger.displayName', { + defaultMessage: 'Grok Debugger', + }), + id: 'grokdebugger', + enableRouting: false, + disabled: false, // TODO: Address this via licensing plugin //!xpackInfo.get('features.grokdebugger.enableLink', false), + tooltipContent: 'Tooltip', // TODO: Address via licensing plugin xpackInfo.get('features.grokdebugger.message'), + async mount(context, { element }) { + // TODO: Address all of this via licensing plugin + // const licenseCheck = { + // showPage: xpackInfo.get('features.grokdebugger.enableLink'), + // message: xpackInfo.get('features.grokdebugger.message'), + // }; + // if (!licenseCheck.showPage) { + // npStart.core.notifications.toasts.addDanger(licenseCheck.message); + // window.location.hash = '/dev_tools'; + // return () => {}; + // } + const [coreStart] = await coreSetup.getStartServices(); + const { renderApp } = await import('./render_app'); + return renderApp(element, coreStart); + }, + }); + } + + start() {} + + stop() {} +} diff --git a/x-pack/plugins/grokdebugger/public/render_app.js b/x-pack/plugins/grokdebugger/public/render_app.js index 2c4894bb70ee1..40d1ffa7939aa 100644 --- a/x-pack/plugins/grokdebugger/public/render_app.js +++ b/x-pack/plugins/grokdebugger/public/render_app.js @@ -10,12 +10,15 @@ import { render, unmountComponentAtNode } from 'react-dom'; import { GrokDebugger } from './components/grok_debugger'; import { GrokdebuggerService } from './services/grokdebugger/grokdebugger_service'; import { I18nProvider } from '@kbn/i18n/react'; +import { KibanaContextProvider } from '../../../../src/plugins/kibana_react/public'; -export function renderApp(element, npStart) { +export function renderApp(element, coreStart) { render( - - - , + + + + + , element ); return () => unmountComponentAtNode(element); diff --git a/x-pack/plugins/grokdebugger/public/services/grokdebugger/grokdebugger_service.js b/x-pack/plugins/grokdebugger/public/services/grokdebugger/grokdebugger_service.js index 7a656b33d59ff..50348643cb23b 100644 --- a/x-pack/plugins/grokdebugger/public/services/grokdebugger/grokdebugger_service.js +++ b/x-pack/plugins/grokdebugger/public/services/grokdebugger/grokdebugger_service.js @@ -4,19 +4,19 @@ * you may not use this file except in compliance with the Elastic License. */ -import chrome from 'ui/chrome'; import { ROUTES } from '../../../common/constants'; -import { GrokdebuggerResponse } from 'plugins/grokdebugger/models/grokdebugger_response'; +import { GrokdebuggerResponse } from '../../models/grokdebugger_response'; export class GrokdebuggerService { constructor(http) { this.http = http; - this.basePath = chrome.addBasePath(ROUTES.API_ROOT); } simulate(grokdebuggerRequest) { return this.http - .post(`${this.basePath}/simulate`, { body: JSON.stringify(grokdebuggerRequest.upstreamJSON) }) + .post(`${ROUTES.API_ROOT}/simulate`, { + body: JSON.stringify(grokdebuggerRequest.upstreamJSON), + }) .then(response => { return GrokdebuggerResponse.fromUpstreamJSON(response.grokdebuggerResponse); }) From acc9826b73d18b65d775104ad769e862f28a36fc Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Thu, 19 Mar 2020 16:55:01 +0000 Subject: [PATCH 06/18] Get end to end simulation working --- .../components/grok_debugger/grok_debugger.js | 4 +- x-pack/plugins/grokdebugger/public/plugin.js | 3 ++ .../plugins/grokdebugger/public/register.js | 33 ------------- .../grokdebugger/public/register_feature.ts | 47 +++++++++---------- .../grokdebugger/grokdebugger_service.js | 2 +- .../register_grok_simulate_route.js | 4 +- 6 files changed, 31 insertions(+), 62 deletions(-) delete mode 100644 x-pack/plugins/grokdebugger/public/register.js diff --git a/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js b/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js index 93aba536bbf69..c7e049af2eabd 100644 --- a/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js +++ b/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js @@ -73,7 +73,7 @@ export class GrokDebuggerComponent extends React.Component { }; simulateGrok = async () => { - const notifications = this.props.kibana.services.notifications; + const notifications = this.props.kibana.notifications; try { const simulateResponse = await this.props.grokdebuggerService.simulate( this.grokdebuggerRequest @@ -85,11 +85,13 @@ export class GrokDebuggerComponent extends React.Component { if (!isEmpty(simulateResponse.error)) { notifications.toasts.danger({ body: simulateResponse.error, + toastLifeTimeMs: 4 * 1000, }); } } catch (e) { notifications.toasts.danger({ body: e, + toastLifeTimeMs: 4 * 1000, }); } }; diff --git a/x-pack/plugins/grokdebugger/public/plugin.js b/x-pack/plugins/grokdebugger/public/plugin.js index bf2c42bf4c665..dfe6d8df2421f 100644 --- a/x-pack/plugins/grokdebugger/public/plugin.js +++ b/x-pack/plugins/grokdebugger/public/plugin.js @@ -5,9 +5,12 @@ */ import { i18n } from '@kbn/i18n'; +import { registerFeature } from './register_feature'; export class Plugin { setup(coreSetup, plugins) { + registerFeature(plugins.home); + plugins.devTools.register({ order: 6, title: i18n.translate('xpack.grokDebugger.displayName', { diff --git a/x-pack/plugins/grokdebugger/public/register.js b/x-pack/plugins/grokdebugger/public/register.js deleted file mode 100644 index 74679d65e52d2..0000000000000 --- a/x-pack/plugins/grokdebugger/public/register.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * 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 { xpackInfo } from 'plugins/xpack_main/services/xpack_info'; -import { npSetup, npStart } from 'ui/new_platform'; - -npSetup.plugins.devTools.register({ - order: 6, - title: i18n.translate('xpack.grokDebugger.displayName', { - defaultMessage: 'Grok Debugger', - }), - id: 'grokdebugger', - enableRouting: false, - disabled: !xpackInfo.get('features.grokdebugger.enableLink', false), - tooltipContent: xpackInfo.get('features.grokdebugger.message'), - async mount(context, { element }) { - const licenseCheck = { - showPage: xpackInfo.get('features.grokdebugger.enableLink'), - message: xpackInfo.get('features.grokdebugger.message'), - }; - if (!licenseCheck.showPage) { - npStart.core.notifications.toasts.addDanger(licenseCheck.message); - window.location.hash = '/dev_tools'; - return () => {}; - } - const { renderApp } = await import('./render_app'); - return renderApp(element, npStart); - }, -}); diff --git a/x-pack/plugins/grokdebugger/public/register_feature.ts b/x-pack/plugins/grokdebugger/public/register_feature.ts index e04634a3b751a..e709dd66d7450 100644 --- a/x-pack/plugins/grokdebugger/public/register_feature.ts +++ b/x-pack/plugins/grokdebugger/public/register_feature.ts @@ -5,30 +5,27 @@ */ import { i18n } from '@kbn/i18n'; -import { npSetup } from 'ui/new_platform'; import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public'; -const { - plugins: { home }, -} = npSetup; - -home.featureCatalogue.register({ - id: 'grokdebugger', - title: i18n.translate('xpack.grokDebugger.registryProviderTitle', { - defaultMessage: '{grokLogParsingTool} Debugger', - values: { - grokLogParsingTool: 'Grok', - }, - }), - description: i18n.translate('xpack.grokDebugger.registryProviderDescription', { - defaultMessage: - 'Simulate and debug {grokLogParsingTool} patterns for data transformation on ingestion.', - values: { - grokLogParsingTool: 'grok', - }, - }), - icon: 'grokApp', - path: '/app/kibana#/dev_tools/grokdebugger', - showOnHomePage: false, - category: FeatureCatalogueCategory.ADMIN, -}); +export const registerFeature = homePlugin => { + homePlugin.featureCatalogue.register({ + id: 'grokdebugger', + title: i18n.translate('xpack.grokDebugger.registryProviderTitle', { + defaultMessage: '{grokLogParsingTool} Debugger', + values: { + grokLogParsingTool: 'Grok', + }, + }), + description: i18n.translate('xpack.grokDebugger.registryProviderDescription', { + defaultMessage: + 'Simulate and debug {grokLogParsingTool} patterns for data transformation on ingestion.', + values: { + grokLogParsingTool: 'grok', + }, + }), + icon: 'grokApp', + path: '/app/kibana#/dev_tools/grokdebugger', + showOnHomePage: false, + category: FeatureCatalogueCategory.ADMIN, + }); +}; diff --git a/x-pack/plugins/grokdebugger/public/services/grokdebugger/grokdebugger_service.js b/x-pack/plugins/grokdebugger/public/services/grokdebugger/grokdebugger_service.js index 50348643cb23b..e26c9c5091e14 100644 --- a/x-pack/plugins/grokdebugger/public/services/grokdebugger/grokdebugger_service.js +++ b/x-pack/plugins/grokdebugger/public/services/grokdebugger/grokdebugger_service.js @@ -18,7 +18,7 @@ export class GrokdebuggerService { body: JSON.stringify(grokdebuggerRequest.upstreamJSON), }) .then(response => { - return GrokdebuggerResponse.fromUpstreamJSON(response.grokdebuggerResponse); + return GrokdebuggerResponse.fromUpstreamJSON(response); }) .catch(e => { throw e.body.message; diff --git a/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js b/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js index 27c7e17808a6b..fef8636fb0bed 100644 --- a/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js +++ b/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js @@ -8,14 +8,14 @@ import { schema } from '@kbn/config-schema'; import { GrokdebuggerRequest } from '../../../models/grokdebugger_request'; import { GrokdebuggerResponse } from '../../../models/grokdebugger_response'; -const escapeHatch = schema.object({}, { allowUnknowns: true }); +const escapeHatch = schema.object({}, { unknowns: 'allow' }); export function registerGrokSimulateRoute(framework) { // TODO: Handle license check here //const licensePreRouting = licensePreRoutingFactory(server); framework.registerRoute( { - method: 'POST', + method: 'post', path: '/api/grokdebugger/simulate', validate: { // TODO: Add real validation here From b4c0cb33707a754e5d03b9240fdf83a271363eb0 Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Fri, 20 Mar 2020 11:52:58 +0000 Subject: [PATCH 07/18] Add server side license checking --- .../check_license/__tests__/check_license.js | 90 ------------------- .../server/lib/check_license/check_license.js | 50 ----------- .../server/lib/check_license/index.js | 7 -- .../server/lib/kibana_framework.ts | 56 +++++++++--- .../__tests__/license_pre_routing_factory.js | 64 ------------- .../lib/license_pre_routing_factory/index.js | 7 -- .../license_pre_routing_factory.js | 24 ----- .../lib/register_license_checker/index.js | 7 -- .../register_license_checker.js | 21 ----- x-pack/plugins/grokdebugger/server/plugin.js | 14 ++- .../register_grok_simulate_route.js | 2 - 11 files changed, 48 insertions(+), 294 deletions(-) delete mode 100644 x-pack/plugins/grokdebugger/server/lib/check_license/__tests__/check_license.js delete mode 100644 x-pack/plugins/grokdebugger/server/lib/check_license/check_license.js delete mode 100644 x-pack/plugins/grokdebugger/server/lib/check_license/index.js delete mode 100644 x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js delete mode 100644 x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/index.js delete mode 100644 x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/license_pre_routing_factory.js delete mode 100644 x-pack/plugins/grokdebugger/server/lib/register_license_checker/index.js delete mode 100644 x-pack/plugins/grokdebugger/server/lib/register_license_checker/register_license_checker.js diff --git a/x-pack/plugins/grokdebugger/server/lib/check_license/__tests__/check_license.js b/x-pack/plugins/grokdebugger/server/lib/check_license/__tests__/check_license.js deleted file mode 100644 index 7e32d68a67ece..0000000000000 --- a/x-pack/plugins/grokdebugger/server/lib/check_license/__tests__/check_license.js +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import expect from '@kbn/expect'; -import { set } from 'lodash'; -import { checkLicense } from '../check_license'; - -describe('check_license', function() { - let mockLicenseInfo; - beforeEach(() => (mockLicenseInfo = {})); - - describe('license information is undefined', () => { - beforeEach(() => (mockLicenseInfo = undefined)); - - it('should set enableLink to false', () => { - expect(checkLicense(mockLicenseInfo).enableLink).to.be(false); - }); - - it('should set enableAPIRoute to false', () => { - expect(checkLicense(mockLicenseInfo).enableAPIRoute).to.be(false); - }); - - it('should set a message', () => { - expect(checkLicense(mockLicenseInfo).message).to.not.be(undefined); - }); - }); - - describe('license information is not available', () => { - beforeEach(() => (mockLicenseInfo.isAvailable = () => false)); - - it('should set enableLink to false', () => { - expect(checkLicense(mockLicenseInfo).enableLink).to.be(false); - }); - - it('should set enableAPIRoute to false', () => { - expect(checkLicense(mockLicenseInfo).enableAPIRoute).to.be(false); - }); - - it('should set a message', () => { - expect(checkLicense(mockLicenseInfo).message).to.not.be(undefined); - }); - }); - - describe('license information is available', () => { - beforeEach( - () => - (mockLicenseInfo = { - isAvailable: () => true, - license: { - getType: () => 'foobar', - }, - }) - ); - - describe('& license is active', () => { - beforeEach(() => set(mockLicenseInfo, 'license.isActive', () => true)); - - it('should set enableLink to true', () => { - expect(checkLicense(mockLicenseInfo).enableLink).to.be(true); - }); - - it('should set enableAPIRoute to true', () => { - expect(checkLicense(mockLicenseInfo).enableAPIRoute).to.be(true); - }); - - it('should NOT set a message', () => { - expect(checkLicense(mockLicenseInfo).message).to.be(undefined); - }); - }); - - describe('& license is expired', () => { - beforeEach(() => set(mockLicenseInfo, 'license.isActive', () => false)); - - it('should set enableLink to false', () => { - expect(checkLicense(mockLicenseInfo).enableLink).to.be(false); - }); - - it('should set enableAPIRoute to false', () => { - expect(checkLicense(mockLicenseInfo).enableAPIRoute).to.be(false); - }); - - it('should set a message', () => { - expect(checkLicense(mockLicenseInfo).message).to.not.be(undefined); - }); - }); - }); -}); diff --git a/x-pack/plugins/grokdebugger/server/lib/check_license/check_license.js b/x-pack/plugins/grokdebugger/server/lib/check_license/check_license.js deleted file mode 100644 index c7a8d2bbca059..0000000000000 --- a/x-pack/plugins/grokdebugger/server/lib/check_license/check_license.js +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * 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'; - -export function checkLicense(xpackLicenseInfo) { - // If, for some reason, we cannot get the license information - // from Elasticsearch, assume worst case and disable the Watcher UI - if (!xpackLicenseInfo || !xpackLicenseInfo.isAvailable()) { - return { - enableLink: false, - enableAPIRoute: false, - message: i18n.translate('xpack.grokDebugger.unavailableLicenseInformationMessage', { - defaultMessage: - 'You cannot use the {grokLogParsingTool} Debugger because license information is not available at this time.', - values: { - grokLogParsingTool: 'Grok', - }, - }), - }; - } - - const isLicenseActive = xpackLicenseInfo.license.isActive(); - const licenseType = xpackLicenseInfo.license.getType(); - - // License is not valid - if (!isLicenseActive) { - return { - enableLink: false, - enableAPIRoute: false, - message: i18n.translate('xpack.grokDebugger.licenseHasExpiredMessage', { - defaultMessage: - 'You cannot use the {grokLogParsingTool} Debugger because your {licenseType} license has expired.', - values: { - licenseType, - grokLogParsingTool: 'Grok', - }, - }), - }; - } - - // License is valid and active - return { - enableLink: true, - enableAPIRoute: true, - }; -} diff --git a/x-pack/plugins/grokdebugger/server/lib/check_license/index.js b/x-pack/plugins/grokdebugger/server/lib/check_license/index.js deleted file mode 100644 index f2c070fd44b6e..0000000000000 --- a/x-pack/plugins/grokdebugger/server/lib/check_license/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { checkLicense } from './check_license'; diff --git a/x-pack/plugins/grokdebugger/server/lib/kibana_framework.ts b/x-pack/plugins/grokdebugger/server/lib/kibana_framework.ts index d3bdd966be29d..605eacd875fa7 100644 --- a/x-pack/plugins/grokdebugger/server/lib/kibana_framework.ts +++ b/x-pack/plugins/grokdebugger/server/lib/kibana_framework.ts @@ -6,54 +6,82 @@ /* eslint-disable @typescript-eslint/array-type */ +import { i18n } from '@kbn/i18n'; + import { CoreSetup, IRouter, - KibanaRequest, RequestHandlerContext, - KibanaResponseFactory, RouteMethod, RouteConfig, - APICaller, RequestHandler, } from 'src/core/server'; +import { ILicense } from '../../../licensing/server'; + type GrokDebuggerRouteConfig = { method: RouteMethod; } & RouteConfig; -// TODO: type properly -type GrokDebuggerPluginDeps = any; - export class KibanaFramework { public router: IRouter; - public plugins: GrokDebuggerPluginDeps; + public license?: ILicense; - constructor(core: CoreSetup, plugins: GrokDebuggerPluginDeps) { + constructor(core: CoreSetup) { this.router = core.http.createRouter(); - this.plugins = plugins; + } + + public setLicense(license: ILicense) { + this.license = license; + } + + private hasActiveLicense() { + if (!this.license) { + throw new Error( + "Please set license information in the plugin's setup method before trying to check the status" + ); + } + return this.license.isActive; } public registerRoute( config: GrokDebuggerRouteConfig, handler: RequestHandler ) { + // Automatically wrap all route registrations with license checking + const wrappedHandler: RequestHandler = async ( + requestContext, + request, + response + ) => { + if (this.hasActiveLicense()) { + return await handler(requestContext, request, response); + } else { + return response.forbidden({ + body: i18n.translate('xpack.grokDebugger.inactiveLicenseError', { + defaultMessage: 'You cannot use the Grok Debugger without an active license.', + }), + }); + } + }; + const routeConfig = { path: config.path, validate: config.validate, }; + switch (config.method) { case 'get': - this.router.get(routeConfig, handler); + this.router.get(routeConfig, wrappedHandler); break; case 'post': - this.router.post(routeConfig, handler); + this.router.post(routeConfig, wrappedHandler); break; case 'delete': - this.router.delete(routeConfig, handler); + this.router.delete(routeConfig, wrappedHandler); break; case 'put': - this.router.put(routeConfig, handler); + this.router.put(routeConfig, wrappedHandler); break; } } @@ -66,7 +94,7 @@ export class KibanaFramework { } ): Promise; - public async callWithRequest( + public async callWithRequest( requestContext: RequestHandlerContext, endpoint: string, options?: any diff --git a/x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js b/x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js deleted file mode 100644 index 135317f050774..0000000000000 --- a/x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import expect from '@kbn/expect'; -import Boom from 'boom'; -import { licensePreRoutingFactory } from '../license_pre_routing_factory'; - -describe('license_pre_routing_factory', () => { - describe('#grokDebuggerFeaturePreRoutingFactory', () => { - let mockServer; - let mockLicenseCheckResults; - - beforeEach(() => { - mockServer = { - plugins: { - xpack_main: { - info: { - feature: () => ({ - getLicenseCheckResults: () => mockLicenseCheckResults, - }), - }, - }, - }, - }; - }); - - describe('isAvailable is false', () => { - beforeEach(() => { - mockLicenseCheckResults = { - isAvailable: false, - }; - }); - - it('replies with 403', async () => { - const licensePreRouting = licensePreRoutingFactory(mockServer); - const stubRequest = {}; - expect(() => licensePreRouting(stubRequest)).to.throwException(response => { - expect(response).to.be.an(Error); - expect(response.isBoom).to.be(true); - expect(response.output.statusCode).to.be(403); - }); - }); - }); - - describe('isAvailable is true', () => { - beforeEach(() => { - mockLicenseCheckResults = { - isAvailable: true, - }; - }); - - it('replies with forbidden', async () => { - const licensePreRouting = licensePreRoutingFactory(mockServer); - const stubRequest = {}; - expect(() => licensePreRouting(stubRequest)).to.throwException(response => { - expect(response).to.eql(Boom.forbidden()); - }); - }); - }); - }); -}); diff --git a/x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/index.js b/x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/index.js deleted file mode 100644 index 0743e443955f4..0000000000000 --- a/x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { licensePreRoutingFactory } from './license_pre_routing_factory'; diff --git a/x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/license_pre_routing_factory.js b/x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/license_pre_routing_factory.js deleted file mode 100644 index 88c844de3e2ca..0000000000000 --- a/x-pack/plugins/grokdebugger/server/lib/license_pre_routing_factory/license_pre_routing_factory.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import Boom from 'boom'; -import { PLUGIN } from '../../../common/constants'; - -export const licensePreRoutingFactory = server => { - const xpackMainPlugin = server.plugins.xpack_main; - - // License checking and enable/disable logic - function licensePreRouting() { - const licenseCheckResults = xpackMainPlugin.info.feature(PLUGIN.ID).getLicenseCheckResults(); - if (!licenseCheckResults.enableAPIRoute) { - throw Boom.forbidden(licenseCheckResults.message); - } - - return null; - } - - return licensePreRouting; -}; diff --git a/x-pack/plugins/grokdebugger/server/lib/register_license_checker/index.js b/x-pack/plugins/grokdebugger/server/lib/register_license_checker/index.js deleted file mode 100644 index 7b0f97c38d129..0000000000000 --- a/x-pack/plugins/grokdebugger/server/lib/register_license_checker/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { registerLicenseChecker } from './register_license_checker'; diff --git a/x-pack/plugins/grokdebugger/server/lib/register_license_checker/register_license_checker.js b/x-pack/plugins/grokdebugger/server/lib/register_license_checker/register_license_checker.js deleted file mode 100644 index 489130f819ab3..0000000000000 --- a/x-pack/plugins/grokdebugger/server/lib/register_license_checker/register_license_checker.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { mirrorPluginStatus } from '../../../../../legacy/server/lib/mirror_plugin_status'; -import { checkLicense } from '../check_license'; -import { PLUGIN } from '../../../common/constants'; - -export function registerLicenseChecker(server) { - const xpackMainPlugin = server.plugins.xpack_main; - const grokdebuggerPlugin = server.plugins[PLUGIN.ID]; - - mirrorPluginStatus(xpackMainPlugin, grokdebuggerPlugin); - xpackMainPlugin.status.once('green', () => { - // Register a function that is called whenever the xpack info changes, - // to re-compute the license check results for this plugin - xpackMainPlugin.info.feature(PLUGIN.ID).registerLicenseCheckResultsGenerator(checkLicense); - }); -} diff --git a/x-pack/plugins/grokdebugger/server/plugin.js b/x-pack/plugins/grokdebugger/server/plugin.js index 33a0ad99cb0a6..06ddd92aefac9 100644 --- a/x-pack/plugins/grokdebugger/server/plugin.js +++ b/x-pack/plugins/grokdebugger/server/plugin.js @@ -15,18 +15,16 @@ export const config = { }; export class Plugin { - constructor(initializerContext) { - this.config$ = initializerContext.config.create(); - } - - setup(coreSetup) { - console.log('STARTING: Grok Debugger'); - // TODO: Add license checking setup + setup(coreSetup, plugins) { const framework = new KibanaFramework(coreSetup); + + plugins.licensing.license$.subscribe(license => { + framework.setLicense(license); + }); + registerGrokdebuggerRoutes(framework); } start() {} - stop() {} } diff --git a/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js b/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js index fef8636fb0bed..27abd81e7a165 100644 --- a/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js +++ b/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js @@ -11,8 +11,6 @@ import { GrokdebuggerResponse } from '../../../models/grokdebugger_response'; const escapeHatch = schema.object({}, { unknowns: 'allow' }); export function registerGrokSimulateRoute(framework) { - // TODO: Handle license check here - //const licensePreRouting = licensePreRoutingFactory(server); framework.registerRoute( { method: 'post', From 6f6c2adfbd468ab2d1541524ee84c068fd1275e5 Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Fri, 20 Mar 2020 12:49:11 +0000 Subject: [PATCH 08/18] Add client side license checking --- x-pack/plugins/grokdebugger/public/plugin.js | 55 ++++++++++--------- .../server/lib/kibana_framework.ts | 4 +- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/x-pack/plugins/grokdebugger/public/plugin.js b/x-pack/plugins/grokdebugger/public/plugin.js index dfe6d8df2421f..71a99203b9099 100644 --- a/x-pack/plugins/grokdebugger/public/plugin.js +++ b/x-pack/plugins/grokdebugger/public/plugin.js @@ -5,40 +5,45 @@ */ import { i18n } from '@kbn/i18n'; +import { first } from 'rxjs/operators'; import { registerFeature } from './register_feature'; +const inactiveLicenseMessage = i18n.translate('xpack.grokDebugger.clientInactiveLicenseError', { + defaultMessage: 'The Grok Debugger tool requires an active license.', +}); + export class Plugin { setup(coreSetup, plugins) { registerFeature(plugins.home); - plugins.devTools.register({ - order: 6, - title: i18n.translate('xpack.grokDebugger.displayName', { - defaultMessage: 'Grok Debugger', - }), - id: 'grokdebugger', - enableRouting: false, - disabled: false, // TODO: Address this via licensing plugin //!xpackInfo.get('features.grokdebugger.enableLink', false), - tooltipContent: 'Tooltip', // TODO: Address via licensing plugin xpackInfo.get('features.grokdebugger.message'), - async mount(context, { element }) { - // TODO: Address all of this via licensing plugin - // const licenseCheck = { - // showPage: xpackInfo.get('features.grokdebugger.enableLink'), - // message: xpackInfo.get('features.grokdebugger.message'), - // }; - // if (!licenseCheck.showPage) { - // npStart.core.notifications.toasts.addDanger(licenseCheck.message); - // window.location.hash = '/dev_tools'; - // return () => {}; - // } - const [coreStart] = await coreSetup.getStartServices(); - const { renderApp } = await import('./render_app'); - return renderApp(element, coreStart); - }, + this.licensing = plugins.licensing; + + this.licensing.license$.pipe(first()).subscribe(license => { + plugins.devTools.register({ + order: 6, + title: i18n.translate('xpack.grokDebugger.displayName', { + defaultMessage: 'Grok Debugger', + }), + id: 'grokdebugger', + enableRouting: false, + disabled: !license.isActive, + tooltipContent: !license.isActive ? inactiveLicenseMessage : null, + async mount(context, { element }) { + const [coreStart] = await coreSetup.getStartServices(); + const { renderApp } = await import('./render_app'); + return renderApp(element, coreStart); + }, + }); }); } - start() {} + start(coreStart) { + this.licensing.license$.subscribe(license => { + coreStart.chrome.navLinks.update('grokdebugger', { + hidden: !license.isActive, + }); + }); + } stop() {} } diff --git a/x-pack/plugins/grokdebugger/server/lib/kibana_framework.ts b/x-pack/plugins/grokdebugger/server/lib/kibana_framework.ts index 605eacd875fa7..749f5e9ebf8f0 100644 --- a/x-pack/plugins/grokdebugger/server/lib/kibana_framework.ts +++ b/x-pack/plugins/grokdebugger/server/lib/kibana_framework.ts @@ -58,8 +58,8 @@ export class KibanaFramework { return await handler(requestContext, request, response); } else { return response.forbidden({ - body: i18n.translate('xpack.grokDebugger.inactiveLicenseError', { - defaultMessage: 'You cannot use the Grok Debugger without an active license.', + body: i18n.translate('xpack.grokDebugger.serverInactiveLicenseError', { + defaultMessage: 'The Grok Debugger tool requires an active license.', }), }); } From ded359ce60e00ded05e0471faa4e75565b7263b3 Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Tue, 24 Mar 2020 11:55:26 +0000 Subject: [PATCH 09/18] Fix typechecking / use constants --- x-pack/plugins/grokdebugger/public/plugin.js | 5 +++-- .../grokdebugger/public/register_feature.ts | 7 +++++-- .../server/lib/error_wrappers/index.js | 7 ------- .../server/lib/error_wrappers/wrap_es_error.js | 18 ------------------ 4 files changed, 8 insertions(+), 29 deletions(-) delete mode 100644 x-pack/plugins/grokdebugger/server/lib/error_wrappers/index.js delete mode 100644 x-pack/plugins/grokdebugger/server/lib/error_wrappers/wrap_es_error.js diff --git a/x-pack/plugins/grokdebugger/public/plugin.js b/x-pack/plugins/grokdebugger/public/plugin.js index 71a99203b9099..3a9c11f47ca88 100644 --- a/x-pack/plugins/grokdebugger/public/plugin.js +++ b/x-pack/plugins/grokdebugger/public/plugin.js @@ -7,6 +7,7 @@ import { i18n } from '@kbn/i18n'; import { first } from 'rxjs/operators'; import { registerFeature } from './register_feature'; +import { PLUGIN } from '../common/constants'; const inactiveLicenseMessage = i18n.translate('xpack.grokDebugger.clientInactiveLicenseError', { defaultMessage: 'The Grok Debugger tool requires an active license.', @@ -24,7 +25,7 @@ export class Plugin { title: i18n.translate('xpack.grokDebugger.displayName', { defaultMessage: 'Grok Debugger', }), - id: 'grokdebugger', + id: PLUGIN, enableRouting: false, disabled: !license.isActive, tooltipContent: !license.isActive ? inactiveLicenseMessage : null, @@ -39,7 +40,7 @@ export class Plugin { start(coreStart) { this.licensing.license$.subscribe(license => { - coreStart.chrome.navLinks.update('grokdebugger', { + coreStart.chrome.navLinks.update(PLUGIN, { hidden: !license.isActive, }); }); diff --git a/x-pack/plugins/grokdebugger/public/register_feature.ts b/x-pack/plugins/grokdebugger/public/register_feature.ts index e709dd66d7450..e86d2ffebce19 100644 --- a/x-pack/plugins/grokdebugger/public/register_feature.ts +++ b/x-pack/plugins/grokdebugger/public/register_feature.ts @@ -5,9 +5,12 @@ */ import { i18n } from '@kbn/i18n'; -import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public'; +import { + FeatureCatalogueCategory, + HomePublicPluginSetup, +} from '../../../../src/plugins/home/public'; -export const registerFeature = homePlugin => { +export const registerFeature = (homePlugin: HomePublicPluginSetup) => { homePlugin.featureCatalogue.register({ id: 'grokdebugger', title: i18n.translate('xpack.grokDebugger.registryProviderTitle', { diff --git a/x-pack/plugins/grokdebugger/server/lib/error_wrappers/index.js b/x-pack/plugins/grokdebugger/server/lib/error_wrappers/index.js deleted file mode 100644 index 3756b0c74fb10..0000000000000 --- a/x-pack/plugins/grokdebugger/server/lib/error_wrappers/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { wrapEsError } from './wrap_es_error'; diff --git a/x-pack/plugins/grokdebugger/server/lib/error_wrappers/wrap_es_error.js b/x-pack/plugins/grokdebugger/server/lib/error_wrappers/wrap_es_error.js deleted file mode 100644 index dfcd4e3b1e17c..0000000000000 --- a/x-pack/plugins/grokdebugger/server/lib/error_wrappers/wrap_es_error.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import Boom from 'boom'; - -/** - * Wraps ES errors into a Boom error response and returns it - * This also handles the permissions issue gracefully - * - * @param err Object ES error - * @return Object Boom error response - */ -export function wrapEsError(err) { - return Boom.boomify(err, { statusCode: err.statusCode }); -} From 8b7fe9bc002d04f48407669ebcd24fb5fa3a530d Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Wed, 25 Mar 2020 11:22:49 +0000 Subject: [PATCH 10/18] Amend object access --- x-pack/plugins/grokdebugger/public/plugin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/grokdebugger/public/plugin.js b/x-pack/plugins/grokdebugger/public/plugin.js index 3a9c11f47ca88..c76d25b039701 100644 --- a/x-pack/plugins/grokdebugger/public/plugin.js +++ b/x-pack/plugins/grokdebugger/public/plugin.js @@ -25,7 +25,7 @@ export class Plugin { title: i18n.translate('xpack.grokDebugger.displayName', { defaultMessage: 'Grok Debugger', }), - id: PLUGIN, + id: PLUGIN.ID, enableRouting: false, disabled: !license.isActive, tooltipContent: !license.isActive ? inactiveLicenseMessage : null, @@ -40,7 +40,7 @@ export class Plugin { start(coreStart) { this.licensing.license$.subscribe(license => { - coreStart.chrome.navLinks.update(PLUGIN, { + coreStart.chrome.navLinks.update(PLUGIN.ID, { hidden: !license.isActive, }); }); From afbc2a89c9a3e0256766001fe6e6acae342388d6 Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Wed, 25 Mar 2020 11:24:52 +0000 Subject: [PATCH 11/18] Update config to point to new app location --- x-pack/.i18nrc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index 2a28e349ace99..ae8d61769b14c 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -16,7 +16,7 @@ "xpack.features": "plugins/features", "xpack.fileUpload": "plugins/file_upload", "xpack.graph": ["legacy/plugins/graph", "plugins/graph"], - "xpack.grokDebugger": "legacy/plugins/grokdebugger", + "xpack.grokDebugger": "plugins/grokdebugger", "xpack.idxMgmt": "plugins/index_management", "xpack.indexLifecycleMgmt": "legacy/plugins/index_lifecycle_management", "xpack.infra": "plugins/infra", From 22fde77c6f5a7d52e9d7cddd4ee4858d13fcf5d2 Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Wed, 25 Mar 2020 18:07:37 +0000 Subject: [PATCH 12/18] Remove unused translations --- x-pack/plugins/translations/translations/ja-JP.json | 2 -- x-pack/plugins/translations/translations/zh-CN.json | 2 -- 2 files changed, 4 deletions(-) diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 15d9bec1189c6..3e71aceae907e 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -5783,14 +5783,12 @@ "xpack.grokDebugger.customPatternsButtonLabel": "カスタムパターン", "xpack.grokDebugger.displayName": "Grok デバッガー", "xpack.grokDebugger.grokPatternLabel": "Grok パターン", - "xpack.grokDebugger.licenseHasExpiredMessage": "{licenseType} ライセンスが期限切れのため {grokLogParsingTool} デバッガーを使用できません", "xpack.grokDebugger.patternsErrorMessage": "提供された {grokLogParsingTool} パターンがインプットのデータと一致していません", "xpack.grokDebugger.registryProviderDescription": "{grokLogParsingTool} パターンを、投入時にデータ変換用にシミュレートしデバッグします。", "xpack.grokDebugger.registryProviderTitle": "{grokLogParsingTool} デバッガー", "xpack.grokDebugger.sampleDataLabel": "サンプルデータ", "xpack.grokDebugger.simulateButtonLabel": "シミュレート", "xpack.grokDebugger.structuredDataLabel": "構造化データ", - "xpack.grokDebugger.unavailableLicenseInformationMessage": "現在ライセンス情報が利用できないため {grokLogParsingTool} デバッガーを使用できません。", "xpack.idxMgmt.appTitle": "インデックス管理", "xpack.idxMgmt.badgeAriaLabel": "{label}。これをフィルタリングするよう選択。", "xpack.idxMgmt.breadcrumb.cloneTemplateLabel": "テンプレートのクローンを作成", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 5037c883037b9..ebc3f6449fab8 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -5783,14 +5783,12 @@ "xpack.grokDebugger.customPatternsButtonLabel": "自定义模式", "xpack.grokDebugger.displayName": "Grok Debugger", "xpack.grokDebugger.grokPatternLabel": "Grok 模式", - "xpack.grokDebugger.licenseHasExpiredMessage": "您不能使用 {grokLogParsingTool} Debugger,因为您的 {licenseType} 许可证已过期。", "xpack.grokDebugger.patternsErrorMessage": "提供的 {grokLogParsingTool} 模式不匹配输入中的数据", "xpack.grokDebugger.registryProviderDescription": "采集时模拟和调试用于数据转换的 {grokLogParsingTool} 模式。", "xpack.grokDebugger.registryProviderTitle": "{grokLogParsingTool} Debugger", "xpack.grokDebugger.sampleDataLabel": "样例数据", "xpack.grokDebugger.simulateButtonLabel": "模拟", "xpack.grokDebugger.structuredDataLabel": "结构化数据", - "xpack.grokDebugger.unavailableLicenseInformationMessage": "您不能使用 {grokLogParsingTool} Debugger,因为许可证信息当前不可用。", "xpack.idxMgmt.appTitle": "索引管理", "xpack.idxMgmt.badgeAriaLabel": "{label}。选择以基于此选项进行筛选。", "xpack.idxMgmt.breadcrumb.cloneTemplateLabel": "克隆模板", From 19a1dbeab6be308fa372b4c22462787aff8db607 Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Thu, 26 Mar 2020 15:02:47 +0000 Subject: [PATCH 13/18] Add real validation for route --- .../api/grokdebugger/register_grok_simulate_route.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js b/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js index 27abd81e7a165..f953bc64c3b4f 100644 --- a/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js +++ b/x-pack/plugins/grokdebugger/server/routes/api/grokdebugger/register_grok_simulate_route.js @@ -8,7 +8,12 @@ import { schema } from '@kbn/config-schema'; import { GrokdebuggerRequest } from '../../../models/grokdebugger_request'; import { GrokdebuggerResponse } from '../../../models/grokdebugger_response'; -const escapeHatch = schema.object({}, { unknowns: 'allow' }); +const requestBodySchema = schema.object({ + pattern: schema.string(), + rawEvent: schema.string(), + // We don't know these key / values up front as they depend on user input + customPatterns: schema.object({}, { unknowns: 'allow' }), +}); export function registerGrokSimulateRoute(framework) { framework.registerRoute( @@ -16,8 +21,7 @@ export function registerGrokSimulateRoute(framework) { method: 'post', path: '/api/grokdebugger/simulate', validate: { - // TODO: Add real validation here - body: escapeHatch, + body: requestBodySchema, }, }, async (requestContext, request, response) => { From 37b665a68ba7a260835ec3f8a945204e5f0c956e Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Mon, 30 Mar 2020 13:37:12 +0100 Subject: [PATCH 14/18] Simplify i18n --- .../plugins/grokdebugger/public/register_feature.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/grokdebugger/public/register_feature.ts b/x-pack/plugins/grokdebugger/public/register_feature.ts index e86d2ffebce19..f05d4c973a5fb 100644 --- a/x-pack/plugins/grokdebugger/public/register_feature.ts +++ b/x-pack/plugins/grokdebugger/public/register_feature.ts @@ -14,17 +14,10 @@ export const registerFeature = (homePlugin: HomePublicPluginSetup) => { homePlugin.featureCatalogue.register({ id: 'grokdebugger', title: i18n.translate('xpack.grokDebugger.registryProviderTitle', { - defaultMessage: '{grokLogParsingTool} Debugger', - values: { - grokLogParsingTool: 'Grok', - }, + defaultMessage: 'Grok Debugger', }), description: i18n.translate('xpack.grokDebugger.registryProviderDescription', { - defaultMessage: - 'Simulate and debug {grokLogParsingTool} patterns for data transformation on ingestion.', - values: { - grokLogParsingTool: 'grok', - }, + defaultMessage: 'Simulate and debug grok patterns for data transformation on ingestion.', }), icon: 'grokApp', path: '/app/kibana#/dev_tools/grokdebugger', From ed846a1b83f6400c8fbac2b949ec8af314920b94 Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Mon, 30 Mar 2020 15:27:27 +0100 Subject: [PATCH 15/18] Adjust client license handling --- .../public/components/inactive_license.js | 91 +++++++++++++++++++ x-pack/plugins/grokdebugger/public/plugin.js | 43 +++------ .../plugins/grokdebugger/public/render_app.js | 29 ++++-- 3 files changed, 125 insertions(+), 38 deletions(-) create mode 100644 x-pack/plugins/grokdebugger/public/components/inactive_license.js diff --git a/x-pack/plugins/grokdebugger/public/components/inactive_license.js b/x-pack/plugins/grokdebugger/public/components/inactive_license.js new file mode 100644 index 0000000000000..2ae8c8e8bcb6c --- /dev/null +++ b/x-pack/plugins/grokdebugger/public/components/inactive_license.js @@ -0,0 +1,91 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { + EuiCallOut, + EuiText, + EuiLink, + EuiCode, + EuiPage, + EuiPageBody, + EuiPageContent, + EuiPageContentBody, +} from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; + +export const InactiveLicenseSlate = () => { + const registerLicenseLinkLabel = i18n.translate('xpack.grokDebugger.registerLicenseLinkLabel', { + defaultMessage: 'register a license', + }); + + const trialLicense = i18n.translate('xpack.grokdDebugger.trialLicenseTitle', { + defaultMessage: 'Trial', + }); + + const basicLicense = i18n.translate('xpack.grokDebugger.basicLicenseTitle', { + defaultMessage: 'Basic', + }); + + const goldLicense = i18n.translate('xpack.grokDebugger.goldLicenseTitle', { + defaultMessage: 'Gold', + }); + + const platinumLicense = i18n.translate('xpack.grokDebugger.platinumLicenseTitle', { + defaultMessage: 'Platinum', + }); + + return ( + + + + + + +

+ + {trialLicense}, {basicLicense},{' '} + {goldLicense} + + ), + platinumLicenseType: {platinumLicense}, + }} + /> +

+

+ + {registerLicenseLinkLabel} + + ), + }} + /> +

+
+
+
+
+
+
+ ); +}; diff --git a/x-pack/plugins/grokdebugger/public/plugin.js b/x-pack/plugins/grokdebugger/public/plugin.js index c76d25b039701..9de4f9c3f8bc0 100644 --- a/x-pack/plugins/grokdebugger/public/plugin.js +++ b/x-pack/plugins/grokdebugger/public/plugin.js @@ -9,42 +9,27 @@ import { first } from 'rxjs/operators'; import { registerFeature } from './register_feature'; import { PLUGIN } from '../common/constants'; -const inactiveLicenseMessage = i18n.translate('xpack.grokDebugger.clientInactiveLicenseError', { - defaultMessage: 'The Grok Debugger tool requires an active license.', -}); - export class Plugin { setup(coreSetup, plugins) { registerFeature(plugins.home); - this.licensing = plugins.licensing; - - this.licensing.license$.pipe(first()).subscribe(license => { - plugins.devTools.register({ - order: 6, - title: i18n.translate('xpack.grokDebugger.displayName', { - defaultMessage: 'Grok Debugger', - }), - id: PLUGIN.ID, - enableRouting: false, - disabled: !license.isActive, - tooltipContent: !license.isActive ? inactiveLicenseMessage : null, - async mount(context, { element }) { - const [coreStart] = await coreSetup.getStartServices(); - const { renderApp } = await import('./render_app'); - return renderApp(element, coreStart); - }, - }); + plugins.devTools.register({ + order: 6, + title: i18n.translate('xpack.grokDebugger.displayName', { + defaultMessage: 'Grok Debugger', + }), + id: PLUGIN.ID, + enableRouting: false, + async mount(context, { element }) { + const [coreStart] = await coreSetup.getStartServices(); + const license = await plugins.licensing.license$.pipe(first()).toPromise(); + const { renderApp } = await import('./render_app'); + return renderApp(license, element, coreStart); + }, }); } - start(coreStart) { - this.licensing.license$.subscribe(license => { - coreStart.chrome.navLinks.update(PLUGIN.ID, { - hidden: !license.isActive, - }); - }); - } + start() {} stop() {} } diff --git a/x-pack/plugins/grokdebugger/public/render_app.js b/x-pack/plugins/grokdebugger/public/render_app.js index 40d1ffa7939aa..02167eb23649e 100644 --- a/x-pack/plugins/grokdebugger/public/render_app.js +++ b/x-pack/plugins/grokdebugger/public/render_app.js @@ -11,15 +11,26 @@ import { GrokDebugger } from './components/grok_debugger'; import { GrokdebuggerService } from './services/grokdebugger/grokdebugger_service'; import { I18nProvider } from '@kbn/i18n/react'; import { KibanaContextProvider } from '../../../../src/plugins/kibana_react/public'; +import { InactiveLicenseSlate } from './components/inactive_license'; -export function renderApp(element, coreStart) { - render( - +export function renderApp(license, element, coreStart) { + if (!license.isActive) { + render( - - - , - element - ); - return () => unmountComponentAtNode(element); + + , + element + ); + return () => unmountComponentAtNode(element); + } else { + render( + + + + + , + element + ); + return () => unmountComponentAtNode(element); + } } From 4825d85fe98a7497fd86588194061b0e646dbe0f Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Mon, 30 Mar 2020 16:13:43 +0100 Subject: [PATCH 16/18] Use addDanger on notifications service directly to workaround useKibana helper wrapper bug --- .../public/components/grok_debugger/grok_debugger.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js b/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js index c7e049af2eabd..c27f3314e60ae 100644 --- a/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js +++ b/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js @@ -73,7 +73,7 @@ export class GrokDebuggerComponent extends React.Component { }; simulateGrok = async () => { - const notifications = this.props.kibana.notifications; + const notifications = this.props.kibana.services.notifications; try { const simulateResponse = await this.props.grokdebuggerService.simulate( this.grokdebuggerRequest @@ -83,15 +83,13 @@ export class GrokDebuggerComponent extends React.Component { }); if (!isEmpty(simulateResponse.error)) { - notifications.toasts.danger({ + notifications.toasts.addDanger({ body: simulateResponse.error, - toastLifeTimeMs: 4 * 1000, }); } } catch (e) { - notifications.toasts.danger({ + notifications.toasts.addDanger({ body: e, - toastLifeTimeMs: 4 * 1000, }); } }; From c588cfd27aeab2bb37d6f9d12c456a418b97577c Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Tue, 31 Mar 2020 12:07:27 +0100 Subject: [PATCH 17/18] Amend renderApp logic in favour of ternary --- .../plugins/grokdebugger/public/render_app.js | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/x-pack/plugins/grokdebugger/public/render_app.js b/x-pack/plugins/grokdebugger/public/render_app.js index 02167eb23649e..82783c7bd9795 100644 --- a/x-pack/plugins/grokdebugger/public/render_app.js +++ b/x-pack/plugins/grokdebugger/public/render_app.js @@ -14,23 +14,19 @@ import { KibanaContextProvider } from '../../../../src/plugins/kibana_react/publ import { InactiveLicenseSlate } from './components/inactive_license'; export function renderApp(license, element, coreStart) { - if (!license.isActive) { - render( + const content = license.isActive ? ( + - - , - element - ); - return () => unmountComponentAtNode(element); - } else { - render( - - - - - , - element - ); - return () => unmountComponentAtNode(element); - } + + + + ) : ( + + + + ); + + render(content, element); + + return () => unmountComponentAtNode(element); } From c1e8411254b6c82f7b1ad5c6b72fdec29baec411 Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Tue, 31 Mar 2020 12:17:10 +0100 Subject: [PATCH 18/18] Fix i18n --- .../plugins/grokdebugger/public/components/inactive_license.js | 2 +- x-pack/plugins/translations/translations/ja-JP.json | 2 -- x-pack/plugins/translations/translations/zh-CN.json | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/x-pack/plugins/grokdebugger/public/components/inactive_license.js b/x-pack/plugins/grokdebugger/public/components/inactive_license.js index 2ae8c8e8bcb6c..ff0306b789190 100644 --- a/x-pack/plugins/grokdebugger/public/components/inactive_license.js +++ b/x-pack/plugins/grokdebugger/public/components/inactive_license.js @@ -23,7 +23,7 @@ export const InactiveLicenseSlate = () => { defaultMessage: 'register a license', }); - const trialLicense = i18n.translate('xpack.grokdDebugger.trialLicenseTitle', { + const trialLicense = i18n.translate('xpack.grokDebugger.trialLicenseTitle', { defaultMessage: 'Trial', }); diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index ef774d5f8b242..a9f3c9acf216d 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -5784,8 +5784,6 @@ "xpack.grokDebugger.displayName": "Grok デバッガー", "xpack.grokDebugger.grokPatternLabel": "Grok パターン", "xpack.grokDebugger.patternsErrorMessage": "提供された {grokLogParsingTool} パターンがインプットのデータと一致していません", - "xpack.grokDebugger.registryProviderDescription": "{grokLogParsingTool} パターンを、投入時にデータ変換用にシミュレートしデバッグします。", - "xpack.grokDebugger.registryProviderTitle": "{grokLogParsingTool} デバッガー", "xpack.grokDebugger.sampleDataLabel": "サンプルデータ", "xpack.grokDebugger.simulateButtonLabel": "シミュレート", "xpack.grokDebugger.structuredDataLabel": "構造化データ", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 99832529b5356..96db297bd519e 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -5784,8 +5784,6 @@ "xpack.grokDebugger.displayName": "Grok Debugger", "xpack.grokDebugger.grokPatternLabel": "Grok 模式", "xpack.grokDebugger.patternsErrorMessage": "提供的 {grokLogParsingTool} 模式不匹配输入中的数据", - "xpack.grokDebugger.registryProviderDescription": "采集时模拟和调试用于数据转换的 {grokLogParsingTool} 模式。", - "xpack.grokDebugger.registryProviderTitle": "{grokLogParsingTool} Debugger", "xpack.grokDebugger.sampleDataLabel": "样例数据", "xpack.grokDebugger.simulateButtonLabel": "模拟", "xpack.grokDebugger.structuredDataLabel": "结构化数据",