forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SLOs] Slo form little things (elastic#193990)
## Summary Slo form little things !! Will auto add values for APM defaults to all instead of forcing user !! ### Changes Details | Before | After -- | -- | -- Data View component | <img width="1262" alt="image" src="https://github.com/user-attachments/assets/79a5cbcd-04e1-49e6-aa86-036b36c8a6e6"> | <img width="1391" alt="image" src="https://github.com/user-attachments/assets/973db8f5-179d-4f89-b57b-39c7b57eb360"> APM SLI | <img width="1183" alt="image" src="https://github.com/user-attachments/assets/a3e083fa-df13-408b-b02d-e26695398225"> | <img width="1158" alt="image" src="https://github.com/user-attachments/assets/a94cfe07-32b0-4367-95e8-ab10d232e98c">
- Loading branch information
Showing
14 changed files
with
254 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...bility_solution/slo/public/pages/slo_edit/components/apm_common/use_apm_default_values.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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 { useFormContext } from 'react-hook-form'; | ||
import { ALL_VALUE, APMTransactionErrorRateIndicator } from '@kbn/slo-schema'; | ||
import { useEffect } from 'react'; | ||
import { useFetchApmIndex } from '../../../../hooks/use_fetch_apm_indices'; | ||
import { CreateSLOForm } from '../../types'; | ||
|
||
export const useApmDefaultValues = () => { | ||
const { watch, setValue } = useFormContext<CreateSLOForm<APMTransactionErrorRateIndicator>>(); | ||
const { data: apmIndex } = useFetchApmIndex(); | ||
|
||
const [serviceName = '', environment = '', transactionType = '', transactionName = ''] = watch([ | ||
'indicator.params.service', | ||
'indicator.params.environment', | ||
'indicator.params.transactionType', | ||
'indicator.params.transactionName', | ||
]); | ||
|
||
useEffect(() => { | ||
if (apmIndex !== '') { | ||
setValue('indicator.params.index', apmIndex); | ||
} | ||
}, [setValue, apmIndex]); | ||
|
||
useEffect(() => { | ||
if (serviceName) { | ||
if (!environment) { | ||
setValue('indicator.params.environment', ALL_VALUE); | ||
} | ||
|
||
if (!transactionType) { | ||
setValue('indicator.params.transactionType', ALL_VALUE); | ||
} | ||
|
||
if (!transactionName) { | ||
setValue('indicator.params.transactionName', ALL_VALUE); | ||
} | ||
} | ||
}, [environment, serviceName, setValue, transactionName, transactionType]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.