mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 07:26:03 -03:30
Add job status on expand row for hosts
Add job status on expand row for hosts. Also, update HostDetail to remove the addition of `type=job` since it is already present on the API hosts endpoint. See: https://github.com/ansible/awx/issues/5236
This commit is contained in:
@@ -29,7 +29,7 @@ function HostDetail({ host }) {
|
|||||||
variables,
|
variables,
|
||||||
summary_fields: {
|
summary_fields: {
|
||||||
inventory,
|
inventory,
|
||||||
recent_jobs,
|
recent_jobs: recentJobs,
|
||||||
created_by,
|
created_by,
|
||||||
modified_by,
|
modified_by,
|
||||||
user_capabilities,
|
user_capabilities,
|
||||||
@@ -66,17 +66,13 @@ function HostDetail({ host }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const recentPlaybookJobs = recent_jobs.map(job => ({ ...job, type: 'job' }));
|
|
||||||
return (
|
return (
|
||||||
<CardBody>
|
<CardBody>
|
||||||
<HostToggle host={host} css="padding-bottom: 40px" />
|
<HostToggle host={host} css="padding-bottom: 40px" />
|
||||||
<DetailList gutter="sm">
|
<DetailList gutter="sm">
|
||||||
<Detail label={t`Name`} value={name} dataCy="host-name" />
|
<Detail label={t`Name`} value={name} dataCy="host-name" />
|
||||||
{recentPlaybookJobs?.length > 0 && (
|
{recentJobs?.length > 0 && (
|
||||||
<Detail
|
<Detail label={t`Activity`} value={<Sparkline jobs={recentJobs} />} />
|
||||||
label={t`Activity`}
|
|
||||||
value={<Sparkline jobs={recentPlaybookJobs} />}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
<Detail label={t`Description`} value={description} />
|
<Detail label={t`Description`} value={description} />
|
||||||
<Detail
|
<Detail
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ function HostList() {
|
|||||||
toolbarSearchableKeys={searchableKeys}
|
toolbarSearchableKeys={searchableKeys}
|
||||||
toolbarRelatedSearchableKeys={relatedSearchableKeys}
|
toolbarRelatedSearchableKeys={relatedSearchableKeys}
|
||||||
headerRow={
|
headerRow={
|
||||||
<HeaderRow qsConfig={QS_CONFIG}>
|
<HeaderRow qsConfig={QS_CONFIG} isExpandable>
|
||||||
<HeaderCell sortKey="name">{t`Name`}</HeaderCell>
|
<HeaderCell sortKey="name">{t`Name`}</HeaderCell>
|
||||||
<HeaderCell>{t`Inventory`}</HeaderCell>
|
<HeaderCell>{t`Inventory`}</HeaderCell>
|
||||||
<HeaderCell>{t`Actions`}</HeaderCell>
|
<HeaderCell>{t`Actions`}</HeaderCell>
|
||||||
|
|||||||
@@ -1,62 +1,97 @@
|
|||||||
import 'styled-components/macro';
|
import 'styled-components/macro';
|
||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import { string, bool, func } from 'prop-types';
|
import { string, bool, func } from 'prop-types';
|
||||||
|
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { Button } from '@patternfly/react-core';
|
import { Button } from '@patternfly/react-core';
|
||||||
import { Tr, Td } from '@patternfly/react-table';
|
import { Tr, Td, ExpandableRowContent } from '@patternfly/react-table';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { PencilAltIcon } from '@patternfly/react-icons';
|
import { PencilAltIcon } from '@patternfly/react-icons';
|
||||||
import { ActionsTd, ActionItem } from '../../../components/PaginatedTable';
|
import { ActionsTd, ActionItem } from '../../../components/PaginatedTable';
|
||||||
import { Host } from '../../../types';
|
import { Host } from '../../../types';
|
||||||
import HostToggle from '../../../components/HostToggle';
|
import HostToggle from '../../../components/HostToggle';
|
||||||
|
import { DetailList, Detail } from '../../../components/DetailList';
|
||||||
|
import Sparkline from '../../../components/Sparkline';
|
||||||
|
|
||||||
function HostListItem({ host, isSelected, onSelect, detailUrl, rowIndex }) {
|
function HostListItem({ host, isSelected, onSelect, detailUrl, rowIndex }) {
|
||||||
const labelId = `check-action-${host.id}`;
|
const labelId = `check-action-${host.id}`;
|
||||||
|
const [isExpanded, setIsExpanded] = useState(false);
|
||||||
|
|
||||||
|
const {
|
||||||
|
summary_fields: { recent_jobs: recentJobs = [] },
|
||||||
|
} = host;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tr id={`host-row-${host.id}`}>
|
<>
|
||||||
<Td
|
<Tr id={`host-row-${host.id}`}>
|
||||||
data-cy={labelId}
|
<Td
|
||||||
select={{
|
expand={{
|
||||||
rowIndex,
|
rowIndex,
|
||||||
isSelected,
|
isExpanded,
|
||||||
onSelect,
|
onToggle: () => setIsExpanded(!isExpanded),
|
||||||
}}
|
}}
|
||||||
dataLabel={t`Selected`}
|
/>
|
||||||
/>
|
<Td
|
||||||
<Td id={labelId} dataLabel={t`Name`}>
|
data-cy={labelId}
|
||||||
<Link to={`${detailUrl}`}>
|
select={{
|
||||||
<b>{host.name}</b>
|
rowIndex,
|
||||||
</Link>
|
isSelected,
|
||||||
</Td>
|
onSelect,
|
||||||
<Td dataLabel={t`Inventory`}>
|
}}
|
||||||
{host.summary_fields.inventory && (
|
dataLabel={t`Selected`}
|
||||||
<Link
|
/>
|
||||||
to={`/inventories/inventory/${host.summary_fields.inventory.id}/details`}
|
<Td id={labelId} dataLabel={t`Name`}>
|
||||||
>
|
<Link to={`${detailUrl}`}>
|
||||||
{host.summary_fields.inventory.name}
|
<b>{host.name}</b>
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
</Td>
|
||||||
</Td>
|
<Td dataLabel={t`Inventory`}>
|
||||||
<ActionsTd dataLabel={t`Actions`} gridColumns="auto 40px">
|
{host.summary_fields.inventory && (
|
||||||
<HostToggle host={host} />
|
<Link
|
||||||
<ActionItem
|
to={`/inventories/inventory/${host.summary_fields.inventory.id}/details`}
|
||||||
visible={host.summary_fields.user_capabilities.edit}
|
>
|
||||||
tooltip={t`Edit Host`}
|
{host.summary_fields.inventory.name}
|
||||||
>
|
</Link>
|
||||||
<Button
|
)}
|
||||||
ouiaId={`${host.id}-edit-button}`}
|
</Td>
|
||||||
aria-label={t`Edit Host`}
|
<ActionsTd dataLabel={t`Actions`} gridColumns="auto 40px">
|
||||||
variant="plain"
|
<HostToggle host={host} />
|
||||||
component={Link}
|
<ActionItem
|
||||||
to={`/hosts/${host.id}/edit`}
|
visible={host.summary_fields.user_capabilities.edit}
|
||||||
|
tooltip={t`Edit Host`}
|
||||||
>
|
>
|
||||||
<PencilAltIcon />
|
<Button
|
||||||
</Button>
|
ouiaId={`${host.id}-edit-button}`}
|
||||||
</ActionItem>
|
aria-label={t`Edit Host`}
|
||||||
</ActionsTd>
|
variant="plain"
|
||||||
</Tr>
|
component={Link}
|
||||||
|
to={`/hosts/${host.id}/edit`}
|
||||||
|
>
|
||||||
|
<PencilAltIcon />
|
||||||
|
</Button>
|
||||||
|
</ActionItem>
|
||||||
|
</ActionsTd>
|
||||||
|
</Tr>
|
||||||
|
<Tr isExpanded={isExpanded}>
|
||||||
|
<Td colSpan={2} />
|
||||||
|
<Td colSpan={4}>
|
||||||
|
<ExpandableRowContent>
|
||||||
|
<DetailList gutter="sm">
|
||||||
|
<Detail
|
||||||
|
label={t`Activity`}
|
||||||
|
value={
|
||||||
|
recentJobs.length > 0 ? (
|
||||||
|
<Sparkline jobs={recentJobs} />
|
||||||
|
) : (
|
||||||
|
t`No job data available`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</DetailList>
|
||||||
|
</ExpandableRowContent>
|
||||||
|
</Td>
|
||||||
|
</Tr>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user