mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-22 16:36:30 +00:00
Merge pull request #205 from alexef/filter-main-branch
Filter main branch
This commit is contained in:
commit
9bf8e05fd0
3 changed files with 36 additions and 3 deletions
|
@ -9,7 +9,7 @@
|
||||||
"lesshint": "lesshint --config .lesshintrc src/",
|
"lesshint": "lesshint --config .lesshintrc src/",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"start": "webpack-dev-server --progress --hot --inline",
|
"start": "webpack-dev-server --progress --hot --inline",
|
||||||
"format": "prettier --use-tabs --trailing-comma all --write {src/*.js,src/**/*.js,src/**/*/*.js,src/*/*/*/*.js,src/*/*/*/*/*.js,src/*/*/*/*/*/*.js,src/*/*/*/*/*/*.js,src/*/*/*/*/*/*/*.js}"
|
"format": "prettier --trailing-comma all --write {src/*.js,src/**/*.js,src/**/*/*.js,src/*/*/*/*.js,src/*/*/*/*/*.js,src/*/*/*/*/*/*.js,src/*/*/*/*/*/*.js,src/*/*/*/*/*/*/*.js}"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"moduleFileExtensions": [
|
"moduleFileExtensions": [
|
||||||
|
|
|
@ -28,6 +28,7 @@ export default class Main extends Component {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
|
|
||||||
this.fetchNextBuildPage = this.fetchNextBuildPage.bind(this);
|
this.fetchNextBuildPage = this.fetchNextBuildPage.bind(this);
|
||||||
|
this.selectBranch = this.selectBranch.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
|
@ -40,7 +41,8 @@ export default class Main extends Component {
|
||||||
(nextProps.builds !== undefined &&
|
(nextProps.builds !== undefined &&
|
||||||
this.props.builds !== nextProps.builds) ||
|
this.props.builds !== nextProps.builds) ||
|
||||||
this.props.error !== nextProps.error ||
|
this.props.error !== nextProps.error ||
|
||||||
this.props.loaded !== nextProps.loaded
|
this.props.loaded !== nextProps.loaded ||
|
||||||
|
this.state.branch !== nextState.branch
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,8 +81,15 @@ export default class Main extends Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selectBranch(branch) {
|
||||||
|
this.setState({
|
||||||
|
branch: branch,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { repo, builds, loaded, error } = this.props;
|
const { repo, builds, loaded, error } = this.props;
|
||||||
|
const { branch } = this.state;
|
||||||
const list = Object.values(builds || {});
|
const list = Object.values(builds || {});
|
||||||
|
|
||||||
function renderBuild(build) {
|
function renderBuild(build) {
|
||||||
|
@ -91,6 +100,10 @@ export default class Main extends Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const filterBranch = build => {
|
||||||
|
return !branch || build.branch === branch;
|
||||||
|
};
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return <div>Not Found</div>;
|
return <div>Not Found</div>;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +122,23 @@ export default class Main extends Component {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.root}>
|
<div className={styles.root}>
|
||||||
<List>{list.sort(compareBuild).map(renderBuild)}</List>
|
<div className={styles.right}>
|
||||||
|
{!branch ? (
|
||||||
|
<button onClick={() => this.selectBranch(repo.default_branch)}>
|
||||||
|
Show {repo.default_branch} branch only
|
||||||
|
</button>
|
||||||
|
) : (
|
||||||
|
<button onClick={() => this.selectBranch(undefined)}>
|
||||||
|
Show all branches
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<List>
|
||||||
|
{list
|
||||||
|
.sort(compareBuild)
|
||||||
|
.filter(filterBranch)
|
||||||
|
.map(renderBuild)}
|
||||||
|
</List>
|
||||||
{list.length < repo.last_build && (
|
{list.length < repo.last_build && (
|
||||||
<button
|
<button
|
||||||
onClick={() => this.fetchNextBuildPage(list)}
|
onClick={() => this.fetchNextBuildPage(list)}
|
||||||
|
|
|
@ -22,3 +22,7 @@ button {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.right {
|
||||||
|
text-align: right;
|
||||||
|
}
|
Loading…
Reference in a new issue