fix: make header sticky for table panel (#5892)

* 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 <srikanth.chekuri92@gmail.com>
This commit is contained in:
SagarRajput-7 2024-09-09 22:05:05 +05:30 committed by GitHub
parent c6ba2b4598
commit b8d228a339
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 48 additions and 20 deletions

View File

@ -40,6 +40,7 @@ const GridPanelSwitch = forwardRef<
data: panelData, data: panelData,
query, query,
thresholds, thresholds,
sticky: true,
}, },
[PANEL_TYPES.LIST]: null, [PANEL_TYPES.LIST]: null,
[PANEL_TYPES.PIE]: null, [PANEL_TYPES.PIE]: null,

View File

@ -23,6 +23,7 @@ function GridTableComponent({
thresholds, thresholds,
columnUnits, columnUnits,
tableProcessedDataRef, tableProcessedDataRef,
sticky,
...props ...props
}: GridTableComponentProps): JSX.Element { }: GridTableComponentProps): JSX.Element {
const { t } = useTranslation(['valueGraph']); const { t } = useTranslation(['valueGraph']);
@ -146,6 +147,7 @@ function GridTableComponent({
loading={false} loading={false}
columns={newColumnData} columns={newColumnData}
dataSource={dataSource} dataSource={dataSource}
sticky={sticky}
// eslint-disable-next-line react/jsx-props-no-spreading // eslint-disable-next-line react/jsx-props-no-spreading
{...props} {...props}
/> />

View File

@ -13,6 +13,7 @@ export type GridTableComponentProps = {
thresholds?: ThresholdProps[]; thresholds?: ThresholdProps[];
columnUnits?: ColumnUnit; columnUnits?: ColumnUnit;
tableProcessedDataRef?: React.MutableRefObject<RowData[]>; tableProcessedDataRef?: React.MutableRefObject<RowData[]>;
sticky?: TableProps<RowData>['sticky'];
} & Pick<LogsExplorerTableProps, 'data'> & } & Pick<LogsExplorerTableProps, 'data'> &
Omit<TableProps<RowData>, 'columns' | 'dataSource'>; Omit<TableProps<RowData>, 'columns' | 'dataSource'>;

View File

@ -30,6 +30,7 @@ function LogsExplorerTable({
queryTableData={data} queryTableData={data}
loading={isLoading} loading={isLoading}
rootClassName="logs-table" rootClassName="logs-table"
sticky
/> />
); );
} }

View File

@ -114,6 +114,7 @@ function TopOperationMetrics(): JSX.Element {
loading={isLoading} loading={isLoading}
renderColumnCell={renderColumnCell} renderColumnCell={renderColumnCell}
downloadOption={topOperationMetricsDownloadOptions} downloadOption={topOperationMetricsDownloadOptions}
sticky
/> />
); );
} }

View File

@ -1,3 +1,4 @@
import { PANEL_TYPES } from 'constants/queryBuilder';
import GridTableComponent from 'container/GridTableComponent'; import GridTableComponent from 'container/GridTableComponent';
import { GRID_TABLE_CONFIG } from 'container/GridTableComponent/config'; import { GRID_TABLE_CONFIG } from 'container/GridTableComponent/config';
@ -18,6 +19,7 @@ function TablePanelWrapper({
thresholds={thresholds} thresholds={thresholds}
columnUnits={widget.columnUnits} columnUnits={widget.columnUnits}
tableProcessedDataRef={tableProcessedDataRef} tableProcessedDataRef={tableProcessedDataRef}
sticky={widget.panelTypes === PANEL_TYPES.TABLE}
// eslint-disable-next-line react/jsx-props-no-spreading // eslint-disable-next-line react/jsx-props-no-spreading
{...GRID_TABLE_CONFIG} {...GRID_TABLE_CONFIG}
/> />

View File

@ -70,20 +70,13 @@ exports[`Table panel wrappper tests table should render fine with the query resp
class="ant-table-container" class="ant-table-container"
> >
<div <div
class="ant-table-content" class="ant-table-header ant-table-sticky-holder"
style="overflow-x: auto; overflow-y: hidden;" style="overflow: hidden; top: 0px;"
> >
<table <table
style="width: auto; min-width: 100%; table-layout: fixed;" style="table-layout: fixed; visibility: hidden;"
> >
<colgroup> <colgroup />
<col
style="width: 145px;"
/>
<col
style="width: 145px;"
/>
</colgroup>
<thead <thead
class="ant-table-thead" class="ant-table-thead"
> >
@ -222,6 +215,23 @@ exports[`Table panel wrappper tests table should render fine with the query resp
</th> </th>
</tr> </tr>
</thead> </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 <tbody
class="ant-table-tbody" class="ant-table-tbody"
> >

View File

@ -18,4 +18,5 @@ export type QueryTableProps = Omit<
downloadOption?: DownloadOptions; downloadOption?: DownloadOptions;
columns?: ColumnsType<RowData>; columns?: ColumnsType<RowData>;
dataSource?: RowData[]; dataSource?: RowData[];
sticky?: TableProps<RowData>['sticky'];
}; };

View File

@ -7,4 +7,10 @@
right: 0px; right: 0px;
z-index: 1; z-index: 1;
} }
.ant-table {
&::-webkit-scrollbar {
width: 0.1rem;
}
}
} }

View File

@ -19,6 +19,7 @@ export function QueryTable({
downloadOption, downloadOption,
columns, columns,
dataSource, dataSource,
sticky,
...props ...props
}: QueryTableProps): JSX.Element { }: QueryTableProps): JSX.Element {
const { isDownloadEnabled = false, fileName = '' } = downloadOption || {}; const { isDownloadEnabled = false, fileName = '' } = downloadOption || {};
@ -71,6 +72,7 @@ export function QueryTable({
dataSource={newDataSource} dataSource={newDataSource}
scroll={{ x: true }} scroll={{ x: true }}
pagination={paginationConfig} pagination={paginationConfig}
sticky={sticky}
// eslint-disable-next-line react/jsx-props-no-spreading // eslint-disable-next-line react/jsx-props-no-spreading
{...props} {...props}
/> />

View File

@ -47,6 +47,7 @@ function TableView(): JSX.Element {
query={stagedQuery || initialQueriesMap.traces} query={stagedQuery || initialQueriesMap.traces}
queryTableData={data?.payload?.data?.newResult?.data?.result || []} queryTableData={data?.payload?.data?.newResult?.data?.result || []}
loading={isLoading} loading={isLoading}
sticky
/> />
</Space.Compact> </Space.Compact>
); );