mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-17 07:16:45 +00:00
Filter default branch
Allow the user to view only builds from main/master.
This commit is contained in:
@@ -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,13 @@ 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;
|
||||||
|
}
|
Reference in New Issue
Block a user