forked from Gitlink/forgeplus-react
merge
This commit is contained in:
parent
03cff6ec2e
commit
99947c0c87
|
@ -25,7 +25,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'
|
||||
}
|
||||
window._debugType = debugType;
|
||||
export function initAxiosInterceptors(props) {
|
||||
|
|
|
@ -45,19 +45,24 @@ function CoderDepot(props){
|
|||
const [ desc , setDesc ] = useState(undefined);
|
||||
const [ website , setWebsite ] = useState(undefined);
|
||||
const [ lesson_url , setLessonUrl ] = useState(undefined);
|
||||
const [ readme , setReadme ] = useState(undefined);
|
||||
const [ defaultBranch , setDefaultBranch ] = useState(undefined)
|
||||
|
||||
const owner = props.match.params.owner;
|
||||
const projectsId = props.match.params.projectsId;
|
||||
const branchName = props.match.params.branchName;
|
||||
const details = props.projectDetail;
|
||||
let pathname = props.history.location.pathname;
|
||||
|
||||
useEffect(()=>{
|
||||
if(props.projectDetail){
|
||||
setProjectDetail(props.projectDetail);
|
||||
setDesc(props.projectDetail.description);
|
||||
setWebsite(props.projectDetail.website);
|
||||
setLessonUrl(props.projectDetail.lesson_url);
|
||||
if(details){
|
||||
setProjectDetail(details);
|
||||
setDesc(details.description);
|
||||
setWebsite(details.website);
|
||||
setLessonUrl(details.lesson_url);
|
||||
setDefaultBranch(details.default_branch);
|
||||
}
|
||||
},[props])
|
||||
},[details])
|
||||
|
||||
useEffect(()=>{
|
||||
if(treeValue){
|
||||
|
@ -67,18 +72,19 @@ function CoderDepot(props){
|
|||
}
|
||||
},[treeValue])
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
if (pathname && projectDetail){
|
||||
if (projectsId && owner && defaultBranch){
|
||||
if(pathname.indexOf(`/projects/${owner}/${projectsId}`) > -1 && pathname.indexOf(`/tree/${branchName}/`) > -1) {
|
||||
let url = pathname.split(`/tree/${branchName}/`)[1];
|
||||
setTreeValue(url);
|
||||
getFileInfo(url,branchName);
|
||||
}else{
|
||||
setTreeValue(undefined);
|
||||
getDirInfo(branchName ||projectDetail.default_branch);
|
||||
getDirInfo(branchName || defaultBranch);
|
||||
}
|
||||
}
|
||||
},[pathname,projectDetail])
|
||||
},[projectsId,owner,pathname,defaultBranch])
|
||||
|
||||
// 获取主目录列表
|
||||
function getDirInfo(branch){
|
||||
|
@ -98,6 +104,7 @@ function CoderDepot(props){
|
|||
setLastCommitAuthor(c && c.committer);
|
||||
setMainFlag(true);
|
||||
setReadOnly(true);
|
||||
setReadme(result.data.readme);
|
||||
}
|
||||
setTimeout(function(){setIsSpin(false);},500);
|
||||
}).catch(error=>{setIsSpin(false);})
|
||||
|
@ -154,8 +161,8 @@ function CoderDepot(props){
|
|||
// 文件相关的下拉项
|
||||
const fileMenu =(
|
||||
<Menu>
|
||||
<Menu.Item><a onClick={()=>urlLink(`/projects/${owner}/${projectsId}/${branchName || (projectDetail && projectDetail.default_branch)}/uploadfile${treeValue === undefined ? "" : `/${treeValue}`}`)}>上传文件</a></Menu.Item>
|
||||
<Menu.Item><a onClick={()=>urlLink(`/projects/${owner}/${projectsId}/${branchName || (projectDetail && projectDetail.default_branch)}/newfile${treeValue === undefined ? "" : `/${treeValue}`}`)}>新建文件</a></Menu.Item>
|
||||
<Menu.Item><a onClick={()=>urlLink(`/projects/${owner}/${projectsId}/${branchName || defaultBranch}/uploadfile${treeValue === undefined ? "" : `/${treeValue}`}`)}>上传文件</a></Menu.Item>
|
||||
<Menu.Item><a onClick={()=>urlLink(`/projects/${owner}/${projectsId}/${branchName || defaultBranch}/newfile${treeValue === undefined ? "" : `/${treeValue}`}`)}>新建文件</a></Menu.Item>
|
||||
</Menu>
|
||||
)
|
||||
|
||||
|
@ -171,7 +178,7 @@ function CoderDepot(props){
|
|||
// 页面地址返回到主目录
|
||||
function returnMain(){
|
||||
setTreeValue(undefined);
|
||||
let branch = branchName || (projectDetail && projectDetail.default_branch);
|
||||
let branch = branchName || defaultBranch;
|
||||
props.history.push(`/projects/${owner}/${projectsId}/tree/${branch}`);
|
||||
};
|
||||
// 子目录路径返回链接
|
||||
|
@ -181,7 +188,7 @@ function CoderDepot(props){
|
|||
// 点击跳转到子目录
|
||||
function goToSubRoot(path,type,filename){
|
||||
setType(type);
|
||||
props.history.push(`/projects/${owner}/${projectsId}${`/tree/${branchName || (projectDetail && projectDetail.default_branch)}`}${path?`/${path}`:""}`);
|
||||
props.history.push(`/projects/${owner}/${projectsId}${`/tree/${branchName || defaultBranch}`}${path?`/${path}`:""}`);
|
||||
}
|
||||
|
||||
function onEdit(readOnly){
|
||||
|
@ -189,7 +196,7 @@ function CoderDepot(props){
|
|||
}
|
||||
function ChangeFile(path, readOnly){
|
||||
//点击直接跳转页面 加载一次路由
|
||||
props.history.push(`/projects/${owner}/${projectsId}/tree/${branchName || (projectDetail && projectDetail.default_branch)}/${path}`);
|
||||
props.history.push(`/projects/${owner}/${projectsId}/tree/${branchName || defaultBranch}/${path}`);
|
||||
setType("file");
|
||||
setReadOnly(readOnly);
|
||||
};
|
||||
|
@ -248,7 +255,7 @@ function CoderDepot(props){
|
|||
owner={owner}
|
||||
projectsId={projectsId}
|
||||
name={projectDetail && projectDetail.name}
|
||||
branch={branchName || (projectDetail && projectDetail.default_branch)}
|
||||
branch={branchName || defaultBranch}
|
||||
visible={visible}
|
||||
onClose={()=>setVisible(false)}
|
||||
list = {mainFlag ? dirInfo : undefined}
|
||||
|
@ -273,14 +280,14 @@ function CoderDepot(props){
|
|||
<SelectBranch
|
||||
repo_id={projectDetail && projectDetail.repo_id}
|
||||
projectsId={projectsId}
|
||||
branch={branchName || (projectDetail && projectDetail.default_branch)}
|
||||
branch={branchName || defaultBranch}
|
||||
changeBranch={changeBranch}
|
||||
owner={owner}
|
||||
history={props.history}
|
||||
branchList={projectDetail && projectDetail.branches && projectDetail.branches.list}
|
||||
></SelectBranch>
|
||||
:
|
||||
<span>分支:<span className="color-grey-6">{branchName || (projectDetail && projectDetail.default_branch)}</span></span>
|
||||
<span>分支:<span className="color-grey-6">{branchName || defaultBranch}</span></span>
|
||||
}
|
||||
</div>
|
||||
<AlignCenter className="mr20">
|
||||
|
@ -361,7 +368,7 @@ function CoderDepot(props){
|
|||
readOnly={readOnly}
|
||||
md={mdFlag}
|
||||
onEdit={onEdit}
|
||||
currentBranch={branchName || (projectDetail && projectDetail.default_branch)}
|
||||
currentBranch={branchName || defaultBranch}
|
||||
type={projectDetail.type}
|
||||
></CoderRootFileDetail>
|
||||
}
|
||||
|
@ -373,7 +380,7 @@ function CoderDepot(props){
|
|||
(dirInfo && dirInfo.length === 0) && (fileInfo && fileInfo.length === 0) ? <Nodata _html="暂未发现文件"/> :""
|
||||
}
|
||||
{/* readme文件显示(显示文件详情时不显示readme文件) */}
|
||||
{ dirInfo && (projectDetail && projectDetail.readme) ? <ReadMe ChangeFile={ChangeFile} readme={projectDetail && projectDetail.readme} operate={props && (props.isManager || props.isDeveloper) && projectDetail.type !==2 } history={props.history} /> :"" }
|
||||
{ dirInfo && (readme && readme.content) ? <ReadMe ChangeFile={ChangeFile} readme={readme} operate={props && (props.isManager || props.isDeveloper) && projectDetail.type !==2 } history={props.history} /> :"" }
|
||||
</div>
|
||||
</LongWidth>
|
||||
{
|
||||
|
@ -389,7 +396,7 @@ function CoderDepot(props){
|
|||
website &&
|
||||
<p className="color-grey-6 df">
|
||||
<i className="iconfont icon-lianjie2 font-15 mr10 color-grey-9"></i>
|
||||
<a href={website} target="_blank" style={{wordBreak:"break-all",lineHeight:"20px",marginTop:"5px",textDecoration:"underline"}}>{website}</a>
|
||||
<a href={website} className="color-grey-6" target="_blank" style={{wordBreak:"break-all",lineHeight:"20px",marginTop:"5px",textDecoration:"underline"}}>{website}</a>
|
||||
</p>
|
||||
}
|
||||
<p>
|
||||
|
@ -397,13 +404,13 @@ function CoderDepot(props){
|
|||
<a href="#readme" className="color-grey-6">README.md</a>
|
||||
</p>
|
||||
<p className="color-grey-6">
|
||||
<i className="iconfont icon-dataBase font-15 mr10 color-grey-9"></i>
|
||||
<i className="iconfont icon-dataBase font-15 mr10 color-grey-6"></i>
|
||||
<span>{projectDetail && projectDetail.size}</span>
|
||||
</p>
|
||||
{
|
||||
projectDetail && projectDetail.license_name &&
|
||||
<p className="color-grey-6">
|
||||
<i className="iconfont icon-tianping font-16 mr10 color-grey-9"></i>
|
||||
<i className="iconfont icon-tianping font-16 mr10 color-grey-3"></i>
|
||||
<span>{projectDetail.license_name}</span>
|
||||
</p>
|
||||
}
|
||||
|
|
|
@ -6,20 +6,27 @@ const $ = window.$;
|
|||
|
||||
function CoderDepotReadme({ operate , history , readme , ChangeFile }){
|
||||
const [ menuList ,setMenuList ] = useState(undefined);
|
||||
const [ content ,setContent ] = useState(undefined);
|
||||
|
||||
useEffect(()=>{
|
||||
if(readme && readme.content){
|
||||
let path = history.location.pathname;
|
||||
const items = $.map($("#readme").find("h1,h2,h3,h4,h5,h6"), function (el, _) {
|
||||
const anchor = el.id;
|
||||
const level = el.tagName.replace("H", "");
|
||||
const href = `#${anchor}`;
|
||||
return { href:`${path}${href}`,text:el.textContent , level:level }
|
||||
});
|
||||
setMenuList(items);
|
||||
setContent(readme.content);
|
||||
}else{
|
||||
setContent(undefined);
|
||||
}
|
||||
},[readme])
|
||||
|
||||
useEffect(()=>{
|
||||
let path = history.location.pathname;
|
||||
const items = $.map($("#readme").find("h1,h2,h3,h4,h5,h6"), function (el, _) {
|
||||
const anchor = el.id;
|
||||
const level = el.tagName.replace("H", "");
|
||||
const href = `#${anchor}`;
|
||||
return { href:`${path}${href}`,text:el.textContent , level:level }
|
||||
});
|
||||
setMenuList(items);
|
||||
},[content])
|
||||
|
||||
function menu(){
|
||||
if(menuList && menuList.length > 0){
|
||||
let hash = history.location.hash;
|
||||
|
@ -53,9 +60,12 @@ function CoderDepotReadme({ operate , history , readme , ChangeFile }){
|
|||
:""
|
||||
}
|
||||
</div>
|
||||
<div className="commonBox-info">
|
||||
<RenderHtml className="break_word_comments imageLayerParent" value={readme && readme.content} url={history.location}/>
|
||||
</div>
|
||||
{
|
||||
content &&
|
||||
<div className="commonBox-info">
|
||||
<RenderHtml className="break_word_comments imageLayerParent" value={content} url={history.location}/>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -462,7 +462,7 @@ class Detail extends Component {
|
|||
firstSync ? "":
|
||||
<span className="df mt25">
|
||||
{
|
||||
current_user && current_user.login && (projectDetail && projectDetail.type && projectDetail.type === 2) ?
|
||||
((current_user && current_user.admin) || isManager) && (projectDetail && projectDetail.type && projectDetail.type === 2) ?
|
||||
<a className="synchronism ml30" onClick={this.synchronismMirror}>同步镜像</a> : ""
|
||||
}
|
||||
<span className="detail_tag_btn">
|
||||
|
@ -636,6 +636,11 @@ class Detail extends Component {
|
|||
}
|
||||
></Route>
|
||||
{/* 新建合并请求 */}
|
||||
<Route path="/projects/:owner/:projectsId/pulls/new/:branch"
|
||||
render={
|
||||
(props) => (<CreateMerge {...this.props} {...props} {...this.state} {...common} is_fork={true} />)
|
||||
}
|
||||
></Route>
|
||||
<Route path="/projects/:owner/:projectsId/pulls/new"
|
||||
render={
|
||||
(props) => (<CreateMerge {...this.props} {...props} {...this.state} {...common} is_fork={true} />)
|
||||
|
|
|
@ -9,13 +9,14 @@ const Option = Select.Option;
|
|||
class NewMerge extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const { branch } = this.props.match.params;
|
||||
this.state = {
|
||||
data: undefined,
|
||||
branches: undefined,
|
||||
merge_branches: undefined,
|
||||
merge_projects: undefined,
|
||||
merge: "master",
|
||||
pull: "master",
|
||||
pull: branch,
|
||||
id: undefined,
|
||||
is_fork: false,
|
||||
projects_names: undefined,
|
||||
|
@ -113,16 +114,19 @@ class NewMerge extends Component {
|
|||
}
|
||||
|
||||
set_default_pull = (branches) => {
|
||||
if(branches && branches.length>0){
|
||||
let default_pull = branches.filter((e) => e.name === "master")
|
||||
if (default_pull.length > 0){
|
||||
this.setState({
|
||||
pull:default_pull[0].name
|
||||
})
|
||||
}else{
|
||||
this.setState({
|
||||
pull:"master"
|
||||
})
|
||||
const { branch } = this.props.match.params;
|
||||
if(!branch){
|
||||
if(branches && branches.length>0){
|
||||
let default_pull = branches.filter((e) => e.name === "master")
|
||||
if (default_pull.length > 0){
|
||||
this.setState({
|
||||
pull:default_pull[0].name
|
||||
})
|
||||
}else{
|
||||
this.setState({
|
||||
pull:"master"
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,10 +167,12 @@ class NewMerge extends Component {
|
|||
};
|
||||
|
||||
selectBrach = (type, value) => {
|
||||
const { projectsId , owner } = this.props.match.params;
|
||||
this.state[type] = value;
|
||||
this.ischeckmerge();
|
||||
let { id ,merge , pull } = this.state;
|
||||
if(type==="pull"){
|
||||
this.props.history.push(`/projects/${owner}/${projectsId}/pulls/new/${pull}`)
|
||||
this.compareProject(id,value,merge);
|
||||
}else{
|
||||
this.compareProject(id,pull,value);
|
||||
|
|
|
@ -144,7 +144,7 @@ export default Form.create()(
|
|||
</div>
|
||||
<p className="mt20">
|
||||
<Button type="primary" className="mr30" onClick={createOrganize}>创建组织</Button>
|
||||
<Button className="grey">取消</Button>
|
||||
<Button className="grey" onClick={()=>{window.history.back(-1)}}>取消</Button>
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
|
|
|
@ -43,6 +43,7 @@ export default Form.create()(
|
|||
}
|
||||
Axios.put(url,params).then(result=>{
|
||||
if(result && result.data){
|
||||
props.showNotification("资料修改成功!")
|
||||
resetUser && resetUser(result.data);
|
||||
}
|
||||
}).catch(error=>{})
|
||||
|
|
|
@ -84,7 +84,7 @@ function Index(props) {
|
|||
let percent = result.data.user && result.data.user.languages_percent;
|
||||
let arr = [];
|
||||
Object.keys(percent).map((item,key)=>{
|
||||
arr.push({name:item,p:percent[item]*100,color:getColor()});
|
||||
arr.push({name:item,p:parseFloat(percent[item]*100).toFixed(1),color:getColor()});
|
||||
})
|
||||
setPercentData(arr);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ function Team(props){
|
|||
<div>
|
||||
<div className="headerbox">
|
||||
<div>
|
||||
<Search value={search} onChange={(e)=>setSearch(e.target.value)} placeholder="请输入项目名称关键字进行搜索" onSearch={onSearch}/>
|
||||
<Search value={search} onChange={(e)=>setSearch(e.target.value)} placeholder="请输入组织名称关键字进行搜索" onSearch={onSearch}/>
|
||||
</div>
|
||||
<p>
|
||||
<Link to={`/organize/new`}><i className="iconfont icon-xinjian1 mr3 font-14"></i>新建组织</Link>
|
||||
|
|
Loading…
Reference in New Issue