Merge branch 'feature_repo_second_page' of https://git.trustie.net/Gitlink/forgeplus-react into feature_repo_second_page
This commit is contained in:
commit
0fea52b923
|
@ -2,7 +2,7 @@ import React from 'react';
|
|||
import { AlignTop } from '../Component/layout';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
function Releases({owner,projectsId,releaseVersions , baseOperate , projectType}){
|
||||
function Releases({ owner, projectsId, releaseVersions, distribution }) {
|
||||
return(
|
||||
<div>
|
||||
<Link to={`/${owner}/${projectsId}/releases`} className="font-16 color-ooo hoverA">
|
||||
|
@ -27,7 +27,8 @@ function Releases({owner,projectsId,releaseVersions , baseOperate , projectType}
|
|||
})
|
||||
:
|
||||
<div className="mt8">
|
||||
您暂未发布任何版本{baseOperate && projectType !==2 && <Link className="color-blue ml20" to={{pathname:`/${owner}/${projectsId}/releases/new`,state:{stable:true}}}>创建新版本</Link>}
|
||||
您暂未发布任何版本
|
||||
{distribution && <Link className="color-blue ml20" to={{pathname:`/${owner}/${projectsId}/releases/new`,state:{stable:true}}}>创建新版本</Link>}
|
||||
</div>
|
||||
}
|
||||
|
||||
|
|
|
@ -67,14 +67,15 @@ function CoderDepot(props){
|
|||
const [ editReadme , setEditReadme ] = useState(false);
|
||||
const [ pullsFlag , setPullsFlag ] = useState(true);
|
||||
const [ issuesFlag , setIssuesFlag ] = useState(true);
|
||||
const [ releaseVersions , setReleaseVersions] = useState(undefined);
|
||||
|
||||
const details = props.projectDetail;
|
||||
const owner = props.match.params.owner;
|
||||
const projectsId = props.match.params.projectsId;
|
||||
let branchName = props.match.params.branchName;
|
||||
branchName = returnbar(branchName);
|
||||
const details = props.projectDetail;
|
||||
let pathname = props.history.location.pathname;
|
||||
//distribution:判断此用户是否可以创建发行版
|
||||
const distribution = details && details.type != 2 && (details.permission === "Admin" || details.permission === "Owner" || details.permission === "Manager");
|
||||
const { bannerList } = props;
|
||||
|
||||
useEffect(()=>{
|
||||
|
@ -90,6 +91,7 @@ function CoderDepot(props){
|
|||
}
|
||||
},[bannerList])
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
if(details){
|
||||
setProjectDetail(details);
|
||||
|
@ -99,7 +101,7 @@ function CoderDepot(props){
|
|||
setDefaultBranch(details.default_branch);
|
||||
setInviteCode(details.invite_code);
|
||||
}
|
||||
})
|
||||
},[details])
|
||||
|
||||
useEffect(()=>{
|
||||
if(treeValue){
|
||||
|
@ -118,30 +120,39 @@ function CoderDepot(props){
|
|||
setTreeValue(url);
|
||||
getFileInfo(url,branchName);
|
||||
setType("file");
|
||||
getReadmeInfo(url,branchName);
|
||||
}else{
|
||||
setTreeValue(undefined);
|
||||
getDirInfo(branchName || defaultBranch);
|
||||
setType("dir");
|
||||
getReadmeInfo('', branchName || defaultBranch);
|
||||
}
|
||||
}
|
||||
},[projectsId,owner,pathname,defaultBranch])
|
||||
|
||||
useEffect(()=>{
|
||||
axios.get(`/${owner}/${projectsId}/releases.json`).then((result)=>{
|
||||
if(result && result.data){
|
||||
const release = {
|
||||
"list":result.data.releases,
|
||||
"total_count":result.data.releases.length
|
||||
}
|
||||
setReleaseVersions(release);
|
||||
// 获取readme信息
|
||||
function getReadmeInfo(path, ref) {
|
||||
axios.get(`/${owner}/${projectsId}/readme.json`, {
|
||||
params:{
|
||||
owner: owner,
|
||||
repo: projectsId,
|
||||
filepath:path,
|
||||
ref:ref || branchName
|
||||
}
|
||||
}).then((result) => {
|
||||
if (result) {
|
||||
setReadme(result.data);
|
||||
} else {
|
||||
setReadme(undefined);
|
||||
}
|
||||
})
|
||||
},[])
|
||||
}
|
||||
|
||||
// 获取主目录列表
|
||||
function getDirInfo(branch){
|
||||
setIsSpin(true);
|
||||
const url = `/${owner}/${projectsId}/entries.json`;
|
||||
|
||||
axios.get(url, {
|
||||
params: { ref: branch }
|
||||
}).then((result) => {
|
||||
|
@ -156,7 +167,7 @@ function CoderDepot(props){
|
|||
setLastCommitAuthor(c && c.committer);
|
||||
setMainFlag(true);
|
||||
setReadOnly(true);
|
||||
setReadme(result.data.readme);
|
||||
// setReadme(result.data.readme);
|
||||
setEditReadme(false);
|
||||
setHide(true);
|
||||
}
|
||||
|
@ -186,7 +197,6 @@ function CoderDepot(props){
|
|||
}
|
||||
}).then((result) => {
|
||||
if (result) {
|
||||
console.log(result)
|
||||
let en = result.data.entries;
|
||||
if(en.type){
|
||||
setDirInfo(undefined);
|
||||
|
@ -201,7 +211,7 @@ function CoderDepot(props){
|
|||
setLastCommit(c && c.commit);
|
||||
setLastCommitAuthor(c && c.committer);
|
||||
setMainFlag(false);
|
||||
setReadme(result.data.readme)
|
||||
// setReadme(result.data.readme);
|
||||
setReadOnly(true);
|
||||
setReadOnly(!editReadme);
|
||||
setHide(true);
|
||||
|
@ -532,16 +542,15 @@ function CoderDepot(props){
|
|||
}
|
||||
{/* 发布 */}
|
||||
{
|
||||
releaseVersions &&
|
||||
projectDetail && projectDetail.release_versions &&
|
||||
<React.Fragment>
|
||||
<Divider />
|
||||
<Releases
|
||||
owner={owner}
|
||||
projectsId={projectsId}
|
||||
releaseVersions={releaseVersions}
|
||||
owner={owner}
|
||||
projectsId={projectsId}
|
||||
releaseVersions={projectDetail.release_versions}
|
||||
history={props.history}
|
||||
baseOperate={baseOperate}
|
||||
projectType={projectDetail.type}
|
||||
distribution={distribution}
|
||||
/>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ class CoderRootCommit extends Component{
|
|||
<AlignTop>
|
||||
<div className="commitDesc"><Link to={{pathname:`/${owner}/${projectsId}/commits/${truncateCommitId(`${item.sha}`)}/${branch}`,query:{commitPage:page}}} className="font-14 color-grey-3 font-bd">{item.message}</Link></div>
|
||||
</AlignTop>
|
||||
<p className="f-wrap-alignCenter mt15">
|
||||
<p className="f-wrap-alignCenter mt15 pb5">
|
||||
<User
|
||||
id={item.id}
|
||||
url={(item.image_url && getImageUrl(`/${item.image_url}`)) || "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3025493530,1989042357&fm=26&gp=0.jpg"}
|
||||
|
|
|
@ -74,8 +74,8 @@ function version(props) {
|
|||
<div className="versionName">
|
||||
<Link to={`/${owner}/${projectsId}/tree/${item.tag_name}`} className="task-hide color-blue hover font-18">{item.name}</Link>
|
||||
<span>
|
||||
{data && data.user_permission && type !== 2 && <Link to={{pathname:`/${owner}/${projectsId}/releases/${item.version_id}/update`,state:{"stable":item.draft==="稳定"}}} className="ml15"><i className="iconfont icon-a-bianji1 font-16 color-grey-6"></i></Link>}
|
||||
{data && data.user_permission && type !== 2 && <i className ="iconfont icon-shanchuicon1 font-16 ml15" onClick={()=>{deleteRelease(item.version_id)}}></i>}
|
||||
{data && data.user_admin_permission && type !== 2 && <Link to={{pathname:`/${owner}/${projectsId}/releases/${item.version_id}/update`,state:{"stable":item.draft==="稳定"}}} className="ml15"><i className="iconfont icon-a-bianji1 font-16 color-grey-6"></i></Link>}
|
||||
{data && data.user_admin_permission && type !== 2 && <i className ="iconfont icon-shanchuicon1 font-16 ml15" onClick={()=>{deleteRelease(item.version_id)}}></i>}
|
||||
</span>
|
||||
</div>
|
||||
<span className="color-grey-3 mb15 version-user">
|
||||
|
@ -84,14 +84,14 @@ function version(props) {
|
|||
id={item.id}
|
||||
url={(item.image_url && getImageUrl(`/${item.image_url}`)) || "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3025493530,1989042357&fm=26&gp=0.jpg"}
|
||||
name={item.user_name}
|
||||
login={item.user_name}
|
||||
login={item.user_login}
|
||||
/>
|
||||
<span className="ml5">发布于{item.created_at}</span>
|
||||
</span>
|
||||
{
|
||||
item.bodyshow &&
|
||||
<div className="body-show">
|
||||
<RenderHtml className="break_word_comments imageLayerParent" value={item.body} url={props.history.location}/>
|
||||
<RenderHtml className="break_word_comments imageLayerParent" value={item.body || ''} url={props.history.location}/>
|
||||
</div>
|
||||
}
|
||||
<RenderHtml />
|
||||
|
@ -113,7 +113,7 @@ function version(props) {
|
|||
return (
|
||||
<React.Fragment>
|
||||
{
|
||||
data && data.user_permission && type !== 2 &&
|
||||
data && data.user_admin_permission && type !== 2 &&
|
||||
<div className="addReleaseBtn">
|
||||
<Button type={"primary"} onClick={addFunc} className="btnblue" style={{height:"36px"}}>发布新版本</Button>
|
||||
</div>
|
||||
|
@ -126,7 +126,7 @@ function version(props) {
|
|||
} else if (releases && releases.length === 0) {
|
||||
return (
|
||||
<Empty
|
||||
operation={data && data.user_permission && type !== 2}
|
||||
operation={data && data.user_admin_permission && type !== 2}
|
||||
addFunc={addFunc}
|
||||
/>
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue