Skip to content

Commit 7c01ff3

Browse files
authored
feat(slo): pre-filled SLO form with template data (elastic#246993)
1 parent 101cdda commit 7c01ff3

File tree

58 files changed

+295
-142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+295
-142
lines changed

x-pack/platform/packages/shared/kbn-slo-schema/src/schema/slo_template.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const sloTemplateSchema = t.intersection([
2323
timeWindow: timeWindowSchema,
2424
tags: tagsSchema,
2525
settings: optionalSettingsSchema,
26+
groupBy: t.array(t.string),
2627
}),
2728
]);
2829

x-pack/solutions/observability/plugins/slo/common/locators/paths.ts renamed to x-pack/platform/plugins/shared/slo_shared/common/locators/paths.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export const SLOS_WELCOME_PATH = '/welcome' as const;
1313
export const SLO_DETAIL_PATH = '/:sloId/:tabId?' as const;
1414
export const SLO_CREATE_PATH = '/create' as const;
1515
export const SLO_EDIT_PATH = '/edit/:sloId' as const;
16-
export const SLOS_OUTDATED_DEFINITIONS_PATH = '/outdated-definitions' as const;
1716
export const SLO_SETTINGS_PATH = '/settings' as const;
1817
export const SLOS_MANAGEMENT_PATH = '/management' as const;
1918

@@ -25,6 +24,8 @@ export const paths = {
2524
sloCreate: `${SLOS_BASE_PATH}${SLO_CREATE_PATH}`,
2625
sloCreateWithEncodedForm: (encodedParams: string) =>
2726
`${SLOS_BASE_PATH}${SLO_CREATE_PATH}?_a=${encodedParams}`,
27+
sloCreateFromTemplate: (templateId: string) =>
28+
`${SLOS_BASE_PATH}${SLO_CREATE_PATH}?fromTemplateId=${encodeURIComponent(templateId)}`,
2829
sloEdit: (sloId: string) => `${SLOS_BASE_PATH}/edit/${encodeURIComponent(sloId)}`,
2930
sloEditWithEncodedForm: (sloId: string, encodedParams: string) =>
3031
`${SLOS_BASE_PATH}/edit/${encodeURIComponent(sloId)}?_a=${encodedParams}`,

x-pack/platform/plugins/shared/slo_shared/server/saved_objects/slo_template.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type { storedSloTemplateSchema } from '@kbn/slo-schema';
1313
import type * as t from 'io-ts';
1414
import { pick } from 'lodash';
1515
import { SO_SLO_TEMPLATE_TYPE } from '../../common';
16+
import { paths } from '../../common/locators/paths';
1617

1718
type StoredSLOTemplate = t.TypeOf<typeof storedSloTemplateSchema>;
1819

@@ -63,6 +64,12 @@ export const sloTemplate: SavedObjectsType = {
6364
},
6465
management: {
6566
importableAndExportable: true,
67+
getInAppUrl: (savedObject: SavedObject<StoredSLOTemplate>) => {
68+
return {
69+
path: paths.sloCreateFromTemplate(savedObject.id),
70+
uiCapabilitiesPath: '',
71+
};
72+
},
6673
getTitle(template: SavedObject<StoredSLOTemplate>) {
6774
const templateName =
6875
'name' in template.attributes && typeof template.attributes.name === 'string'

x-pack/solutions/observability/plugins/slo/common/field_names/slo.ts renamed to x-pack/solutions/observability/plugins/slo/common/burn_rate_rule/field_names.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,3 @@ export const SLO_ID_FIELD = 'slo.id';
99
export const SLO_REVISION_FIELD = 'slo.revision';
1010
export const SLO_INSTANCE_ID_FIELD = 'slo.instanceId';
1111
export const SLO_DATA_VIEW_ID_FIELD = 'slo.dataViewId';
12-
13-
export const SLO_BURN_RATE_AAD_FIELDS = [
14-
SLO_ID_FIELD,
15-
SLO_REVISION_FIELD,
16-
SLO_INSTANCE_ID_FIELD,
17-
SLO_DATA_VIEW_ID_FIELD,
18-
];

x-pack/solutions/observability/plugins/slo/common/types.ts renamed to x-pack/solutions/observability/plugins/slo/common/burn_rate_rule/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,4 @@ export const DependencyRT = t.type({
1111
actionGroupsToSuppressOn: t.array(t.string),
1212
});
1313

14-
export const DependenciesRT = t.array(DependencyRT);
15-
1614
export type Dependency = t.OutputOf<typeof DependencyRT>;

x-pack/solutions/observability/plugins/slo/common/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@
77

88
export const sloAppId = 'slo';
99
export const PLUGIN_NAME = 'SLOs';
10-
11-
import { paths } from './locators/paths';
12-
export const sloPaths = paths;

x-pack/solutions/observability/plugins/slo/public/components/burn_rate_rule_editor/dependencies.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { i18n } from '@kbn/i18n';
1818

1919
import React from 'react';
2020
import { useFetchSLOsWithBurnRateRules } from '../../hooks/use_fetch_slos_with_burn_rate_rules';
21-
import type { Dependency } from '../../../common/types';
21+
import type { Dependency } from '../../../common/burn_rate_rule/types';
2222
import {
2323
ALERT_ACTION,
2424
HIGH_PRIORITY_ACTION,

x-pack/solutions/observability/plugins/slo/public/components/burn_rate_rule_editor/dependency_editor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import { FormattedMessage } from '@kbn/i18n-react';
2121
import type { Rule } from '@kbn/triggers-actions-ui-plugin/public';
2222
import { isRight } from 'fp-ts/Either';
2323
import type { SloRule } from '../../hooks/use_fetch_slos_with_burn_rate_rules';
24-
import type { Dependency } from '../../../common/types';
25-
import { DependencyRT } from '../../../common/types';
24+
import type { Dependency } from '../../../common/burn_rate_rule/types';
25+
import { DependencyRT } from '../../../common/burn_rate_rule/types';
2626
import {
2727
ALERT_ACTION,
2828
HIGH_PRIORITY_ACTION,

x-pack/solutions/observability/plugins/slo/public/components/header_menu/header_menu.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiHeaderLink, EuiHeaderLinks } from '@elast
99
import { i18n } from '@kbn/i18n';
1010
import { HeaderMenuPortal } from '@kbn/observability-shared-plugin/public';
1111
import React from 'react';
12-
import { SLOS_BASE_PATH, SLO_SETTINGS_PATH } from '../../../common/locators/paths';
12+
import { paths } from '@kbn/slo-shared-plugin/common/locators/paths';
1313
import { useKibana } from '../../hooks/use_kibana';
1414
import { usePluginContext } from '../../hooks/use_plugin_context';
1515
import { FeedbackButton } from '../../pages/slos/components/common/feedback_button';
@@ -40,15 +40,12 @@ export function HeaderMenu(): React.ReactElement | null {
4040
defaultMessage: 'SLO documentation',
4141
})}
4242
</EuiHeaderLink>
43-
<EuiHeaderLink
44-
color="primary"
45-
href={http.basePath.prepend(`${SLOS_BASE_PATH}${SLO_SETTINGS_PATH}`)}
46-
>
43+
<EuiHeaderLink color="primary" href={http.basePath.prepend(paths.slosSettings)}>
4744
{i18n.translate('xpack.slo.headerMenu.settings', {
4845
defaultMessage: 'Settings',
4946
})}
5047
</EuiHeaderLink>
51-
<EuiHeaderLink color="primary" href={http.basePath.prepend('/app/slos/management')}>
48+
<EuiHeaderLink color="primary" href={http.basePath.prepend(paths.slosManagement)}>
5249
{i18n.translate('xpack.slo.home.manage', {
5350
defaultMessage: 'Manage SLOs',
5451
})}

x-pack/solutions/observability/plugins/slo/public/components/slo/slo_outdated_callout/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
* 2.0.
66
*/
77
import { EuiButton, EuiCallOut, EuiSpacer } from '@elastic/eui';
8-
import React from 'react';
98
import { i18n } from '@kbn/i18n';
109
import { FormattedMessage } from '@kbn/i18n-react';
1110
import { encode } from '@kbn/rison';
12-
import { useKibana } from '../../../hooks/use_kibana';
11+
import { paths } from '@kbn/slo-shared-plugin/common/locators/paths';
12+
import React from 'react';
1313
import { useFetchSloDefinitions } from '../../../hooks/use_fetch_slo_definitions';
14-
import { paths } from '../../../../common/locators/paths';
14+
import { useKibana } from '../../../hooks/use_kibana';
1515

1616
export function SloOutdatedCallout() {
1717
const {

0 commit comments

Comments
 (0)