-
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
[Exploratory view] Label field filters/breakdowns #113766
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
82f78a3
added breakdown/filters by label fields
shahzad31 5061ad9
update
shahzad31 1c81585
Merge branch 'master' of github.com:elastic/kibana into label-field-f…
shahzad31 0cd1203
remove duplicates
shahzad31 cf9d59c
Merge branch 'master' of github.com:elastic/kibana into label-field-f…
shahzad31 5cee9d1
fix invalid breakdown
shahzad31 a2c9165
Merge branch 'master' of github.com:elastic/kibana into label-field-f…
shahzad31 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
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
File renamed without changes.
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
67 changes: 67 additions & 0 deletions
67
...ity/public/components/shared/exploratory_view/series_editor/breakdown/label_breakdown.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,67 @@ | ||
/* | ||
* 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 { EuiComboBox, EuiFlexItem } from '@elastic/eui'; | ||
import React from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { SeriesConfig, SeriesUrl } from '../../types'; | ||
import { useAppIndexPatternContext } from '../../hooks/use_app_index_pattern'; | ||
import { useSeriesStorage } from '../../hooks/use_series_storage'; | ||
import { LABEL_FIELDS_BREAKDOWN } from '../../configurations/constants'; | ||
|
||
interface Props { | ||
seriesId: number; | ||
series: SeriesUrl; | ||
seriesConfig?: SeriesConfig; | ||
} | ||
export function LabelsBreakdown({ series, seriesId }: Props) { | ||
const { indexPattern } = useAppIndexPatternContext(series.dataType); | ||
|
||
const labelFields = indexPattern?.fields.filter((field) => field.name.startsWith('labels.')); | ||
|
||
const { setSeries } = useSeriesStorage(); | ||
|
||
const { breakdown } = series; | ||
|
||
const hasLabelBreakdown = | ||
breakdown === LABEL_FIELDS_BREAKDOWN || breakdown?.startsWith('labels.'); | ||
|
||
if (!hasLabelBreakdown) { | ||
return null; | ||
} | ||
|
||
const labelFieldOptions = labelFields?.map((field) => { | ||
return { | ||
label: field.name, | ||
value: field.name, | ||
}; | ||
}); | ||
|
||
return ( | ||
<EuiFlexItem grow={false} style={{ minWidth: 200 }}> | ||
<EuiComboBox | ||
selectedOptions={labelFieldOptions?.filter((labelField) => labelField.label === breakdown)} | ||
options={labelFieldOptions} | ||
placeholder={CHOOSE_BREAKDOWN_FIELD} | ||
onChange={(value) => { | ||
setSeries(seriesId, { | ||
...series, | ||
breakdown: value?.[0]?.label ?? LABEL_FIELDS_BREAKDOWN, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}); | ||
}} | ||
singleSelection={{ asPlainText: true }} | ||
/> | ||
</EuiFlexItem> | ||
); | ||
} | ||
|
||
export const CHOOSE_BREAKDOWN_FIELD = i18n.translate( | ||
'xpack.observability.expView.seriesBuilder.labelField', | ||
{ | ||
defaultMessage: 'Choose label field', | ||
} | ||
); |
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.
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.
Is this supposed to have a colon?