From 92699347ec2da809a8a844f5d084a2f2302b7f6b Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Tue, 24 Nov 2020 18:00:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E6=94=AF=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AppConfig.js | 2 +- src/forge/DevOps/Dispose.jsx | 3 ++- src/forge/Main/CoderRootCommit.js | 4 ++-- src/forge/Main/CoderRootDirectory.js | 9 ++++----- src/forge/Main/CoderRootIndex.js | 3 ++- src/forge/Main/Detail.js | 8 ++++++-- src/forge/Settings/Branch.js | 17 ++++++++++++++--- src/forge/Settings/Setting.js | 1 - 8 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/AppConfig.js b/src/AppConfig.js index d387eb1d..a369d843 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -28,7 +28,7 @@ if (isDev) { debugType = window.location.search.indexOf('debug=t') !== -1 ? 'teacher' : window.location.search.indexOf('debug=s') !== -1 ? 'student' : window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'admin' -} +} function clearAllCookie() { cookie.remove('_educoder_session', { path: '/' }); cookie.remove('autologin_trustie', { path: '/' }); diff --git a/src/forge/DevOps/Dispose.jsx b/src/forge/DevOps/Dispose.jsx index 04f3558c..f8aad2eb 100644 --- a/src/forge/DevOps/Dispose.jsx +++ b/src/forge/DevOps/Dispose.jsx @@ -55,8 +55,9 @@ function Dispose(props){ // 确定提交 function submit(){ let url = ''; + const { defaultBranch } = props; let params = { - branch: "master", + branch: defaultBranch, content:ymlValue, filepath:info, message:'' diff --git a/src/forge/Main/CoderRootCommit.js b/src/forge/Main/CoderRootCommit.js index ddb47a2b..0b3526ac 100644 --- a/src/forge/Main/CoderRootCommit.js +++ b/src/forge/Main/CoderRootCommit.js @@ -98,9 +98,9 @@ class CoderRootCommit extends Component{ } render(){ const { commitDatas , dataCount , limit , page , isSpining } = this.state; - const { projectDetail, commit_class } = this.props; + const { projectDetail, commit_class , defaultBranch } = this.props; const { projectsId , owner , branchName } = this.props.match.params; - let branch = branchName || "master"; + let branch = branchName || defaultBranch; return(
diff --git a/src/forge/Main/CoderRootDirectory.js b/src/forge/Main/CoderRootDirectory.js index 41dc9b51..7b86bc1a 100644 --- a/src/forge/Main/CoderRootDirectory.js +++ b/src/forge/Main/CoderRootDirectory.js @@ -15,7 +15,6 @@ import Nodata from '../Nodata'; import axios from "axios"; /** * address:http和SSH,http_url(对应git地址) - * branch:当前分支 * filePath:点击目录时当前目录的路径 * subfileType:保存当前点击目录的文件类型(显示目录列表时才显示新建文件,如果点击的是文件就不显示新建文件按钮) * readMeContent:根目录下面的readme文件内容 @@ -34,7 +33,6 @@ class CoderRootDirectory extends Component { super(props); this.state = { address: "http", - branch: props.match.params.branchName || "master", filePath: undefined, subFileType: undefined, readMeContent: undefined, @@ -80,7 +78,8 @@ class CoderRootDirectory extends Component { Init = () => { let { search } = this.props.history.location; const { branchName } = this.props.match.params; - let branch = branchName || "master"; + const { defaultBranch } = this.props; + let branch = branchName || defaultBranch; if (search && (search.indexOf("?url=") > -1 || search.indexOf("&url=") > -1)) { let url = search.split("url=")[1]; if(url && decodeURI(url).indexOf("&")){ @@ -410,10 +409,10 @@ class CoderRootDirectory extends Component { render(){ const { branchLastCommit , lastCommitAuthor , rootList ,filePath , fileDetail , subFileType , readMeContent, isSpin , zip_url , tar_url} = this.state; - const { isManager , isDeveloper , projectDetail , platform } = this.props; + const { isManager , isDeveloper , projectDetail , platform , defaultBranch } = this.props; const { projectsId , owner , branchName } = this.props.match.params; - let branch = branchName || "master"; + let branch = branchName || defaultBranch; const columns = [ { dataIndex: 'name', diff --git a/src/forge/Main/CoderRootIndex.js b/src/forge/Main/CoderRootIndex.js index 0649c5dd..27dbbb9d 100644 --- a/src/forge/Main/CoderRootIndex.js +++ b/src/forge/Main/CoderRootIndex.js @@ -67,7 +67,8 @@ class CoderRootIndex extends Component{ Init=()=>{ const { branchName } = this.props.match.params; - this.getTopCount(branchName || "master"); + const { defaultBranch } = this.props; + this.getTopCount(branchName || defaultBranch); } getTopCount=(branch)=>{ diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index 431c1f4d..685e297d 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -168,6 +168,8 @@ class Detail extends Component { firstSync:false, secondSync:false, open_devops:false, + // 默认分支 + defaultBranch:undefined, // 非本平台项目 platform:false @@ -281,6 +283,7 @@ class Detail extends Component { watchers_count: result.data.watchers_count, praises_count: result.data.praises_count, forked_count: result.data.forked_count, + defaultBranch:result.data.default_branch }) } }).catch((error) => { }) @@ -381,7 +384,7 @@ class Detail extends Component { const { projectDetail, watchers_count, praises_count, forked_count, firstSync , secondSync , isManager, watched, praised, - project , open_devops , platform } = this.state; + project , open_devops , platform , defaultBranch } = this.state; const url = this.props.history.location.pathname; const urlArr = url.split("/"); const urlFlag = (urlArr.length === 3); @@ -403,7 +406,8 @@ class Detail extends Component { const common = { getDetail: this.getDetail, - changeOpenDevops:this.changeOpenDevops + changeOpenDevops:this.changeOpenDevops, + defaultBranch } return (
diff --git a/src/forge/Settings/Branch.js b/src/forge/Settings/Branch.js index b23eb985..487463df 100644 --- a/src/forge/Settings/Branch.js +++ b/src/forge/Settings/Branch.js @@ -3,7 +3,7 @@ import SelectBranch from '../Branch/Select'; import Title from '../Component/Title'; import styled from 'styled-components'; import { Blueline , FlexAJ , NumUl , GreenUnder , AlignCenter , WhiteBack } from '../Component/layout'; - +import axios from 'axios'; const Div = styled.div`{ padding:20px 30px; min-height:500px; @@ -15,7 +15,18 @@ export default ((props)=>{ const projectDetail = props.projectDetail; function resetSetting(){ - + const url = `/${owner}/${projectsId}.json`; + axios.put(url, { + default_branch:branch + }) + .then((result) => { + if (result) { + this.props.showNotification(`分支设置成功!`); + } + }) + .catch((error) => { + console.log(error); + }); } function settingRule(){ props.history.push(`/projects/${owner}/${projectsId}/setting/branch/new`); @@ -36,7 +47,7 @@ export default ((props)=>{ owner={owner} history={props.history} /> - 设为默认分支 + resetSetting()}>设为默认分支
diff --git a/src/forge/Settings/Setting.js b/src/forge/Settings/Setting.js index ea557de4..4aeeb4b2 100644 --- a/src/forge/Settings/Setting.js +++ b/src/forge/Settings/Setting.js @@ -144,7 +144,6 @@ class Setting extends Component { }); }; changePrivate = (e) => { - console.log(e); this.setState({ private_check: e.target.checked, });