import React, { Component, PropTypes } from 'react'; import { EmptyStateView, Table } from '@jenkins-cd/design-language'; import Runs from './Runs'; import Pipeline from '../api/Pipeline'; import { RunRecord, ChangeSetRecord } from './records'; import RunPipeline from './RunPipeline.jsx'; import { actions, currentRuns as runsSelector, createSelector, connect, } from '../redux'; const { object, array, func, string, bool } = PropTypes; const EmptyState = ({ repoName, pipeline, showRunButton }) => (

Ready, get set...

Hmm, looks like there are no runs in this pipeline’s history.

Commit to the repository {repoName} or run the pipeline manually.

{showRunButton && }
); EmptyState.propTypes = { repoName: string, pipeline: object, showRunButton: bool, }; const RunNonMultiBranchPipeline = ({ pipeline, buttonText }) => ( ); RunNonMultiBranchPipeline.propTypes = { pipeline: object, buttonText: string, }; export class Activity extends Component { componentWillMount() { if (this.context.config && this.context.params) { const { params: { pipeline, }, config = {}, } = this.context; config.pipeline = pipeline; this.props.fetchRunsIfNeeded(config); } } render() { const { runs, pipeline } = this.props; // early out if (!runs) { return null; } // Only show the Run button for non multi-branch pipelines. // Multi-branch pipelines have the Run/play button beside them on // the Branches/PRs tab. const showRunButton = (pipeline && !Pipeline.isMultibranch(pipeline)); if (!runs.length) { return (); } const headers = [ 'Status', 'Build', 'Commit', { label: 'Branch', className: 'branch' }, { label: 'Message', className: 'message' }, { label: 'Duration', className: 'duration' }, { label: 'Completed', className: 'completed' }, { label: '', className: 'actions' }, ]; return (
{showRunButton && } { runs.map((run, index) => { const changeset = run.changeSet; let latestRecord = {}; if (changeset && changeset.length > 0) { latestRecord = new ChangeSetRecord(changeset[ Object.keys(changeset)[0] ]); } return (); }) }
); } } Activity.contextTypes = { params: object.isRequired, location: object.isRequired, config: object.isRequired, }; Activity.propTypes = { runs: array, pipeline: object, fetchRunsIfNeeded: func, }; const selectors = createSelector([runsSelector], (runs) => ({ runs })); export default connect(selectors, actions)(Activity);