Skip to content

Commit

Permalink
v4.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
novykh committed Apr 17, 2024
1 parent fb88bff commit 1cecd04
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@netdata/netdata-ui",
"version": "4.4.1",
"version": "4.4.2",
"description": "netdata UI kit",
"main": "dist/index.js",
"module": "dist/es6/index.js",
Expand Down
20 changes: 17 additions & 3 deletions src/components/table/body/header/cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ const rerenderSelector = state => ({
selecting: state.selectedRows,
})

const BodyHeaderCell = ({ header, table, testPrefix, coloredSortedColumn, index }) => {
const BodyHeaderCell = ({
header,
table,
testPrefix,
coloredSortedColumn,
index,
children,
isSubheader,
}) => {
useTableState(rerenderSelector)

const { column } = header
Expand Down Expand Up @@ -75,7 +83,7 @@ const BodyHeaderCell = ({ header, table, testPrefix, coloredSortedColumn, index
background: "columnHighlight",
backgroundOpacity: "0.2",
})}
padding={[1, 2]}
padding={isSubheader ? [0] : [1, 2]}
{...headStyles}
column
>
Expand All @@ -90,7 +98,12 @@ const BodyHeaderCell = ({ header, table, testPrefix, coloredSortedColumn, index
>
<Sorting sortable={column.getCanSort()} sorting={column.getIsSorted()} />
{column.isPlaceholder ? null : (
<Label sorting={column.getIsSorted()} sortable={column.getCanSort()}>
<Label
as={column.columnDef.labelAs}
{...column.columnDef.labelProps}
sorting={column.getIsSorted()}
sortable={column.getCanSort()}
>
{flexRender(column.columnDef.header, header.getContext())}
</Label>
)}
Expand All @@ -99,6 +112,7 @@ const BodyHeaderCell = ({ header, table, testPrefix, coloredSortedColumn, index
</Flex>
<Info meta={meta} />
<ResizeHandler header={header} table={table} />
{children}
</Flex>
)
}
Expand Down
35 changes: 20 additions & 15 deletions src/components/table/body/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,25 @@ const rerenderSelector = state => {
}
}

const HeaderGroup = ({ headerGroup, testPrefix, ...rest }) => (
<Flex
id={headerGroup.id}
data-testid={`netdata-table-headRow${testPrefix}`}
flex
background="tableRowBg2"
>
{headerGroup.headers.map((header, index) => (
<Cell key={header.id} index={index} {...rest} header={header} testPrefix={testPrefix} />
))}
</Flex>
)
const HeaderGroup = ({ id, headers, testPrefix, ...rest }) => {
return (
<Flex id={id} data-testid={`netdata-table-headRow${testPrefix}`} flex background="tableRowBg2">
{headers.map((header, index) => (
<Cell key={header.id} index={index} {...rest} header={header} testPrefix={testPrefix}>
{!!header.subHeaders.length && (
<HeaderGroup
headers={header.subHeaders}
id={header.id}
key={header.id}
{...rest}
isSubheader
/>
)}
</Cell>
))}
</Flex>
)
}

const HeaderGroups = ({ groups, size, side, ...rest }) => {
if (!groups[0].headers.length) return null
Expand All @@ -44,9 +51,7 @@ const HeaderGroups = ({ groups, size, side, ...rest }) => {
flex="grow"
column
>
{groups.map(headerGroup => (
<HeaderGroup headerGroup={headerGroup} key={headerGroup.id} {...rest} />
))}
<HeaderGroup headers={groups[0].headers} id={groups[0].id} key={groups[0].id} {...rest} />
</Flex>
)
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/table/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const Table = memo(
virtualizeOptions,
tableRef,
className,
width,
...rest
},
ref
Expand Down Expand Up @@ -219,6 +220,7 @@ const Table = memo(
flex="1"
ref={ref}
className={className}
width={width}
>
<Header
q={globalFilter}
Expand Down

0 comments on commit 1cecd04

Please sign in to comment.