1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix ItemObjectList to not display column toggles for columns without IDs

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-10-03 10:31:16 -04:00
parent 3c0394374b
commit 78ebdd8405

View File

@ -252,7 +252,7 @@ class NonInjectedItemListLayoutContent<
} }
renderTableHeader() { renderTableHeader() {
const { customizeTableRowProps, renderTableHeader, isSelectable, isConfigurable, store } = this.props; const { customizeTableRowProps, renderTableHeader, isSelectable, isConfigurable, store, tableId } = this.props;
if (!renderTableHeader) { if (!renderTableHeader) {
return null; return null;
@ -283,7 +283,10 @@ class NonInjectedItemListLayoutContent<
)) ))
} }
<TableCell className="menu"> <TableCell className="menu">
{isConfigurable && this.renderColumnVisibilityMenu()} {(isConfigurable && tableId)
? this.renderColumnVisibilityMenu(tableId)
: undefined
}
</TableCell> </TableCell>
</TableHead> </TableHead>
); );
@ -341,8 +344,8 @@ class NonInjectedItemListLayoutContent<
return !isConfigurable || !tableId || !this.props.userStore.isTableColumnHidden(tableId, columnId, showWithColumn); return !isConfigurable || !tableId || !this.props.userStore.isTableColumnHidden(tableId, columnId, showWithColumn);
} }
renderColumnVisibilityMenu() { renderColumnVisibilityMenu(tableId: string) {
const { renderTableHeader = [], tableId } = this.props; const { renderTableHeader = [] } = this.props;
return ( return (
<MenuActions <MenuActions
@ -354,20 +357,16 @@ class NonInjectedItemListLayoutContent<
{ {
renderTableHeader renderTableHeader
.filter(isDefined) .filter(isDefined)
.map((cellProps, index) => ( .filter((props): props is TableCellProps & { id: string } => !!props.id)
!cellProps.showWithColumn && ( .filter(props => !props.showWithColumn)
<MenuItem key={index} className="input"> .map((cellProps) => (
<Checkbox <MenuItem key={cellProps.id} className="input">
label={cellProps.title ?? `<${cellProps.className}>`} <Checkbox
value={this.showColumn(cellProps)} label={cellProps.title ?? `<${cellProps.className}>`}
onChange={( value={this.showColumn(cellProps)}
tableId onChange={() => this.props.userStore.toggleTableColumnVisibility(tableId, cellProps.id)}
? (() => cellProps.id && this.props.userStore.toggleTableColumnVisibility(tableId, cellProps.id)) />
: undefined </MenuItem>
)}
/>
</MenuItem>
)
)) ))
} }
</MenuActions> </MenuActions>