Skip to content

Commit

Permalink
update types
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Dec 20, 2023
1 parent 08d4688 commit 19354c1
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
1 change: 1 addition & 0 deletions x-pack/packages/kbn-slo-schema/src/rest_specs/slo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const createSLOParamsSchema = t.type({
settings: optionalSettingsSchema,
tags: tagsSchema,
groupBy: allOrAnyString,
revision: t.number,
}),
]),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>;
}) {
slo?: GetSLOResponse;
}
export function InspectSLOPortal(props: SloInspectPortalProps) {
return (
<InPortal node={InspectSLOPortalNode}>
<SLOInspectWrapper {...props} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>;
}) {
export function SLOInspectWrapper(props: SloInspectPortalProps) {
const {
services: { uiSettings },
} = useKibana();
Expand All @@ -52,13 +49,7 @@ export function SLOInspectWrapper(props: {
return isDev || isInspectorEnabled ? <SLOInspect {...props} /> : null;
}

function SLOInspect({
getValues,
trigger,
}: {
getValues: () => CreateSLOForm;
trigger: () => Promise<boolean>;
}) {
function SLOInspect({ getValues, trigger, slo }: SloInspectPortalProps) {
const { share, http } = useKibana<ObservabilityPublicPluginsStart>().services;
const [isFlyoutVisible, setIsFlyoutVisible] = useState(false);
const { mutateAsync: inspectSlo, data, isLoading } = useInspectSlo();
Expand All @@ -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<IngestPipelinesListParams>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export function SloEditForm({ slo }: Props) {
/>
</EuiFlexGroup>
</EuiFlexGroup>
<InspectSLOPortal trigger={trigger} getValues={getValues} />
<InspectSLOPortal trigger={trigger} getValues={getValues} slo={slo} />
</FormProvider>

<BurnRateRuleFlyout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class CreateSLO {
syncDelay: params.settings?.syncDelay ?? new Duration(1, DurationUnit.Minute),
frequency: params.settings?.frequency ?? new Duration(1, DurationUnit.Minute),
},
revision: 1,
revision: params.revision ?? 1,
enabled: true,
tags: params.tags ?? [],
createdAt: now,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const createTransformManagerMock = (): jest.Mocked<TransformManager> => {
uninstall: jest.fn(),
start: jest.fn(),
stop: jest.fn(),
inspect: jest.fn(),
};
};

Expand All @@ -35,6 +36,7 @@ const createSummaryTransformManagerMock = (): jest.Mocked<TransformManager> => {
uninstall: jest.fn(),
start: jest.fn(),
stop: jest.fn(),
inspect: jest.fn(),
};
};

Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/observability/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down

0 comments on commit 19354c1

Please sign in to comment.