forked from Gitlink/forgeplus-react
Merge branch 'develop' into dev_m_copy
This commit is contained in:
commit
4b8d72a6eb
|
@ -32,7 +32,7 @@ function List({ list, operate , projectsId , owner , showModal , deleteFunc }){
|
|||
ellipsis:true,
|
||||
render:(value,item)=>{
|
||||
return(
|
||||
<Link to={`/projects/${owner}/${projectsId}/branch/${item.branch}?url=${value}`} className="color-blue">{value}</Link>
|
||||
<Link to={`/projects/${owner}/${projectsId}/branch/${item.branch}/tree/${value}`} className="color-blue">{value}</Link>
|
||||
)
|
||||
}
|
||||
},
|
||||
|
|
|
@ -52,7 +52,8 @@ class CoderRootDirectory extends Component {
|
|||
tar_url:undefined,
|
||||
chooseType:undefined,
|
||||
|
||||
md:false
|
||||
md:false,
|
||||
treeValue:undefined
|
||||
}
|
||||
}
|
||||
changeAddress = (address) => {
|
||||
|
@ -87,15 +88,13 @@ class CoderRootDirectory extends Component {
|
|||
};
|
||||
|
||||
Init = () => {
|
||||
let { search } = this.props.history.location;
|
||||
const { branchName } = this.props.match.params;
|
||||
let { pathname } = this.props.history.location;
|
||||
const { branchName , owner , projectsId } = this.props.match.params;
|
||||
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("&")){
|
||||
url=decodeURI(url).split("&")[0];
|
||||
}
|
||||
if (pathname && (pathname.indexOf(`/projects/${owner}/${projectsId}`) > -1 && pathname.indexOf("/tree/") > -1)) {
|
||||
let url = pathname.split("/tree/")[1];
|
||||
this.setState({treeValue:url})
|
||||
this.getFileDetail(decodeURI(url),branch);
|
||||
} else {
|
||||
this.getProjectRoot(branch);
|
||||
|
@ -106,7 +105,8 @@ class CoderRootDirectory extends Component {
|
|||
returnMain = (branch) => {
|
||||
const { projectsId , owner , branchName } = this.props.match.params;
|
||||
this.setState({
|
||||
readOnly:true
|
||||
readOnly:true,
|
||||
treeValue:undefined
|
||||
})
|
||||
this.props.history.push(`/projects/${owner}/${projectsId}${branchName?`/branch/${branchName}`:""}`);
|
||||
this.getProjectRoot(branch);
|
||||
|
@ -145,45 +145,13 @@ class CoderRootDirectory extends Component {
|
|||
ChangeFile = (arr, readOnly) => {
|
||||
const { projectsId , owner } = this.props.match.params;
|
||||
//点击直接跳转页面 加载一次路由
|
||||
this.props.history.push(`/projects/${owner}/${projectsId}?url=${arr.path}`);
|
||||
this.props.history.push(`/projects/${owner}/${projectsId}/tree/${arr.path}`);
|
||||
this.setState({
|
||||
readOnly: readOnly,
|
||||
chooseType:"file"
|
||||
});
|
||||
};
|
||||
|
||||
renderUrl = (name, path, type) => {
|
||||
let list = [];
|
||||
const { filePath } = this.state;
|
||||
if (path.indexOf("/")) {
|
||||
const array = path.split("/");
|
||||
let str = "";
|
||||
array.map((i, k) => {
|
||||
str += "/" + i;
|
||||
return list.push({
|
||||
key: k,
|
||||
index: k,
|
||||
name: i,
|
||||
path: str.substr(1),
|
||||
type: filePath && filePath.length > 0 ? filePath[k] ? filePath[k].type : type : type,
|
||||
});
|
||||
});
|
||||
const { projectsId , owner } = this.props.match.params;
|
||||
//点击直接跳转页面 加载一次路由
|
||||
this.props.history.push(`/projects/${owner}/${projectsId}?url=${str.substr(1)}`);
|
||||
} else {
|
||||
list.push({
|
||||
index: 0,
|
||||
name,
|
||||
path,
|
||||
type,
|
||||
});
|
||||
}
|
||||
this.setState({
|
||||
filePath: list,
|
||||
});
|
||||
};
|
||||
|
||||
// 获取子目录
|
||||
getFileDetail = (path, ref) => {
|
||||
this.setState({
|
||||
|
@ -267,7 +235,7 @@ class CoderRootDirectory extends Component {
|
|||
chooseType:type
|
||||
})
|
||||
const { projectsId, owner , branchName } = this.props.match.params;
|
||||
this.props.history.push(`/projects/${owner}/${projectsId}${branchName?`/branch/${branchName}`:""}?url=${path}`);
|
||||
this.props.history.push(`/projects/${owner}/${projectsId}${branchName?`/branch/${branchName}`:""}${path?`/tree/${path}`:""}`);
|
||||
if(filename.substring(filename.length - 3) === ".md"){
|
||||
this.setState({
|
||||
md:true
|
||||
|
@ -320,17 +288,9 @@ class CoderRootDirectory extends Component {
|
|||
|
||||
// 选择分支
|
||||
changeBranch = (value) => {
|
||||
let { search } = this.props.history.location;
|
||||
const { projectsId , owner } = this.props.match.params;
|
||||
|
||||
let url = `/projects/${owner}/${projectsId}${value && `/branch/${value}`}`;
|
||||
if (search && (search.indexOf("?url=") > -1 || search.indexOf("&url=") > -1)) {
|
||||
let u = search.split("url=")[1];
|
||||
if(u && decodeURI(u).indexOf("&")){
|
||||
u=decodeURI(u).split("&")[0];
|
||||
}
|
||||
url += `?url=${u}`;
|
||||
}
|
||||
const { treeValue } = this.state;
|
||||
let url = `/projects/${owner}/${projectsId}${value && `/branch/${value}`}${treeValue ? `/tree/${treeValue}`:""}`;
|
||||
this.props.history.push(url);
|
||||
}
|
||||
|
||||
|
@ -338,10 +298,11 @@ class CoderRootDirectory extends Component {
|
|||
returnUlr=(url)=>{
|
||||
this.setState({
|
||||
chooseType:"dir",
|
||||
readOnly:true
|
||||
readOnly:true,
|
||||
treeValue:url
|
||||
})
|
||||
const { projectsId , owner } = this.props.match.params;
|
||||
this.props.history.push(`/projects/${owner}/${projectsId}?url=${url}`);
|
||||
const { projectsId , owner , branchName } = this.props.match.params;
|
||||
this.props.history.push(`/projects/${owner}/${projectsId}${branchName?`/branch/${branchName}`:""}/tree/${url}`);
|
||||
}
|
||||
|
||||
onEdit=(readOnly)=>{
|
||||
|
|
|
@ -47,7 +47,7 @@ function Files({data,history,owner,projectsId}){
|
|||
<span>{item.name}</span>
|
||||
</AlignCenter>
|
||||
<span>
|
||||
<Button className="mr20" onClick={()=>{history.push(`/projects/${owner}/${projectsId}${item.sha ? `/branch/${truncateCommitId(item.sha)}?`:"?"}url=${item.name}`)}}>查看文件</Button>
|
||||
<Button className="mr20" onClick={()=>{history.push(`/projects/${owner}/${projectsId}${item.sha ? `/branch/${truncateCommitId(item.sha)}/`:"/"}tree/${item.name}`)}}>查看文件</Button>
|
||||
<span className="color-green">+{item.addition}</span>
|
||||
<span className="color-red ml20">-{item.deletion}</span>
|
||||
</span>
|
||||
|
|
Loading…
Reference in New Issue