-
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
[ML] Add index pattern management to index Data Visualizer #101316
Merged
qn895
merged 18 commits into
elastic:master
from
qn895:ml-move-index-data-visualizer-part-2
Jun 23, 2021
Merged
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
15abdec
[ML] Add index pattern editor flyout
qn895 63f0434
[ML] Add indexPatternField editor plugin as opt dependency
qn895 e5385bd
[ML] Remove lens from ML's dependency
qn895 f5e9c37
Merge branch 'master' into ml-move-index-data-visualizer-part-2
kibanamachine 32bd10b
Merge remote-tracking branch 'upstream/master' into ml-move-index-dat…
qn895 a2eed85
[ML] Fix custom display name cause field to be missing
qn895 1afeb8a
[ML] Add delete option
qn895 c8004f2
[ML] Fix aggregatableFields logic
qn895 d68dcfb
Merge remote-tracking branch 'upstream/master' into ml-move-index-dat…
qn895 3a5950f
[ML] Add functional tests
qn895 4c74b9b
[ML] Fix labels & consolidate addRuntimeFields
qn895 c6edebb
Merge remote-tracking branch 'upstream/master' into ml-move-index-dat…
qn895 40505a3
[ML] Add tooltip to show or hide distributions
qn895 38dbf37
Merge remote-tracking branch 'upstream/master' into ml-move-index-dat…
qn895 036a727
Merge remote-tracking branch 'upstream/master' into ml-move-index-dat…
qn895 dcd6cfa
Consolidate refreshPage
qn895 6c51e92
[ML] Fix tests
qn895 7279583
Merge branch 'master' into ml-move-index-data-visualizer-part-2
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,19 +7,31 @@ | |
|
||
import { i18n } from '@kbn/i18n'; | ||
import { Action } from '@elastic/eui/src/components/basic_table/action_types'; | ||
import { MutableRefObject } from 'react'; | ||
import { getCompatibleLensDataType, getLensAttributes } from './lens_utils'; | ||
import { IndexPattern } from '../../../../../../../../../src/plugins/data/common/index_patterns/index_patterns'; | ||
import { CombinedQuery } from '../../../../index_data_visualizer/types/combined_query'; | ||
import { FieldVisConfig } from '../../stats_table/types'; | ||
import { LensPublicStart } from '../../../../../../../lens/public'; | ||
import { DataVisualizerKibanaReactContextValue } from '../../../../kibana_context'; | ||
import { | ||
dataVisualizerRefresh$, | ||
Refresh, | ||
} from '../../../../index_data_visualizer/services/timefilter_refresh_service'; | ||
|
||
export function getActions( | ||
indexPattern: IndexPattern, | ||
lensPlugin: LensPublicStart, | ||
combinedQuery: CombinedQuery | ||
services: DataVisualizerKibanaReactContextValue['services'], | ||
combinedQuery: CombinedQuery, | ||
actionFlyoutRef: MutableRefObject<(() => void | undefined) | undefined> | ||
): Array<Action<FieldVisConfig>> { | ||
const canUseLensEditor = lensPlugin.canUseEditor(); | ||
return [ | ||
{ | ||
const { lens: lensPlugin, indexPatternFieldEditor } = services; | ||
|
||
const actions: Array<Action<FieldVisConfig>> = []; | ||
|
||
// Navigate to Lens with prefilled chart for data field | ||
if (lensPlugin !== undefined) { | ||
const canUseLensEditor = lensPlugin?.canUseEditor(); | ||
actions.push({ | ||
name: i18n.translate('xpack.dataVisualizer.index.dataGrid.exploreInLensTitle', { | ||
defaultMessage: 'Explore in Lens', | ||
}), | ||
|
@@ -40,6 +52,66 @@ export function getActions( | |
} | ||
}, | ||
'data-test-subj': 'dataVisualizerActionViewInLensButton', | ||
}, | ||
]; | ||
}); | ||
} | ||
|
||
// Allow to edit index pattern field | ||
if (indexPatternFieldEditor?.userPermissions.editIndexPattern()) { | ||
actions.push({ | ||
name: i18n.translate('xpack.dataVisualizer.index.dataGrid.editIndexPatternFieldTitle', { | ||
defaultMessage: 'Edit index pattern field', | ||
}), | ||
description: i18n.translate( | ||
'xpack.dataVisualizer.index.dataGrid.editIndexPatternFieldDescription', | ||
{ | ||
defaultMessage: 'Edit index pattern field', | ||
} | ||
), | ||
type: 'icon', | ||
icon: 'indexEdit', | ||
onClick: (item: FieldVisConfig) => { | ||
actionFlyoutRef.current = indexPatternFieldEditor?.openEditor({ | ||
ctx: { indexPattern }, | ||
fieldName: item.fieldName, | ||
onSave: () => { | ||
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. nit, 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. Updated here dcd6cfa |
||
const refresh: Refresh = { | ||
lastRefresh: Date.now(), | ||
}; | ||
dataVisualizerRefresh$.next(refresh); | ||
}, | ||
}); | ||
}, | ||
'data-test-subj': 'dataVisualizerActionEditIndexPatternFieldButton', | ||
}); | ||
actions.push({ | ||
name: i18n.translate('xpack.dataVisualizer.index.dataGrid.deleteIndexPatternFieldTitle', { | ||
defaultMessage: 'Delete index pattern field', | ||
}), | ||
description: i18n.translate( | ||
'xpack.dataVisualizer.index.dataGrid.deleteIndexPatternFieldDescription', | ||
{ | ||
defaultMessage: 'Delete index pattern field', | ||
} | ||
), | ||
type: 'icon', | ||
icon: 'trash', | ||
available: (item: FieldVisConfig) => { | ||
return item.deletable === true; | ||
}, | ||
onClick: (item: FieldVisConfig) => { | ||
actionFlyoutRef.current = indexPatternFieldEditor?.openDeleteModal({ | ||
ctx: { indexPattern }, | ||
fieldName: item.fieldName!, | ||
onDelete: () => { | ||
const refresh: Refresh = { | ||
lastRefresh: Date.now(), | ||
}; | ||
dataVisualizerRefresh$.next(refresh); | ||
}, | ||
}); | ||
}, | ||
'data-test-subj': 'dataVisualizerActionDeleteIndexPatternFieldButton', | ||
}); | ||
} | ||
return actions; | ||
} |
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
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 see in Discover you get the option to delete runtime fields that have been added to the index pattern? Did you look into providing that functionality? Not a requirement for this PR, but just wondered how much work that would involve?
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.
Note as far I'm aware, the delete action should only be added for runtime fields defined in the index pattern.
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.
Added the delete index pattern field option here if it's a runtime field and if user has edit index pattern permission. Note that the current EUI behavior automatically makes it a dropdown menu if there's > 2 actions. This seems to be a strict EUI guideline so I think we should revisit where would be the best place for the

delete
buttonThere 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 think this looks ok, and follows the EUI guidelines with the ellipses icon used when there are more than 2 actions.