Add instance node type to associate modal.

This commit is contained in:
Kia Lam
2021-09-02 20:01:03 -04:00
parent 9ee9de76b5
commit bba2a264ea
2 changed files with 23 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: 'Name' },
{ key: 'node_type', name: '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,20 @@ function OptionsList({
sortSelectedItems, sortSelectedItems,
value, value,
}) { }) {
const buildHeaderRow = (
<HeaderRow qsConfig={qsConfig}>
{columns?.length > 0 ? (
columns.map((col) => (
<HeaderCell
key={col.key}
sortKey={col.key}
>{t`${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 +97,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 +106,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)}