-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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' into severity_column
- Loading branch information
Showing
109 changed files
with
2,739 additions
and
15,466 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
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
64 changes: 64 additions & 0 deletions
64
x-pack/plugins/observability/public/pages/alerts/filter_for_value.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,64 @@ | ||
/* | ||
* 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 React, { useCallback, useMemo } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
export const filterForValueButtonLabel = i18n.translate( | ||
'xpack.observability.hoverActions.filterForValueButtonLabel', | ||
{ | ||
defaultMessage: 'Filter for value', | ||
} | ||
); | ||
|
||
import { EuiButtonIcon, EuiButtonEmpty } from '@elastic/eui'; | ||
|
||
interface FilterForValueProps { | ||
Component?: typeof EuiButtonEmpty | typeof EuiButtonIcon; | ||
field: string; | ||
value: string[] | string | null | undefined; | ||
addToQuery: (value: string) => void; | ||
} | ||
|
||
const FilterForValueButton: React.FC<FilterForValueProps> = React.memo( | ||
({ Component, field, value, addToQuery }) => { | ||
const text = useMemo(() => `${field}${value != null ? `: "${value}"` : ''}`, [field, value]); | ||
const onClick = useCallback(() => { | ||
addToQuery(text); | ||
}, [text, addToQuery]); | ||
const button = useMemo( | ||
() => | ||
Component ? ( | ||
<Component | ||
aria-label={filterForValueButtonLabel} | ||
data-test-subj="filter-for-value" | ||
iconType="plusInCircle" | ||
onClick={onClick} | ||
title={filterForValueButtonLabel} | ||
> | ||
{filterForValueButtonLabel} | ||
</Component> | ||
) : ( | ||
<EuiButtonIcon | ||
aria-label={filterForValueButtonLabel} | ||
className="timelines__hoverActionButton" | ||
data-test-subj="filter-for-value" | ||
iconSize="s" | ||
iconType="plusInCircle" | ||
onClick={onClick} | ||
/> | ||
), | ||
[Component, onClick] | ||
); | ||
return button; | ||
} | ||
); | ||
|
||
FilterForValueButton.displayName = 'FilterForValueButton'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export { FilterForValueButton as default }; |
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.