mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 18:40:01 -03:30
add missing template list data; add ids to relevant page elements
This commit is contained in:
parent
78ef11d558
commit
03eb9bafb7
@ -10,12 +10,13 @@ import AlertModal from '../AlertModal';
|
||||
import ErrorDetail from '../ErrorDetail';
|
||||
|
||||
function CopyButton({
|
||||
i18n,
|
||||
id,
|
||||
copyItem,
|
||||
isDisabled,
|
||||
onCopyStart,
|
||||
onCopyFinish,
|
||||
helperText,
|
||||
i18n,
|
||||
}) {
|
||||
const { isLoading, error: copyError, request: copyItemToAPI } = useRequest(
|
||||
copyItem
|
||||
@ -34,6 +35,7 @@ function CopyButton({
|
||||
<>
|
||||
<Tooltip content={helperText.tooltip} position="top">
|
||||
<Button
|
||||
id={id}
|
||||
isDisabled={isLoading || isDisabled}
|
||||
aria-label={i18n._(t`Copy`)}
|
||||
variant="plain"
|
||||
|
||||
@ -34,6 +34,7 @@ const DetailValue = styled(
|
||||
`;
|
||||
|
||||
const Detail = ({
|
||||
id,
|
||||
label,
|
||||
value,
|
||||
fullWidth,
|
||||
@ -77,6 +78,7 @@ const Detail = ({
|
||||
);
|
||||
};
|
||||
Detail.propTypes = {
|
||||
id: string,
|
||||
label: node.isRequired,
|
||||
value: node,
|
||||
fullWidth: bool,
|
||||
@ -84,6 +86,7 @@ Detail.propTypes = {
|
||||
helpText: string,
|
||||
};
|
||||
Detail.defaultProps = {
|
||||
id: null,
|
||||
value: null,
|
||||
fullWidth: false,
|
||||
alwaysVisible: false,
|
||||
|
||||
@ -242,6 +242,7 @@ function JobList({ i18n, defaultParams, showTypeColumn = false }) {
|
||||
<HeaderCell sortKey="finished">
|
||||
{i18n._(t`Finish Time`)}
|
||||
</HeaderCell>
|
||||
<HeaderCell>{i18n._(t`Actions`)}</HeaderCell>
|
||||
</HeaderRow>
|
||||
}
|
||||
toolbarSearchableKeys={searchableKeys}
|
||||
|
||||
@ -77,6 +77,7 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
|
||||
alwaysVisible={false}
|
||||
fullWidth={false}
|
||||
helpText={null}
|
||||
id={null}
|
||||
label="Name"
|
||||
value="jane brown"
|
||||
/>
|
||||
@ -90,6 +91,7 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
|
||||
alwaysVisible={false}
|
||||
fullWidth={false}
|
||||
helpText={null}
|
||||
id={null}
|
||||
label="Team Roles"
|
||||
value={
|
||||
<WithI18n
|
||||
@ -143,6 +145,7 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
|
||||
alwaysVisible={false}
|
||||
fullWidth={false}
|
||||
helpText={null}
|
||||
id={null}
|
||||
label="Name"
|
||||
value="jane brown"
|
||||
/>
|
||||
@ -156,6 +159,7 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
|
||||
alwaysVisible={false}
|
||||
fullWidth={false}
|
||||
helpText={null}
|
||||
id={null}
|
||||
label="Team Roles"
|
||||
value={
|
||||
<WithI18n
|
||||
@ -232,6 +236,7 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
|
||||
alwaysVisible={false}
|
||||
fullWidth={false}
|
||||
helpText={null}
|
||||
id={null}
|
||||
label="Name"
|
||||
value="jane brown"
|
||||
/>
|
||||
@ -245,6 +250,7 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
|
||||
alwaysVisible={false}
|
||||
fullWidth={false}
|
||||
helpText={null}
|
||||
id={null}
|
||||
label="Team Roles"
|
||||
value={
|
||||
<WithI18n
|
||||
@ -456,6 +462,7 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
|
||||
alwaysVisible={false}
|
||||
fullWidth={false}
|
||||
helpText={null}
|
||||
id={null}
|
||||
label="Name"
|
||||
value="jane brown"
|
||||
>
|
||||
@ -680,6 +687,7 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
|
||||
alwaysVisible={false}
|
||||
fullWidth={false}
|
||||
helpText={null}
|
||||
id={null}
|
||||
label="Team Roles"
|
||||
value={
|
||||
<WithI18n
|
||||
|
||||
@ -215,8 +215,9 @@ function TemplateList({ i18n }) {
|
||||
<HeaderCell sortKey="name">{i18n._(t`Name`)}</HeaderCell>
|
||||
<HeaderCell sortKey="type">{i18n._(t`Type`)}</HeaderCell>
|
||||
<HeaderCell sortKey="last_job_run">
|
||||
{i18n._(t`Last Run`)}
|
||||
{i18n._(t`Last Ran`)}
|
||||
</HeaderCell>
|
||||
<HeaderCell>{i18n._(t`Actions`)}</HeaderCell>
|
||||
</HeaderRow>
|
||||
}
|
||||
renderToolbar={props => (
|
||||
|
||||
@ -25,6 +25,7 @@ import { JobTemplatesAPI, WorkflowJobTemplatesAPI } from '../../../api';
|
||||
import LaunchButton from '../../../components/LaunchButton';
|
||||
import Sparkline from '../../../components/Sparkline';
|
||||
import { toTitleCase } from '../../../util/strings';
|
||||
import { formatDateString } from '../../../util/dates';
|
||||
import CopyButton from '../../../components/CopyButton';
|
||||
|
||||
function TemplateListItem({
|
||||
@ -87,6 +88,15 @@ function TemplateListItem({
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
let lastRun = '';
|
||||
const mostRecentJob = template.summary_fields.recent_jobs
|
||||
? template.summary_fields.recent_jobs[0]
|
||||
: null;
|
||||
if (mostRecentJob) {
|
||||
lastRun = mostRecentJob.finished
|
||||
? formatDateString(mostRecentJob.finished)
|
||||
: i18n._(t`Running`);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -122,15 +132,14 @@ function TemplateListItem({
|
||||
)}
|
||||
</Td>
|
||||
<Td dataLabel={i18n._(t`Type`)}>{toTitleCase(template.type)}</Td>
|
||||
<Td dataLabel={i18n._(t`Recent Jobs`)}>
|
||||
<Sparkline jobs={template.summary_fields.recent_jobs} />
|
||||
</Td>
|
||||
<Td dataLabel={i18n._(t`Last Ran`)}>{lastRun}</Td>
|
||||
<ActionsTd dataLabel={i18n._(t`Actions`)}>
|
||||
<ActionItem
|
||||
visible={template.type === 'workflow_job_template'}
|
||||
tooltip={i18n._(t`Visualizer`)}
|
||||
>
|
||||
<Button
|
||||
id={`template-action-visualizer-${template.id}`}
|
||||
isDisabled={isDisabled}
|
||||
aria-label={i18n._(t`Visualizer`)}
|
||||
variant="plain"
|
||||
@ -147,6 +156,7 @@ function TemplateListItem({
|
||||
<LaunchButton resource={template}>
|
||||
{({ handleLaunch }) => (
|
||||
<Button
|
||||
id={`template-action-launch-${template.id}`}
|
||||
isDisabled={isDisabled}
|
||||
aria-label={i18n._(t`Launch template`)}
|
||||
variant="plain"
|
||||
@ -162,6 +172,7 @@ function TemplateListItem({
|
||||
tooltip={i18n._(t`Edit Template`)}
|
||||
>
|
||||
<Button
|
||||
id={`template-action-edit-${template.id}`}
|
||||
isDisabled={isDisabled}
|
||||
aria-label={i18n._(t`Edit Template`)}
|
||||
variant="plain"
|
||||
@ -173,6 +184,7 @@ function TemplateListItem({
|
||||
</ActionItem>
|
||||
<ActionItem visible={template.summary_fields.user_capabilities.copy}>
|
||||
<CopyButton
|
||||
id={`template-action-copy-${template.id}`}
|
||||
helperText={{
|
||||
errorMessage: i18n._(t`Failed to copy template.`),
|
||||
tooltip: i18n._(t`Copy Template`),
|
||||
@ -193,6 +205,7 @@ function TemplateListItem({
|
||||
<Detail
|
||||
label={i18n._(t`Activity`)}
|
||||
value={<Sparkline jobs={summaryFields.recent_jobs} />}
|
||||
dataCy={`template-${template.id}-activity`}
|
||||
/>
|
||||
{summaryFields.credentials && summaryFields.credentials.length && (
|
||||
<Detail
|
||||
@ -207,6 +220,7 @@ function TemplateListItem({
|
||||
))}
|
||||
</ChipGroup>
|
||||
}
|
||||
dataCy={`template-${template.id}-credentials`}
|
||||
/>
|
||||
)}
|
||||
{summaryFields.inventory ? (
|
||||
@ -216,6 +230,7 @@ function TemplateListItem({
|
||||
summaryFields.inventory.kind,
|
||||
summaryFields.inventory.id
|
||||
)}
|
||||
dataCy={`template-${template.id}-inventory`}
|
||||
/>
|
||||
) : (
|
||||
!askInventoryOnLaunch && (
|
||||
@ -237,9 +252,10 @@ function TemplateListItem({
|
||||
))}
|
||||
</ChipGroup>
|
||||
}
|
||||
dataCy={`template-${template.id}-labels`}
|
||||
/>
|
||||
)}
|
||||
{summaryFields.project ? (
|
||||
{summaryFields.project && (
|
||||
<Detail
|
||||
label={i18n._(t`Project`)}
|
||||
value={
|
||||
@ -247,10 +263,14 @@ function TemplateListItem({
|
||||
{summaryFields.project.name}
|
||||
</Link>
|
||||
}
|
||||
dataCy={`template-${template.id}-project`}
|
||||
/>
|
||||
) : (
|
||||
<DeletedDetail label={i18n._(t`Project`)} />
|
||||
)}
|
||||
<Detail
|
||||
label={i18n._(t`Last Modified`)}
|
||||
value={formatDateString(template.modified)}
|
||||
dataCy={`template-${template.id}-last-modified`}
|
||||
/>
|
||||
</DetailList>
|
||||
</ExpandableRowContent>
|
||||
</Td>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user