mirror of
https://github.com/reactos/developer-web-interface.git
synced 2024-11-23 03:49:43 +00:00
indentation fix
This commit is contained in:
parent
07df420005
commit
bfadfd4fdb
310
app.js
310
app.js
@ -12,230 +12,230 @@ const key = process.env.SECRET;
|
||||
|
||||
//settings for production Environment
|
||||
if (!dev) {
|
||||
app.disable('x-powered-by');
|
||||
// Serve static files from the React app
|
||||
app.use(express.static(path.join(__dirname, 'client/build')));
|
||||
app.disable('x-powered-by');
|
||||
// Serve static files from the React app
|
||||
app.use(express.static(path.join(__dirname, 'client/build')));
|
||||
}
|
||||
|
||||
//------- COMMITS END-POINT -------
|
||||
|
||||
function commitReq(sha, page) {
|
||||
const commits = {
|
||||
uri: 'https://api.github.com/repos/reactos/reactos/commits',
|
||||
resolveWithFullResponse: true,
|
||||
qs: {
|
||||
access_token: key,
|
||||
sha: sha,
|
||||
per_page: 10,
|
||||
page: page
|
||||
},
|
||||
headers: {
|
||||
'User-Agent': 'Request-Promise'
|
||||
},
|
||||
json: true
|
||||
};
|
||||
const commits = {
|
||||
uri: 'https://api.github.com/repos/reactos/reactos/commits',
|
||||
resolveWithFullResponse: true,
|
||||
qs: {
|
||||
access_token: key,
|
||||
sha: sha,
|
||||
per_page: 10,
|
||||
page: page
|
||||
},
|
||||
headers: {
|
||||
'User-Agent': 'Request-Promise'
|
||||
},
|
||||
json: true
|
||||
};
|
||||
|
||||
return commits;
|
||||
return commits;
|
||||
}
|
||||
|
||||
app.get('/api/commits', (req, res) => {
|
||||
rp(commitReq(req.query.sha, req.query.page))
|
||||
.then(body => {
|
||||
let link = body.headers.link;
|
||||
let parsed = parse(link);
|
||||
let dataAndPage = {
|
||||
page: {
|
||||
...parsed
|
||||
},
|
||||
commits: body
|
||||
};
|
||||
rp(commitReq(req.query.sha, req.query.page))
|
||||
.then(body => {
|
||||
let link = body.headers.link;
|
||||
let parsed = parse(link);
|
||||
let dataAndPage = {
|
||||
page: {
|
||||
...parsed
|
||||
},
|
||||
commits: body
|
||||
};
|
||||
|
||||
res.json(dataAndPage);
|
||||
})
|
||||
.catch(function(err) {
|
||||
res.json({ error: 'oops...something went wrong', err: err });
|
||||
});
|
||||
res.json(dataAndPage);
|
||||
})
|
||||
.catch(function(err) {
|
||||
res.json({ error: 'oops...something went wrong', err: err });
|
||||
});
|
||||
});
|
||||
|
||||
//------- BRANCHES END-POINT -------
|
||||
|
||||
function branchReq() {
|
||||
const branches = {
|
||||
uri: 'https://api.github.com/repos/reactos/reactos/branches',
|
||||
resolveWithFullResponse: false,
|
||||
qs: {
|
||||
access_token: key,
|
||||
per_page: 100
|
||||
},
|
||||
headers: {
|
||||
'User-Agent': 'Request-Promise'
|
||||
},
|
||||
json: true
|
||||
};
|
||||
const branches = {
|
||||
uri: 'https://api.github.com/repos/reactos/reactos/branches',
|
||||
resolveWithFullResponse: false,
|
||||
qs: {
|
||||
access_token: key,
|
||||
per_page: 100
|
||||
},
|
||||
headers: {
|
||||
'User-Agent': 'Request-Promise'
|
||||
},
|
||||
json: true
|
||||
};
|
||||
|
||||
return branches;
|
||||
return branches;
|
||||
}
|
||||
|
||||
app.get('/api/branches', (req, res) => {
|
||||
rp(branchReq())
|
||||
.then(body => {
|
||||
res.json(body);
|
||||
})
|
||||
.catch(function(err) {
|
||||
res.json({ error: 'oops...something went wrong' });
|
||||
});
|
||||
rp(branchReq())
|
||||
.then(body => {
|
||||
res.json(body);
|
||||
})
|
||||
.catch(function(err) {
|
||||
res.json({ error: 'oops...something went wrong' });
|
||||
});
|
||||
});
|
||||
|
||||
//------- PR'S END-POINT -------
|
||||
|
||||
function pullReq(state, page) {
|
||||
const pulls = {
|
||||
uri: 'https://api.github.com/repos/reactos/reactos/pulls',
|
||||
resolveWithFullResponse: true,
|
||||
qs: {
|
||||
access_token: key,
|
||||
state: state,
|
||||
per_page: 10,
|
||||
page: page
|
||||
},
|
||||
headers: {
|
||||
'User-Agent': 'Request-Promise'
|
||||
},
|
||||
json: true
|
||||
};
|
||||
const pulls = {
|
||||
uri: 'https://api.github.com/repos/reactos/reactos/pulls',
|
||||
resolveWithFullResponse: true,
|
||||
qs: {
|
||||
access_token: key,
|
||||
state: state,
|
||||
per_page: 10,
|
||||
page: page
|
||||
},
|
||||
headers: {
|
||||
'User-Agent': 'Request-Promise'
|
||||
},
|
||||
json: true
|
||||
};
|
||||
|
||||
return pulls;
|
||||
return pulls;
|
||||
}
|
||||
|
||||
app.get('/api/pulls', (req, res) => {
|
||||
rp(pullReq(req.query.state, req.query.page))
|
||||
.then(body => {
|
||||
let link = body.headers.link;
|
||||
let parsed = parse(link);
|
||||
let dataAndPage = {
|
||||
page: {
|
||||
...parsed
|
||||
},
|
||||
pulls: body
|
||||
};
|
||||
rp(pullReq(req.query.state, req.query.page))
|
||||
.then(body => {
|
||||
let link = body.headers.link;
|
||||
let parsed = parse(link);
|
||||
let dataAndPage = {
|
||||
page: {
|
||||
...parsed
|
||||
},
|
||||
pulls: body
|
||||
};
|
||||
|
||||
res.json(dataAndPage);
|
||||
})
|
||||
.catch(function(err) {
|
||||
res.json({ error: 'oops...something went wrong' });
|
||||
});
|
||||
res.json(dataAndPage);
|
||||
})
|
||||
.catch(function(err) {
|
||||
res.json({ error: 'oops...something went wrong' });
|
||||
});
|
||||
});
|
||||
|
||||
//------- BUILD-SET END-POINT -------
|
||||
|
||||
function buildSetReq() {
|
||||
const buildSets = {
|
||||
uri:
|
||||
'https://build.reactos.org/api/v2/buildsets?field=bsid&field=sourcestamps&order=-bsid&offset=0&limit=200',
|
||||
headers: {
|
||||
'User-Agent': 'Request-Promise'
|
||||
},
|
||||
json: true
|
||||
};
|
||||
const buildSets = {
|
||||
uri:
|
||||
'https://build.reactos.org/api/v2/buildsets?field=bsid&field=sourcestamps&order=-bsid&offset=0&limit=200',
|
||||
headers: {
|
||||
'User-Agent': 'Request-Promise'
|
||||
},
|
||||
json: true
|
||||
};
|
||||
|
||||
return buildSets;
|
||||
return buildSets;
|
||||
}
|
||||
|
||||
app.get('/api/buildsets', (req, res) => {
|
||||
rp(buildSetReq())
|
||||
.then(body => {
|
||||
res.json(body);
|
||||
})
|
||||
.catch(function(err) {
|
||||
res.json({ error: 'oops...something went wrong' });
|
||||
});
|
||||
rp(buildSetReq())
|
||||
.then(body => {
|
||||
res.json(body);
|
||||
})
|
||||
.catch(function(err) {
|
||||
res.json({ error: 'oops...something went wrong' });
|
||||
});
|
||||
});
|
||||
|
||||
//------- BUILD-REQUEST END-POINT -------
|
||||
|
||||
function buildReq(str) {
|
||||
const buildReq = {
|
||||
uri: `https://build.reactos.org/api/v2/buildrequests?${str}&field=buildsetid&field=buildrequestid&order=-buildsetid`,
|
||||
headers: {
|
||||
'User-Agent': 'Request-Promise'
|
||||
},
|
||||
json: true
|
||||
};
|
||||
const buildReq = {
|
||||
uri: `https://build.reactos.org/api/v2/buildrequests?${str}&field=buildsetid&field=buildrequestid&order=-buildsetid`,
|
||||
headers: {
|
||||
'User-Agent': 'Request-Promise'
|
||||
},
|
||||
json: true
|
||||
};
|
||||
|
||||
return buildReq;
|
||||
return buildReq;
|
||||
}
|
||||
|
||||
app.get('/api/buildreq', (req, res) => {
|
||||
let f = req.query.buildsetid__contains;
|
||||
let queryStr = f.join('&buildsetid__contains=');
|
||||
queryStr = 'buildsetid__contains=' + queryStr;
|
||||
rp(buildReq(queryStr))
|
||||
.then(body => {
|
||||
res.json(body);
|
||||
})
|
||||
.catch(function(err) {
|
||||
res.json({ error: 'oops...something went wrong' });
|
||||
});
|
||||
let f = req.query.buildsetid__contains;
|
||||
let queryStr = f.join('&buildsetid__contains=');
|
||||
queryStr = 'buildsetid__contains=' + queryStr;
|
||||
rp(buildReq(queryStr))
|
||||
.then(body => {
|
||||
res.json(body);
|
||||
})
|
||||
.catch(function(err) {
|
||||
res.json({ error: 'oops...something went wrong' });
|
||||
});
|
||||
});
|
||||
|
||||
//------- BUILDS END-POINT -------
|
||||
|
||||
function builds(str) {
|
||||
const builds = {
|
||||
uri: `https://build.reactos.org/api/v2/builds?${str}&order=-buildrequestid`,
|
||||
headers: {
|
||||
'User-Agent': 'Request-Promise'
|
||||
},
|
||||
json: true
|
||||
};
|
||||
const builds = {
|
||||
uri: `https://build.reactos.org/api/v2/builds?${str}&order=-buildrequestid`,
|
||||
headers: {
|
||||
'User-Agent': 'Request-Promise'
|
||||
},
|
||||
json: true
|
||||
};
|
||||
|
||||
return builds;
|
||||
return builds;
|
||||
}
|
||||
|
||||
app.get('/api/builds', (req, res) => {
|
||||
let f = req.query.buildrequestid__contains;
|
||||
let queryStr = f.join('&buildrequestid__contains=');
|
||||
queryStr = 'buildrequestid__contains=' + queryStr;
|
||||
rp(builds(queryStr))
|
||||
.then(body => {
|
||||
res.json(body);
|
||||
})
|
||||
.catch(function(err) {
|
||||
res.json({ error: 'oops...something went wrong' });
|
||||
});
|
||||
let f = req.query.buildrequestid__contains;
|
||||
let queryStr = f.join('&buildrequestid__contains=');
|
||||
queryStr = 'buildrequestid__contains=' + queryStr;
|
||||
rp(builds(queryStr))
|
||||
.then(body => {
|
||||
res.json(body);
|
||||
})
|
||||
.catch(function(err) {
|
||||
res.json({ error: 'oops...something went wrong' });
|
||||
});
|
||||
});
|
||||
|
||||
//------- BRANCHES END-POINT -------
|
||||
|
||||
function builderReq() {
|
||||
const builders = {
|
||||
uri: 'https://build.reactos.org/api/v2/builders',
|
||||
resolveWithFullResponse: false,
|
||||
headers: {
|
||||
'User-Agent': 'Request-Promise'
|
||||
},
|
||||
json: true
|
||||
};
|
||||
const builders = {
|
||||
uri: 'https://build.reactos.org/api/v2/builders',
|
||||
resolveWithFullResponse: false,
|
||||
headers: {
|
||||
'User-Agent': 'Request-Promise'
|
||||
},
|
||||
json: true
|
||||
};
|
||||
|
||||
return builders;
|
||||
return builders;
|
||||
}
|
||||
|
||||
app.get('/api/builders', (req, res) => {
|
||||
rp(builderReq())
|
||||
.then(body => {
|
||||
res.json(body);
|
||||
})
|
||||
.catch(function(err) {
|
||||
res.json({ error: 'oops...something went wrong' });
|
||||
});
|
||||
rp(builderReq())
|
||||
.then(body => {
|
||||
res.json(body);
|
||||
})
|
||||
.catch(function(err) {
|
||||
res.json({ error: 'oops...something went wrong' });
|
||||
});
|
||||
});
|
||||
|
||||
if (!dev) {
|
||||
app.get('*', (req, res) => {
|
||||
res.sendFile(path.join(__dirname + '/client/build/index.html'));
|
||||
});
|
||||
app.get('*', (req, res) => {
|
||||
res.sendFile(path.join(__dirname + '/client/build/index.html'));
|
||||
});
|
||||
}
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log('server started');
|
||||
console.log('server started');
|
||||
});
|
||||
|
@ -1,94 +1,94 @@
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
Dropdown,
|
||||
DropdownToggle,
|
||||
DropdownMenu,
|
||||
DropdownItem
|
||||
Dropdown,
|
||||
DropdownToggle,
|
||||
DropdownMenu,
|
||||
DropdownItem
|
||||
} from 'reactstrap';
|
||||
import {
|
||||
loadBranches,
|
||||
loadCommits,
|
||||
currBranch,
|
||||
loadBuilders
|
||||
loadBranches,
|
||||
loadCommits,
|
||||
currBranch,
|
||||
loadBuilders
|
||||
} from '../redux/actions';
|
||||
|
||||
class Branches extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
dropdownOpen: false
|
||||
};
|
||||
}
|
||||
componentDidMount() {
|
||||
this.props.loadBuilders();
|
||||
this.props.loadBranches();
|
||||
}
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
dropdownOpen: false
|
||||
};
|
||||
}
|
||||
componentDidMount() {
|
||||
this.props.loadBuilders();
|
||||
this.props.loadBranches();
|
||||
}
|
||||
|
||||
renderBranches = branch => {
|
||||
return (
|
||||
<DropdownItem
|
||||
onClick={() => {
|
||||
this.props.currBranch(branch.name);
|
||||
this.props.loadCommits(1);
|
||||
}}
|
||||
key={branch.name}
|
||||
>
|
||||
{branch.name}
|
||||
</DropdownItem>
|
||||
);
|
||||
};
|
||||
toggle = () => {
|
||||
this.setState(prevState => ({
|
||||
dropdownOpen: !prevState.dropdownOpen
|
||||
}));
|
||||
};
|
||||
Stylemodif = data => {
|
||||
return {
|
||||
...data,
|
||||
styles: {
|
||||
...data.styles,
|
||||
overflow: 'auto',
|
||||
maxHeight: 500
|
||||
}
|
||||
renderBranches = branch => {
|
||||
return (
|
||||
<DropdownItem
|
||||
onClick={() => {
|
||||
this.props.currBranch(branch.name);
|
||||
this.props.loadCommits(1);
|
||||
}}
|
||||
key={branch.name}
|
||||
>
|
||||
{branch.name}
|
||||
</DropdownItem>
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Dropdown isOpen={this.state.dropdownOpen} toggle={this.toggle}>
|
||||
<DropdownToggle caret>
|
||||
<i className='fa fa-sitemap' />
|
||||
Branches
|
||||
</DropdownToggle>
|
||||
<DropdownMenu
|
||||
modifiers={{
|
||||
setMaxHeight: {
|
||||
enabled: true,
|
||||
order: 890,
|
||||
fn: this.Stylemodif
|
||||
toggle = () => {
|
||||
this.setState(prevState => ({
|
||||
dropdownOpen: !prevState.dropdownOpen
|
||||
}));
|
||||
};
|
||||
Stylemodif = data => {
|
||||
return {
|
||||
...data,
|
||||
styles: {
|
||||
...data.styles,
|
||||
overflow: 'auto',
|
||||
maxHeight: 500
|
||||
}
|
||||
}}
|
||||
>
|
||||
{this.props.branches.map(this.renderBranches)}
|
||||
</DropdownMenu>
|
||||
</Dropdown>
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Dropdown isOpen={this.state.dropdownOpen} toggle={this.toggle}>
|
||||
<DropdownToggle caret>
|
||||
<i className='fa fa-sitemap' />
|
||||
Branches
|
||||
</DropdownToggle>
|
||||
<DropdownMenu
|
||||
modifiers={{
|
||||
setMaxHeight: {
|
||||
enabled: true,
|
||||
order: 890,
|
||||
fn: this.Stylemodif
|
||||
}
|
||||
}}
|
||||
>
|
||||
{this.props.branches.map(this.renderBranches)}
|
||||
</DropdownMenu>
|
||||
</Dropdown>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = ({ branches }) => ({
|
||||
branches
|
||||
branches
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
loadCommits: next => dispatch(loadCommits(next)),
|
||||
loadBranches: () => dispatch(loadBranches()),
|
||||
loadBuilders: () => dispatch(loadBuilders()),
|
||||
currBranch: branch => dispatch(currBranch(branch))
|
||||
loadCommits: next => dispatch(loadCommits(next)),
|
||||
loadBranches: () => dispatch(loadBranches()),
|
||||
loadBuilders: () => dispatch(loadBuilders()),
|
||||
currBranch: branch => dispatch(currBranch(branch))
|
||||
});
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(Branches);
|
||||
|
@ -1,85 +1,85 @@
|
||||
import { COMMITS, BRANCHES, PULLS, BUILD_DATA, BUILDERS } from '../constants';
|
||||
|
||||
export const loadCommits = newPage => ({
|
||||
type: COMMITS.LOAD,
|
||||
newPage
|
||||
type: COMMITS.LOAD,
|
||||
newPage
|
||||
});
|
||||
|
||||
export const setCommits = commits => ({
|
||||
type: COMMITS.LOAD_SUCCESS,
|
||||
commits
|
||||
type: COMMITS.LOAD_SUCCESS,
|
||||
commits
|
||||
});
|
||||
|
||||
export const setCommitsError = error => ({
|
||||
type: COMMITS.LOAD_FAIL,
|
||||
error
|
||||
type: COMMITS.LOAD_FAIL,
|
||||
error
|
||||
});
|
||||
|
||||
export const loadBuildSets = () => ({
|
||||
type: BUILD_DATA.LOAD
|
||||
type: BUILD_DATA.LOAD
|
||||
});
|
||||
export const setBuilds = build => ({
|
||||
type: BUILD_DATA.LOAD_SUCCESS,
|
||||
build
|
||||
type: BUILD_DATA.LOAD_SUCCESS,
|
||||
build
|
||||
});
|
||||
|
||||
export const setBuildSetsError = error => ({
|
||||
type: BUILD_DATA.LOAD_FAIL,
|
||||
error
|
||||
type: BUILD_DATA.LOAD_FAIL,
|
||||
error
|
||||
});
|
||||
|
||||
export const setPages = (next, prev) => ({
|
||||
type: 'PAGE_LOAD_SUCCESS',
|
||||
next,
|
||||
prev
|
||||
type: 'PAGE_LOAD_SUCCESS',
|
||||
next,
|
||||
prev
|
||||
});
|
||||
export const loadBranches = () => ({
|
||||
type: BRANCHES.LOAD
|
||||
type: BRANCHES.LOAD
|
||||
});
|
||||
|
||||
export const setBranches = branches => ({
|
||||
type: BRANCHES.LOAD_SUCCESS,
|
||||
branches
|
||||
type: BRANCHES.LOAD_SUCCESS,
|
||||
branches
|
||||
});
|
||||
export const currBranch = branch => ({
|
||||
type: BRANCHES.CURRENT,
|
||||
branch
|
||||
type: BRANCHES.CURRENT,
|
||||
branch
|
||||
});
|
||||
|
||||
export const setBranchesError = error => ({
|
||||
type: BRANCHES.LOAD_FAIL,
|
||||
error
|
||||
type: BRANCHES.LOAD_FAIL,
|
||||
error
|
||||
});
|
||||
|
||||
export const loadBuilders = () => ({
|
||||
type: BUILDERS.LOAD
|
||||
type: BUILDERS.LOAD
|
||||
});
|
||||
|
||||
export const setBuilders = builders => ({
|
||||
type: BUILDERS.LOAD_SUCCESS,
|
||||
builders
|
||||
type: BUILDERS.LOAD_SUCCESS,
|
||||
builders
|
||||
});
|
||||
|
||||
export const setBuildersError = error => ({
|
||||
type: BUILDERS.LOAD_FAIL,
|
||||
error
|
||||
type: BUILDERS.LOAD_FAIL,
|
||||
error
|
||||
});
|
||||
|
||||
export const currState = pullState => ({
|
||||
type: PULLS.CURRENT,
|
||||
pullState
|
||||
type: PULLS.CURRENT,
|
||||
pullState
|
||||
});
|
||||
export const loadPulls = newPage => ({
|
||||
type: PULLS.LOAD,
|
||||
newPage
|
||||
type: PULLS.LOAD,
|
||||
newPage
|
||||
});
|
||||
|
||||
export const setPulls = pulls => ({
|
||||
type: PULLS.LOAD_SUCCESS,
|
||||
pulls
|
||||
type: PULLS.LOAD_SUCCESS,
|
||||
pulls
|
||||
});
|
||||
|
||||
export const setPullsError = error => ({
|
||||
type: PULLS.LOAD_FAIL,
|
||||
error
|
||||
type: PULLS.LOAD_FAIL,
|
||||
error
|
||||
});
|
||||
|
@ -1,61 +1,61 @@
|
||||
export const fetchCommits = async (sha, page) => {
|
||||
const response = await fetch(`/api/commits?sha=${sha}&page=${page}`);
|
||||
const data = await response.json();
|
||||
if (response.status >= 400) {
|
||||
throw new Error(data.errors);
|
||||
}
|
||||
return data;
|
||||
const response = await fetch(`/api/commits?sha=${sha}&page=${page}`);
|
||||
const data = await response.json();
|
||||
if (response.status >= 400) {
|
||||
throw new Error(data.errors);
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
export const fetchBuildSets = async () => {
|
||||
const response = await fetch('/api/buildsets');
|
||||
const data = await response.json();
|
||||
if (response.status >= 400) {
|
||||
throw new Error(data.errors);
|
||||
}
|
||||
return data.buildsets;
|
||||
const response = await fetch('/api/buildsets');
|
||||
const data = await response.json();
|
||||
if (response.status >= 400) {
|
||||
throw new Error(data.errors);
|
||||
}
|
||||
return data.buildsets;
|
||||
};
|
||||
|
||||
export const fetchBuildReq = async str => {
|
||||
const response = await fetch(`/api/buildreq?${str}`);
|
||||
const data = await response.json();
|
||||
if (response.status >= 400) {
|
||||
throw new Error(data.errors);
|
||||
}
|
||||
return data.buildrequests;
|
||||
const response = await fetch(`/api/buildreq?${str}`);
|
||||
const data = await response.json();
|
||||
if (response.status >= 400) {
|
||||
throw new Error(data.errors);
|
||||
}
|
||||
return data.buildrequests;
|
||||
};
|
||||
|
||||
export const fetchBuilds = async str => {
|
||||
const response = await fetch(`/api/builds?${str}`);
|
||||
const data = await response.json();
|
||||
if (response.status >= 400) {
|
||||
throw new Error(data.errors);
|
||||
}
|
||||
return data.builds;
|
||||
const response = await fetch(`/api/builds?${str}`);
|
||||
const data = await response.json();
|
||||
if (response.status >= 400) {
|
||||
throw new Error(data.errors);
|
||||
}
|
||||
return data.builds;
|
||||
};
|
||||
|
||||
export const fetchBuilders = async () => {
|
||||
const response = await fetch('/api/builders');
|
||||
const data = await response.json();
|
||||
if (response.status >= 400) {
|
||||
throw new Error(data.errors);
|
||||
}
|
||||
return data.builders;
|
||||
const response = await fetch('/api/builders');
|
||||
const data = await response.json();
|
||||
if (response.status >= 400) {
|
||||
throw new Error(data.errors);
|
||||
}
|
||||
return data.builders;
|
||||
};
|
||||
|
||||
export const fetchBranches = async () => {
|
||||
const response = await fetch('/api/branches');
|
||||
const data = await response.json();
|
||||
if (response.status >= 400) {
|
||||
throw new Error(data.errors);
|
||||
}
|
||||
return data;
|
||||
const response = await fetch('/api/branches');
|
||||
const data = await response.json();
|
||||
if (response.status >= 400) {
|
||||
throw new Error(data.errors);
|
||||
}
|
||||
return data;
|
||||
};
|
||||
export const fetchPulls = async (state, page) => {
|
||||
const response = await fetch(`/api/pulls?state=${state}&page=${page}`);
|
||||
const data = await response.json();
|
||||
if (response.status >= 400) {
|
||||
throw new Error(data.errors);
|
||||
}
|
||||
return data;
|
||||
const response = await fetch(`/api/pulls?state=${state}&page=${page}`);
|
||||
const data = await response.json();
|
||||
if (response.status >= 400) {
|
||||
throw new Error(data.errors);
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
@ -1,31 +1,31 @@
|
||||
export const COMMITS = {
|
||||
LOAD: 'COMMITS_LOAD',
|
||||
LOAD_SUCCESS: 'COMMITS_LOAD_SUCCESS',
|
||||
LOAD_FAIL: 'COMMITS_LOAD_FAIL'
|
||||
LOAD: 'COMMITS_LOAD',
|
||||
LOAD_SUCCESS: 'COMMITS_LOAD_SUCCESS',
|
||||
LOAD_FAIL: 'COMMITS_LOAD_FAIL'
|
||||
};
|
||||
|
||||
export const BRANCHES = {
|
||||
LOAD: 'BRANCHES_LOAD',
|
||||
LOAD_SUCCESS: 'BRANCHES_LOAD_SUCCESS',
|
||||
LOAD_FAIL: 'BRANCHES_LOAD_FAIL',
|
||||
CURRENT: 'CURRENT_BRANCH'
|
||||
LOAD: 'BRANCHES_LOAD',
|
||||
LOAD_SUCCESS: 'BRANCHES_LOAD_SUCCESS',
|
||||
LOAD_FAIL: 'BRANCHES_LOAD_FAIL',
|
||||
CURRENT: 'CURRENT_BRANCH'
|
||||
};
|
||||
|
||||
export const PULLS = {
|
||||
LOAD: 'PULLS_LOAD',
|
||||
LOAD_SUCCESS: 'PULLS_LOAD_SUCCESS',
|
||||
LOAD_FAIL: 'PULLS_LOAD_FAIL',
|
||||
CURRENT: 'CURRENT_STATE'
|
||||
LOAD: 'PULLS_LOAD',
|
||||
LOAD_SUCCESS: 'PULLS_LOAD_SUCCESS',
|
||||
LOAD_FAIL: 'PULLS_LOAD_FAIL',
|
||||
CURRENT: 'CURRENT_STATE'
|
||||
};
|
||||
|
||||
export const BUILD_DATA = {
|
||||
LOAD: 'BUILD_DATA_LOAD',
|
||||
LOAD_SUCCESS: 'BUILD_DATA_LOAD_SUCCESS',
|
||||
LOAD_FAIL: 'BUILD_DATA_LOAD_FAIL'
|
||||
LOAD: 'BUILD_DATA_LOAD',
|
||||
LOAD_SUCCESS: 'BUILD_DATA_LOAD_SUCCESS',
|
||||
LOAD_FAIL: 'BUILD_DATA_LOAD_FAIL'
|
||||
};
|
||||
|
||||
export const BUILDERS = {
|
||||
LOAD: 'BUILDER_LOAD',
|
||||
LOAD_SUCCESS: 'BUILDER_LOAD_SUCCESS',
|
||||
LOAD_FAIL: 'BUILDER_LOAD_FAIL'
|
||||
LOAD: 'BUILDER_LOAD',
|
||||
LOAD_SUCCESS: 'BUILDER_LOAD_SUCCESS',
|
||||
LOAD_FAIL: 'BUILDER_LOAD_FAIL'
|
||||
};
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { BUILDERS } from '../constants';
|
||||
|
||||
const builderReducer = (state = [], action) => {
|
||||
if (action.type === BUILDERS.LOAD_SUCCESS) {
|
||||
return [...action.builders];
|
||||
}
|
||||
return state;
|
||||
if (action.type === BUILDERS.LOAD_SUCCESS) {
|
||||
return [...action.builders];
|
||||
}
|
||||
return state;
|
||||
};
|
||||
|
||||
export default builderReducer;
|
||||
|
@ -12,16 +12,16 @@ import pullStateReducer from './pullStateReducer';
|
||||
import buildStatusReducer from './buildStatusReducer';
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
isLoading: loadingReducer,
|
||||
commits: commitsReducer,
|
||||
error: errorReducer,
|
||||
branches: branchReducer,
|
||||
builders: builderReducer,
|
||||
branch: selectedBranchReducer,
|
||||
pulls: pullsReducer,
|
||||
pullState: pullStateReducer,
|
||||
page: pageReducer,
|
||||
build: buildStatusReducer
|
||||
isLoading: loadingReducer,
|
||||
commits: commitsReducer,
|
||||
error: errorReducer,
|
||||
branches: branchReducer,
|
||||
builders: builderReducer,
|
||||
branch: selectedBranchReducer,
|
||||
pulls: pullsReducer,
|
||||
pullState: pullStateReducer,
|
||||
page: pageReducer,
|
||||
build: buildStatusReducer
|
||||
});
|
||||
|
||||
export default rootReducer;
|
||||
|
@ -1,46 +1,46 @@
|
||||
import { COMMITS, BRANCHES, PULLS, BUILD_DATA, BUILDERS } from '../constants';
|
||||
|
||||
const loadingReducer = (state = { newPage: 1, load: false }, action) => {
|
||||
switch (action.type) {
|
||||
case COMMITS.LOAD:
|
||||
return { newPage: action.newPage, load: true };
|
||||
switch (action.type) {
|
||||
case COMMITS.LOAD:
|
||||
return { newPage: action.newPage, load: true };
|
||||
|
||||
case BUILDERS.LOAD:
|
||||
return { ...state, load: true };
|
||||
case BUILDERS.LOAD:
|
||||
return { ...state, load: true };
|
||||
|
||||
case PULLS.LOAD:
|
||||
return { newPage: action.newPage, load: true };
|
||||
case PULLS.LOAD:
|
||||
return { newPage: action.newPage, load: true };
|
||||
|
||||
case BRANCHES.LOAD:
|
||||
return { newPage: action.newPage, load: true };
|
||||
case BRANCHES.LOAD:
|
||||
return { newPage: action.newPage, load: true };
|
||||
|
||||
case BUILD_DATA.LOAD:
|
||||
return { newPage: action.newPage, load: true };
|
||||
case BUILD_DATA.LOAD:
|
||||
return { newPage: action.newPage, load: true };
|
||||
|
||||
case COMMITS.LOAD_SUCCESS:
|
||||
return { ...state, load: false };
|
||||
case COMMITS.LOAD_SUCCESS:
|
||||
return { ...state, load: false };
|
||||
|
||||
case BUILDERS.LOAD_SUCCESS:
|
||||
return { ...state, load: true };
|
||||
case BUILDERS.LOAD_SUCCESS:
|
||||
return { ...state, load: true };
|
||||
|
||||
case PULLS.LOAD_SUCCESS:
|
||||
return { ...state, load: false };
|
||||
case PULLS.LOAD_SUCCESS:
|
||||
return { ...state, load: false };
|
||||
|
||||
case BRANCHES.LOAD_SUCCESS:
|
||||
return { newPage: action.newPage, load: true };
|
||||
case BRANCHES.LOAD_SUCCESS:
|
||||
return { newPage: action.newPage, load: true };
|
||||
|
||||
case BUILD_DATA.LOAD_SUCCESS:
|
||||
return { load: false };
|
||||
case BUILD_DATA.LOAD_SUCCESS:
|
||||
return { load: false };
|
||||
|
||||
case COMMITS.LOAD_FAIL:
|
||||
return { ...state, load: false };
|
||||
case COMMITS.LOAD_FAIL:
|
||||
return { ...state, load: false };
|
||||
|
||||
case PULLS.LOAD_FAIL:
|
||||
return { ...state, load: false };
|
||||
case PULLS.LOAD_FAIL:
|
||||
return { ...state, load: false };
|
||||
|
||||
default:
|
||||
return { ...state, load: false };
|
||||
}
|
||||
default:
|
||||
return { ...state, load: false };
|
||||
}
|
||||
};
|
||||
|
||||
export default loadingReducer;
|
||||
|
@ -4,15 +4,14 @@ import { fetchBuilders } from '../api';
|
||||
import { setBuilders, setBuildersError } from '../actions';
|
||||
|
||||
function* handleBuildersLoad() {
|
||||
try {
|
||||
const builders = yield call(fetchBuilders);
|
||||
console.log(builders);
|
||||
yield put(setBuilders(builders));
|
||||
} catch (error) {
|
||||
yield put(setBuildersError(error.toString()));
|
||||
}
|
||||
try {
|
||||
const builders = yield call(fetchBuilders);
|
||||
yield put(setBuilders(builders));
|
||||
} catch (error) {
|
||||
yield put(setBuildersError(error.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
export default function* watchBuildersLoad() {
|
||||
yield takeEvery(BUILDERS.LOAD, handleBuildersLoad);
|
||||
yield takeEvery(BUILDERS.LOAD, handleBuildersLoad);
|
||||
}
|
||||
|
@ -7,11 +7,11 @@ import buildersSaga from './buildersSaga';
|
||||
import buildSetSaga from './buildSetSaga';
|
||||
|
||||
export default function* rootSaga() {
|
||||
yield all([
|
||||
commitsSaga(),
|
||||
branchesSaga(),
|
||||
pullsSaga(),
|
||||
buildersSaga(),
|
||||
buildSetSaga()
|
||||
]);
|
||||
yield all([
|
||||
commitsSaga(),
|
||||
branchesSaga(),
|
||||
pullsSaga(),
|
||||
buildersSaga(),
|
||||
buildSetSaga()
|
||||
]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user