From 7fdd6925cedd7312fa9e8645f7a850f8e20588d6 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 22 Nov 2022 11:25:52 -0500 Subject: [PATCH] [8.6] [ML] Explain Log Rate Spikes: improve the display of large groups (#145609) (#145934) # Backport This will backport the following commits from `main` to `8.6`: - [[ML] Explain Log Rate Spikes: improve the display of large groups (#145609)](https://github.com/elastic/kibana/pull/145609) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Melissa Alvarez --- .../spike_analysis_table_groups.tsx | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/aiops/public/components/spike_analysis_table/spike_analysis_table_groups.tsx b/x-pack/plugins/aiops/public/components/spike_analysis_table/spike_analysis_table_groups.tsx index 51f9e38704910..ad022de63bd2c 100644 --- a/x-pack/plugins/aiops/public/components/spike_analysis_table/spike_analysis_table_groups.tsx +++ b/x-pack/plugins/aiops/public/components/spike_analysis_table/spike_analysis_table_groups.tsx @@ -41,6 +41,7 @@ const NARROW_COLUMN_WIDTH = '120px'; const EXPAND_COLUMN_WIDTH = '40px'; const ACTIONS_COLUMN_WIDTH = '60px'; const NOT_AVAILABLE = '--'; +const MAX_GROUP_BADGES = 10; const PAGINATION_SIZE_OPTIONS = [5, 10, 20, 50]; const DEFAULT_SORT_FIELD = 'pValue'; @@ -250,8 +251,11 @@ export const SpikeAnalysisGroupsTable: FC = ({ ), render: (_, { group, repeatedValues }) => { const valuesBadges = []; + const hasExtraBadges = Object.keys(group).length > MAX_GROUP_BADGES; + for (const fieldName in group) { if (group.hasOwnProperty(fieldName)) { + if (valuesBadges.length === MAX_GROUP_BADGES) break; valuesBadges.push( <> = ({ ); } } - if (Object.keys(repeatedValues).length > 0) { + if (Object.keys(repeatedValues).length > 0 || hasExtraBadges) { valuesBadges.push( <> = ({ data-test-subj="aiopsSpikeAnalysisGroupsTableColumnGroupBadge" color="hollow" > - +{Object.keys(repeatedValues).length}{' '} - + {hasExtraBadges ? ( + <> + +
+ + ) : null} + {Object.keys(repeatedValues).length > 0 ? ( + + ) : null}