Skip to content

Commit

Permalink
feat(QueryResultTable): display row number (#1714)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemmufazalov authored Nov 27, 2024
1 parent 9b3f779 commit eba72a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/QueryResultTable/QueryResultTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const TABLE_SETTINGS: Settings = {
...DEFAULT_TABLE_SETTINGS,
stripedRows: true,
sortable: false,
displayIndices: true,
};

export const b = cn('ydb-query-result-table');
Expand Down Expand Up @@ -69,6 +70,9 @@ const prepareGenericColumns = (data: KeyValueRow[]) => {

const getRowIndex = (_: unknown, index: number) => index;

// Display row number in format 1-10 instead of 0-9
const getVisibleRowIndex = (_: unknown, index: number) => index + 1;

interface QueryResultTableProps
extends Omit<ResizeableDataTableProps<KeyValueRow>, 'data' | 'columns'> {
data?: KeyValueRow[];
Expand Down Expand Up @@ -100,6 +104,7 @@ export const QueryResultTable = (props: QueryResultTableProps) => {
settings={TABLE_SETTINGS}
// prevent accessing row.id in case it is present but is not the PK (i.e. may repeat)
rowKey={getRowIndex}
visibleRowIndex={getVisibleRowIndex}
{...restProps}
/>
);
Expand Down
1 change: 1 addition & 0 deletions src/styles/mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
max-width: 600px;

cursor: pointer;
vertical-align: middle;
white-space: nowrap;
text-overflow: ellipsis;
}
Expand Down

0 comments on commit eba72a0

Please sign in to comment.