Skip to content

Commit

Permalink
add some data-test-subj and fix PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Anan Zhuang <[email protected]>
  • Loading branch information
ananzh committed Dec 16, 2022
1 parent bf2f4ef commit 73a636a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ export const TableVisComponent = ({
return (({ rowIndex, columnId }) => {
const rawContent = sortedRows[rowIndex][columnId];
const colIndex = columns.findIndex((col) => col.id === columnId);
const column = columns[colIndex];
const htmlContent = column.formatter.convert(rawContent, 'html');
const htmlContent = columns[colIndex].formatter.convert(rawContent, 'html');
const formattedContent = (
/*
* Justification for dangerouslySetInnerHTML:
Expand Down Expand Up @@ -119,8 +118,7 @@ export const TableVisComponent = ({

const footerCellValue = visConfig.showTotal
? ({ columnId }: { columnId: any }) => {
const colIndex = columns.findIndex((col) => col.id === columnId);
return columns[colIndex]?.formattedTotal || null;
return columns.find((col) => col.id === columnId)?.formattedTotal || null;
}
: undefined;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const getDataGridColumns = (
cols: FormattedColumn[],
table: Table,
event: IInterpreterRenderHandlers['event'],
columnsWidth: ColumnWidth[]
columnWidths: ColumnWidth[]
) => {
const filterBucket = (rowIndex: number, columnIndex: number, negate: boolean) => {
const foramttedColumnId = cols[columnIndex].id;
Expand Down Expand Up @@ -117,7 +117,7 @@ export const getDataGridColumns = (
]
: undefined;

const initialWidth = columnsWidth.find((c) => c.colIndex === colIndex);
const initialWidth = columnWidths.find((c) => c.colIndex === colIndex);

const dataGridColumn: EuiDataGridColumn = {
id: col.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ function TableOptions({
paramName="showTotal"
value={stateParams.showTotal}
setValue={setValue}
data-test-subj="showTotal"
/>

<SelectOption
Expand All @@ -143,6 +144,7 @@ function TableOptions({
paramName="totalFunc"
value={stateParams.totalFunc}
setValue={setValue}
data-test-subj="totalFunctionOptions"
/>

<SelectOption
Expand All @@ -153,7 +155,7 @@ function TableOptions({
paramName="percentageCol"
value={stateParams.percentageCol}
setValue={setValue}
id="datatableVisualizationPercentageCol"
data-test-subj="datatableVisualizationPercentageCol"
/>
</EuiPanel>
);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/vis_type_table/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@ export interface TableUiState {
sort: SortColumn;
setSort: (sort: SortColumn) => void;
width: ColumnWidth[];
setWidth: (columnsWidth: ColumnWidth[]) => void;
setWidth: (columnWidths: ColumnWidth[]) => void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,26 +110,26 @@ export const InspectorDataGrid = ({ columns, data, dataGridAriaLabel }: Inspecto
}, [gridData, pagination]);

// Resize
const [columnsWidth, setColumnsWidth] = useState<Record<string, number>>({});
const [columnWidths, setColumnWidths] = useState<Record<string, number>>({});

const onColumnResize: EuiDataGridProps['onColumnResize'] = useCallback(
({ columnId, width }) => {
setColumnsWidth({
...columnsWidth,
setColumnWidths({
...columnWidths,
[columnId]: width,
});
},
[columnsWidth]
[columnWidths]
);

return (
<EuiDataGrid
aria-label={dataGridAriaLabel}
columns={columns.map((column) => {
if (columnsWidth[column.id]) {
if (columnWidths[column.id]) {
return {
...column,
initialWidth: columnsWidth[column.id],
initialWidth: columnWidths[column.id],
};
}
return column;
Expand Down

0 comments on commit 73a636a

Please sign in to comment.