Fix visual glitches

Change-Id: I4f2875202f1a45445157adb4a9a0e18bc2e0afa8
This commit is contained in:
Guillaume Vincent 2019-05-31 12:10:28 +02:00
parent ce1e66dc2e
commit 06e13e80fd
6 changed files with 56 additions and 48 deletions

View File

@ -2,7 +2,6 @@ import React, { Component } from "react";
import { import {
Card, Card,
CardHeader, CardHeader,
CardBody,
PageSection, PageSection,
PageSectionVariants PageSectionVariants
} from "@patternfly/react-core"; } from "@patternfly/react-core";
@ -38,15 +37,14 @@ export class PlaybookPage extends Component {
return <Page404 />; return <Page404 />;
} }
return ( return (
<PageSection variant={PageSectionVariants.light}> <PageSection variant={PageSectionVariants.default}>
<PlaybookSummary <PlaybookSummary
key={playbook.id} key={playbook.id}
playbook={playbook} playbook={playbook}
history={history} history={history}
/> />
<Card> <Card className="pf-u-mb-xs">
<CardHeader>Hosts</CardHeader> <CardHeader>Hosts</CardHeader>
<CardBody>
<table className="pf-c-table pf-m-compact pf-m-grid-md" role="grid"> <table className="pf-c-table pf-m-compact pf-m-grid-md" role="grid">
<thead> <thead>
<tr> <tr>
@ -71,7 +69,6 @@ export class PlaybookPage extends Component {
))} ))}
</tbody> </tbody>
</table> </table>
</CardBody>
</Card> </Card>
<Card> <Card>
<CardHeader>Plays</CardHeader> <CardHeader>Plays</CardHeader>

View File

@ -4,7 +4,9 @@ import { Card, CardBody, Label } from "@patternfly/react-core";
import { import {
CheckCircleIcon, CheckCircleIcon,
ExclamationCircleIcon, ExclamationCircleIcon,
PauseCircleIcon PauseCircleIcon,
CalendarAltIcon,
ClockIcon
} from "@patternfly/react-icons"; } from "@patternfly/react-icons";
import { import {
global_danger_color_100, global_danger_color_100,
@ -155,9 +157,10 @@ export default class Playbook extends Component {
<PlaybookContent> <PlaybookContent>
<StatusAndName> <StatusAndName>
<StatusIcon status={playbook.status} /> <StatusIcon status={playbook.status} />
{new Date(playbook.started).toUTCString()}
<h1 className="pf-c-title pf-m-xl pf-u-ml-md"> <h1 className="pf-c-title pf-m-xl pf-u-ml-md">
{(playbook.name ? playbook.name : playbook.path.split("/").slice(-1)[0])} {playbook.name
? playbook.name
: playbook.path.split("/").slice(-1)[0]}
</h1> </h1>
</StatusAndName> </StatusAndName>
<PlaybookInfos> <PlaybookInfos>
@ -182,11 +185,19 @@ export default class Playbook extends Component {
</PlaybookInfos> </PlaybookInfos>
<Labels> <Labels>
{playbook.labels.map(label => ( {playbook.labels.map(label => (
<Label className="pf-u-mr-md" isCompact>{label.name}</Label> <Label className="pf-u-mr-md" isCompact>
{label.name}
</Label>
))} ))}
</Labels> </Labels>
<Duration> <Duration>
<i className="fa fa-clock" /> <CalendarAltIcon />
<span className="pf-u-ml-sm">
{new Date(playbook.started).toUTCString()}
</span>
</Duration>
<Duration>
<ClockIcon />
<span className="pf-u-ml-sm"> <span className="pf-u-ml-sm">
{Math.round(playbook.duration)} sec {Math.round(playbook.duration)} sec
</span> </span>

View File

@ -78,9 +78,9 @@ export default class TaskRow extends Component {
className={`pf-c-table__expandable-row ${isExpanded && className={`pf-c-table__expandable-row ${isExpanded &&
"pf-m-expanded"}`} "pf-m-expanded"}`}
> >
<td colspan="5"> <td colspan="5" className="pf-u-p-0">
<div <div
className={`pf-c-table__expandable-row-content pf-u-p-2xl ${isExpanded && className={`pf-c-table__expandable-row-content ${isExpanded &&
"pf-m-expanded"}`} "pf-m-expanded"}`}
> >
<table <table
@ -90,16 +90,22 @@ export default class TaskRow extends Component {
<caption>Task results</caption> <caption>Task results</caption>
<thead> <thead>
<tr> <tr>
<th className="pf-u-text-align-center">Status</th>
<th className="pf-u-text-align-center">Host</th> <th className="pf-u-text-align-center">Host</th>
<th className="pf-u-text-align-center">Started</th> <th className="pf-u-text-align-center">Started</th>
<th className="pf-u-text-align-center">Ended</th> <th className="pf-u-text-align-center">Ended</th>
<th className="pf-u-text-align-center">Duration</th> <th className="pf-u-text-align-center">Duration</th>
<th className="pf-u-text-align-center">Status</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{task.results.map(result => ( {task.results.map(result => (
<tr> <tr>
<td
data-label="Status"
className="pf-u-text-align-center"
>
<Status status={result.status}>{result.status}</Status>
</td>
<td data-label="Host" className="pf-u-text-align-center"> <td data-label="Host" className="pf-u-text-align-center">
{result.host.name} {result.host.name}
</td> </td>
@ -118,19 +124,12 @@ export default class TaskRow extends Component {
> >
{result.duration} {result.duration}
</td> </td>
<td
data-label="Status"
className="pf-u-text-align-center"
>
<Status status={result.status}>{result.status}</Status>
</td>
</tr> </tr>
))} ))}
</tbody> </tbody>
</table> </table>
</div> </div>
</td> </td>
<td />
</tr> </tr>
</tbody> </tbody>
); );

View File

@ -6,7 +6,7 @@ export default class Tasks extends Component {
const { tasks } = this.props; const { tasks } = this.props;
return ( return (
<table <table
className="pf-c-table pf-m-expandable" className="pf-c-table pf-m-compact pf-m-expandable"
role="grid" role="grid"
aria-label="Tasks table" aria-label="Tasks table"
> >

View File

@ -4,7 +4,8 @@ function _getAveragesFromTask(task) {
(acc, result) => { (acc, result) => {
acc.statuses[result.status] += 1; acc.statuses[result.status] += 1;
acc.total_duration += parseFloat(result.duration); acc.total_duration += parseFloat(result.duration);
acc.average_duration = acc.total_duration / results.length; acc.average_duration =
Math.round((acc.total_duration * 100) / results.length) / 100;
return acc; return acc;
}, },
{ {

View File

@ -100,7 +100,7 @@ test("extractTasksFromPlays", () => {
{ {
name: "Gathering Facts", name: "Gathering Facts",
action: "gather_facts", action: "gather_facts",
average_duration: 1.702101, average_duration: 1.7,
statuses: { statuses: {
ok: 1, ok: 1,
failed: 0, failed: 0,
@ -125,7 +125,7 @@ test("extractTasksFromPlays", () => {
{ {
name: "Gathering Facts", name: "Gathering Facts",
action: "gather_facts", action: "gather_facts",
average_duration: 1.296572, average_duration: 1.3,
statuses: { statuses: {
ok: 3, ok: 3,
failed: 0, failed: 0,
@ -161,7 +161,7 @@ test("extractTasksFromPlays", () => {
ended: "2019-05-17T16:55:12.195753", ended: "2019-05-17T16:55:12.195753",
status: "ok" status: "ok"
} }
], ]
} }
]; ];
expect(extractTasksFromPlays(plays)).toEqual(expectedTasks); expect(extractTasksFromPlays(plays)).toEqual(expectedTasks);