-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* filter for value * code clean up * fix i18n tests * fix type errors * revert changes to reason field to make reason field clickable again * [RAC Observability] fix reason field * fix type issues * filter my kibana.alert. status on load (will refactor) * refactor filter for alert status on load * remove rest params * fix eslint errors * hard code alert status for now, will be fixed in another PR * move filter_for button in a separate file * fix errors * comply with kibana i18n guideines * simpler implementation for default filtering * fix syntax error * fix type errors * fix eslint errors * fix eslint errors Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: mgiota <giota85@gmail.com>
- Loading branch information
1 parent
5b2da7e
commit 6910a2e
Showing
5 changed files
with
119 additions
and
59 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
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
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