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

the select all checkbox should not select disabled items (#2151)

* the select all checkbox should not select disabled items

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* remove improper bullet-proofing

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* added default for customizeTableRowProps

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
Jim Ehrismann 2021-02-25 09:09:39 -05:00 committed by GitHub
parent f18d8618cd
commit 38c3734d5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,7 +89,8 @@ const defaultProps: Partial<ItemListLayoutProps> = {
filterItems: [], filterItems: [],
hasDetailsView: true, hasDetailsView: true,
onDetails: noop, onDetails: noop,
virtual: true virtual: true,
customizeTableRowProps: () => ({} as TableRowProps),
}; };
interface ItemListLayoutUserSettings { interface ItemListLayoutUserSettings {
@ -241,7 +242,7 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
sortItem={item} sortItem={item}
selected={detailsItem && detailsItem.getId() === itemId} selected={detailsItem && detailsItem.getId() === itemId}
onClick={hasDetailsView ? prevDefault(() => onDetails(item)) : undefined} onClick={hasDetailsView ? prevDefault(() => onDetails(item)) : undefined}
{...(customizeTableRowProps ? customizeTableRowProps(item) : {})} {...customizeTableRowProps(item)}
> >
{isSelectable && ( {isSelectable && (
<TableCell <TableCell
@ -392,19 +393,21 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
} }
renderTableHeader() { renderTableHeader() {
const { renderTableHeader, isSelectable, isConfigurable, store } = this.props; const { customizeTableRowProps, renderTableHeader, isSelectable, isConfigurable, store } = this.props;
if (!renderTableHeader) { if (!renderTableHeader) {
return; return;
} }
const enabledItems = this.items.filter(item => !customizeTableRowProps(item).disabled);
return ( return (
<TableHead showTopLine nowrap> <TableHead showTopLine nowrap>
{isSelectable && ( {isSelectable && (
<TableCell <TableCell
checkbox checkbox
isChecked={store.isSelectedAll(this.items)} isChecked={store.isSelectedAll(enabledItems)}
onClick={prevDefault(() => store.toggleSelectionAll(this.items))} onClick={prevDefault(() => store.toggleSelectionAll(enabledItems))}
/> />
)} )}
{renderTableHeader.map((cellProps, index) => { {renderTableHeader.map((cellProps, index) => {