Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions packages/iris-grid/src/IrisGrid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,53 @@ describe('handleResizeColumn', () => {
});
});

describe('handleRollupChange', () => {
it('un-hides group-by columns', () => {
const columns = irisGridTestUtils.makeColumns(3);
const irisGrid = makeComponent(
irisGridTestUtils.makeModel(irisGridTestUtils.makeTable({ columns }))
);
const { metricCalculator } = irisGrid.state;
const resetColumnWidth = jest.spyOn(metricCalculator, 'resetColumnWidth');

const groupByNames = [columns[1].name, columns[2].name];

act(() => {
irisGrid.handleRollupChange({
columns: groupByNames,
showConstituents: true,
showNonAggregatedColumns: true,
Comment thread
vbabich marked this conversation as resolved.
});
});

expect(resetColumnWidth).toHaveBeenCalledWith(1);
expect(resetColumnWidth).toHaveBeenCalledWith(2);
expect(irisGrid.state.rollupConfig?.columns).toEqual(groupByNames);
Comment on lines +269 to +292
});

it('does not call resetColumnWidth when there are no group-by columns', () => {
const irisGrid = makeComponent(
irisGridTestUtils.makeModel(
irisGridTestUtils.makeTable({
columns: irisGridTestUtils.makeColumns(3),
})
)
);
const { metricCalculator } = irisGrid.state;
const resetColumnWidth = jest.spyOn(metricCalculator, 'resetColumnWidth');

act(() => {
irisGrid.handleRollupChange({
columns: [],
showConstituents: true,
showNonAggregatedColumns: true,
});
});

expect(resetColumnWidth).not.toHaveBeenCalled();
});
});

// auto resize -> reset user width and set calculated width to content width
// manual resize -> set user width to content width
describe('handleResizeAllColumns', () => {
Expand Down
13 changes: 12 additions & 1 deletion packages/iris-grid/src/IrisGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3797,8 +3797,19 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
handleRollupChange(rollupConfig: UIRollupConfig): void {
log.info('Rollup change', rollupConfig);

// Un-hide group-by columns for the rollup
if (rollupConfig?.columns != null && rollupConfig.columns.length > 0) {
const { model } = this.props;
const { metricCalculator } = this.state;
rollupConfig.columns.forEach(name => {
const modelIndex = model.getColumnIndexByName(name);
if (modelIndex != null) {
metricCalculator.resetColumnWidth(modelIndex);
}
});
Comment thread
vbabich marked this conversation as resolved.
Outdated
}

this.resetGridViewState();
this.showAllColumns();
this.clearAllFilters();

this.startLoading(
Expand Down
Loading