From 7fc4a1f80f69dfbb4b7ace3922328c840838e339 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Thu, 27 May 2021 09:43:12 -0500 Subject: [PATCH] Add kibana.yml configuration for cases (#100583) Make it so `xpack.observability.unsafe.alertingExperience.enabled` only shows and hides the Alerts page, and `xpack.observability.unsafe.cases.enabled` show and hides the Cases page. --- .../resources/base/bin/kibana-docker | 1 + x-pack/plugins/observability/README.md | 12 ++++++++++-- .../public/application/application.test.tsx | 2 +- .../public/components/app/section/apm/index.test.tsx | 2 +- .../public/components/app/section/ux/index.test.tsx | 2 +- .../public/hooks/use_time_range.test.ts | 4 ++-- x-pack/plugins/observability/public/index.ts | 2 +- .../public/pages/overview/overview.stories.tsx | 2 +- x-pack/plugins/observability/public/plugin.ts | 2 ++ .../observability/public/utils/test_helper.tsx | 2 +- x-pack/plugins/observability/server/index.ts | 3 ++- 11 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker b/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker index 2f54bd1d818b56..47b5888da4ce87 100755 --- a/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker +++ b/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker @@ -231,6 +231,7 @@ kibana_vars=( xpack.maps.showMapVisualizationTypes xpack.ml.enabled xpack.observability.unsafe.alertingExperience.enabled + xpack.observability.unsafe.cases.enabled xpack.reporting.capture.browser.autoDownload xpack.reporting.capture.browser.chromium.disableSandbox xpack.reporting.capture.browser.chromium.inspect diff --git a/x-pack/plugins/observability/README.md b/x-pack/plugins/observability/README.md index 943a7482a25eec..cfa13315734159 100644 --- a/x-pack/plugins/observability/README.md +++ b/x-pack/plugins/observability/README.md @@ -9,13 +9,21 @@ case management. If you have: +```yaml +xpack.observability.unsafe.cases.enabled: true +``` + +In your Kibana configuration, the Cases page will be available. + +If you have: + ```yaml xpack.observability.unsafe.alertingExperience.enabled: true ``` -In your Kibana configuration, the Alerts and Cases pages will be available. +In your Kibana configuration, the Alerts page will be available. -This will only enable the UI for these pages. In order to have alert data indexed +This will only enable the UI for this page when. In order to have alert data indexed you'll need to enable writing in the [Rule Registry plugin](../rule_registry/README.md): ```yaml diff --git a/x-pack/plugins/observability/public/application/application.test.tsx b/x-pack/plugins/observability/public/application/application.test.tsx index 9182a0e8196c89..76b8eb5c7fd085 100644 --- a/x-pack/plugins/observability/public/application/application.test.tsx +++ b/x-pack/plugins/observability/public/application/application.test.tsx @@ -45,7 +45,7 @@ describe('renderApp', () => { uiSettings: { get: () => false }, http: { basePath: { prepend: (path: string) => path } }, } as unknown) as CoreStart; - const config = { unsafe: { alertingExperience: { enabled: true } } }; + const config = { unsafe: { alertingExperience: { enabled: true }, cases: { enabled: true } } }; const params = ({ element: window.document.createElement('div'), history: createMemoryHistory(), diff --git a/x-pack/plugins/observability/public/components/app/section/apm/index.test.tsx b/x-pack/plugins/observability/public/components/app/section/apm/index.test.tsx index 67fede05f3ced6..aa83c49c9f52a2 100644 --- a/x-pack/plugins/observability/public/components/app/section/apm/index.test.tsx +++ b/x-pack/plugins/observability/public/components/app/section/apm/index.test.tsx @@ -41,7 +41,7 @@ describe('APMSection', () => { http: { basePath: { prepend: jest.fn() } }, } as unknown) as CoreStart, appMountParameters: {} as AppMountParameters, - config: { unsafe: { alertingExperience: { enabled: true } } }, + config: { unsafe: { alertingExperience: { enabled: true }, cases: { enabled: true } } }, observabilityRuleTypeRegistry: createObservabilityRuleTypeRegistryMock(), plugins: ({ data: { diff --git a/x-pack/plugins/observability/public/components/app/section/ux/index.test.tsx b/x-pack/plugins/observability/public/components/app/section/ux/index.test.tsx index b4227cc122dde3..5c237bfbc31ecb 100644 --- a/x-pack/plugins/observability/public/components/app/section/ux/index.test.tsx +++ b/x-pack/plugins/observability/public/components/app/section/ux/index.test.tsx @@ -40,7 +40,7 @@ describe('UXSection', () => { http: { basePath: { prepend: jest.fn() } }, } as unknown) as CoreStart, appMountParameters: {} as AppMountParameters, - config: { unsafe: { alertingExperience: { enabled: true } } }, + config: { unsafe: { alertingExperience: { enabled: true }, cases: { enabled: true } } }, plugins: ({ data: { query: { diff --git a/x-pack/plugins/observability/public/hooks/use_time_range.test.ts b/x-pack/plugins/observability/public/hooks/use_time_range.test.ts index 8808d6390e3651..3b0bdb8dc96033 100644 --- a/x-pack/plugins/observability/public/hooks/use_time_range.test.ts +++ b/x-pack/plugins/observability/public/hooks/use_time_range.test.ts @@ -24,7 +24,7 @@ describe('useTimeRange', () => { jest.spyOn(pluginContext, 'usePluginContext').mockImplementation(() => ({ core: {} as CoreStart, appMountParameters: {} as AppMountParameters, - config: { unsafe: { alertingExperience: { enabled: true } } }, + config: { unsafe: { alertingExperience: { enabled: true }, cases: { enabled: true } } }, plugins: ({ data: { query: { @@ -66,7 +66,7 @@ describe('useTimeRange', () => { jest.spyOn(pluginContext, 'usePluginContext').mockImplementation(() => ({ core: {} as CoreStart, appMountParameters: {} as AppMountParameters, - config: { unsafe: { alertingExperience: { enabled: true } } }, + config: { unsafe: { alertingExperience: { enabled: true }, cases: { enabled: true } } }, plugins: ({ data: { query: { diff --git a/x-pack/plugins/observability/public/index.ts b/x-pack/plugins/observability/public/index.ts index 8dd2f6a57eefe9..a49d3461529c28 100644 --- a/x-pack/plugins/observability/public/index.ts +++ b/x-pack/plugins/observability/public/index.ts @@ -22,7 +22,7 @@ export type { export { enableInspectEsQueries } from '../common/ui_settings_keys'; export interface ConfigSchema { - unsafe: { alertingExperience: { enabled: boolean } }; + unsafe: { alertingExperience: { enabled: boolean }; cases: { enabled: boolean } }; } export const plugin: PluginInitializer< diff --git a/x-pack/plugins/observability/public/pages/overview/overview.stories.tsx b/x-pack/plugins/observability/public/pages/overview/overview.stories.tsx index ebd1c738591690..12f8900034eb26 100644 --- a/x-pack/plugins/observability/public/pages/overview/overview.stories.tsx +++ b/x-pack/plugins/observability/public/pages/overview/overview.stories.tsx @@ -45,7 +45,7 @@ const withCore = makeDecorator({ appMountParameters: ({ setHeaderActionMenu: () => {}, } as unknown) as AppMountParameters, - config: { unsafe: { alertingExperience: { enabled: true } } }, + config: { unsafe: { alertingExperience: { enabled: true }, cases: { enabled: true } } }, core: options as CoreStart, plugins: ({ data: { diff --git a/x-pack/plugins/observability/public/plugin.ts b/x-pack/plugins/observability/public/plugin.ts index 6856bc97b4a360..16363d4181c5be 100644 --- a/x-pack/plugins/observability/public/plugin.ts +++ b/x-pack/plugins/observability/public/plugin.ts @@ -119,7 +119,9 @@ export class Plugin mount, updater$, }); + } + if (config.unsafe.cases.enabled) { coreSetup.application.register({ id: 'observability-cases', title: 'Cases', diff --git a/x-pack/plugins/observability/public/utils/test_helper.tsx b/x-pack/plugins/observability/public/utils/test_helper.tsx index ef7c62a143f250..2434f0eec10edc 100644 --- a/x-pack/plugins/observability/public/utils/test_helper.tsx +++ b/x-pack/plugins/observability/public/utils/test_helper.tsx @@ -31,7 +31,7 @@ export const core = ({ }, } as unknown) as CoreStart; -const config = { unsafe: { alertingExperience: { enabled: true } } }; +const config = { unsafe: { alertingExperience: { enabled: true }, cases: { enabled: true } } }; const plugins = ({ data: { query: { timefilter: { timefilter: { setTime: jest.fn() } } } }, diff --git a/x-pack/plugins/observability/server/index.ts b/x-pack/plugins/observability/server/index.ts index ec471df164fe1d..52a60a92f5b957 100644 --- a/x-pack/plugins/observability/server/index.ts +++ b/x-pack/plugins/observability/server/index.ts @@ -17,7 +17,7 @@ export * from './types'; export const config = { exposeToBrowser: { - unsafe: { alertingExperience: { enabled: true } }, + unsafe: { alertingExperience: { enabled: true }, cases: { enabled: true } }, }, schema: schema.object({ enabled: schema.boolean({ defaultValue: true }), @@ -27,6 +27,7 @@ export const config = { }), unsafe: schema.object({ alertingExperience: schema.object({ enabled: schema.boolean({ defaultValue: false }) }), + cases: schema.object({ enabled: schema.boolean({ defaultValue: false }) }), }), }), };