mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Add SLO Edit Form locator (#161753)
This commit is contained in:
parent
11856ab1d2
commit
62c9a1f6cb
5 changed files with 71 additions and 0 deletions
|
@ -65,6 +65,7 @@ export const alertsLocatorID = 'ALERTS_LOCATOR';
|
|||
export const ruleDetailsLocatorID = 'RULE_DETAILS_LOCATOR';
|
||||
export const rulesLocatorID = 'RULES_LOCATOR';
|
||||
export const sloDetailsLocatorID = 'SLO_DETAILS_LOCATOR';
|
||||
export const sloEditLocatorID = 'SLO_EDIT_LOCATOR';
|
||||
|
||||
export type { AlertsLocatorParams } from './locators/alerts';
|
||||
|
||||
|
|
|
@ -46,9 +46,12 @@ export {
|
|||
ruleDetailsLocatorID,
|
||||
rulesLocatorID,
|
||||
sloDetailsLocatorID,
|
||||
sloEditLocatorID,
|
||||
uptimeOverviewLocatorID,
|
||||
} from '../common';
|
||||
|
||||
export type { SloEditLocatorParams } from './locators/slo_edit';
|
||||
|
||||
export type { UXMetrics } from './pages/overview/components/sections/ux/core_web_vitals/core_vitals';
|
||||
export { getCoreVitalsComponent } from './pages/overview/components/sections/ux/core_web_vitals/get_core_web_vitals_lazy';
|
||||
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { buildSlo } from '../data/slo/slo';
|
||||
import { SloEditLocatorDefinition } from './slo_edit';
|
||||
|
||||
describe('SloEditLocator', () => {
|
||||
const locator = new SloEditLocatorDefinition();
|
||||
|
||||
it('should return correct url when empty params are provided', async () => {
|
||||
const location = await locator.getLocation({});
|
||||
expect(location.app).toEqual('observability');
|
||||
expect(location.path).toEqual('/slos/create?_a=()');
|
||||
});
|
||||
|
||||
it('should return correct url when slo is provided', async () => {
|
||||
const location = await locator.getLocation(buildSlo({ id: 'foo' }));
|
||||
expect(location.path).toEqual(
|
||||
"/slos/edit/foo?_a=(budgetingMethod:occurrences,createdAt:'2022-12-29T10:11:12.000Z',description:'some%20description%20useful',enabled:!t,id:foo,indicator:(params:(filter:'baz:%20foo%20and%20bar%20%3E%202',good:'http_status:%202xx',index:some-index,timestampField:custom_timestamp,total:'a%20query'),type:sli.kql.custom),name:'super%20important%20level%20service',objective:(target:0.98),revision:1,settings:(frequency:'1m',syncDelay:'1m'),summary:(errorBudget:(consumed:0.064,initial:0.02,isEstimated:!f,remaining:0.936),sliValue:0.99872,status:HEALTHY),tags:!(k8s,production,critical),timeWindow:(duration:'30d',type:rolling),updatedAt:'2022-12-29T10:11:12.000Z')"
|
||||
);
|
||||
});
|
||||
});
|
37
x-pack/plugins/observability/public/locators/slo_edit.ts
Normal file
37
x-pack/plugins/observability/public/locators/slo_edit.ts
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/public';
|
||||
import type { RecursivePartial } from '@elastic/charts';
|
||||
import type { SerializableRecord } from '@kbn/utility-types';
|
||||
import type { LocatorDefinition } from '@kbn/share-plugin/public';
|
||||
import type { CreateSLOForm } from '../pages/slo_edit/types';
|
||||
import { sloEditLocatorID } from '../../common';
|
||||
import { SLO_CREATE_PATH, SLOS_PATH } from '../routes/paths';
|
||||
|
||||
export type SloEditParams = RecursivePartial<CreateSLOForm>;
|
||||
|
||||
export interface SloEditLocatorParams extends SloEditParams, SerializableRecord {}
|
||||
|
||||
export class SloEditLocatorDefinition implements LocatorDefinition<SloEditLocatorParams> {
|
||||
public readonly id = sloEditLocatorID;
|
||||
|
||||
public readonly getLocation = async (slo: SloEditLocatorParams) => {
|
||||
return {
|
||||
app: 'observability',
|
||||
path: setStateToKbnUrl<SloEditParams>(
|
||||
'_a',
|
||||
{
|
||||
...slo,
|
||||
},
|
||||
{ useHash: false, storeInHashQuery: false },
|
||||
slo.id ? `${SLOS_PATH}/edit/${encodeURI(String(slo.id))}` : SLO_CREATE_PATH
|
||||
),
|
||||
state: {},
|
||||
};
|
||||
};
|
||||
}
|
|
@ -54,6 +54,7 @@ import { ExploratoryViewPublicStart } from '@kbn/exploratory-view-plugin/public'
|
|||
import { RulesLocatorDefinition } from './locators/rules';
|
||||
import { RuleDetailsLocatorDefinition } from './locators/rule_details';
|
||||
import { SloDetailsLocatorDefinition } from './locators/slo_details';
|
||||
import { SloEditLocatorDefinition } from './locators/slo_edit';
|
||||
import { observabilityAppId, observabilityFeatureId } from '../common';
|
||||
import { registerDataHandler } from './context/has_data_context/data_handler';
|
||||
import {
|
||||
|
@ -223,6 +224,8 @@ export class Plugin
|
|||
new SloDetailsLocatorDefinition()
|
||||
);
|
||||
|
||||
const sloEditLocator = pluginsSetup.share.url.locators.create(new SloEditLocatorDefinition());
|
||||
|
||||
const mount = async (params: AppMountParameters<unknown>) => {
|
||||
// Load application bundle
|
||||
const { renderApp } = await import('./application');
|
||||
|
@ -349,6 +352,7 @@ export class Plugin
|
|||
rulesLocator,
|
||||
ruleDetailsLocator,
|
||||
sloDetailsLocator,
|
||||
sloEditLocator,
|
||||
getCoPilotService: () => this.coPilotService!,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue