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;
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 (
<TableRow
key={itemId}
@@ -241,7 +248,7 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
sortItem={item}
selected={detailsItem && detailsItem.getId() === itemId}
onClick={hasDetailsView ? prevDefault(() => onDetails(item)) : undefined}
{...(customizeTableRowProps ? customizeTableRowProps(item) : {})}
{...customProps}
>
{isSelectable && (
<TableCell
@@ -392,19 +399,24 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
}
renderTableHeader() {
const { renderTableHeader, isSelectable, isConfigurable, store } = this.props;
const { customizeTableRowProps, renderTableHeader, isSelectable, isConfigurable, store } = this.props;
if (!renderTableHeader) {
return;
}
let items = this.items;
if ( customizeTableRowProps ) {
items = items.filter((item) => !customizeTableRowProps(item).disabled);
}
return (
<TableHead showTopLine nowrap>
{isSelectable && (
<TableCell
checkbox
isChecked={store.isSelectedAll(this.items)}
onClick={prevDefault(() => store.toggleSelectionAll(this.items))}
isChecked={store.isSelectedAll(items)}
onClick={prevDefault(() => store.toggleSelectionAll(items))}
/>
)}
{renderTableHeader.map((cellProps, index) => {