diff --git a/web-common/src/features/dashboards/pivot/pivot-data-store.ts b/web-common/src/features/dashboards/pivot/pivot-data-store.ts index 47b9f3cbb19..5a70b37826a 100644 --- a/web-common/src/features/dashboards/pivot/pivot-data-store.ts +++ b/web-common/src/features/dashboards/pivot/pivot-data-store.ts @@ -170,6 +170,7 @@ export function createTableCellQuery( totalsRow: PivotDataRow, rowDimensionValues: string[], ) { + if (!rowDimensionValues.length) return readable(null); let allDimensions = config.colDimensionNames; if (anchorDimension) { allDimensions = config.colDimensionNames.concat([anchorDimension]); @@ -376,8 +377,9 @@ function createPivotDataStore(ctx: StateManagers): PivotDataStore { ); } - const displayTotalsRow = - rowDimensionNames.length && measureNames.length; + const displayTotalsRow = Boolean( + rowDimensionNames.length && measureNames.length, + ); if ( (rowDimensionNames.length || colDimensionNames.length) && measureNames.length @@ -430,18 +432,6 @@ function createPivotDataStore(ctx: StateManagers): PivotDataStore { const rowDimensionValues = rowDimensionAxes?.data?.[anchorDimension] || []; - if (rowDimensionValues.length === 0 && rowPage > 1) { - return axesSet({ - isFetching: false, - data: lastPivotData, - columnDef: lastPivotColumnDef, - assembled: true, - totalColumns: lastTotalColumns, - totalsRowData: displayTotalsRow ? totalsRowData : undefined, - reachedEndForRowData: true, - }); - } - const totalColumns = getTotalColumnCount(totalsRowData); const axesRowTotals = @@ -585,12 +575,15 @@ function createPivotDataStore(ctx: StateManagers): PivotDataStore { lastPivotColumnDef = columnDef; lastTotalColumns = totalColumns; + const reachedEndForRowData = + rowDimensionValues.length === 0 && rowPage > 1; return { isFetching: false, data: tableDataExpanded, columnDef, assembled: true, totalColumns, + reachedEndForRowData, totalsRowData: displayTotalsRow ? totalsRowData : undefined, diff --git a/web-common/src/features/dashboards/pivot/pivot-expansion.ts b/web-common/src/features/dashboards/pivot/pivot-expansion.ts index d7ae1b480e0..53393e61ae0 100644 --- a/web-common/src/features/dashboards/pivot/pivot-expansion.ts +++ b/web-common/src/features/dashboards/pivot/pivot-expansion.ts @@ -322,6 +322,7 @@ export function addExpandedDataToPivot( columnDimensionAxes, skeletonSubTable, expandedRowData?.data, + true, ); } diff --git a/web-common/src/features/dashboards/pivot/pivot-table-transformations.ts b/web-common/src/features/dashboards/pivot/pivot-table-transformations.ts index 93b82dc044e..4e4b7c8e935 100644 --- a/web-common/src/features/dashboards/pivot/pivot-table-transformations.ts +++ b/web-common/src/features/dashboards/pivot/pivot-table-transformations.ts @@ -49,10 +49,11 @@ export function reduceTableCellDataIntoRows( columnDimensionAxes: Record, tableData: PivotDataRow[], cellData: V1MetricsViewAggregationResponseDataItem[], + isExpanded = false, ) { const colDimensionNames = config.colDimensionNames; const rowPage = config.pivot.rowPage; - const rowOffset = (rowPage - 1) * NUM_ROWS_PER_PAGE; + const rowOffset = isExpanded ? 0 : (rowPage - 1) * NUM_ROWS_PER_PAGE; /** * Create a map of row dimension values to their index in the row dimension axes.