From ad71dc3e98789c9fea34fd7f5221012ce2323a0e Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Tue, 19 Jan 2021 15:00:41 -0800 Subject: [PATCH] add expandable row details to template list --- .../Template/TemplateList/TemplateList.jsx | 30 +- .../TemplateList/TemplateListItem.jsx | 295 ++++++++++++------ 2 files changed, 204 insertions(+), 121 deletions(-) diff --git a/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx b/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx index 82a2dffcf4..1380291a26 100644 --- a/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx +++ b/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx @@ -208,40 +208,14 @@ function TemplateList({ i18n }) { key: 'modified_by__username__icontains', }, ]} - toolbarSortColumns={[ - { - name: i18n._(t`Inventory`), - key: 'job_template__inventory__id', - }, - { - name: i18n._(t`Last Job Run`), - key: 'last_job_run', - }, - { - name: i18n._(t`Modified`), - key: 'modified', - }, - { - name: i18n._(t`Name`), - key: 'name', - }, - { - name: i18n._(t`Project`), - key: 'jobtemplate__project__id', - }, - { - name: i18n._(t`Type`), - key: 'type', - }, - ]} toolbarSearchableKeys={searchableKeys} toolbarRelatedSearchableKeys={relatedSearchableKeys} headerRow={ - + {i18n._(t`Name`)} {i18n._(t`Type`)} - {i18n._(t`Recent Jobs`)} + {i18n._(t`Last Run`)} } diff --git a/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx b/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx index 6481f7072d..29f94f78e6 100644 --- a/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx +++ b/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx @@ -1,8 +1,8 @@ import 'styled-components/macro'; import React, { useState, useCallback } from 'react'; import { Link } from 'react-router-dom'; -import { Button, Tooltip } from '@patternfly/react-core'; -import { Tr, Td } from '@patternfly/react-table'; +import { Button, Tooltip, Chip } from '@patternfly/react-core'; +import { Tr, Td, ExpandableRowContent } from '@patternfly/react-table'; import { t } from '@lingui/macro'; import { withI18n } from '@lingui/react'; import { @@ -12,6 +12,13 @@ import { RocketIcon, } from '@patternfly/react-icons'; import { ActionsTd, ActionItem } from '../../../components/PaginatedTable'; +import { + DetailList, + Detail, + DeletedDetail, +} from '../../../components/DetailList'; +import ChipGroup from '../../../components/ChipGroup'; +import CredentialChip from '../../../components/CredentialChip'; import { timeOfDay } from '../../../util/dates'; import { JobTemplatesAPI, WorkflowJobTemplatesAPI } from '../../../api'; @@ -29,6 +36,7 @@ function TemplateListItem({ fetchTemplates, rowIndex, }) { + const [isExpanded, setIsExpanded] = useState(false); const [isDisabled, setIsDisabled] = useState(false); const labelId = `check-action-${template.id}`; @@ -53,102 +61,203 @@ function TemplateListItem({ setIsDisabled(false); }, []); + const { + summary_fields: summaryFields, + ask_inventory_on_launch: askInventoryOnLaunch, + } = template; + const missingResourceIcon = template.type === 'job_template' && - (!template.summary_fields.project || - (!template.summary_fields.inventory && - !template.ask_inventory_on_launch)); - return ( - - - - - {template.name} + (!summaryFields.project || + (!summaryFields.inventory && !askInventoryOnLaunch)); + + const inventoryValue = (kind, id) => { + const inventorykind = kind === 'smart' ? 'smart_inventory' : 'inventory'; + + return askInventoryOnLaunch ? ( + <> + + {summaryFields.inventory.name} - {missingResourceIcon && ( - - - - - - )} - - {toTitleCase(template.type)} - - - - - - - - - - {({ handleLaunch }) => ( - - )} - - - - - - - - - - + + + + + {({ handleLaunch }) => ( + + )} + + + + + + + + + + + + + + + + } + /> + {summaryFields.credentials && summaryFields.credentials.length && ( + + {summaryFields.credentials.map(c => ( + + ))} + + } + /> + )} + {summaryFields.inventory ? ( + + ) : ( + !askInventoryOnLaunch && ( + + ) + )} + {summaryFields.labels && summaryFields.labels.results.length > 0 && ( + + {summaryFields.labels.results.map(l => ( + + {l.name} + + ))} + + } + /> + )} + {summaryFields.project ? ( + + {summaryFields.project.name} + + } + /> + ) : ( + + )} + + + + + ); }