diff --git a/src/AppConfig.js b/src/AppConfig.js index c81b0553..d387eb1d 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -27,7 +27,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 || 'student' + window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'admin' } function clearAllCookie() { cookie.remove('_educoder_session', { path: '/' }); diff --git a/src/forge/Branch/Select.jsx b/src/forge/Branch/Select.jsx index 30e7d59c..55bb0345 100644 --- a/src/forge/Branch/Select.jsx +++ b/src/forge/Branch/Select.jsx @@ -4,7 +4,7 @@ import './branch.css'; import { getBranch , getTag } from '../GetData/getData'; -export default (({ projectsId , repo_id , changeBranch , branch , owner })=>{ +export default (({ projectsId , branch , owner , history , changeBranch })=>{ const [ showValue , setShowValue ] = useState(branch); const [ inputValue , setInputValue] = useState(undefined); const [ nav , setNav ] = useState(0); @@ -17,6 +17,7 @@ export default (({ projectsId , repo_id , changeBranch , branch , owner })=>{ useEffect(()=>{ setShowValue(branch); },[branch]) + useEffect(()=>{ document.body.addEventListener('click', e => { let name = e.target.className; @@ -63,7 +64,7 @@ export default (({ projectsId , repo_id , changeBranch , branch , owner })=>{ } } function chooseitem(value){ - setShowValue(value); + // setShowValue(value); changeBranch(value); } diff --git a/src/forge/Main/CoderRootBranch.js b/src/forge/Main/CoderRootBranch.js index 4fde90e4..4369d2fe 100644 --- a/src/forge/Main/CoderRootBranch.js +++ b/src/forge/Main/CoderRootBranch.js @@ -32,7 +32,7 @@ export default ((props)=>{ return(
{item.last_commit && truncateCommitId(item.last_commit.sha)}
{item.last_commit && item.last_commit.message}
diff --git a/src/forge/Main/CoderRootCommit.js b/src/forge/Main/CoderRootCommit.js
index 36585fe3..ddb47a2b 100644
--- a/src/forge/Main/CoderRootCommit.js
+++ b/src/forge/Main/CoderRootCommit.js
@@ -12,7 +12,6 @@ class CoderRootCommit extends Component{
constructor(props){
super(props)
this.state={
- branch:"master",
commitDatas:undefined,
dataCount:undefined,
limit:20,
@@ -22,11 +21,23 @@ class CoderRootCommit extends Component{
}
componentDidMount=()=>{
- const { branch , page , limit } = this.state;
+ this.Init();
+ }
+
+ componentDidUpdate=(prevProps)=>{
+ const { location } = this.props;
+ const prevlocation = prevProps && prevProps.location;
+ if (location !== prevlocation) {
+ this.Init();
+ }
+ }
+ Init =()=>{
+ const { branchName } = this.props.match.params;
+ const { page , limit } = this.state;
this.setState({
isSpining:true
})
- this.getCommitList( branch , page , limit );
+ this.getCommitList( branchName , page , limit );
}
getCommitList=(branch , page , limit)=>{
@@ -68,26 +79,28 @@ 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 { 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}`);
}
ChangePage=(page)=>{
-
- const { branch , limit } = this.state;
- this.getCommitList(branch , page , limit);
+ const { branchName } = this.props.match.params;
+ const { limit } = this.state;
+ this.getCommitList(branchName , page , limit);
}
render(){
- const { branch , commitDatas , dataCount , limit , page , isSpining } = this.state;
- const { branchs , projectDetail, commit_class } = this.props;
- const { projectsId , owner } = this.props.match.params;
-
+ const { commitDatas , dataCount , limit , page , isSpining } = this.state;
+ const { projectDetail, commit_class } = this.props;
+ const { projectsId , owner , branchName } = this.props.match.params;
+ let branch = branchName || "master";
return(
{commit.message}
}
-
+
- + 分支设置