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.
Merge branch 'master' of github.com:elastic/kibana into np/watcher/ou…
…t-of-legacy * 'master' of github.com:elastic/kibana: [Watcher] Add support for additional watch action statuses (elastic#55092) [ML] Fix entity controls update. (elastic#55524) [ML] Fixing ML's watcher integration (elastic#55439) [ML] Fixes permissions checks for data visualizer create job links (elastic#55431) [SearchProfiler] Move out of legacy (elastic#55331) # Conflicts: # x-pack/plugins/watcher/server/models/action_status/action_status.js
- Loading branch information
Showing
114 changed files
with
581 additions
and
571 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
133 changes: 133 additions & 0 deletions
133
...s/ml/public/application/jobs/jobs_list/components/create_watch_flyout/select_severity.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,133 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
/* | ||
* React component for rendering a select element with threshold levels. | ||
* This is basically a copy of SelectSeverity in public/application/components/controls/select_severity | ||
* but which stores its state internally rather than in the appState | ||
*/ | ||
import React, { Fragment, FC, useState } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
|
||
import { EuiHealth, EuiSpacer, EuiSuperSelect, EuiText } from '@elastic/eui'; | ||
|
||
import { getSeverityColor } from '../../../../../../common/util/anomaly_utils'; | ||
|
||
const warningLabel = i18n.translate('xpack.ml.controls.selectSeverity.warningLabel', { | ||
defaultMessage: 'warning', | ||
}); | ||
const minorLabel = i18n.translate('xpack.ml.controls.selectSeverity.minorLabel', { | ||
defaultMessage: 'minor', | ||
}); | ||
const majorLabel = i18n.translate('xpack.ml.controls.selectSeverity.majorLabel', { | ||
defaultMessage: 'major', | ||
}); | ||
const criticalLabel = i18n.translate('xpack.ml.controls.selectSeverity.criticalLabel', { | ||
defaultMessage: 'critical', | ||
}); | ||
|
||
const optionsMap = { | ||
[warningLabel]: 0, | ||
[minorLabel]: 25, | ||
[majorLabel]: 50, | ||
[criticalLabel]: 75, | ||
}; | ||
|
||
interface TableSeverity { | ||
val: number; | ||
display: string; | ||
color: string; | ||
} | ||
|
||
export const SEVERITY_OPTIONS: TableSeverity[] = [ | ||
{ | ||
val: 0, | ||
display: warningLabel, | ||
color: getSeverityColor(0), | ||
}, | ||
{ | ||
val: 25, | ||
display: minorLabel, | ||
color: getSeverityColor(25), | ||
}, | ||
{ | ||
val: 50, | ||
display: majorLabel, | ||
color: getSeverityColor(50), | ||
}, | ||
{ | ||
val: 75, | ||
display: criticalLabel, | ||
color: getSeverityColor(75), | ||
}, | ||
]; | ||
|
||
function optionValueToThreshold(value: number) { | ||
// Get corresponding threshold object with required display and val properties from the specified value. | ||
let threshold = SEVERITY_OPTIONS.find(opt => opt.val === value); | ||
|
||
// Default to warning if supplied value doesn't map to one of the options. | ||
if (threshold === undefined) { | ||
threshold = SEVERITY_OPTIONS[0]; | ||
} | ||
|
||
return threshold; | ||
} | ||
|
||
const TABLE_SEVERITY_DEFAULT = SEVERITY_OPTIONS[0]; | ||
|
||
const getSeverityOptions = () => | ||
SEVERITY_OPTIONS.map(({ color, display, val }) => ({ | ||
value: display, | ||
inputDisplay: ( | ||
<Fragment> | ||
<EuiHealth color={color} style={{ lineHeight: 'inherit' }}> | ||
{display} | ||
</EuiHealth> | ||
</Fragment> | ||
), | ||
dropdownDisplay: ( | ||
<Fragment> | ||
<EuiHealth color={color} style={{ lineHeight: 'inherit' }}> | ||
{display} | ||
</EuiHealth> | ||
<EuiSpacer size="xs" /> | ||
<EuiText size="xs" color="subdued"> | ||
<p className="euiTextColor--subdued"> | ||
<FormattedMessage | ||
id="xpack.ml.controls.selectSeverity.scoreDetailsDescription" | ||
defaultMessage="score {value} and above" | ||
values={{ value: val }} | ||
/> | ||
</p> | ||
</EuiText> | ||
</Fragment> | ||
), | ||
})); | ||
|
||
interface Props { | ||
onChange: (sev: TableSeverity) => void; | ||
} | ||
|
||
export const SelectSeverity: FC<Props> = ({ onChange }) => { | ||
const [severity, setSeverity] = useState(TABLE_SEVERITY_DEFAULT); | ||
|
||
const onSeverityChange = (valueDisplay: string) => { | ||
const option = optionValueToThreshold(optionsMap[valueDisplay]); | ||
setSeverity(option); | ||
onChange(option); | ||
}; | ||
|
||
return ( | ||
<EuiSuperSelect | ||
hasDividers | ||
options={getSeverityOptions()} | ||
valueOfSelected={severity.display} | ||
onChange={onSeverityChange} | ||
/> | ||
); | ||
}; |
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 was deleted.
Oops, something went wrong.
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
File renamed without changes.
Oops, something went wrong.