This commit is contained in:
caishi 2020-12-08 17:16:07 +08:00
parent 6b203d9d24
commit ee79efa6de
7 changed files with 66 additions and 23 deletions

View File

@ -4,7 +4,7 @@ import './branch.css';
import { getBranch , getTag } from '../GetData/getData';
export default (({ projectsId , branch , owner , history , changeBranch })=>{
export default (({ projectsId , branch , owner , changeBranch , branchList })=>{
const [ showValue , setShowValue ] = useState(branch);
const [ inputValue , setInputValue] = useState(undefined);
const [ nav , setNav ] = useState(0);
@ -31,8 +31,12 @@ export default (({ projectsId , branch , owner , history , changeBranch })=>{
})
useEffect(()=>{
getBranchs(projectsId,owner);
},[owner])
if(branchList){
setData(branchList);
setDatas(branchList);
setIsSpin(false);
}
},[branchList])
async function getBranchs(id,owner){

View File

@ -11,6 +11,7 @@ function PasswordAuthority({ authorityValBox , successFunc , cancelFunc }){
// -
function cancelAuthority(){
setAuthorityVal(undefined);
cancelFunc();
}
//

View File

@ -4,6 +4,7 @@ import { getImageUrl } from 'educoder';
import { truncateCommitId } from '../common/util';
import SelectBranch from '../Branch/Select';
import Nodata from '../Nodata';
import { getBranch } from '../GetData/getData';
import axios from 'axios';
import {Link} from "react-router-dom";
@ -16,12 +17,24 @@ class CoderRootCommit extends Component{
dataCount:undefined,
limit:20,
page:1,
isSpining:false
isSpining:false,
branchList:undefined
}
}
componentDidMount=()=>{
this.Init();
this.getBranchs();
}
// 获取分支列表
getBranchs=()=>{
const { projectsId , owner } = this.props.match.params;
axios.get(`/${owner}/${projectsId}/branches.json`).then(result=>{
this.setState({
branchList:result.data
})
}).catch((error)=>{})
}
componentDidUpdate=(prevProps)=>{
@ -79,14 +92,6 @@ class CoderRootCommit extends Component{
// 切换分支 search:tag为根据标签搜索
changeBranch=(value)=>{
// const { page , limit } = this.state;
// const { getTopCount } = this.props;
// this.setState({
// isSpining:true,
// branch:value,
// })
// this.getCommitList(value , page , limit);
// getTopCount && getTopCount(value);
const { projectsId , owner } = this.props.match.params;
this.props.history.push(`/projects/${owner}/${projectsId}/commits/branch/${value}`);
}
@ -97,7 +102,7 @@ class CoderRootCommit extends Component{
this.getCommitList(branchName , page , limit);
}
render(){
const { commitDatas , dataCount , limit , page , isSpining } = this.state;
const { commitDatas , dataCount , limit , page , isSpining , branchList } = this.state;
const { projectDetail, commit_class , defaultBranch } = this.props;
const { projectsId , owner , branchName } = this.props.match.params;
let branch = branchName || defaultBranch;
@ -112,6 +117,7 @@ class CoderRootCommit extends Component{
changeBranch={this.changeBranch}
owner={owner}
history={this.props.history}
branchList={branchList}
></SelectBranch>
</div>
<Spin spinning={isSpining}>

View File

@ -11,6 +11,7 @@ import CoderRootFileDetail from './CoderRootFileDetail';
import { truncateCommitId } from '../common/util';
import RenderHtml from '../../components/render-html';
import Nodata from '../Nodata';
import { getBranch } from '../GetData/getData';
import axios from "axios";
/**
@ -62,7 +63,17 @@ class CoderRootDirectory extends Component {
componentDidMount = () => {
this.Init();
this.getBranchs();
};
// 获取分支列表
getBranchs=()=>{
const { projectsId , owner } = this.props.match.params;
axios.get(`/${owner}/${projectsId}/branches.json`).then(result=>{
this.setState({
branchList:result.data
})
}).catch((error)=>{})
}
componentDidUpdate = (prevState) => {
const { location } = this.props;
@ -399,7 +410,7 @@ class CoderRootDirectory extends Component {
}
render(){
const { branchLastCommit , lastCommitAuthor , rootList ,filePath , fileDetail , subFileType , readMeContent, isSpin , zip_url , tar_url} = this.state;
const { branchLastCommit , lastCommitAuthor , rootList ,filePath , fileDetail , subFileType , readMeContent, isSpin , zip_url , tar_url , branchList} = this.state;
const { isManager , isDeveloper , projectDetail , platform , defaultBranch } = this.props;
const { projectsId , owner , branchName } = this.props.match.params;
@ -456,6 +467,7 @@ class CoderRootDirectory extends Component {
changeBranch={this.changeBranch}
owner={owner}
history={this.props.history}
branchList={branchList}
></SelectBranch>
:
<span>分支<span className="color-grey-6">master</span></span>

View File

@ -4,7 +4,7 @@ import Title from '../Component/Title';
import styled from 'styled-components';
import { AlignCenter , WhiteBack , FlexAJ } from '../Component/layout';
import axios from 'axios';
import { Button, Select } from 'antd';
import { Button, Select , Pagination } from 'antd';
import { getBranch } from '../GetData/getData';
const Div = styled.div`{
@ -13,18 +13,26 @@ const Div = styled.div`{
}`
export default ((props)=>{
const LIMIT = 15;
const [ branch , setBranch ] = useState("master");
const [ branchList , setBranchList ] = useState(undefined);
const [ protectBranch , setProtectBranch ] = useState(undefined);
const [ protectBranch , setProtectBranch ] = useState("master");
const [ protectBranchList , setProtectBranchList ] = useState(undefined);
const [ count , setCount ] = useState(0);
const [ page , setPage ] = useState(1);
let defaultBranch = props.defaultBranch;
useEffect(()=>{
if(defaultBranch){
setBranch(defaultBranch);
setProtectBranch(defaultBranch);
}
},[defaultBranch]);
const { projectsId , owner } = props.match.params;
const projectDetail = props.projectDetail;
const { defaultBranch } = props;
useEffect(()=>{
if(defaultBranch){
setBranch(defaultBranch);
@ -43,7 +51,7 @@ export default ((props)=>{
const url = `/${owner}/${repo}/protected_branches.json`;
axios.get(url,{
params:{
page,limit:15
page,limit:LIMIT
}
}).then(result=>{
if(result){
@ -57,7 +65,6 @@ export default ((props)=>{
async function getBranchs(id,owner){
let re = await getBranch(id,owner);
setBranchList(re);
}
// 设为默认分支
@ -81,6 +88,11 @@ export default ((props)=>{
props.history.push(`/projects/${owner}/${projectsId}/setting/branch/${protectBranch}`);
}
// 翻页
function changePageNum(page){
setPage(page);
}
return(
<WhiteBack>
<Title>分支设置</Title>
@ -96,6 +108,7 @@ export default ((props)=>{
changeBranch={setBranch}
owner={owner}
history={props.history}
branchList = {branchList}
/>
<a className="color-blue ml20" onClick={()=>resetSetting()}>设为默认分支</a>
</AlignCenter>
@ -105,6 +118,7 @@ export default ((props)=>{
<AlignCenter>
<Select
showSearch
defaultValue={branch}
className="setHeight"
style={{ width: 240, height: 40 }}
placeholder="选择分支"
@ -122,7 +136,7 @@ export default ((props)=>{
})
}
</Select>
<a className="color-blue ml20" onClick={()=>settingRule(protectBranch)}>设置分支保护</a>
<a className={ protectBranchList && protectBranchList.length > 0?"color-blue ml20":"color-grey ml20"} onClick={()=>settingRule(protectBranch)}>设置分支保护</a>
</AlignCenter>
{
protectBranchList && protectBranchList.length > 0 &&
@ -139,6 +153,12 @@ export default ((props)=>{
}
</div>
}
{
count > LIMIT &&
<div className="mt15 mb20" style={{textAlign:"center"}}>
<Pagination simple current={page} pageSize={LIMIT} total={count} onChange={changePageNum}></Pagination>
</div>
}
</div>
</Div>
</WhiteBack>

View File

@ -116,7 +116,7 @@ export default Form.create()(
}
return (
<div style={{backgroundColor:"#fff"}}>
<Title>新建保护分支规则</Title>
<Title>新建'{branch}'保护分支规则</Title>
<Form>
<div style={{padding:"20px 30px"}}>
{helper(

View File

@ -189,7 +189,7 @@
}
.shortStyle{
.setStyleRule{
height: 35px;
min-height: 35px;
}
.columsRadio{
display: block;
@ -209,7 +209,7 @@
}
}
.setStyleRule{
height: 35px;
min-height: 35px;
.ant-row.ant-form-item{
margin-bottom: 10px;
}