Apply prettier on javascript files

use prettier 2.0

Change-Id: I3a7b8ae39029a7f52f3c8f953bba7bfea82c2f1a
This commit is contained in:
Guillaume Vincent 2020-04-20 10:05:39 +02:00 committed by David Moreau Simard
parent a7213aeffb
commit 57acf74e4a
30 changed files with 143 additions and 159 deletions

View File

@ -16,7 +16,7 @@ class App extends Component {
_isMounted = false; _isMounted = false;
state = { state = {
isLoading: true isLoading: true,
}; };
componentDidMount() { componentDidMount() {
@ -24,7 +24,7 @@ class App extends Component {
store store
.dispatch(getConfig()) .dispatch(getConfig())
.then(() => store.dispatch(checkAuthentification())) .then(() => store.dispatch(checkAuthentification()))
.catch(error => { .catch((error) => {
if (this._isMounted) { if (this._isMounted) {
console.error(error); console.error(error);
} }

View File

@ -9,7 +9,7 @@ const axiosMock = new axiosMockAdapter(axios);
it("renders without crashing", () => { it("renders without crashing", () => {
axiosMock.onGet("config.json").reply(200, { axiosMock.onGet("config.json").reply(200, {
apiURL: "http://localhost:8000" apiURL: "http://localhost:8000",
}); });
const div = document.createElement("div"); const div = document.createElement("div");
ReactDOM.render(<App />, div); ReactDOM.render(<App />, div);

View File

@ -8,14 +8,14 @@ class PrivateRoute extends Component {
return ( return (
<Route <Route
{...props} {...props}
render={props => render={(props) =>
isAuthenticated ? ( isAuthenticated ? (
<Component {...props} /> <Component {...props} />
) : ( ) : (
<Redirect <Redirect
to={{ to={{
pathname: "/login", pathname: "/login",
state: { from: props.location } state: { from: props.location },
}} }}
/> />
) )
@ -27,7 +27,7 @@ class PrivateRoute extends Component {
function mapStateToProps(state) { function mapStateToProps(state) {
return { return {
isAuthenticated: state.auth.isAuthenticated isAuthenticated: state.auth.isAuthenticated,
}; };
} }

View File

@ -5,7 +5,7 @@ import { setCredentials, removeCredentials } from "./localStorage";
export function logout() { export function logout() {
removeCredentials(); removeCredentials();
return { return {
type: types.LOGOUT type: types.LOGOUT,
}; };
} }
@ -14,15 +14,15 @@ export function checkAuthentification() {
const state = getState(); const state = getState();
return http({ return http({
method: "get", method: "get",
url: `${state.config.apiURL}/api/v1/` url: `${state.config.apiURL}/api/v1/`,
}) })
.then(response => { .then((response) => {
dispatch({ dispatch({
type: types.LOGIN type: types.LOGIN,
}); });
return response; return response;
}) })
.catch(error => { .catch((error) => {
if (error.response && error.response.status === 401) { if (error.response && error.response.status === 401) {
dispatch(logout()); dispatch(logout());
} }
@ -32,7 +32,7 @@ export function checkAuthentification() {
} }
export function login(username, password) { export function login(username, password) {
return dispatch => { return (dispatch) => {
setCredentials({ username, password }); setCredentials({ username, password });
return dispatch(checkAuthentification()); return dispatch(checkAuthentification());
}; };

View File

@ -15,8 +15,8 @@ it("checkAuthentification", () => {
axiosMock.onGet("https://api.example.org/api/v1/").reply(200, {}); axiosMock.onGet("https://api.example.org/api/v1/").reply(200, {});
const expectedActions = [ const expectedActions = [
{ {
type: types.LOGIN type: types.LOGIN,
} },
]; ];
const store = mockStore({ config: { apiURL: "https://api.example.org" } }); const store = mockStore({ config: { apiURL: "https://api.example.org" } });
return store.dispatch(checkAuthentification()).then(() => { return store.dispatch(checkAuthentification()).then(() => {
@ -28,8 +28,8 @@ it("checkAuthentification unauthorized", () => {
axiosMock.onGet("https://api.example.org/api/v1/").reply(401, {}); axiosMock.onGet("https://api.example.org/api/v1/").reply(401, {});
const expectedActions = [ const expectedActions = [
{ {
type: types.LOGOUT type: types.LOGOUT,
} },
]; ];
const store = mockStore({ config: { apiURL: "https://api.example.org" } }); const store = mockStore({ config: { apiURL: "https://api.example.org" } });
return store.dispatch(checkAuthentification()).catch(() => { return store.dispatch(checkAuthentification()).catch(() => {

View File

@ -1,7 +1,7 @@
import * as types from "./authActionsTypes"; import * as types from "./authActionsTypes";
const initialState = { const initialState = {
isAuthenticated: true isAuthenticated: true,
}; };
export default function (state = initialState, action) { export default function (state = initialState, action) {
@ -9,12 +9,12 @@ export default function(state = initialState, action) {
case types.LOGIN: case types.LOGIN:
return { return {
...state, ...state,
isAuthenticated: true isAuthenticated: true,
}; };
case types.LOGOUT: case types.LOGOUT:
return { return {
...state, ...state,
isAuthenticated: false isAuthenticated: false,
}; };
default: default:
return state; return state;

View File

@ -7,18 +7,18 @@ it("returns the initial state", () => {
it("LOGIN", () => { it("LOGIN", () => {
const newState = reducer(undefined, { const newState = reducer(undefined, {
type: types.LOGIN type: types.LOGIN,
}); });
expect(newState).toEqual({ expect(newState).toEqual({
isAuthenticated: true isAuthenticated: true,
}); });
}); });
it("LOGOUT", () => { it("LOGOUT", () => {
const newState = reducer(undefined, { const newState = reducer(undefined, {
type: types.LOGOUT type: types.LOGOUT,
}); });
expect(newState).toEqual({ expect(newState).toEqual({
isAuthenticated: false isAuthenticated: false,
}); });
}); });

View File

@ -1,7 +1,7 @@
import { import {
setCredentials, setCredentials,
getCredentials, getCredentials,
removeCredentials removeCredentials,
} from "./localStorage"; } from "./localStorage";
it("localStorage getCredentials", () => { it("localStorage getCredentials", () => {
@ -11,7 +11,7 @@ it("localStorage getCredentials", () => {
it("localStorage setCredentials getCredentials removeCredentials", () => { it("localStorage setCredentials getCredentials removeCredentials", () => {
const credentials = { const credentials = {
username: "foo", username: "foo",
password: "bar" password: "bar",
}; };
setCredentials(credentials); setCredentials(credentials);
expect(getCredentials()).toEqual(credentials); expect(getCredentials()).toEqual(credentials);

View File

@ -4,13 +4,15 @@ import * as types from "./configActionsTypes";
export function setConfig(config) { export function setConfig(config) {
return { return {
type: types.SET_CONFIG, type: types.SET_CONFIG,
config config,
}; };
} }
export function getConfig() { export function getConfig() {
return dispatch => { return (dispatch) => {
return http.get(`${process.env.PUBLIC_URL}/config.json`).then(response => { return http
.get(`${process.env.PUBLIC_URL}/config.json`)
.then((response) => {
const config = response.data; const config = response.data;
dispatch(setConfig(config)); dispatch(setConfig(config));
return response; return response;

View File

@ -5,7 +5,7 @@ it("setConfig", () => {
const config = { apiURL: "http://example.org" }; const config = { apiURL: "http://example.org" };
const expectedActions = { const expectedActions = {
type: types.SET_CONFIG, type: types.SET_CONFIG,
config config,
}; };
expect(actions.setConfig(config)).toEqual(expectedActions); expect(actions.setConfig(config)).toEqual(expectedActions);
}); });

View File

@ -6,7 +6,7 @@ export default function(state = initialState, action) {
switch (action.type) { switch (action.type) {
case types.SET_CONFIG: case types.SET_CONFIG:
return { return {
...action.config ...action.config,
}; };
default: default:
return state; return state;

View File

@ -11,8 +11,8 @@ it("SET_CONFIG", () => {
{ {
type: types.SET_CONFIG, type: types.SET_CONFIG,
config: { config: {
apiURL: "http://example.org" apiURL: "http://example.org",
} },
} }
); );
expect(state.apiURL).toBe("http://example.org"); expect(state.apiURL).toBe("http://example.org");

View File

@ -1,7 +1,7 @@
import axios from "axios"; import axios from "axios";
import { getCredentials } from "./auth/localStorage"; import { getCredentials } from "./auth/localStorage";
axios.interceptors.request.use(config => { axios.interceptors.request.use((config) => {
const credentials = getCredentials(); const credentials = getCredentials();
if (credentials) { if (credentials) {
config.auth = credentials; config.auth = credentials;

View File

@ -8,7 +8,7 @@ import {
NavItem, NavItem,
NavList, NavList,
NavVariants, NavVariants,
PageHeader PageHeader,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
import logo from "../images/logo.svg"; import logo from "../images/logo.svg";
@ -53,7 +53,7 @@ class Header extends Component {
function mapStateToProps(state) { function mapStateToProps(state) {
return { return {
isAuthenticated: state.auth.isAuthenticated isAuthenticated: state.auth.isAuthenticated,
}; };
} }

View File

@ -4,17 +4,17 @@ import {
Card, Card,
CardBody, CardBody,
PageSection, PageSection,
PageSectionVariants PageSectionVariants,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
export default class LoadingPage extends Component { export default class LoadingPage extends Component {
state = { state = {
seconds: 0 seconds: 0,
}; };
tick() { tick() {
this.setState(state => ({ this.setState((state) => ({
seconds: state.seconds + 1 seconds: state.seconds + 1,
})); }));
} }

View File

@ -3,7 +3,7 @@ import {
Bullseye, Bullseye,
Button, Button,
PageSection, PageSection,
PageSectionVariants PageSectionVariants,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
export default class Page404 extends Component { export default class Page404 extends Component {

View File

@ -4,7 +4,7 @@ import {
LoginFooterItem, LoginFooterItem,
LoginForm, LoginForm,
LoginPage, LoginPage,
ListItem ListItem,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
import { Redirect } from "react-router-dom"; import { Redirect } from "react-router-dom";
import logo from "../images/logo.svg"; import logo from "../images/logo.svg";
@ -18,18 +18,18 @@ export class AraLoginPage extends Component {
isValidUsername: true, isValidUsername: true,
password: "", password: "",
isValidPassword: true, isValidPassword: true,
redirectToReferrer: false redirectToReferrer: false,
}; };
handleUsernameChange = username => { handleUsernameChange = (username) => {
this.setState({ username }); this.setState({ username });
}; };
handlePasswordChange = password => { handlePasswordChange = (password) => {
this.setState({ password }); this.setState({ password });
}; };
onLoginButtonClick = event => { onLoginButtonClick = (event) => {
event.preventDefault(); event.preventDefault();
const { username, password } = this.state; const { username, password } = this.state;
const { login } = this.props; const { login } = this.props;
@ -42,7 +42,7 @@ export class AraLoginPage extends Component {
showHelperText: true, showHelperText: true,
isValidUsername: false, isValidUsername: false,
isValidPassword: false, isValidPassword: false,
helperText: "Invalid username or password" helperText: "Invalid username or password",
}); });
}); });
}; };
@ -55,7 +55,7 @@ export class AraLoginPage extends Component {
isValidPassword, isValidPassword,
showHelperText, showHelperText,
helperText, helperText,
redirectToReferrer redirectToReferrer,
} = this.state; } = this.state;
const { location, isAuthenticated } = this.props; const { location, isAuthenticated } = this.props;
const { from } = location.state || { from: { pathname: "/" } }; const { from } = location.state || { from: { pathname: "/" } };
@ -100,17 +100,14 @@ export class AraLoginPage extends Component {
function mapStateToProps(state) { function mapStateToProps(state) {
return { return {
isAuthenticated: state.auth.isAuthenticated isAuthenticated: state.auth.isAuthenticated,
}; };
} }
function mapDispatchToProps(dispatch) { function mapDispatchToProps(dispatch) {
return { return {
login: (username, password) => dispatch(login(username, password)) login: (username, password) => dispatch(login(username, password)),
}; };
} }
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(AraLoginPage);
mapStateToProps,
mapDispatchToProps
)(AraLoginPage);

View File

@ -3,7 +3,7 @@ import {
Card, Card,
CardHeader, CardHeader,
PageSection, PageSection,
PageSectionVariants PageSectionVariants,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { isEmpty } from "lodash"; import { isEmpty } from "lodash";
@ -16,14 +16,14 @@ import { extractTasksFromPlays } from "../tasks/task";
export class PlaybookPage extends Component { export class PlaybookPage extends Component {
state = { state = {
isLoading: true, isLoading: true,
playbook: null playbook: null,
}; };
componentDidMount() { componentDidMount() {
this.props this.props
.getPlaybook({ id: this.props.match.params.id }) .getPlaybook({ id: this.props.match.params.id })
.then(response => this.setState({ playbook: response.data })) .then((response) => this.setState({ playbook: response.data }))
.catch(error => console.log(error)) .catch((error) => console.log(error))
.then(() => this.setState({ isLoading: false })); .then(() => this.setState({ isLoading: false }));
} }
@ -57,7 +57,7 @@ export class PlaybookPage extends Component {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{playbook.hosts.map(host => ( {playbook.hosts.map((host) => (
<tr key={host.id}> <tr key={host.id}>
<td data-label="Name">{host.name}</td> <td data-label="Name">{host.name}</td>
<td data-label="OK">{host.ok}</td> <td data-label="OK">{host.ok}</td>
@ -81,11 +81,8 @@ export class PlaybookPage extends Component {
function mapDispatchToProps(dispatch) { function mapDispatchToProps(dispatch) {
return { return {
getPlaybook: playbook => dispatch(getPlaybook(playbook)) getPlaybook: (playbook) => dispatch(getPlaybook(playbook)),
}; };
} }
export default connect( export default connect(null, mapDispatchToProps)(PlaybookPage);
null,
mapDispatchToProps
)(PlaybookPage);

View File

@ -6,14 +6,14 @@ import {
ExclamationCircleIcon, ExclamationCircleIcon,
PauseCircleIcon, PauseCircleIcon,
CalendarAltIcon, CalendarAltIcon,
ClockIcon ClockIcon,
} from "@patternfly/react-icons"; } from "@patternfly/react-icons";
import { import {
global_danger_color_100, global_danger_color_100,
global_success_color_100, global_success_color_100,
global_active_color_100, global_active_color_100,
global_warning_color_100, global_warning_color_100,
global_Color_light_100 global_Color_light_100,
} from "@patternfly/react-tokens"; } from "@patternfly/react-tokens";
const StatusIcon = ({ status }) => { const StatusIcon = ({ status }) => {
@ -56,21 +56,13 @@ const StatusIcon = ({ status }) => {
function getBackground(status, backgroundColor = global_Color_light_100.value) { function getBackground(status, backgroundColor = global_Color_light_100.value) {
switch (status) { switch (status) {
case "running": case "running":
return `linear-gradient(to right,${global_active_color_100.value} 0,${ return `linear-gradient(to right,${global_active_color_100.value} 0,${global_active_color_100.value} 5px,${backgroundColor} 5px,${backgroundColor} 100%) no-repeat`;
global_active_color_100.value
} 5px,${backgroundColor} 5px,${backgroundColor} 100%) no-repeat`;
case "completed": case "completed":
return `linear-gradient(to right,${global_success_color_100.value} 0,${ return `linear-gradient(to right,${global_success_color_100.value} 0,${global_success_color_100.value} 5px,${backgroundColor} 5px,${backgroundColor} 100%) no-repeat`;
global_success_color_100.value
} 5px,${backgroundColor} 5px,${backgroundColor} 100%) no-repeat`;
case "failed": case "failed":
return `linear-gradient(to right,${global_danger_color_100.value} 0,${ return `linear-gradient(to right,${global_danger_color_100.value} 0,${global_danger_color_100.value} 5px,${backgroundColor} 5px,${backgroundColor} 100%) no-repeat`;
global_danger_color_100.value
} 5px,${backgroundColor} 5px,${backgroundColor} 100%) no-repeat`;
default: default:
return `linear-gradient(to right,${global_warning_color_100.value} 0,${ return `linear-gradient(to right,${global_warning_color_100.value} 0,${global_warning_color_100.value} 5px,${backgroundColor} 5px,${backgroundColor} 100%) no-repeat`;
global_warning_color_100.value
} 5px,${backgroundColor} 5px,${backgroundColor} 100%) no-repeat`;
} }
} }
@ -78,7 +70,7 @@ const PlaybookWrapper = styled.div`
cursor: pointer; cursor: pointer;
&:hover { &:hover {
.pf-c-card { .pf-c-card {
background: ${props => getBackground(props.status)}; background: ${(props) => getBackground(props.status)};
} }
`; `;
@ -184,7 +176,7 @@ export default class Playbook extends Component {
</PlaybookInfo> </PlaybookInfo>
</PlaybookInfos> </PlaybookInfos>
<Labels> <Labels>
{playbook.labels.map(label => ( {playbook.labels.map((label) => (
<Label className="pf-u-mr-md" isCompact> <Label className="pf-u-mr-md" isCompact>
{label.name} {label.name}
</Label> </Label>
@ -198,9 +190,7 @@ export default class Playbook extends Component {
</Duration> </Duration>
<Duration> <Duration>
<ClockIcon /> <ClockIcon />
<span className="pf-u-ml-sm"> <span className="pf-u-ml-sm">{playbook.duration}</span>
{playbook.duration}
</span>
</Duration> </Duration>
</PlaybookContent> </PlaybookContent>
</CardBody> </CardBody>

View File

@ -12,7 +12,7 @@ import {
EmptyStateBody, EmptyStateBody,
PageSection, PageSection,
PageSectionVariants, PageSectionVariants,
Title Title,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
import { CubesIcon, ErrorCircleOIcon } from "@patternfly/react-icons"; import { CubesIcon, ErrorCircleOIcon } from "@patternfly/react-icons";
import { LoadingPage } from "../pages"; import { LoadingPage } from "../pages";
@ -23,20 +23,18 @@ export class PlaybooksPage extends Component {
state = { state = {
isLoading: true, isLoading: true,
hasError: false, hasError: false,
errorMessage: "" errorMessage: "",
}; };
componentDidMount() { componentDidMount() {
const { getPlaybooks, config } = this.props; const { getPlaybooks, config } = this.props;
getPlaybooks() getPlaybooks()
.catch(error => { .catch((error) => {
let errorMessage = ""; let errorMessage = "";
if (error.response) { if (error.response) {
errorMessage = error.message; errorMessage = error.message;
} else { } else {
errorMessage = `Server located at ${ errorMessage = `Server located at ${config.apiURL} is unreachable. Check your configuration. Verify that cross-origin requests are not blocked.`;
config.apiURL
} is unreachable. Check your configuration. Verify that cross-origin requests are not blocked.`;
} }
this.setState({ errorMessage, hasError: true }); this.setState({ errorMessage, hasError: true });
}) })
@ -105,7 +103,7 @@ export class PlaybooksPage extends Component {
return ( return (
<PageSection variant={PageSectionVariants.default}> <PageSection variant={PageSectionVariants.default}>
{playbooks.map(playbook => ( {playbooks.map((playbook) => (
<PlaybookSummary <PlaybookSummary
key={playbook.id} key={playbook.id}
playbook={playbook} playbook={playbook}
@ -120,17 +118,14 @@ export class PlaybooksPage extends Component {
function mapStateToProps(state) { function mapStateToProps(state) {
return { return {
config: state.config, config: state.config,
playbooks: Object.values(state.playbooks) playbooks: Object.values(state.playbooks),
}; };
} }
function mapDispatchToProps(dispatch) { function mapDispatchToProps(dispatch) {
return { return {
getPlaybooks: () => dispatch(getPlaybooks()) getPlaybooks: () => dispatch(getPlaybooks()),
}; };
} }
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(PlaybooksPage);
mapStateToProps,
mapDispatchToProps
)(PlaybooksPage);

View File

@ -4,10 +4,10 @@ import * as types from "./playbooksActionsTypes";
export function getPlaybooks() { export function getPlaybooks() {
return (dispatch, getState) => { return (dispatch, getState) => {
const { apiURL } = getState().config; const { apiURL } = getState().config;
return http.get(`${apiURL}/api/v1/playbooks`).then(response => { return http.get(`${apiURL}/api/v1/playbooks`).then((response) => {
dispatch({ dispatch({
type: types.FETCH_PLAYBOOKS, type: types.FETCH_PLAYBOOKS,
playbooks: response.data.results playbooks: response.data.results,
}); });
return response; return response;
}); });

View File

@ -16,13 +16,13 @@ it("getPlaybooks", () => {
count: 1, count: 1,
next: null, next: null,
previous: null, previous: null,
results: [{ id: "p1" }] results: [{ id: "p1" }],
}); });
const expectedActions = [ const expectedActions = [
{ {
type: types.FETCH_PLAYBOOKS, type: types.FETCH_PLAYBOOKS,
playbooks: [{ id: "p1" }] playbooks: [{ id: "p1" }],
} },
]; ];
const store = mockStore({ config: { apiURL: "https://api.example.org" } }); const store = mockStore({ config: { apiURL: "https://api.example.org" } });
return store.dispatch(getPlaybooks()).then(() => { return store.dispatch(getPlaybooks()).then(() => {

View File

@ -4,9 +4,9 @@ import * as types from "./playbooksActionsTypes";
it("FETCH_PLAYBOOKS", () => { it("FETCH_PLAYBOOKS", () => {
const newState = reducer(undefined, { const newState = reducer(undefined, {
type: types.FETCH_PLAYBOOKS, type: types.FETCH_PLAYBOOKS,
playbooks: [{ id: "p1" }] playbooks: [{ id: "p1" }],
}); });
expect(newState).toEqual({ expect(newState).toEqual({
p1: { id: "p1" } p1: { id: "p1" },
}); });
}); });

View File

@ -12,7 +12,7 @@ const localStorageMock = (function() {
}, },
clear: function () { clear: function () {
store = {}; store = {};
} },
}; };
})(); })();

View File

@ -8,7 +8,7 @@ const store = createStore(
combineReducers({ combineReducers({
config: configReducer, config: configReducer,
playbooks: playbooksReducer, playbooks: playbooksReducer,
auth: authReducer auth: authReducer,
}), }),
applyMiddleware(thunk) applyMiddleware(thunk)
); );

View File

@ -3,7 +3,7 @@ import {
global_danger_color_100, global_danger_color_100,
global_success_color_100, global_success_color_100,
global_active_color_100, global_active_color_100,
global_warning_color_100 global_warning_color_100,
} from "@patternfly/react-tokens"; } from "@patternfly/react-tokens";
const Status = ({ status, children }) => { const Status = ({ status, children }) => {
@ -14,7 +14,7 @@ const Status = ({ status, children }) => {
unreachable: global_warning_color_100.value, unreachable: global_warning_color_100.value,
changed: global_active_color_100.value, changed: global_active_color_100.value,
ignored: global_warning_color_100.value, ignored: global_warning_color_100.value,
unknown: global_warning_color_100.value unknown: global_warning_color_100.value,
}; };
return ( return (
<span <span
@ -30,8 +30,8 @@ const Statuses = ({ statuses }) => {
return ( return (
<div> <div>
{Object.keys(statuses) {Object.keys(statuses)
.filter(status => statuses[status] !== 0) .filter((status) => statuses[status] !== 0)
.map(status => ( .map((status) => (
<Status status={status}>{`${statuses[status]} ${status}`}</Status> <Status status={status}>{`${statuses[status]} ${status}`}</Status>
))} ))}
</div> </div>
@ -40,11 +40,11 @@ const Statuses = ({ statuses }) => {
export default class TaskRow extends Component { export default class TaskRow extends Component {
state = { state = {
isExpanded: false isExpanded: false,
}; };
toggleExpand = () => { toggleExpand = () => {
this.setState(prevState => ({ isExpanded: !prevState.isExpanded })); this.setState((prevState) => ({ isExpanded: !prevState.isExpanded }));
}; };
render() { render() {
const { isExpanded } = this.state; const { isExpanded } = this.state;
@ -54,8 +54,9 @@ export default class TaskRow extends Component {
<tr> <tr>
<td className="pf-c-table__toggle"> <td className="pf-c-table__toggle">
<button <button
className={`pf-c-button pf-m-plain ${isExpanded && className={`pf-c-button pf-m-plain ${
"pf-m-expanded"}`} isExpanded && "pf-m-expanded"
}`}
aria-label="Details" aria-label="Details"
aria-controls={`expandable task ${task.name}`} aria-controls={`expandable task ${task.name}`}
aria-expanded={isExpanded ? "true" : "false"} aria-expanded={isExpanded ? "true" : "false"}
@ -75,13 +76,15 @@ export default class TaskRow extends Component {
</td> </td>
</tr> </tr>
<tr <tr
className={`pf-c-table__expandable-row ${isExpanded && className={`pf-c-table__expandable-row ${
"pf-m-expanded"}`} isExpanded && "pf-m-expanded"
}`}
> >
<td colspan="5" className="pf-u-p-0"> <td colspan="5" className="pf-u-p-0">
<div <div
className={`pf-c-table__expandable-row-content ${isExpanded && className={`pf-c-table__expandable-row-content ${
"pf-m-expanded"}`} isExpanded && "pf-m-expanded"
}`}
> >
<table <table
className="pf-c-table pf-m-compact pf-m-no-border-rows" className="pf-c-table pf-m-compact pf-m-no-border-rows"
@ -98,7 +101,7 @@ export default class TaskRow extends Component {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{task.results.map(result => ( {task.results.map((result) => (
<tr> <tr>
<td <td
data-label="Status" data-label="Status"

View File

@ -19,7 +19,7 @@ export default class Tasks extends Component {
<td className="pf-u-text-align-center">Status</td> <td className="pf-u-text-align-center">Status</td>
</tr> </tr>
</thead> </thead>
{tasks.map(task => ( {tasks.map((task) => (
<TaskRow task={task} /> <TaskRow task={task} />
))} ))}
</table> </table>

View File

@ -18,8 +18,8 @@ function _getAveragesFromTask(task) {
unreachable: 0, unreachable: 0,
changed: 0, changed: 0,
ignored: 0, ignored: 0,
unknown: 0 unknown: 0,
} },
} }
); );
} }
@ -33,7 +33,7 @@ export function extractTasksFromPlays(plays) {
results: task.results, results: task.results,
task_id: task.id, task_id: task.id,
statuses: taskAverages.statuses, statuses: taskAverages.statuses,
average_duration: taskAverages.average_duration average_duration: taskAverages.average_duration,
}); });
} }
return acc; return acc;

View File

@ -17,13 +17,13 @@ test("extractTasksFromPlays", () => {
host: { id: 3, name: "localhost", alias: "localhost" }, host: { id: 3, name: "localhost", alias: "localhost" },
started: "2019-05-17T16:55:07.993741", started: "2019-05-17T16:55:07.993741",
ended: "2019-05-17T16:55:09.695842", ended: "2019-05-17T16:55:09.695842",
status: "ok" status: "ok",
} },
], ],
file: { file: {
id: 6, id: 6,
path: path:
"/home/zuul/src/opendev.org/recordsansible/ara/tests/integration/hosts.yaml" "/home/zuul/src/opendev.org/recordsansible/ara/tests/integration/hosts.yaml",
}, },
started: "2019-05-17T16:55:07.993741", started: "2019-05-17T16:55:07.993741",
ended: "2019-05-17T16:55:09.787161", ended: "2019-05-17T16:55:09.787161",
@ -32,13 +32,13 @@ test("extractTasksFromPlays", () => {
lineno: 19, lineno: 19,
handler: false, handler: false,
status: "completed", status: "completed",
play: 4 play: 4,
} },
], ],
started: "2019-05-17T16:55:07.795907", started: "2019-05-17T16:55:07.795907",
ended: "2019-05-17T16:55:10.006643", ended: "2019-05-17T16:55:10.006643",
name: "Create fake hosts for host tests", name: "Create fake hosts for host tests",
status: "completed" status: "completed",
}, },
{ {
id: 5, id: 5,
@ -55,7 +55,7 @@ test("extractTasksFromPlays", () => {
host: { id: 5, name: "host3", alias: null }, host: { id: 5, name: "host3", alias: null },
started: "2019-05-17T16:55:10.330416", started: "2019-05-17T16:55:10.330416",
ended: "2019-05-17T16:55:11.263736", ended: "2019-05-17T16:55:11.263736",
status: "ok" status: "ok",
}, },
{ {
id: 7, id: 7,
@ -63,7 +63,7 @@ test("extractTasksFromPlays", () => {
host: { id: 6, name: "host2", alias: null }, host: { id: 6, name: "host2", alias: null },
started: "2019-05-17T16:55:10.330416", started: "2019-05-17T16:55:10.330416",
ended: "2019-05-17T16:55:11.421475", ended: "2019-05-17T16:55:11.421475",
status: "ok" status: "ok",
}, },
{ {
id: 8, id: 8,
@ -71,13 +71,13 @@ test("extractTasksFromPlays", () => {
host: { id: 7, name: "host1", alias: null }, host: { id: 7, name: "host1", alias: null },
started: "2019-05-17T16:55:10.330416", started: "2019-05-17T16:55:10.330416",
ended: "2019-05-17T16:55:12.195753", ended: "2019-05-17T16:55:12.195753",
status: "ok" status: "ok",
} },
], ],
file: { file: {
id: 6, id: 6,
path: path:
"/home/zuul/src/opendev.org/recordsansible/ara/tests/integration/hosts.yaml" "/home/zuul/src/opendev.org/recordsansible/ara/tests/integration/hosts.yaml",
}, },
started: "2019-05-17T16:55:10.330416", started: "2019-05-17T16:55:10.330416",
ended: "2019-05-17T16:55:12.289771", ended: "2019-05-17T16:55:12.289771",
@ -86,14 +86,14 @@ test("extractTasksFromPlays", () => {
lineno: 33, lineno: 33,
handler: false, handler: false,
status: "completed", status: "completed",
play: 5 play: 5,
} },
], ],
started: "2019-05-17T16:55:10.135506", started: "2019-05-17T16:55:10.135506",
ended: "2019-05-17T16:55:14.488333", ended: "2019-05-17T16:55:14.488333",
name: "ARA Hosts test play", name: "ARA Hosts test play",
status: "completed" status: "completed",
} },
]; ];
const expectedTasks = [ const expectedTasks = [
@ -108,7 +108,7 @@ test("extractTasksFromPlays", () => {
unreachable: 0, unreachable: 0,
changed: 0, changed: 0,
ignored: 0, ignored: 0,
unknown: 0 unknown: 0,
}, },
results: [ results: [
{ {
@ -117,10 +117,10 @@ test("extractTasksFromPlays", () => {
host: { id: 3, name: "localhost", alias: "localhost" }, host: { id: 3, name: "localhost", alias: "localhost" },
started: "2019-05-17T16:55:07.993741", started: "2019-05-17T16:55:07.993741",
ended: "2019-05-17T16:55:09.695842", ended: "2019-05-17T16:55:09.695842",
status: "ok" status: "ok",
} },
], ],
task_id: 5 task_id: 5,
}, },
{ {
name: "Gathering Facts", name: "Gathering Facts",
@ -133,7 +133,7 @@ test("extractTasksFromPlays", () => {
unreachable: 0, unreachable: 0,
changed: 0, changed: 0,
ignored: 0, ignored: 0,
unknown: 0 unknown: 0,
}, },
task_id: 6, task_id: 6,
results: [ results: [
@ -143,7 +143,7 @@ test("extractTasksFromPlays", () => {
host: { id: 5, name: "host3", alias: null }, host: { id: 5, name: "host3", alias: null },
started: "2019-05-17T16:55:10.330416", started: "2019-05-17T16:55:10.330416",
ended: "2019-05-17T16:55:11.263736", ended: "2019-05-17T16:55:11.263736",
status: "ok" status: "ok",
}, },
{ {
id: 7, id: 7,
@ -151,7 +151,7 @@ test("extractTasksFromPlays", () => {
host: { id: 6, name: "host2", alias: null }, host: { id: 6, name: "host2", alias: null },
started: "2019-05-17T16:55:10.330416", started: "2019-05-17T16:55:10.330416",
ended: "2019-05-17T16:55:11.421475", ended: "2019-05-17T16:55:11.421475",
status: "ok" status: "ok",
}, },
{ {
id: 8, id: 8,
@ -159,10 +159,10 @@ test("extractTasksFromPlays", () => {
host: { id: 7, name: "host1", alias: null }, host: { id: 7, name: "host1", alias: null },
started: "2019-05-17T16:55:10.330416", started: "2019-05-17T16:55:10.330416",
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);
}); });