From 1f5666f8ef2da361c80d9f6f6f8cc85fd19b0eee Mon Sep 17 00:00:00 2001 From: Melissa Date: Tue, 10 Jan 2023 11:36:24 -0700 Subject: [PATCH] use euiIconTip to mark unique pairs --- x-pack/packages/ml/agg_utils/src/types.ts | 1 + .../spike_analysis_table.tsx | 32 +++++++++++++++++++ .../spike_analysis_table_groups.tsx | 19 ++++++----- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/x-pack/packages/ml/agg_utils/src/types.ts b/x-pack/packages/ml/agg_utils/src/types.ts index a2c0d9f9a1569..5cebd7613765b 100644 --- a/x-pack/packages/ml/agg_utils/src/types.ts +++ b/x-pack/packages/ml/agg_utils/src/types.ts @@ -68,6 +68,7 @@ export interface ChangePoint extends FieldValuePair { pValue: number | null; normalizedScore: number; histogram?: ChangePointHistogramItem[]; + unique?: boolean; } /** diff --git a/x-pack/plugins/aiops/public/components/spike_analysis_table/spike_analysis_table.tsx b/x-pack/plugins/aiops/public/components/spike_analysis_table/spike_analysis_table.tsx index bc71b0042d4e1..aaf5b8e523dca 100644 --- a/x-pack/plugins/aiops/public/components/spike_analysis_table/spike_analysis_table.tsx +++ b/x-pack/plugins/aiops/public/components/spike_analysis_table/spike_analysis_table.tsx @@ -14,6 +14,7 @@ import { EuiBasicTable, EuiBasicTableColumn, EuiIcon, + EuiIconTip, EuiTableSortingType, EuiToolTip, } from '@elastic/eui'; @@ -34,6 +35,7 @@ import { useSpikeAnalysisTableRowContext } from './spike_analysis_table_row_prov const NARROW_COLUMN_WIDTH = '120px'; const ACTIONS_COLUMN_WIDTH = '60px'; +const UNIQUE_COLUMN_WIDTH = '40px'; const NOT_AVAILABLE = '--'; const PAGINATION_SIZE_OPTIONS = [5, 10, 20, 50]; @@ -50,12 +52,14 @@ interface SpikeAnalysisTableProps { changePoints: ChangePoint[]; dataViewId?: string; loading: boolean; + isExpandedRow?: boolean; } export const SpikeAnalysisTable: FC = ({ changePoints, dataViewId, loading, + isExpandedRow, }) => { const euiTheme = useEuiTheme(); const primaryBackgroundColor = useEuiBackgroundColor('primary'); @@ -278,6 +282,34 @@ export const SpikeAnalysisTable: FC = ({ }, ]; + if (isExpandedRow === true) { + columns.unshift({ + 'data-test-subj': 'aiopsSpikeAnalysisTableColumnUnique', + width: UNIQUE_COLUMN_WIDTH, + field: 'unique', + name: '', + render: (_, { unique }) => { + if (unique) { + return ( + + ); + } + return ''; + }, + sortable: false, + valign: 'top', + }); + } + const onChange = useCallback((tableSettings) => { const { index, size } = tableSettings.page; const { field, direction } = tableSettings.sort; 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 0a394ef2adee9..5b3946a5f4dab 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 @@ -84,14 +84,13 @@ export const SpikeAnalysisGroupsTable: FC = ({ useSpikeAnalysisTableRowContext(); const pushExpandedTableItem = ( - expandedTableItems: FieldValuePair[], + expandedTableItems: ChangePoint[], items: FieldValuePair[], - appendString?: string + unique = false ) => { for (const groupItem of items) { const { fieldName, fieldValue } = groupItem; - - expandedTableItems.push({ + const itemToPush = { ...(changePoints.find( (changePoint) => (changePoint.fieldName === fieldName || @@ -100,8 +99,11 @@ export const SpikeAnalysisGroupsTable: FC = ({ changePoint.fieldValue === `${fieldValue}.keyword`) ) ?? {}), fieldName: `${fieldName}`, - fieldValue: `${fieldValue} ${appendString ? appendString : ''}`, - }); + fieldValue: `${fieldValue}`, + unique, + } as ChangePoint; + + expandedTableItems.push(itemToPush); } return expandedTableItems; }; @@ -112,9 +114,9 @@ export const SpikeAnalysisGroupsTable: FC = ({ delete itemIdToExpandedRowMapValues[item.id]; } else { const { group, repeatedValues } = item; - const expandedTableItems: FieldValuePair[] = []; + const expandedTableItems: ChangePoint[] = []; - pushExpandedTableItem(expandedTableItems, group, '*'); + pushExpandedTableItem(expandedTableItems, group, true); pushExpandedTableItem(expandedTableItems, repeatedValues); itemIdToExpandedRowMapValues[item.id] = ( @@ -122,6 +124,7 @@ export const SpikeAnalysisGroupsTable: FC = ({ changePoints={expandedTableItems as ChangePoint[]} loading={loading} dataViewId={dataViewId} + isExpandedRow /> ); }