From 19354c1ca90e061b08c4061d8282212ddb890ccf Mon Sep 17 00:00:00 2001 From: shahzad31 Date: Wed, 20 Dec 2023 12:31:19 +0100 Subject: [PATCH] update types --- .../kbn-slo-schema/src/rest_specs/slo.ts | 1 + .../components/common/inspect_slo_portal.tsx | 7 +++++-- .../components/common/slo_inspect.tsx | 19 +++++-------------- .../slo_edit/components/slo_edit_form.tsx | 2 +- .../server/services/slo/create_slo.ts | 2 +- .../server/services/slo/mocks/index.ts | 2 ++ x-pack/plugins/observability/tsconfig.json | 1 + 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/x-pack/packages/kbn-slo-schema/src/rest_specs/slo.ts b/x-pack/packages/kbn-slo-schema/src/rest_specs/slo.ts index 574a7eb1f9244..38233d2982c08 100644 --- a/x-pack/packages/kbn-slo-schema/src/rest_specs/slo.ts +++ b/x-pack/packages/kbn-slo-schema/src/rest_specs/slo.ts @@ -50,6 +50,7 @@ const createSLOParamsSchema = t.type({ settings: optionalSettingsSchema, tags: tagsSchema, groupBy: allOrAnyString, + revision: t.number, }), ]), }); diff --git a/x-pack/plugins/observability/public/pages/slo_edit/components/common/inspect_slo_portal.tsx b/x-pack/plugins/observability/public/pages/slo_edit/components/common/inspect_slo_portal.tsx index ce3327dd3af90..d03772c9bf4ce 100644 --- a/x-pack/plugins/observability/public/pages/slo_edit/components/common/inspect_slo_portal.tsx +++ b/x-pack/plugins/observability/public/pages/slo_edit/components/common/inspect_slo_portal.tsx @@ -7,14 +7,17 @@ import React from 'react'; import { InPortal } from 'react-reverse-portal'; +import { GetSLOResponse } from '@kbn/slo-schema'; import { CreateSLOForm } from '../../types'; import { SLOInspectWrapper } from './slo_inspect'; import { InspectSLOPortalNode } from '../../slo_edit'; -export function InspectSLOPortal(props: { +export interface SloInspectPortalProps { getValues: () => CreateSLOForm; trigger: () => Promise; -}) { + slo?: GetSLOResponse; +} +export function InspectSLOPortal(props: SloInspectPortalProps) { return ( diff --git a/x-pack/plugins/observability/public/pages/slo_edit/components/common/slo_inspect.tsx b/x-pack/plugins/observability/public/pages/slo_edit/components/common/slo_inspect.tsx index b084e66d5116a..2c96c0d2d05bc 100644 --- a/x-pack/plugins/observability/public/pages/slo_edit/components/common/slo_inspect.tsx +++ b/x-pack/plugins/observability/public/pages/slo_edit/components/common/slo_inspect.tsx @@ -30,17 +30,14 @@ import { INGEST_PIPELINES_PAGES, IngestPipelinesListParams, } from '@kbn/ingest-pipelines-plugin/public'; +import { SloInspectPortalProps } from './inspect_slo_portal'; import { ObservabilityPublicPluginsStart } from '../../../..'; import { useInspectSlo } from '../../../../hooks/slo/use_inspect_slo'; -import { CreateSLOForm } from '../../types'; import { transformCreateSLOFormToCreateSLOInput } from '../../helpers/process_slo_form_values'; import { enableInspectEsQueries } from '../../../../../common'; import { usePluginContext } from '../../../../hooks/use_plugin_context'; -export function SLOInspectWrapper(props: { - getValues: () => CreateSLOForm; - trigger: () => Promise; -}) { +export function SLOInspectWrapper(props: SloInspectPortalProps) { const { services: { uiSettings }, } = useKibana(); @@ -52,13 +49,7 @@ export function SLOInspectWrapper(props: { return isDev || isInspectorEnabled ? : null; } -function SLOInspect({ - getValues, - trigger, -}: { - getValues: () => CreateSLOForm; - trigger: () => Promise; -}) { +function SLOInspect({ getValues, trigger, slo }: SloInspectPortalProps) { const { share, http } = useKibana().services; const [isFlyoutVisible, setIsFlyoutVisible] = useState(false); const { mutateAsync: inspectSlo, data, isLoading } = useInspectSlo(); @@ -72,9 +63,9 @@ function SLOInspect({ return; } const sloForm = transformCreateSLOFormToCreateSLOInput(getValues()); - inspectSlo({ slo: sloForm }); + inspectSlo({ slo: { ...sloForm, id: slo?.id, revision: slo?.revision } }); return sloForm; - }, [isFlyoutVisible, trigger, getValues, inspectSlo]); + }, [isFlyoutVisible, trigger, getValues, inspectSlo, slo]); const { data: pipeLineUrl } = useFetcher(async () => { const ingestPipeLocator = share.url.locators.get( diff --git a/x-pack/plugins/observability/public/pages/slo_edit/components/slo_edit_form.tsx b/x-pack/plugins/observability/public/pages/slo_edit/components/slo_edit_form.tsx index 41978a53a5567..bf32535118293 100644 --- a/x-pack/plugins/observability/public/pages/slo_edit/components/slo_edit_form.tsx +++ b/x-pack/plugins/observability/public/pages/slo_edit/components/slo_edit_form.tsx @@ -241,7 +241,7 @@ export function SloEditForm({ slo }: Props) { /> - + => { uninstall: jest.fn(), start: jest.fn(), stop: jest.fn(), + inspect: jest.fn(), }; }; @@ -35,6 +36,7 @@ const createSummaryTransformManagerMock = (): jest.Mocked => { uninstall: jest.fn(), start: jest.fn(), stop: jest.fn(), + inspect: jest.fn(), }; }; diff --git a/x-pack/plugins/observability/tsconfig.json b/x-pack/plugins/observability/tsconfig.json index 61762322f9eed..cf3402a90c888 100644 --- a/x-pack/plugins/observability/tsconfig.json +++ b/x-pack/plugins/observability/tsconfig.json @@ -100,6 +100,7 @@ "@kbn/presentation-util-plugin", "@kbn/task-manager-plugin", "@kbn/core-elasticsearch-client-server-mocks", + "@kbn/ingest-pipelines-plugin", "@kbn/core-saved-objects-api-server-mocks" ], "exclude": [