2021-03-18 17:28:53 +08:00
|
|
|
|
import React , { useEffect , useState } from 'react';
|
|
|
|
|
|
import { WhiteBack , Box , LongWidth , ShortWidth , Gap , AlignCenter , FlexAJ } from '../Component/layout';
|
2021-08-12 15:24:45 +08:00
|
|
|
|
import { Dropdown , Menu , Divider , Spin, Button , Typography } from 'antd';
|
2021-03-18 17:28:53 +08:00
|
|
|
|
import { getImageUrl } from "educoder";
|
|
|
|
|
|
import { Link } from 'react-router-dom';
|
2021-09-09 16:09:16 +08:00
|
|
|
|
import { truncateCommitId } from "../common/util";
|
2021-03-19 17:22:02 +08:00
|
|
|
|
import CloneAddress from '../Branch/CloneAddress';
|
2021-03-18 17:28:53 +08:00
|
|
|
|
|
|
|
|
|
|
import SelectBranch from '../Branch/Select';
|
|
|
|
|
|
import User from '../Component/User';
|
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
|
import Path from './CoderDepotPath';
|
|
|
|
|
|
import Catalogue from './CoderDepotCatalogue';
|
|
|
|
|
|
import ReadMe from './CoderDepotReadme';
|
|
|
|
|
|
import CoderRootFileDetail from './CoderRootFileDetail';
|
|
|
|
|
|
import './Index.scss';
|
|
|
|
|
|
import Releases from '../Component/Releases';
|
|
|
|
|
|
import Contributors from '../Component/Contributors';
|
|
|
|
|
|
import LanguagePower from '../Component/LanguagePower';
|
|
|
|
|
|
import DrawerPanel from '../Component/DrawerPanel';
|
2021-03-24 14:08:10 +08:00
|
|
|
|
import UpdateDescModal from './sub/UpdateDescModal';
|
2021-03-18 17:28:53 +08:00
|
|
|
|
import Nodata from '../Nodata';
|
2021-07-09 17:10:55 +08:00
|
|
|
|
import Invite from './sub/Invite';
|
2021-09-01 17:46:58 +08:00
|
|
|
|
import CheckProfile from '../Component/ProfileModal/Profile';
|
2021-04-08 10:07:55 +08:00
|
|
|
|
/**
|
2021-04-08 14:21:35 +08:00
|
|
|
|
* projectDetail.type:0是托管项目,1是镜像项目,2是同步镜像项目(为2时不支持在线创建、在线上传、在线修改、在线删除、创建合并请求等功能)
|
2021-04-08 10:07:55 +08:00
|
|
|
|
*/
|
2021-08-12 15:24:45 +08:00
|
|
|
|
const { Paragraph } = Typography;
|
2021-07-08 15:24:56 +08:00
|
|
|
|
function turnbar(str){
|
|
|
|
|
|
if(str && str.length>0 && str.indexOf("/")>-1){
|
|
|
|
|
|
return str.replaceAll('/','%2F');
|
|
|
|
|
|
}
|
|
|
|
|
|
return str;
|
|
|
|
|
|
}
|
|
|
|
|
|
function returnbar(str){
|
|
|
|
|
|
if(str && str.length>0 && str.indexOf("%2F")>-1){
|
|
|
|
|
|
return str.replaceAll('%2F','/');
|
|
|
|
|
|
}
|
|
|
|
|
|
return str;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-18 17:28:53 +08:00
|
|
|
|
function CoderDepot(props){
|
|
|
|
|
|
const [ projectDetail , setProjectDetail ]= useState(undefined);
|
2021-07-09 17:10:55 +08:00
|
|
|
|
const [ inviteCode , setInviteCode ] = useState(undefined);
|
2021-03-18 17:28:53 +08:00
|
|
|
|
const [ treeValue , setTreeValue ] = useState(undefined);
|
|
|
|
|
|
const [ treeValuePath , setTreeValuePath ] = useState(undefined);
|
|
|
|
|
|
const [ lastCommit,setLastCommit ] = useState(undefined);
|
|
|
|
|
|
const [ lastCommitAuthor,setLastCommitAuthor ] = useState(undefined);
|
|
|
|
|
|
const [ type ,setType ] = useState('dir');
|
|
|
|
|
|
const [ hide , setHide ] = useState(true);
|
|
|
|
|
|
const [ hideBtn , setHideBtn ] = useState(false);
|
|
|
|
|
|
const [ commitCount ,setCommitCount ] = useState(0);
|
|
|
|
|
|
const [ dirInfo ,setDirInfo ] = useState(undefined);//文件夹目录列表
|
|
|
|
|
|
const [ fileInfo ,setFileInfo ] = useState(undefined);//文件内容信息
|
|
|
|
|
|
const [ zip_url , setZip_url ] = useState(undefined);
|
|
|
|
|
|
const [ tar_url , setTar_url ] = useState(undefined);
|
|
|
|
|
|
const [ readOnly , setReadOnly] = useState(true);
|
|
|
|
|
|
const [ isSpin , setIsSpin] = useState(true);
|
|
|
|
|
|
const [ visible ,setVisible ] = useState(false);
|
2021-03-19 16:29:43 +08:00
|
|
|
|
const [ mainFlag ,setMainFlag ] = useState(false);
|
2021-03-24 14:08:10 +08:00
|
|
|
|
const [ openModal , setOpenModal ] = useState(false);
|
|
|
|
|
|
const [ desc , setDesc ] = useState(undefined);
|
|
|
|
|
|
const [ website , setWebsite ] = useState(undefined);
|
2021-04-08 15:37:01 +08:00
|
|
|
|
const [ lesson_url , setLessonUrl ] = useState(undefined);
|
2021-05-26 16:00:55 +08:00
|
|
|
|
const [ readme , setReadme ] = useState(undefined);
|
2021-07-07 11:16:07 +08:00
|
|
|
|
const [ defaultBranch , setDefaultBranch ] = useState(undefined);
|
|
|
|
|
|
const [ editReadme , setEditReadme ] = useState(false);
|
2021-08-05 17:13:57 +08:00
|
|
|
|
const [ pullsFlag , setPullsFlag ] = useState(true);
|
|
|
|
|
|
const [ issuesFlag , setIssuesFlag ] = useState(true);
|
2021-09-29 21:04:40 +08:00
|
|
|
|
const [ releaseVersions , setReleaseVersions] = useState(undefined);
|
2021-03-18 17:28:53 +08:00
|
|
|
|
|
2021-09-29 21:04:40 +08:00
|
|
|
|
const details = props.projectDetail;
|
2021-03-18 17:28:53 +08:00
|
|
|
|
const owner = props.match.params.owner;
|
|
|
|
|
|
const projectsId = props.match.params.projectsId;
|
2021-06-25 14:10:13 +08:00
|
|
|
|
let branchName = props.match.params.branchName;
|
2021-07-08 15:24:56 +08:00
|
|
|
|
branchName = returnbar(branchName);
|
2021-03-18 17:28:53 +08:00
|
|
|
|
let pathname = props.history.location.pathname;
|
2021-08-05 17:13:57 +08:00
|
|
|
|
const { bannerList } = props;
|
|
|
|
|
|
|
2021-03-18 17:28:53 +08:00
|
|
|
|
useEffect(()=>{
|
2021-08-05 17:13:57 +08:00
|
|
|
|
if(bannerList && bannerList.length>0){
|
|
|
|
|
|
let a = bannerList.filter(i=>i.menu_name === "pulls");
|
|
|
|
|
|
let i = bannerList.filter(i=>i.menu_name === "issues");
|
|
|
|
|
|
if(a && a.length === 0){
|
|
|
|
|
|
setPullsFlag(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(i && i.length === 0){
|
|
|
|
|
|
setIssuesFlag(false);
|
|
|
|
|
|
}
|
2021-03-18 17:28:53 +08:00
|
|
|
|
}
|
2021-08-05 17:13:57 +08:00
|
|
|
|
},[bannerList])
|
|
|
|
|
|
|
2021-03-18 17:28:53 +08:00
|
|
|
|
useEffect(()=>{
|
2021-05-21 18:58:17 +08:00
|
|
|
|
if(details){
|
|
|
|
|
|
setProjectDetail(details);
|
|
|
|
|
|
setDesc(details.description);
|
|
|
|
|
|
setWebsite(details.website);
|
|
|
|
|
|
setLessonUrl(details.lesson_url);
|
2021-05-26 16:00:55 +08:00
|
|
|
|
setDefaultBranch(details.default_branch);
|
2021-07-09 17:10:55 +08:00
|
|
|
|
setInviteCode(details.invite_code);
|
2021-03-18 17:28:53 +08:00
|
|
|
|
}
|
2021-09-29 21:04:40 +08:00
|
|
|
|
})
|
2021-03-18 17:28:53 +08:00
|
|
|
|
|
|
|
|
|
|
useEffect(()=>{
|
|
|
|
|
|
if(treeValue){
|
|
|
|
|
|
setTreeValuePath(treeValue.split('/'));
|
|
|
|
|
|
}else{
|
|
|
|
|
|
setTreeValuePath(undefined);
|
|
|
|
|
|
}
|
|
|
|
|
|
},[treeValue])
|
|
|
|
|
|
|
2021-05-21 18:58:17 +08:00
|
|
|
|
|
2021-03-18 17:28:53 +08:00
|
|
|
|
useEffect(()=>{
|
2021-05-26 16:00:55 +08:00
|
|
|
|
if (projectsId && owner && defaultBranch){
|
2021-07-08 15:24:56 +08:00
|
|
|
|
let b = turnbar(branchName) ;
|
2021-09-01 09:33:22 +08:00
|
|
|
|
if(pathname.indexOf(`/${owner}/${projectsId}`) > -1 && pathname.indexOf(`/tree/${b}/`) > -1) {
|
2021-06-25 14:10:13 +08:00
|
|
|
|
let url = pathname.split(`/tree/${b}/`)[1];
|
2021-03-18 17:28:53 +08:00
|
|
|
|
setTreeValue(url);
|
|
|
|
|
|
getFileInfo(url,branchName);
|
2021-06-18 16:55:52 +08:00
|
|
|
|
setType("file");
|
2021-03-18 17:28:53 +08:00
|
|
|
|
}else{
|
|
|
|
|
|
setTreeValue(undefined);
|
2021-05-26 16:00:55 +08:00
|
|
|
|
getDirInfo(branchName || defaultBranch);
|
2021-06-18 16:55:52 +08:00
|
|
|
|
setType("dir");
|
2021-03-18 17:28:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-05-26 16:00:55 +08:00
|
|
|
|
},[projectsId,owner,pathname,defaultBranch])
|
2021-03-18 17:28:53 +08:00
|
|
|
|
|
2021-09-29 21:04:40 +08:00
|
|
|
|
useEffect(()=>{
|
|
|
|
|
|
axios.get(`/${owner}/${projectsId}/releases.json`).then((result)=>{
|
|
|
|
|
|
if(result && result.data && result.data.releases){
|
|
|
|
|
|
const release = {
|
|
|
|
|
|
"list":result.data.releases,
|
|
|
|
|
|
"total_count":result.data.releases.length
|
|
|
|
|
|
}
|
|
|
|
|
|
setReleaseVersions(release);
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},[releaseVersions])
|
|
|
|
|
|
|
2021-03-18 17:28:53 +08:00
|
|
|
|
// 获取主目录列表
|
|
|
|
|
|
function getDirInfo(branch){
|
|
|
|
|
|
setIsSpin(true);
|
|
|
|
|
|
const url = `/${owner}/${projectsId}/entries.json`;
|
|
|
|
|
|
axios.get(url, {
|
|
|
|
|
|
params: { ref: branch }
|
|
|
|
|
|
}).then((result) => {
|
|
|
|
|
|
if (result) {
|
|
|
|
|
|
setCommitCount(result.data.commits_count);
|
|
|
|
|
|
setDirInfo(result.data.entries);
|
|
|
|
|
|
setFileInfo(undefined);
|
|
|
|
|
|
setTar_url(result.data.tar_url);
|
|
|
|
|
|
setZip_url(result.data.zip_url);
|
|
|
|
|
|
let c = result.data.last_commit
|
|
|
|
|
|
setLastCommit(c && c.commit);
|
2021-03-30 15:01:25 +08:00
|
|
|
|
setLastCommitAuthor(c && c.committer);
|
2021-03-19 16:29:43 +08:00
|
|
|
|
setMainFlag(true);
|
2021-04-25 17:46:38 +08:00
|
|
|
|
setReadOnly(true);
|
2021-05-21 18:58:17 +08:00
|
|
|
|
setReadme(result.data.readme);
|
2021-07-07 11:16:07 +08:00
|
|
|
|
setEditReadme(false);
|
2021-06-21 17:52:48 +08:00
|
|
|
|
setHide(true);
|
2021-03-18 17:28:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
setTimeout(function(){setIsSpin(false);},500);
|
|
|
|
|
|
}).catch(error=>{setIsSpin(false);})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(()=>{
|
|
|
|
|
|
if(projectDetail && lastCommit)
|
|
|
|
|
|
{
|
|
|
|
|
|
let ele = document.getElementById("ptxt");
|
|
|
|
|
|
if(ele){
|
|
|
|
|
|
let h = ele.offsetHeight;
|
2021-06-21 17:52:48 +08:00
|
|
|
|
if( h > 18 ) setHideBtn(true);
|
2021-03-18 17:28:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},[projectDetail,lastCommit])
|
|
|
|
|
|
// 获取子目录列表
|
|
|
|
|
|
function getFileInfo(path, ref){
|
|
|
|
|
|
setIsSpin(true);
|
|
|
|
|
|
const url = `/${owner}/${projectsId}/sub_entries.json`;
|
|
|
|
|
|
axios.get(url, {
|
|
|
|
|
|
params:{
|
|
|
|
|
|
filepath:path,
|
|
|
|
|
|
ref:ref || branchName,
|
|
|
|
|
|
type
|
|
|
|
|
|
}
|
|
|
|
|
|
}).then((result) => {
|
|
|
|
|
|
if (result) {
|
2021-09-28 11:09:23 +08:00
|
|
|
|
console.log(result)
|
2021-03-18 17:28:53 +08:00
|
|
|
|
let en = result.data.entries;
|
|
|
|
|
|
if(en.type){
|
|
|
|
|
|
setDirInfo(undefined);
|
|
|
|
|
|
setFileInfo(en);
|
|
|
|
|
|
setType(en.type);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
setFileInfo(undefined);
|
|
|
|
|
|
setDirInfo(en);
|
|
|
|
|
|
setType("dir");
|
|
|
|
|
|
}
|
|
|
|
|
|
let c = result.data.last_commit
|
|
|
|
|
|
setLastCommit(c && c.commit);
|
2021-03-30 15:01:25 +08:00
|
|
|
|
setLastCommitAuthor(c && c.committer);
|
2021-03-19 16:29:43 +08:00
|
|
|
|
setMainFlag(false);
|
2021-04-25 17:46:38 +08:00
|
|
|
|
setReadOnly(true);
|
2021-07-07 11:16:07 +08:00
|
|
|
|
setReadOnly(!editReadme);
|
2021-06-21 17:52:48 +08:00
|
|
|
|
setHide(true);
|
2021-03-18 17:28:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
setTimeout(function(){setIsSpin(false);},500)
|
|
|
|
|
|
}).catch(error=>{setIsSpin(false);})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 切换分支或者标签
|
|
|
|
|
|
function changeBranch(value){
|
2021-07-08 15:24:56 +08:00
|
|
|
|
let checkvalue = turnbar(value);
|
2021-09-01 09:33:22 +08:00
|
|
|
|
let url = `/${owner}/${projectsId}${value && `/tree/${checkvalue}`}${treeValue ? `/${treeValue}`:""}`;
|
2021-03-18 17:28:53 +08:00
|
|
|
|
props.history.push(url);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 文件相关的下拉项
|
2021-06-25 14:10:13 +08:00
|
|
|
|
function fileMenu(){
|
|
|
|
|
|
let b = branchName || defaultBranch;
|
2021-07-08 15:24:56 +08:00
|
|
|
|
let checkvalue = turnbar(b);
|
2021-06-25 14:10:13 +08:00
|
|
|
|
return (
|
2021-09-10 09:50:29 +08:00
|
|
|
|
<Menu className="fileMenu">
|
2021-09-03 13:48:07 +08:00
|
|
|
|
<Menu.Item>
|
|
|
|
|
|
<CheckProfile {...props} sureFunc={()=>urlLink(`/${owner}/${projectsId}/${checkvalue}/uploadfile${treeValue === undefined ? "" : `/${treeValue}`}`)}>上传文件</CheckProfile>
|
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
|
<Menu.Item>
|
|
|
|
|
|
<CheckProfile {...props} sureFunc={()=>urlLink(`/${owner}/${projectsId}/${checkvalue}/newfile${treeValue === undefined ? "" : `/${treeValue}`}`)}>新建文件</CheckProfile>
|
|
|
|
|
|
</Menu.Item>
|
2021-03-18 17:28:53 +08:00
|
|
|
|
</Menu>
|
2021-06-25 14:10:13 +08:00
|
|
|
|
)
|
|
|
|
|
|
}
|
2021-03-18 17:28:53 +08:00
|
|
|
|
|
|
|
|
|
|
function getPathUrl(array,index){
|
|
|
|
|
|
if(array && array.length>0 && index){
|
|
|
|
|
|
let str = "";
|
|
|
|
|
|
for(let i=0;i<index;i++){
|
|
|
|
|
|
str += `/${array[i]}`;
|
|
|
|
|
|
}
|
|
|
|
|
|
return str.substr(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 页面地址返回到主目录
|
|
|
|
|
|
function returnMain(){
|
|
|
|
|
|
setTreeValue(undefined);
|
2021-05-26 16:00:55 +08:00
|
|
|
|
let branch = branchName || defaultBranch;
|
2021-07-08 15:24:56 +08:00
|
|
|
|
let checkvalue = turnbar(branch);
|
2021-09-01 09:33:22 +08:00
|
|
|
|
props.history.push(`/${owner}/${projectsId}/tree/${checkvalue}`);
|
2021-03-18 17:28:53 +08:00
|
|
|
|
};
|
|
|
|
|
|
// 子目录路径返回链接
|
|
|
|
|
|
function returnUlr(url){
|
2021-07-08 15:24:56 +08:00
|
|
|
|
let enBranch = turnbar(branchName);
|
2021-09-01 09:33:22 +08:00
|
|
|
|
props.history.push(`/${owner}/${projectsId}/tree${enBranch?`/${enBranch}`:""}/${url}`);
|
2021-03-18 17:28:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
// 点击跳转到子目录
|
|
|
|
|
|
function goToSubRoot(path,type,filename){
|
2021-07-09 11:28:51 +08:00
|
|
|
|
if(type!=="submodule"){
|
|
|
|
|
|
let enBranch = branchName || defaultBranch;
|
|
|
|
|
|
let checkvalue = turnbar(enBranch);
|
|
|
|
|
|
setType(type);
|
2021-09-01 09:33:22 +08:00
|
|
|
|
props.history.push(`/${owner}/${projectsId}${`/tree/${checkvalue}`}${path?`/${path}`:""}`);
|
2021-07-09 11:28:51 +08:00
|
|
|
|
}
|
2021-03-18 17:28:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function onEdit(readOnly){
|
|
|
|
|
|
setReadOnly(readOnly);
|
2021-07-07 11:16:07 +08:00
|
|
|
|
setEditReadme(false);
|
2021-03-18 17:28:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
function ChangeFile(path, readOnly){
|
|
|
|
|
|
//点击直接跳转页面 加载一次路由
|
2021-07-08 15:24:56 +08:00
|
|
|
|
let enBranch = branchName || defaultBranch;
|
|
|
|
|
|
let checkvalue = turnbar(enBranch);
|
2021-09-01 09:33:22 +08:00
|
|
|
|
props.history.push(`/${owner}/${projectsId}/tree/${checkvalue}/${path}`);
|
2021-03-18 17:28:53 +08:00
|
|
|
|
setType("file");
|
2021-07-07 11:16:07 +08:00
|
|
|
|
setEditReadme(true);
|
2021-03-18 17:28:53 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function changeHide(hide){
|
|
|
|
|
|
setHide(!hide);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-19 17:22:02 +08:00
|
|
|
|
function urlLink(link){
|
|
|
|
|
|
if(props.checkIfLogin()===false){
|
|
|
|
|
|
props.showLoginDialog()
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
props.history.push(link);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-18 17:28:53 +08:00
|
|
|
|
const downloadMenu = (
|
2021-07-22 17:44:12 +08:00
|
|
|
|
<CloneAddress
|
|
|
|
|
|
http_url={projectDetail && projectDetail.clone_url}
|
|
|
|
|
|
ssh_url = {projectDetail && projectDetail.ssh_url}
|
|
|
|
|
|
zip_url={zip_url}
|
|
|
|
|
|
tar_url={tar_url}
|
|
|
|
|
|
showNotification={props.showNotification}/>
|
2021-03-18 17:28:53 +08:00
|
|
|
|
)
|
2021-04-08 17:44:31 +08:00
|
|
|
|
// 确认修改简介、website、实践课程链接
|
2021-04-08 15:37:01 +08:00
|
|
|
|
function okUpdate(d,w,l){
|
2021-03-24 14:08:10 +08:00
|
|
|
|
const url = `/${owner}/${projectsId}.json`;
|
|
|
|
|
|
axios.put(url,{
|
2021-04-08 15:37:01 +08:00
|
|
|
|
description:d,website:w,lesson_url:l
|
2021-03-24 14:08:10 +08:00
|
|
|
|
}).then(result=>{
|
|
|
|
|
|
if(result && result.data && result.data.id){
|
|
|
|
|
|
setDesc(result.data.description);
|
|
|
|
|
|
setWebsite(result.data.website);
|
2021-04-08 15:37:01 +08:00
|
|
|
|
setLessonUrl(result.data.lesson_url);
|
2021-03-24 14:08:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2021-04-20 15:31:49 +08:00
|
|
|
|
let n = fileInfo && fileInfo.name;
|
|
|
|
|
|
const mdFlag = n && n.substring(n.length-3,n.length) === ".md";
|
2021-06-11 11:01:46 +08:00
|
|
|
|
|
|
|
|
|
|
const { current_user } = props;
|
2021-08-03 17:37:14 +08:00
|
|
|
|
const baseOperate = projectDetail && projectDetail.permission && projectDetail.permission !=="Reporter";
|
2021-07-06 14:40:23 +08:00
|
|
|
|
const fileOperate = type === "dir" && projectDetail && projectDetail.type !== 2 && ((projectDetail.permission && projectDetail.permission !=="Reporter") || (current_user && current_user.admin));
|
2021-09-09 16:09:16 +08:00
|
|
|
|
|
2021-03-18 17:28:53 +08:00
|
|
|
|
return(
|
|
|
|
|
|
<WhiteBack>
|
2021-04-08 15:37:01 +08:00
|
|
|
|
<UpdateDescModal desc={desc} website={website} lesson_url={lesson_url} visible={openModal} onCancel={()=>setOpenModal(false)} onOk={okUpdate}/>
|
2021-03-18 17:28:53 +08:00
|
|
|
|
<Spin spinning={isSpin}>
|
|
|
|
|
|
{
|
2021-03-19 16:29:43 +08:00
|
|
|
|
(dirInfo || fileInfo) &&
|
2021-03-18 17:28:53 +08:00
|
|
|
|
<React.Fragment>
|
|
|
|
|
|
<DrawerPanel
|
|
|
|
|
|
history={props.history}
|
|
|
|
|
|
owner={owner}
|
|
|
|
|
|
projectsId={projectsId}
|
|
|
|
|
|
name={projectDetail && projectDetail.name}
|
2021-05-26 16:00:55 +08:00
|
|
|
|
branch={branchName || defaultBranch}
|
2021-03-18 17:28:53 +08:00
|
|
|
|
visible={visible}
|
|
|
|
|
|
onClose={()=>setVisible(false)}
|
2021-03-19 16:29:43 +08:00
|
|
|
|
list = {mainFlag ? dirInfo : undefined}
|
2021-03-18 17:28:53 +08:00
|
|
|
|
/>
|
2021-03-30 10:26:02 +08:00
|
|
|
|
<div className="drawerBtn" onClick={()=>setVisible(true)}>
|
2021-08-13 17:12:56 +08:00
|
|
|
|
<i className="iconfont icon-zuohuaicon font-14"></i>
|
2021-03-30 10:26:02 +08:00
|
|
|
|
<span>目录</span>
|
|
|
|
|
|
</div>
|
2021-03-18 17:28:53 +08:00
|
|
|
|
</React.Fragment>
|
|
|
|
|
|
}
|
|
|
|
|
|
<div style={{minHeight:"500px"}}>
|
|
|
|
|
|
{
|
|
|
|
|
|
projectDetail &&
|
|
|
|
|
|
<Box className="Panels">
|
|
|
|
|
|
<LongWidth>
|
|
|
|
|
|
<div className="panelmenu">
|
|
|
|
|
|
<FlexAJ>
|
|
|
|
|
|
<AlignCenter>
|
2021-08-13 17:12:56 +08:00
|
|
|
|
<div className="mr30">
|
2021-03-18 17:28:53 +08:00
|
|
|
|
{
|
|
|
|
|
|
props && props.platform ?
|
|
|
|
|
|
<SelectBranch
|
|
|
|
|
|
repo_id={projectDetail && projectDetail.repo_id}
|
|
|
|
|
|
projectsId={projectsId}
|
2021-05-26 16:00:55 +08:00
|
|
|
|
branch={branchName || defaultBranch}
|
2021-03-18 17:28:53 +08:00
|
|
|
|
changeBranch={changeBranch}
|
|
|
|
|
|
owner={owner}
|
|
|
|
|
|
history={props.history}
|
|
|
|
|
|
branchList={projectDetail && projectDetail.branches && projectDetail.branches.list}
|
|
|
|
|
|
></SelectBranch>
|
|
|
|
|
|
:
|
2021-09-28 11:09:23 +08:00
|
|
|
|
<span>分支:<span className="color-grey-6">{branchName || defaultBranch}</span></span>
|
2021-03-18 17:28:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
</div>
|
2021-09-28 11:09:23 +08:00
|
|
|
|
{
|
|
|
|
|
|
treeValuePath && treeValuePath.length > 0 ?
|
|
|
|
|
|
<Path
|
|
|
|
|
|
identifier={projectDetail && projectDetail.identifier}
|
|
|
|
|
|
treeValuePath={treeValuePath}
|
|
|
|
|
|
returnUlr={returnUlr}
|
|
|
|
|
|
returnMain={returnMain}
|
|
|
|
|
|
getPathUrl={getPathUrl}
|
|
|
|
|
|
/>
|
|
|
|
|
|
:
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<AlignCenter className="mr20">
|
|
|
|
|
|
<Link to={`/${owner}/${projectsId}/branches`} className="iconBtn">
|
|
|
|
|
|
<i className="iconfont icon-master_icon font-16"></i>
|
|
|
|
|
|
<span>分支</span>
|
|
|
|
|
|
<span>{projectDetail && projectDetail.branches && projectDetail.branches.total_count}</span>
|
|
|
|
|
|
</Link>
|
|
|
|
|
|
</AlignCenter>
|
|
|
|
|
|
<AlignCenter className="mr20">
|
|
|
|
|
|
<Link to={`/${owner}/${projectsId}/tags`} className="iconBtn">
|
|
|
|
|
|
<i className="iconfont icon-biaoqianicon font-16"></i>
|
|
|
|
|
|
<span>标签</span>
|
|
|
|
|
|
<span>{projectDetail && projectDetail.tags && projectDetail.tags.total_count}</span>
|
|
|
|
|
|
</Link>
|
|
|
|
|
|
</AlignCenter>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
}
|
2021-03-18 17:28:53 +08:00
|
|
|
|
</AlignCenter>
|
2021-08-13 17:12:56 +08:00
|
|
|
|
<AlignCenter className="depotBtn">
|
2021-08-03 17:37:14 +08:00
|
|
|
|
{
|
2021-08-06 14:07:59 +08:00
|
|
|
|
baseOperate && ((projectDetail.type !== 2 && pullsFlag) || issuesFlag )&&
|
2021-09-09 17:50:46 +08:00
|
|
|
|
<div className="addOptionBtn">
|
2021-08-03 17:37:14 +08:00
|
|
|
|
{
|
2021-08-05 17:13:57 +08:00
|
|
|
|
projectDetail.type !== 2 && pullsFlag &&
|
2021-09-01 17:46:58 +08:00
|
|
|
|
<CheckProfile {...props} sureFunc={()=>urlLink(`/${owner}/${projectsId}/pulls/new`)} >+ 合并请求</CheckProfile>
|
2021-08-03 17:37:14 +08:00
|
|
|
|
}
|
2021-08-05 17:13:57 +08:00
|
|
|
|
{
|
|
|
|
|
|
issuesFlag &&
|
2021-09-10 11:47:48 +08:00
|
|
|
|
<CheckProfile {...props} sureFunc={()=>urlLink(`/${owner}/${projectsId}/issues/new`)} >+ 易修</CheckProfile>
|
2021-08-05 17:13:57 +08:00
|
|
|
|
}
|
2021-08-03 17:37:14 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
}
|
2021-06-11 11:01:46 +08:00
|
|
|
|
{ fileOperate &&
|
2021-09-10 09:50:29 +08:00
|
|
|
|
<Dropdown
|
|
|
|
|
|
overlay={fileMenu()}
|
|
|
|
|
|
className="mr10"
|
|
|
|
|
|
trigger={['click']}
|
|
|
|
|
|
getPopupContainer={document.parentNode}
|
|
|
|
|
|
>
|
|
|
|
|
|
<a>文件 <i className="iconfont icon-sanjiaoxing-down ml3 font-14 color-grey-6 mr-5"></i></a>
|
2021-03-30 11:50:25 +08:00
|
|
|
|
</Dropdown>
|
|
|
|
|
|
}
|
2021-04-08 14:21:35 +08:00
|
|
|
|
|
2021-04-27 17:11:37 +08:00
|
|
|
|
<Dropdown overlay={downloadMenu} placement="bottomRight" trigger={['click']}>
|
2021-08-13 17:12:56 +08:00
|
|
|
|
<Button type={'primary'}>下载 <i className="iconfont icon-sanjiaoxing-down ml3 font-14 color-white mr-3"></i></Button>
|
2021-04-08 14:21:35 +08:00
|
|
|
|
</Dropdown>
|
2021-03-18 17:28:53 +08:00
|
|
|
|
</AlignCenter>
|
|
|
|
|
|
</FlexAJ>
|
|
|
|
|
|
{
|
2021-08-27 10:53:00 +08:00
|
|
|
|
(dirInfo && dirInfo.length>0) || fileInfo ?
|
2021-03-18 17:28:53 +08:00
|
|
|
|
<div className="listtable">
|
|
|
|
|
|
{
|
|
|
|
|
|
lastCommit &&
|
|
|
|
|
|
<div className="listtablehead">
|
2021-04-19 17:52:01 +08:00
|
|
|
|
<User url={getImageUrl(`/${lastCommitAuthor && lastCommitAuthor.image_url}`)} name={lastCommitAuthor && lastCommitAuthor.name} id={lastCommitAuthor && lastCommitAuthor.id} login={lastCommitAuthor && lastCommitAuthor.login}/>
|
2021-09-09 16:09:16 +08:00
|
|
|
|
<div onClick={()=>props.history.push(`/${owner}/${projectsId}/commits/${truncateCommitId(lastCommit.sha)}`)} className={hideBtn && hide ? "ellipsistxt hidetxt" :"ellipsistxt"}>
|
|
|
|
|
|
<pre id="ptxt">{lastCommit.message}</pre>
|
2021-06-21 17:52:48 +08:00
|
|
|
|
</div>
|
2021-03-18 17:28:53 +08:00
|
|
|
|
{ hideBtn && <span className="ellipsis" onClick={()=>changeHide(hide)}><i className="iconfont icon-shenglvehao"></i></span> }
|
|
|
|
|
|
|
2021-09-09 16:09:16 +08:00
|
|
|
|
<span className="ml20 color-grey-6 font-12 mt3">{lastCommit.time_from_now}</span>
|
|
|
|
|
|
{
|
|
|
|
|
|
commitCount ?
|
2021-09-10 09:50:29 +08:00
|
|
|
|
<Link to={`/${owner}/${projectsId}/commits/branch/${turnbar(branchName || defaultBranch)}`} className="ml20 color-grey-3"style={{height:"28px",lineHeight:"28px"}}>
|
|
|
|
|
|
<i className="iconfont icon-tijiaoicon mr3 font-16"></i><span style={{fontWeight:"500"}}>{commitCount}次提交</span>
|
2021-09-09 16:09:16 +08:00
|
|
|
|
</Link>:""
|
|
|
|
|
|
}
|
2021-03-18 17:28:53 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
}
|
|
|
|
|
|
<ul className="listtablebody">
|
|
|
|
|
|
{
|
|
|
|
|
|
dirInfo && dirInfo.length > 0 &&
|
|
|
|
|
|
dirInfo.map((item,key)=>{
|
|
|
|
|
|
return(
|
|
|
|
|
|
<Catalogue
|
|
|
|
|
|
owner={owner}
|
|
|
|
|
|
item={item}
|
|
|
|
|
|
projectsId={projectsId}
|
|
|
|
|
|
goToSubRoot={goToSubRoot}
|
|
|
|
|
|
/>
|
|
|
|
|
|
)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
{
|
|
|
|
|
|
fileInfo &&
|
|
|
|
|
|
<CoderRootFileDetail
|
|
|
|
|
|
{...props}
|
|
|
|
|
|
detail={fileInfo}
|
|
|
|
|
|
readOnly={readOnly}
|
2021-04-20 15:31:49 +08:00
|
|
|
|
md={mdFlag}
|
2021-03-18 17:28:53 +08:00
|
|
|
|
onEdit={onEdit}
|
2021-05-26 16:00:55 +08:00
|
|
|
|
currentBranch={branchName || defaultBranch}
|
2021-04-08 14:21:35 +08:00
|
|
|
|
type={projectDetail.type}
|
2021-03-18 17:28:53 +08:00
|
|
|
|
></CoderRootFileDetail>
|
|
|
|
|
|
}
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</div>
|
2021-03-19 16:29:43 +08:00
|
|
|
|
: ""
|
2021-03-18 17:28:53 +08:00
|
|
|
|
}
|
2021-03-19 16:29:43 +08:00
|
|
|
|
{
|
2021-08-26 17:29:28 +08:00
|
|
|
|
(dirInfo && dirInfo.length === 0) && !fileInfo ? <Nodata _html="暂未发现文件"/> :""
|
2021-03-19 16:29:43 +08:00
|
|
|
|
}
|
2021-03-18 17:28:53 +08:00
|
|
|
|
{/* readme文件显示(显示文件详情时不显示readme文件) */}
|
2021-09-28 11:09:23 +08:00
|
|
|
|
{ (readme && readme.content) ? <ReadMe ChangeFile={ChangeFile} readme={readme} operate={props && (props.isManager || props.isDeveloper) && projectDetail.type !==2 } history={props.history} /> :"" }
|
2021-03-18 17:28:53 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</LongWidth>
|
|
|
|
|
|
{
|
2021-09-28 11:09:23 +08:00
|
|
|
|
(!(treeValuePath && treeValuePath.length > 0) && !fileInfo) &&
|
2021-03-18 17:28:53 +08:00
|
|
|
|
<ShortWidth>
|
|
|
|
|
|
<Gap style={{paddingLeft:"30px"}}>
|
|
|
|
|
|
<div className="panelmenu">
|
2021-09-09 16:09:16 +08:00
|
|
|
|
<FlexAJ className="font-18 color-ooo mb20" style={{lineHeight:"28px"}}>关于
|
2021-09-02 14:13:16 +08:00
|
|
|
|
{
|
|
|
|
|
|
projectDetail.permission && (projectDetail.permission==="Admin" || projectDetail.permission==="Owner" || projectDetail.permission==="Manager") &&
|
2021-09-10 11:47:48 +08:00
|
|
|
|
<i onClick={()=>setOpenModal(true)} className="iconfont icon-a-shezhi color-grey-9 font-15"></i>
|
2021-09-02 14:13:16 +08:00
|
|
|
|
}
|
2021-03-24 14:08:10 +08:00
|
|
|
|
</FlexAJ>
|
2021-08-13 17:12:56 +08:00
|
|
|
|
{desc && <p className="font-14 color-grey-3 mb15 task-hide-2" style={{lineHeight:"24px",WebkitLineClamp:"4",textAlign:"justify",wordBreak:"break-all"}}>{desc}</p>}
|
2021-03-18 17:28:53 +08:00
|
|
|
|
{
|
2021-03-24 14:08:10 +08:00
|
|
|
|
website &&
|
2021-08-12 15:24:45 +08:00
|
|
|
|
<div className="color-grey-6 df pinfos mb5">
|
|
|
|
|
|
<i className="iconfont icon-lianjie2 font-15 mr10"></i>
|
2021-04-08 15:37:01 +08:00
|
|
|
|
<a href={website} target="_blank" style={{wordBreak:"break-all",lineHeight:"20px",marginTop:"5px",textDecoration:"underline"}}>{website}</a>
|
2021-08-12 15:24:45 +08:00
|
|
|
|
</div>
|
2021-03-18 17:28:53 +08:00
|
|
|
|
}
|
2021-08-12 15:24:45 +08:00
|
|
|
|
<div className="pinfos mb5">
|
2021-08-13 17:12:56 +08:00
|
|
|
|
<i className="iconfont icon-zishuwenjian_icon font-15 mr10"></i>
|
2021-08-12 15:24:45 +08:00
|
|
|
|
<a href="#readme">README.md</a>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="color-grey-6 mb5">
|
|
|
|
|
|
<i className="iconfont icon-neicunicon font-15 mr10"></i>
|
2021-03-18 17:28:53 +08:00
|
|
|
|
<span>{projectDetail && projectDetail.size}</span>
|
2021-08-12 15:24:45 +08:00
|
|
|
|
</div>
|
2021-03-18 17:28:53 +08:00
|
|
|
|
{
|
|
|
|
|
|
projectDetail && projectDetail.license_name &&
|
2021-09-09 16:09:16 +08:00
|
|
|
|
<div className="pinfos">
|
|
|
|
|
|
<i className="iconfont icon-xieyiicon font-16 mr10"></i>
|
|
|
|
|
|
<Link to={`/${owner}/${projectsId}/tree/${branchName || defaultBranch}/LICENSE`} className="color-grey-6">{projectDetail.license_name}</Link>
|
2021-08-12 15:24:45 +08:00
|
|
|
|
</div>
|
2021-03-18 17:28:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
</div>
|
2021-07-09 17:10:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
inviteCode &&
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<Divider />
|
2021-08-12 11:45:56 +08:00
|
|
|
|
<Invite code={inviteCode}/>
|
2021-07-09 17:10:55 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
}
|
2021-04-08 15:37:01 +08:00
|
|
|
|
{
|
|
|
|
|
|
lesson_url &&
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<Divider />
|
2021-08-13 17:12:56 +08:00
|
|
|
|
<p className="font-16 color-ooo">实践课程</p>
|
2021-08-05 10:57:43 +08:00
|
|
|
|
<a href={lesson_url} target="_blank" className="color-grey-6" style={{textDecoration:"underline",wordBreak:"break-all"}}>{lesson_url}</a>
|
2021-04-08 15:37:01 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
}
|
2021-03-18 17:28:53 +08:00
|
|
|
|
{/* 发布 */}
|
|
|
|
|
|
{
|
2021-09-29 21:04:40 +08:00
|
|
|
|
releaseVersions &&
|
2021-03-18 17:28:53 +08:00
|
|
|
|
<React.Fragment>
|
|
|
|
|
|
<Divider />
|
2021-08-03 17:37:14 +08:00
|
|
|
|
<Releases
|
|
|
|
|
|
owner={owner}
|
|
|
|
|
|
projectsId={projectsId}
|
2021-09-29 21:04:40 +08:00
|
|
|
|
releaseVersions={releaseVersions}
|
2021-08-03 17:37:14 +08:00
|
|
|
|
history={props.history}
|
|
|
|
|
|
baseOperate={baseOperate}
|
2021-08-05 17:13:57 +08:00
|
|
|
|
projectType={projectDetail.type}
|
2021-08-03 17:37:14 +08:00
|
|
|
|
/>
|
2021-03-18 17:28:53 +08:00
|
|
|
|
</React.Fragment>
|
|
|
|
|
|
}
|
|
|
|
|
|
{/* 贡献者 */}
|
|
|
|
|
|
{
|
2021-09-09 16:09:16 +08:00
|
|
|
|
projectDetail && projectDetail.contributors && projectDetail.contributors.total_count >0 &&
|
|
|
|
|
|
<Contributors contributors={projectDetail.contributors} owner={owner} projectsId={projectsId} />
|
2021-03-18 17:28:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
{/* 语言 */}
|
2021-09-09 16:09:16 +08:00
|
|
|
|
{ projectDetail && projectDetail.languages &&
|
2021-03-18 17:28:53 +08:00
|
|
|
|
<React.Fragment>
|
|
|
|
|
|
<Divider />
|
|
|
|
|
|
<LanguagePower languages={projectDetail.languages}/>
|
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
|
}
|
|
|
|
|
|
</Gap>
|
|
|
|
|
|
</ShortWidth>
|
|
|
|
|
|
}
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Spin>
|
|
|
|
|
|
</WhiteBack>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
export default CoderDepot;
|