Skip to content

Commit d7e3651

Browse files
committed
Fixes #38830 - Add sub-menu Host collections to bulk hosts Change associations
1 parent 7d08c42 commit d7e3651

File tree

4 files changed

+52
-34
lines changed

4 files changed

+52
-34
lines changed

webpack/assets/javascripts/react_app/components/HostsIndex/RowSelectTd.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

webpack/assets/javascripts/react_app/components/HostsIndex/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import Slot from '../common/Slot';
6161
import forceSingleton from '../../common/forceSingleton';
6262
import './index.scss';
6363
import { STATUS } from '../../constants';
64-
import { RowSelectTd } from './RowSelectTd';
64+
import { RowSelectTd } from '../PF4/TableIndexPage/RowSelectTd';
6565
import {
6666
useCurrentUserTablePreferences,
6767
useSetParamsAndApiAndSearch,
@@ -304,6 +304,12 @@ const HostsIndex = () => {
304304
>
305305
{__('Host group')}
306306
</MenuItem>
307+
<Slot
308+
id="_host-associations"
309+
fetchBulkParams={fetchBulkParams}
310+
selectedCount={selectedCount}
311+
multi
312+
/>
307313
<MenuItem
308314
itemId="change-owner-dropdown-item"
309315
key="change-owner-dropdown-item"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { Td } from '@patternfly/react-table';
4+
5+
export const RowSelectTd = ({
6+
rowData,
7+
selectOne,
8+
isSelected,
9+
isSelectable,
10+
idColumnName = 'id',
11+
}) => {
12+
const isRowSelectable = isSelectable ? isSelectable(rowData) : true;
13+
14+
return (
15+
<Td
16+
select={{
17+
rowIndex: rowData[idColumnName],
18+
onSelect: (_event, isSelecting) => {
19+
selectOne(isSelecting, rowData[idColumnName], rowData);
20+
},
21+
isSelected: isSelected(rowData[idColumnName]),
22+
isDisabled: !isRowSelectable,
23+
}}
24+
/>
25+
);
26+
};
27+
28+
RowSelectTd.propTypes = {
29+
rowData: PropTypes.object.isRequired,
30+
selectOne: PropTypes.func.isRequired,
31+
isSelected: PropTypes.func.isRequired,
32+
isSelectable: PropTypes.func,
33+
idColumnName: PropTypes.string,
34+
};
35+
36+
RowSelectTd.defaultProps = {
37+
isSelectable: null,
38+
idColumnName: 'id',
39+
};

webpack/assets/javascripts/react_app/components/PF4/TableIndexPage/Table/Table.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Pagination from '../../../Pagination';
1616
import { DeleteModal } from './DeleteModal';
1717
import EmptyPage from '../../../../routes/common/EmptyPage';
1818
import { getColumnHelpers } from './helpers';
19+
import { RowSelectTd as DefaultRowSelectTd } from '../RowSelectTd';
1920

2021
export const Table = ({
2122
columns,
@@ -28,6 +29,7 @@ export const Table = ({
2829
itemCount,
2930
selectOne,
3031
isSelected,
32+
isSelectable,
3133
params,
3234
refreshData,
3335
results,
@@ -106,7 +108,7 @@ export const Table = ({
106108
})),
107109
].filter(Boolean);
108110
};
109-
const RowSelectTd = rowSelectTd;
111+
const RowSelectTd = rowSelectTd === noop ? DefaultRowSelectTd : rowSelectTd;
110112
return (
111113
<>
112114
<DeleteModal
@@ -206,6 +208,7 @@ export const Table = ({
206208
rowData={result}
207209
selectOne={selectOne}
208210
isSelected={isSelected}
211+
isSelectable={isSelectable}
209212
idColumnName={idColumn}
210213
/>
211214
)}
@@ -256,6 +259,7 @@ Table.propTypes = {
256259
idColumn: PropTypes.string,
257260
selectOne: PropTypes.func,
258261
isSelected: PropTypes.func,
262+
isSelectable: PropTypes.func,
259263
showCheckboxes: PropTypes.bool,
260264
bottomPagination: PropTypes.node,
261265
childrenOutsideTbody: PropTypes.bool,
@@ -279,6 +283,7 @@ Table.defaultProps = {
279283
idColumn: 'id',
280284
selectOne: noop,
281285
isSelected: noop,
286+
isSelectable: null,
282287
showCheckboxes: false,
283288
bottomPagination: null,
284289
childrenOutsideTbody: false,

0 commit comments

Comments
 (0)