-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(slo): allow configuration of advanced settings from UI #200822
Merged
Merged
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
b807203
cleanup form default values initialization logic
kdelemme 83992f5
Use default gap between inputs
kdelemme 05f3955
Move indicators into own folder
kdelemme 9596596
Move advanced settings in own component
kdelemme e8b9bfd
Add syncDelay advanced settings
kdelemme 9dcfc55
Add sync delay in overview
kdelemme 01425db
Add frequency settings
kdelemme 04c8423
Use grid
kdelemme c214e12
Introduce syncField settings and use it in transforms
kdelemme c15af8c
Use syncField when provided
kdelemme f9c5f20
Handle sync field value
kdelemme e3011a8
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine cebdf80
Ensure dataview dependant fields are cleared on update
kdelemme 199721e
remove console log
kdelemme 8774b98
Append optional text
kdelemme 7485773
Update locator
kdelemme 17823db
Fix default values when no state provided
kdelemme 0bf8b60
Merge branch 'main' into feat/advanced-settings-slo
kdelemme 887fbb0
Merge branch 'main' into feat/advanced-settings-slo
kdelemme b2c9133
Merge branch 'main' into feat/advanced-settings-slo
kdelemme 389fcc4
Merge branch 'main' into feat/advanced-settings-slo
kdelemme 4c0e028
Fix invalid state
kdelemme da345b6
Merge branch 'main' into feat/advanced-settings-slo
shahzad31 1dd3775
Update x-pack/plugins/observability_solution/slo/public/pages/slo_edi…
kdelemme 3eb4929
Merge branch 'main' into feat/advanced-settings-slo
kdelemme 27e00b0
Remove unecessary parseInt
kdelemme 9a4ce7f
Add syncField in OpenAPI spec
kdelemme ca6df89
[CI] Auto-commit changed files from 'make api-docs'
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
174 changes: 174 additions & 0 deletions
174
...ublic/pages/slo_edit/components/indicator_section/advanced_settings/advanced_settings.tsx
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,174 @@ | ||
/* | ||
* 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 { | ||
EuiAccordion, | ||
EuiCheckbox, | ||
EuiFieldNumber, | ||
EuiFlexGrid, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiFormRow, | ||
EuiIcon, | ||
EuiIconTip, | ||
EuiTitle, | ||
useGeneratedHtmlId, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import React from 'react'; | ||
import { Controller, useFormContext } from 'react-hook-form'; | ||
import { CreateSLOForm } from '../../../types'; | ||
import { SyncFieldSelector } from './sync_field_selector'; | ||
|
||
export function AdvancedSettings() { | ||
const { control, getFieldState } = useFormContext<CreateSLOForm>(); | ||
const preventBackfillCheckbox = useGeneratedHtmlId({ prefix: 'preventBackfill' }); | ||
const advancedSettingsAccordion = useGeneratedHtmlId({ prefix: 'advancedSettingsAccordion' }); | ||
|
||
return ( | ||
<EuiAccordion | ||
paddingSize="s" | ||
id={advancedSettingsAccordion} | ||
buttonContent={ | ||
<EuiFlexGroup gutterSize="s" alignItems="center" responsive={false}> | ||
<EuiFlexItem grow={false}> | ||
<EuiIcon type="controlsVertical" size="m" /> | ||
</EuiFlexItem> | ||
|
||
<EuiFlexItem> | ||
<EuiTitle size="xxs"> | ||
<h3> | ||
{i18n.translate('xpack.slo.sloEdit.settings.advancedSettingsLabel', { | ||
defaultMessage: 'Advanced settings', | ||
})} | ||
</h3> | ||
</EuiTitle> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
} | ||
> | ||
<EuiFlexGroup direction="column" gutterSize="m"> | ||
<EuiFlexGrid columns={3} gutterSize="m"> | ||
<EuiFlexItem> | ||
<SyncFieldSelector /> | ||
</EuiFlexItem> | ||
|
||
<EuiFlexItem> | ||
<EuiFormRow | ||
isInvalid={getFieldState('settings.syncDelay').invalid} | ||
label={ | ||
<span> | ||
{i18n.translate('xpack.slo.sloEdit.settings.syncDelay.label', { | ||
defaultMessage: 'Sync delay (in minutes)', | ||
})}{' '} | ||
<EuiIconTip | ||
content={i18n.translate('xpack.slo.sloEdit.settings.syncDelay.tooltip', { | ||
defaultMessage: | ||
'The time delay in minutes between the current time and the latest source data time. Increasing the value will delay any alerting. The default value is 1 minute. The minimum value is 1m and the maximum is 359m. It should always be greater then source index refresh interval.', | ||
})} | ||
position="top" | ||
/> | ||
</span> | ||
} | ||
> | ||
<Controller | ||
name="settings.syncDelay" | ||
defaultValue={1} | ||
control={control} | ||
rules={{ required: true, min: 1, max: 359 }} | ||
render={({ field: { ref, onChange, ...field }, fieldState }) => ( | ||
<EuiFieldNumber | ||
{...field} | ||
data-test-subj="sloAdvancedSettingsSyncDelay" | ||
isInvalid={fieldState.invalid} | ||
required | ||
value={field.value} | ||
min={1} | ||
max={359} | ||
step={1} | ||
onChange={(event) => onChange(event.target.value)} | ||
/> | ||
)} | ||
/> | ||
</EuiFormRow> | ||
</EuiFlexItem> | ||
|
||
<EuiFlexItem> | ||
<EuiFormRow | ||
isInvalid={getFieldState('settings.frequency').invalid} | ||
label={ | ||
<span> | ||
{i18n.translate('xpack.slo.sloEdit.settings.frequency.label', { | ||
defaultMessage: 'Frequency (in minutes)', | ||
})}{' '} | ||
<EuiIconTip | ||
content={i18n.translate('xpack.slo.sloEdit.settings.frequency.tooltip', { | ||
defaultMessage: | ||
'The interval between checks for changes in the source data. The minimum value is 1m and the maximum is 59m. The default value is 1 minute.', | ||
})} | ||
position="top" | ||
/> | ||
</span> | ||
} | ||
> | ||
<Controller | ||
name="settings.frequency" | ||
defaultValue={1} | ||
control={control} | ||
rules={{ required: true, min: 1, max: 59 }} | ||
render={({ field: { ref, onChange, ...field }, fieldState }) => ( | ||
<EuiFieldNumber | ||
{...field} | ||
data-test-subj="sloAdvancedSettingsFrequency" | ||
isInvalid={fieldState.invalid} | ||
required | ||
value={field.value} | ||
min={1} | ||
max={59} | ||
step={1} | ||
onChange={(event) => onChange(event.target.value)} | ||
/> | ||
)} | ||
/> | ||
</EuiFormRow> | ||
</EuiFlexItem> | ||
</EuiFlexGrid> | ||
|
||
<EuiFormRow isInvalid={getFieldState('settings.preventInitialBackfill').invalid}> | ||
<Controller | ||
name="settings.preventInitialBackfill" | ||
control={control} | ||
render={({ field: { ref, onChange, ...field } }) => ( | ||
<EuiCheckbox | ||
id={preventBackfillCheckbox} | ||
label={ | ||
<span> | ||
{i18n.translate('xpack.slo.sloEdit.settings.preventInitialBackfill.label', { | ||
defaultMessage: 'Prevent initial backfill of data', | ||
})}{' '} | ||
<EuiIconTip | ||
content={i18n.translate( | ||
'xpack.slo.sloEdit.settings.preventInitialBackfill.tooltip', | ||
{ | ||
defaultMessage: | ||
'Start aggregating data from the time the SLO is created, instead of backfilling data from the beginning of the time window.', | ||
} | ||
)} | ||
position="top" | ||
/> | ||
</span> | ||
} | ||
checked={Boolean(field.value)} | ||
onChange={(event: any) => onChange(event.target.checked)} | ||
/> | ||
)} | ||
/> | ||
</EuiFormRow> | ||
</EuiFlexGroup> | ||
</EuiAccordion> | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not spending too much time here since Maciej has some plan for the new overview section