add missing template list data; add ids to relevant page elements

This commit is contained in:
Keith Grant
2021-01-28 14:28:08 -08:00
parent 78ef11d558
commit 03eb9bafb7
6 changed files with 43 additions and 8 deletions

View File

@@ -10,12 +10,13 @@ import AlertModal from '../AlertModal';
import ErrorDetail from '../ErrorDetail'; import ErrorDetail from '../ErrorDetail';
function CopyButton({ function CopyButton({
i18n, id,
copyItem, copyItem,
isDisabled, isDisabled,
onCopyStart, onCopyStart,
onCopyFinish, onCopyFinish,
helperText, helperText,
i18n,
}) { }) {
const { isLoading, error: copyError, request: copyItemToAPI } = useRequest( const { isLoading, error: copyError, request: copyItemToAPI } = useRequest(
copyItem copyItem
@@ -34,6 +35,7 @@ function CopyButton({
<> <>
<Tooltip content={helperText.tooltip} position="top"> <Tooltip content={helperText.tooltip} position="top">
<Button <Button
id={id}
isDisabled={isLoading || isDisabled} isDisabled={isLoading || isDisabled}
aria-label={i18n._(t`Copy`)} aria-label={i18n._(t`Copy`)}
variant="plain" variant="plain"

View File

@@ -34,6 +34,7 @@ const DetailValue = styled(
`; `;
const Detail = ({ const Detail = ({
id,
label, label,
value, value,
fullWidth, fullWidth,
@@ -77,6 +78,7 @@ const Detail = ({
); );
}; };
Detail.propTypes = { Detail.propTypes = {
id: string,
label: node.isRequired, label: node.isRequired,
value: node, value: node,
fullWidth: bool, fullWidth: bool,
@@ -84,6 +86,7 @@ Detail.propTypes = {
helpText: string, helpText: string,
}; };
Detail.defaultProps = { Detail.defaultProps = {
id: null,
value: null, value: null,
fullWidth: false, fullWidth: false,
alwaysVisible: false, alwaysVisible: false,

View File

@@ -242,6 +242,7 @@ function JobList({ i18n, defaultParams, showTypeColumn = false }) {
<HeaderCell sortKey="finished"> <HeaderCell sortKey="finished">
{i18n._(t`Finish Time`)} {i18n._(t`Finish Time`)}
</HeaderCell> </HeaderCell>
<HeaderCell>{i18n._(t`Actions`)}</HeaderCell>
</HeaderRow> </HeaderRow>
} }
toolbarSearchableKeys={searchableKeys} toolbarSearchableKeys={searchableKeys}

View File

@@ -77,6 +77,7 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
alwaysVisible={false} alwaysVisible={false}
fullWidth={false} fullWidth={false}
helpText={null} helpText={null}
id={null}
label="Name" label="Name"
value="jane brown" value="jane brown"
/> />
@@ -90,6 +91,7 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
alwaysVisible={false} alwaysVisible={false}
fullWidth={false} fullWidth={false}
helpText={null} helpText={null}
id={null}
label="Team Roles" label="Team Roles"
value={ value={
<WithI18n <WithI18n
@@ -143,6 +145,7 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
alwaysVisible={false} alwaysVisible={false}
fullWidth={false} fullWidth={false}
helpText={null} helpText={null}
id={null}
label="Name" label="Name"
value="jane brown" value="jane brown"
/> />
@@ -156,6 +159,7 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
alwaysVisible={false} alwaysVisible={false}
fullWidth={false} fullWidth={false}
helpText={null} helpText={null}
id={null}
label="Team Roles" label="Team Roles"
value={ value={
<WithI18n <WithI18n
@@ -232,6 +236,7 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
alwaysVisible={false} alwaysVisible={false}
fullWidth={false} fullWidth={false}
helpText={null} helpText={null}
id={null}
label="Name" label="Name"
value="jane brown" value="jane brown"
/> />
@@ -245,6 +250,7 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
alwaysVisible={false} alwaysVisible={false}
fullWidth={false} fullWidth={false}
helpText={null} helpText={null}
id={null}
label="Team Roles" label="Team Roles"
value={ value={
<WithI18n <WithI18n
@@ -456,6 +462,7 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
alwaysVisible={false} alwaysVisible={false}
fullWidth={false} fullWidth={false}
helpText={null} helpText={null}
id={null}
label="Name" label="Name"
value="jane brown" value="jane brown"
> >
@@ -680,6 +687,7 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
alwaysVisible={false} alwaysVisible={false}
fullWidth={false} fullWidth={false}
helpText={null} helpText={null}
id={null}
label="Team Roles" label="Team Roles"
value={ value={
<WithI18n <WithI18n

View File

@@ -215,8 +215,9 @@ function TemplateList({ i18n }) {
<HeaderCell sortKey="name">{i18n._(t`Name`)}</HeaderCell> <HeaderCell sortKey="name">{i18n._(t`Name`)}</HeaderCell>
<HeaderCell sortKey="type">{i18n._(t`Type`)}</HeaderCell> <HeaderCell sortKey="type">{i18n._(t`Type`)}</HeaderCell>
<HeaderCell sortKey="last_job_run"> <HeaderCell sortKey="last_job_run">
{i18n._(t`Last Run`)} {i18n._(t`Last Ran`)}
</HeaderCell> </HeaderCell>
<HeaderCell>{i18n._(t`Actions`)}</HeaderCell>
</HeaderRow> </HeaderRow>
} }
renderToolbar={props => ( renderToolbar={props => (

View File

@@ -25,6 +25,7 @@ import { JobTemplatesAPI, WorkflowJobTemplatesAPI } from '../../../api';
import LaunchButton from '../../../components/LaunchButton'; import LaunchButton from '../../../components/LaunchButton';
import Sparkline from '../../../components/Sparkline'; import Sparkline from '../../../components/Sparkline';
import { toTitleCase } from '../../../util/strings'; import { toTitleCase } from '../../../util/strings';
import { formatDateString } from '../../../util/dates';
import CopyButton from '../../../components/CopyButton'; import CopyButton from '../../../components/CopyButton';
function TemplateListItem({ function TemplateListItem({
@@ -87,6 +88,15 @@ function TemplateListItem({
</Link> </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 ( return (
<> <>
@@ -122,15 +132,14 @@ function TemplateListItem({
)} )}
</Td> </Td>
<Td dataLabel={i18n._(t`Type`)}>{toTitleCase(template.type)}</Td> <Td dataLabel={i18n._(t`Type`)}>{toTitleCase(template.type)}</Td>
<Td dataLabel={i18n._(t`Recent Jobs`)}> <Td dataLabel={i18n._(t`Last Ran`)}>{lastRun}</Td>
<Sparkline jobs={template.summary_fields.recent_jobs} />
</Td>
<ActionsTd dataLabel={i18n._(t`Actions`)}> <ActionsTd dataLabel={i18n._(t`Actions`)}>
<ActionItem <ActionItem
visible={template.type === 'workflow_job_template'} visible={template.type === 'workflow_job_template'}
tooltip={i18n._(t`Visualizer`)} tooltip={i18n._(t`Visualizer`)}
> >
<Button <Button
id={`template-action-visualizer-${template.id}`}
isDisabled={isDisabled} isDisabled={isDisabled}
aria-label={i18n._(t`Visualizer`)} aria-label={i18n._(t`Visualizer`)}
variant="plain" variant="plain"
@@ -147,6 +156,7 @@ function TemplateListItem({
<LaunchButton resource={template}> <LaunchButton resource={template}>
{({ handleLaunch }) => ( {({ handleLaunch }) => (
<Button <Button
id={`template-action-launch-${template.id}`}
isDisabled={isDisabled} isDisabled={isDisabled}
aria-label={i18n._(t`Launch template`)} aria-label={i18n._(t`Launch template`)}
variant="plain" variant="plain"
@@ -162,6 +172,7 @@ function TemplateListItem({
tooltip={i18n._(t`Edit Template`)} tooltip={i18n._(t`Edit Template`)}
> >
<Button <Button
id={`template-action-edit-${template.id}`}
isDisabled={isDisabled} isDisabled={isDisabled}
aria-label={i18n._(t`Edit Template`)} aria-label={i18n._(t`Edit Template`)}
variant="plain" variant="plain"
@@ -173,6 +184,7 @@ function TemplateListItem({
</ActionItem> </ActionItem>
<ActionItem visible={template.summary_fields.user_capabilities.copy}> <ActionItem visible={template.summary_fields.user_capabilities.copy}>
<CopyButton <CopyButton
id={`template-action-copy-${template.id}`}
helperText={{ helperText={{
errorMessage: i18n._(t`Failed to copy template.`), errorMessage: i18n._(t`Failed to copy template.`),
tooltip: i18n._(t`Copy Template`), tooltip: i18n._(t`Copy Template`),
@@ -193,6 +205,7 @@ function TemplateListItem({
<Detail <Detail
label={i18n._(t`Activity`)} label={i18n._(t`Activity`)}
value={<Sparkline jobs={summaryFields.recent_jobs} />} value={<Sparkline jobs={summaryFields.recent_jobs} />}
dataCy={`template-${template.id}-activity`}
/> />
{summaryFields.credentials && summaryFields.credentials.length && ( {summaryFields.credentials && summaryFields.credentials.length && (
<Detail <Detail
@@ -207,6 +220,7 @@ function TemplateListItem({
))} ))}
</ChipGroup> </ChipGroup>
} }
dataCy={`template-${template.id}-credentials`}
/> />
)} )}
{summaryFields.inventory ? ( {summaryFields.inventory ? (
@@ -216,6 +230,7 @@ function TemplateListItem({
summaryFields.inventory.kind, summaryFields.inventory.kind,
summaryFields.inventory.id summaryFields.inventory.id
)} )}
dataCy={`template-${template.id}-inventory`}
/> />
) : ( ) : (
!askInventoryOnLaunch && ( !askInventoryOnLaunch && (
@@ -237,9 +252,10 @@ function TemplateListItem({
))} ))}
</ChipGroup> </ChipGroup>
} }
dataCy={`template-${template.id}-labels`}
/> />
)} )}
{summaryFields.project ? ( {summaryFields.project && (
<Detail <Detail
label={i18n._(t`Project`)} label={i18n._(t`Project`)}
value={ value={
@@ -247,10 +263,14 @@ function TemplateListItem({
{summaryFields.project.name} {summaryFields.project.name}
</Link> </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> </DetailList>
</ExpandableRowContent> </ExpandableRowContent>
</Td> </Td>