the select all checkbox should not select disabled items

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
Jim Ehrismann committed 2021-02-12 19:19:25 -05:00
1 parent ebf9177098
commit 3dc1f639b3
1 file changed
+16 -4
@@ -233,6 +233,13 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
if (!item) return; if (!item) return;
const itemId = item.getId(); const itemId = item.getId();
const customProps = customizeTableRowProps ? customizeTableRowProps(item) : {};
// make sure a disabled item is not in the selected state
if (customProps.disabled) {
store.unselect(item);
}
return ( return (
<TableRow <TableRow
key={itemId} key={itemId}
@@ -241,7 +248,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) : {})} {...customProps}
> >
{isSelectable && ( {isSelectable && (
<TableCell <TableCell
@@ -392,19 +399,24 @@ 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;
} }
let items = this.items;
if ( customizeTableRowProps ) {
items = 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(items)}
onClick={prevDefault(() => store.toggleSelectionAll(this.items))} onClick={prevDefault(() => store.toggleSelectionAll(items))}
/> />
)} )}
{renderTableHeader.map((cellProps, index) => { {renderTableHeader.map((cellProps, index) => {