Merge pull request #11014 from kialam/add-node-type-to-associate-modal

Add instance node type to associate modal.
This commit is contained in:
Sarah Akus
2021-09-09 10:17:12 -04:00
committed by GitHub
2 changed files with 22 additions and 5 deletions

View File

@@ -18,6 +18,10 @@ const QS_CONFIG = (order_by = 'name') =>
function AssociateModal({ function AssociateModal({
header = t`Items`, header = t`Items`,
columns = [
{ key: 'hostname', name: t`Name` },
{ key: 'node_type', name: t`Node Type` },
],
title = t`Select Items`, title = t`Select Items`,
onClose, onClose,
onAssociate, onAssociate,
@@ -123,6 +127,7 @@ function AssociateModal({
<OptionsList <OptionsList
displayKey={displayKey} displayKey={displayKey}
contentError={contentError} contentError={contentError}
columns={columns}
deselectItem={handleSelect} deselectItem={handleSelect}
header={header} header={header}
isLoading={isLoading} isLoading={isLoading}

View File

@@ -23,6 +23,7 @@ const ModalList = styled.div`
`; `;
function OptionsList({ function OptionsList({
columns,
contentError, contentError,
deselectItem, deselectItem,
displayKey, displayKey,
@@ -44,6 +45,19 @@ function OptionsList({
sortSelectedItems, sortSelectedItems,
value, value,
}) { }) {
const buildHeaderRow = (
<HeaderRow qsConfig={qsConfig}>
{columns?.length > 0 ? (
columns.map((col) => (
<HeaderCell key={col.key} sortKey={col.key}>
{col.name}
</HeaderCell>
))
) : (
<HeaderCell sortKey="name">{t`Name`}</HeaderCell>
)}
</HeaderRow>
);
let selectionPreview = null; let selectionPreview = null;
if (value.length > 0) { if (value.length > 0) {
if (isSelectedDraggable) { if (isSelectedDraggable) {
@@ -82,11 +96,7 @@ function OptionsList({
toolbarSearchableKeys={searchableKeys} toolbarSearchableKeys={searchableKeys}
toolbarRelatedSearchableKeys={relatedSearchableKeys} toolbarRelatedSearchableKeys={relatedSearchableKeys}
hasContentLoading={isLoading} hasContentLoading={isLoading}
headerRow={ headerRow={buildHeaderRow}
<HeaderRow qsConfig={qsConfig}>
<HeaderCell sortKey="name">{t`Name`}</HeaderCell>
</HeaderRow>
}
onRowClick={selectItem} onRowClick={selectItem}
renderRow={(item, index) => ( renderRow={(item, index) => (
<CheckboxListItem <CheckboxListItem
@@ -95,6 +105,8 @@ function OptionsList({
itemId={item.id} itemId={item.id}
name={multiple ? item[displayKey] : name} name={multiple ? item[displayKey] : name}
label={item[displayKey]} label={item[displayKey]}
columns={columns}
item={item}
isSelected={value.some((i) => i.id === item.id)} isSelected={value.some((i) => i.id === item.id)}
onSelect={() => selectItem(item)} onSelect={() => selectItem(item)}
onDeselect={() => deselectItem(item)} onDeselect={() => deselectItem(item)}