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

View File

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