2019-11-22 21:34:57 +03:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
2021-04-21 21:59:21 +03:00
|
|
|
import PlatformConfig from './PlatformConfig';
|
2019-11-22 21:34:57 +03:00
|
|
|
|
|
|
|
export default class JobListMetric extends React.PureComponent {
|
|
|
|
render() {
|
2021-04-21 21:59:21 +03:00
|
|
|
const {
|
|
|
|
data,
|
|
|
|
currentRepo,
|
|
|
|
revision,
|
|
|
|
notify,
|
|
|
|
selectedJobName,
|
|
|
|
selectedTaskId,
|
|
|
|
updateParamsAndState,
|
|
|
|
} = this.props;
|
|
|
|
const { name, result, details } = data;
|
|
|
|
const jobNames = {};
|
2020-12-03 01:42:08 +03:00
|
|
|
|
|
|
|
let msgForZeroJobs = `All ${name} passed`;
|
|
|
|
const correctGrammer = name.slice(-1) === 's' ? 'are' : 'is';
|
|
|
|
|
|
|
|
if (result === 'unknown') {
|
|
|
|
msgForZeroJobs = `${name} ${correctGrammer} in progress. No failures detected.`;
|
|
|
|
}
|
2019-11-22 21:34:57 +03:00
|
|
|
|
2021-04-21 21:59:21 +03:00
|
|
|
details.forEach((job) => {
|
|
|
|
if (!jobNames[job.job_type_name]) {
|
|
|
|
jobNames[job.job_type_name] = [job];
|
|
|
|
} else {
|
|
|
|
jobNames[job.job_type_name].push(job);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const jobsList = Object.entries(jobNames);
|
|
|
|
|
2019-11-22 21:34:57 +03:00
|
|
|
return (
|
2020-07-08 06:30:39 +03:00
|
|
|
<div>
|
2021-04-21 21:59:21 +03:00
|
|
|
{jobsList.length > 0 ? (
|
|
|
|
jobsList.map(([jobName, jobs]) => (
|
|
|
|
<PlatformConfig
|
|
|
|
key={jobName}
|
|
|
|
jobName={jobName}
|
|
|
|
currentRepo={currentRepo}
|
|
|
|
revision={revision}
|
|
|
|
notify={notify}
|
|
|
|
selectedJobName={selectedJobName}
|
|
|
|
selectedTaskId={selectedTaskId}
|
|
|
|
updateParamsAndState={updateParamsAndState}
|
|
|
|
jobs={jobs}
|
|
|
|
>
|
|
|
|
<span className="px-2 text-darker-secondary font-weight-500">
|
|
|
|
{jobName}
|
|
|
|
</span>
|
|
|
|
</PlatformConfig>
|
2020-07-08 06:30:39 +03:00
|
|
|
))
|
|
|
|
) : (
|
|
|
|
<div>{msgForZeroJobs}</div>
|
|
|
|
)}
|
|
|
|
</div>
|
2019-11-22 21:34:57 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
JobListMetric.propTypes = {
|
2020-04-23 22:19:25 +03:00
|
|
|
data: PropTypes.shape({
|
|
|
|
name: PropTypes.string.isRequired,
|
|
|
|
result: PropTypes.string.isRequired,
|
|
|
|
details: PropTypes.array.isRequired,
|
|
|
|
}).isRequired,
|
2021-04-21 21:59:21 +03:00
|
|
|
currentRepo: PropTypes.shape({}).isRequired,
|
|
|
|
updateParamsAndState: PropTypes.func.isRequired,
|
2019-11-22 21:34:57 +03:00
|
|
|
};
|