Improved UI of Pull Requests page

This commit is contained in:
Victor Perevertkin 2019-11-03 03:49:56 +03:00
parent f53f79e23b
commit 542576fbbd
No known key found for this signature in database
GPG Key ID: C750B7222E9C7830
7 changed files with 23 additions and 32 deletions

View File

@ -54,7 +54,7 @@ const mapStateToProps = ({ builders }, ownProps) => {
return { return {
builds: ownProps.builds.map(build => ({ builds: ownProps.builds.map(build => ({
...build, ...build,
builderName: builders[build.builderid].name builderName: builders[build.builderid] && builders[build.builderid].name
})) }))
}; };
}; };

View File

@ -7,6 +7,7 @@ import {
DropdownItem DropdownItem
} from 'reactstrap'; } from 'reactstrap';
import { currState, loadPulls } from '../redux/actions'; import { currState, loadPulls } from '../redux/actions';
import {PULL_STATE} from '../redux/constants'
class pullState extends React.Component { class pullState extends React.Component {
constructor(props) { constructor(props) {
@ -57,7 +58,7 @@ class pullState extends React.Component {
} }
}} }}
> >
{this.props.pullState.pullsState.map(this.renderPullsState)} {Object.values(PULL_STATE).map(this.renderPullsState)}
</DropdownMenu> </DropdownMenu>
</Dropdown> </Dropdown>
); );

View File

@ -3,35 +3,25 @@ import { UncontrolledCollapse, CardBody, Card, CardHeader } from 'reactstrap';
import BuildDetails from './BuildDetails'; import BuildDetails from './BuildDetails';
import TestDetails from './TestDetails'; import TestDetails from './TestDetails';
function PullsCard(props) { function PullsCard(props) {
let tog = 'toggler' + props.id; let tog = 'toggler' + props.id;
let createdDate = new Date(props.created_at); let createdDate = new Date(props.created_at);
let closedDate = new Date(props.closed_at); let closedDate = new Date(props.closed_at);
let mergedDate = new Date(props.merged_at); let mergedDate = new Date(props.merged_at);
return ( return (
<Card> <Card>
<CardHeader className='new' type='button' id={tog}> <CardHeader className='new' type='button' id={tog}>
<div className='row'> <div className='row'>
<div className='col-sm'>{props.number}</div> <div className='col-sm-1'><a href={props.html_url}>#{props.number}</a></div>
<div className='col-sm'>{props.merge_commit_sha.substring(0, 7)}</div> <div className='col-sm-9'>{props.title}</div>
<div className='col-sm'>{props.state}</div> <div className='col-sm-2'>{props.user.login}</div>
<div className='col-sm'>{props.user.login}</div>
</div> </div>
</CardHeader> </CardHeader>
<UncontrolledCollapse toggler={tog}> <UncontrolledCollapse toggler={tog}>
<CardBody className='indent'> <CardBody className='indent'>
<p> <p style={{whiteSpace: "pre-line"}}>{props.body}</p>
<strong>Pull number: </strong>{' '}
<a target='_blank' rel='noreferrer noopener' href={props.html_url}>
{props.number}
</a>
</p>
<p>
<strong>Title:</strong> {props.title}
</p>
<p>
<strong>Body:</strong> {props.body}
</p>
<div className='row'> <div className='row'>
<div className='col-sm'> <div className='col-sm'>
<strong>Created at: </strong> <strong>Created at: </strong>

View File

@ -6,7 +6,6 @@
display: block; display: block;
} }
.s { .s {
text-align: center;
margin-top: 2em; margin-top: 2em;
} }
.m1 { .m1 {
@ -20,6 +19,7 @@
border-bottom: 1px solid #aaa; border-bottom: 1px solid #aaa;
margin: 10px 0px; margin: 10px 0px;
padding: 0; padding: 0;
text-align: center;
} }
.react-tabs__tab { .react-tabs__tab {

View File

@ -1,3 +1,9 @@
export const PULL_STATE = {
OPEN: 'open',
CLOSED: 'closed',
ALL: 'all',
}
export const COMMITS = { export const COMMITS = {
LOAD: 'COMMITS_LOAD', LOAD: 'COMMITS_LOAD',
LOAD_SUCCESS: 'COMMITS_LOAD_SUCCESS', LOAD_SUCCESS: 'COMMITS_LOAD_SUCCESS',

View File

@ -1,14 +1,8 @@
import { PULLS } from '../constants'; import { PULLS, PULL_STATE } from '../constants';
const pullStateReducer = ( const pullStateReducer = (state = PULL_STATE.OPEN, action) => {
state = { pullsState: ['open', 'closed', 'all'], currentPullState: 'all' },
action
) => {
if (action.type === PULLS.CURRENT) { if (action.type === PULLS.CURRENT) {
return { return action.pullState;
...state,
currentPullState: action.pullState
};
} }
return state; return state;

View File

@ -3,7 +3,7 @@ import { PULLS } from '../constants';
import { fetchPulls } from '../api'; import { fetchPulls } from '../api';
import { setPulls, setPullsError, setPages } from '../actions'; import { setPulls, setPullsError, setPages } from '../actions';
const getNewPage = state => parseInt(state.isLoading.newPage, 10); const getNewPage = state => parseInt(state.isLoading.newPage, 10);
const getNewState = state => state.pullState.currentPullState; const getNewState = state => state.pullState;
function* handlePullsLoad() { function* handlePullsLoad() {
try { try {
const newPage = yield select(getNewPage); const newPage = yield select(getNewPage);