Skip to content

Commit

Permalink
fix: make header sticky for table panel (#5892)
Browse files Browse the repository at this point in the history
* fix: make header sticky for table panel

* fix: added sticky prop conditionally and updated test cases

* fix: added a smaller scrollbar

---------

Co-authored-by: Srikanth Chekuri <[email protected]>
  • Loading branch information
SagarRajput-7 and srikanthccv committed Sep 9, 2024
1 parent c6ba2b4 commit b8d228a
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 20 deletions.
1 change: 1 addition & 0 deletions frontend/src/container/GridPanelSwitch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const GridPanelSwitch = forwardRef<
data: panelData,
query,
thresholds,
sticky: true,
},
[PANEL_TYPES.LIST]: null,
[PANEL_TYPES.PIE]: null,
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/container/GridTableComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function GridTableComponent({
thresholds,
columnUnits,
tableProcessedDataRef,
sticky,
...props
}: GridTableComponentProps): JSX.Element {
const { t } = useTranslation(['valueGraph']);
Expand Down Expand Up @@ -146,6 +147,7 @@ function GridTableComponent({
loading={false}
columns={newColumnData}
dataSource={dataSource}
sticky={sticky}
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
/>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/container/GridTableComponent/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type GridTableComponentProps = {
thresholds?: ThresholdProps[];
columnUnits?: ColumnUnit;
tableProcessedDataRef?: React.MutableRefObject<RowData[]>;
sticky?: TableProps<RowData>['sticky'];
} & Pick<LogsExplorerTableProps, 'data'> &
Omit<TableProps<RowData>, 'columns' | 'dataSource'>;

Expand Down
1 change: 1 addition & 0 deletions frontend/src/container/LogsExplorerTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function LogsExplorerTable({
queryTableData={data}
loading={isLoading}
rootClassName="logs-table"
sticky
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ function TopOperationMetrics(): JSX.Element {
loading={isLoading}
renderColumnCell={renderColumnCell}
downloadOption={topOperationMetricsDownloadOptions}
sticky
/>
);
}
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/container/PanelWrapper/TablePanelWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PANEL_TYPES } from 'constants/queryBuilder';
import GridTableComponent from 'container/GridTableComponent';
import { GRID_TABLE_CONFIG } from 'container/GridTableComponent/config';

Expand All @@ -18,6 +19,7 @@ function TablePanelWrapper({
thresholds={thresholds}
columnUnits={widget.columnUnits}
tableProcessedDataRef={tableProcessedDataRef}
sticky={widget.panelTypes === PANEL_TYPES.TABLE}
// eslint-disable-next-line react/jsx-props-no-spreading
{...GRID_TABLE_CONFIG}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,13 @@ exports[`Table panel wrappper tests table should render fine with the query resp
class="ant-table-container"
>
<div
class="ant-table-content"
style="overflow-x: auto; overflow-y: hidden;"
class="ant-table-header ant-table-sticky-holder"
style="overflow: hidden; top: 0px;"
>
<table
style="width: auto; min-width: 100%; table-layout: fixed;"
style="table-layout: fixed; visibility: hidden;"
>
<colgroup>
<col
style="width: 145px;"
/>
<col
style="width: 145px;"
/>
</colgroup>
<colgroup />
<thead
class="ant-table-thead"
>
Expand Down Expand Up @@ -222,6 +215,23 @@ exports[`Table panel wrappper tests table should render fine with the query resp
</th>
</tr>
</thead>
</table>
</div>
<div
class="ant-table-body"
style="overflow-x: auto; overflow-y: hidden;"
>
<table
style="width: auto; min-width: 100%; table-layout: fixed;"
>
<colgroup>
<col
style="width: 145px;"
/>
<col
style="width: 145px;"
/>
</colgroup>
<tbody
class="ant-table-tbody"
>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/container/QueryTable/QueryTable.intefaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ export type QueryTableProps = Omit<
downloadOption?: DownloadOptions;
columns?: ColumnsType<RowData>;
dataSource?: RowData[];
sticky?: TableProps<RowData>['sticky'];
};
24 changes: 15 additions & 9 deletions frontend/src/container/QueryTable/QueryTable.styles.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
.query-table {
position: relative;
height: inherit;
.query-table--download {
position: absolute;
top: 15px;
right: 0px;
z-index: 1;
}
}
position: relative;
height: inherit;
.query-table--download {
position: absolute;
top: 15px;
right: 0px;
z-index: 1;
}

.ant-table {
&::-webkit-scrollbar {
width: 0.1rem;
}
}
}
2 changes: 2 additions & 0 deletions frontend/src/container/QueryTable/QueryTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function QueryTable({
downloadOption,
columns,
dataSource,
sticky,
...props
}: QueryTableProps): JSX.Element {
const { isDownloadEnabled = false, fileName = '' } = downloadOption || {};
Expand Down Expand Up @@ -71,6 +72,7 @@ export function QueryTable({
dataSource={newDataSource}
scroll={{ x: true }}
pagination={paginationConfig}
sticky={sticky}
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
/>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/container/TracesExplorer/TableView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function TableView(): JSX.Element {
query={stagedQuery || initialQueriesMap.traces}
queryTableData={data?.payload?.data?.newResult?.data?.result || []}
loading={isLoading}
sticky
/>
</Space.Compact>
);
Expand Down

0 comments on commit b8d228a

Please sign in to comment.