Merge branch 'newVersion_forge' of http://gitea.trustie.net/jasder/forgeplus-react into newVersion_forge
This commit is contained in:
commit
cdff82f74b
|
|
@ -1,7 +1,7 @@
|
|||
import React , { Component } from 'react';
|
||||
import {Menu, Spin} from 'antd';
|
||||
import { getImageUrl } from 'educoder';
|
||||
import { Link } from 'react-router-dom';
|
||||
import React, { Component } from "react";
|
||||
import { Menu, Spin, Button } from "antd";
|
||||
import { getImageUrl } from "educoder";
|
||||
import { Link } from "react-router-dom";
|
||||
|
||||
import './list.css';
|
||||
import SelectBranch from '../Branch/Select';
|
||||
|
|
@ -11,7 +11,7 @@ import CoderRootFileDetail from './CoderRootFileDetail';
|
|||
import { truncateCommitId } from '../common/util';
|
||||
import RenderHtml from '../../components/render-html';
|
||||
|
||||
import axios from 'axios';
|
||||
import axios from "axios";
|
||||
/**
|
||||
* address:http和SSH,http_url(对应git地址)
|
||||
* branch:当前分支
|
||||
|
|
@ -20,158 +20,171 @@ import axios from 'axios';
|
|||
* readMeContent:根目录下面的readme文件内容
|
||||
*/
|
||||
|
||||
class CoderRootDirectory extends Component{
|
||||
constructor(props){
|
||||
class CoderRootDirectory extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state={
|
||||
address:"http",
|
||||
branch:"master",
|
||||
filePath:undefined,
|
||||
subFileType:undefined,
|
||||
readMeContent:undefined,
|
||||
this.state = {
|
||||
address: "http",
|
||||
branch: "master",
|
||||
filePath: undefined,
|
||||
subFileType: undefined,
|
||||
readMeContent: undefined,
|
||||
readMeFile: undefined,
|
||||
|
||||
isSpin:true,
|
||||
isSpin: true,
|
||||
|
||||
branchList:undefined,
|
||||
fileDetail:undefined,
|
||||
branchLastCommit:undefined,
|
||||
lastCommitAuthor:undefined,
|
||||
branchList: undefined,
|
||||
fileDetail: undefined,
|
||||
branchLastCommit: undefined,
|
||||
lastCommitAuthor: undefined,
|
||||
|
||||
rootList:undefined,
|
||||
rootList: undefined,
|
||||
readOnly: true,
|
||||
zip_url:undefined,
|
||||
tar_url:undefined,
|
||||
chooseType:undefined
|
||||
}
|
||||
}
|
||||
changeAddress=(address)=>{
|
||||
changeAddress = (address) => {
|
||||
this.setState({
|
||||
address
|
||||
})
|
||||
}
|
||||
address,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
componentDidMount=()=>{
|
||||
componentDidMount = () => {
|
||||
this.Init();
|
||||
}
|
||||
};
|
||||
|
||||
componentDidUpdate=(prevState)=>{
|
||||
const {location} = this.props;
|
||||
componentDidUpdate = (prevState) => {
|
||||
const { location } = this.props;
|
||||
const prevlocation = prevState && prevState.location;
|
||||
if(location !== prevlocation){
|
||||
if (location !== prevlocation) {
|
||||
this.setState({
|
||||
isSpin:true
|
||||
})
|
||||
isSpin: true,
|
||||
});
|
||||
this.Init();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Init=()=>{
|
||||
Init = () => {
|
||||
let { search } = this.props.history.location;
|
||||
let branchName = undefined;
|
||||
if(search && search.indexOf("?branch=")>-1){
|
||||
if (search && search.indexOf("?branch=") > -1) {
|
||||
branchName = search.split("?branch=")[1];
|
||||
this.setState({
|
||||
branch:branchName
|
||||
})
|
||||
branch: branchName,
|
||||
});
|
||||
}
|
||||
if(search && search.indexOf("?url=")>-1){
|
||||
let url =search.split("?url=")[1];
|
||||
if (search && search.indexOf("?url=") > -1) {
|
||||
let url = search.split("?url=")[1];
|
||||
this.setState({
|
||||
filePath:url
|
||||
})
|
||||
filePath: url,
|
||||
});
|
||||
this.getFileDetail(url);
|
||||
}else{
|
||||
} else {
|
||||
const { branch } = this.state;
|
||||
this.getProjectRoot( branchName || branch);
|
||||
this.getProjectRoot(branchName || branch);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 页面地址返回到主目录
|
||||
returnMain=(branch)=>{
|
||||
returnMain = (branch) => {
|
||||
const { projectsId } = this.props.match.params;
|
||||
this.props.history.push(`/projects/${projectsId}/coders`);
|
||||
this.getProjectRoot(branch);
|
||||
}
|
||||
};
|
||||
|
||||
// 获取根目录
|
||||
getProjectRoot=(branch)=>{
|
||||
getProjectRoot = (branch) => {
|
||||
const { projectsId } = this.props.match.params;
|
||||
const url = `/repositories/${projectsId}/entries.json`;
|
||||
axios.get((url),{
|
||||
params:{
|
||||
branch
|
||||
}
|
||||
}).then((result)=>{
|
||||
if(result){
|
||||
let last_commit = result.data && result.data.last_commit;
|
||||
let entries = result.data && result.data.entries;
|
||||
this.setState({
|
||||
filePath:undefined,
|
||||
fileDetail:undefined,
|
||||
isSpin: false,
|
||||
branchLastCommit:last_commit && last_commit.commit,
|
||||
lastCommitAuthor:last_commit && (last_commit.author || (last_commit.commit && last_commit.commit.author)),
|
||||
zip_url:result.data.zip_url,
|
||||
tar_url:result.data.tar_url
|
||||
})
|
||||
if(entries && entries.length > 0){
|
||||
this.renderData(entries);
|
||||
axios
|
||||
.get(url, {
|
||||
params: {
|
||||
branch,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
if (result) {
|
||||
let last_commit = result.data && result.data.last_commit;
|
||||
let entries = result.data && result.data.entries;
|
||||
this.setState({
|
||||
filePath: undefined,
|
||||
fileDetail: undefined,
|
||||
isSpin: false,
|
||||
branchLastCommit: last_commit && last_commit.commit,
|
||||
lastCommitAuthor:
|
||||
last_commit &&
|
||||
(last_commit.author ||
|
||||
(last_commit.commit && last_commit.commit.author)),
|
||||
zip_url: result.data.zip_url,
|
||||
tar_url: result.data.tar_url,
|
||||
});
|
||||
if (entries && entries.length > 0) {
|
||||
this.renderData(entries);
|
||||
}
|
||||
this.setState({
|
||||
rootList: entries,
|
||||
subFileType: true,
|
||||
});
|
||||
}
|
||||
this.setState({
|
||||
rootList:entries,
|
||||
subFileType:true
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch((error) => {});
|
||||
};
|
||||
|
||||
}).catch((error)=>{})
|
||||
}
|
||||
|
||||
ChangeFile=(arr,readOnly)=>{
|
||||
ChangeFile = (arr, readOnly) => {
|
||||
const { projectsId } = this.props.match.params;
|
||||
//点击直接跳转页面 加载一次路由
|
||||
this.props.history.push(`/projects/${projectsId}/coders?url=${arr.path}`);
|
||||
this.setState({
|
||||
readOnly: readOnly
|
||||
})
|
||||
}
|
||||
readOnly: readOnly,
|
||||
});
|
||||
};
|
||||
|
||||
renderUrl=(name,path,type)=>{
|
||||
let list =[];
|
||||
renderUrl = (name, path, type) => {
|
||||
let list = [];
|
||||
const { filePath } = this.state;
|
||||
if(path.indexOf("/")){
|
||||
if (path.indexOf("/")) {
|
||||
const array = path.split("/");
|
||||
let str = "";
|
||||
array.map((i,k)=>{
|
||||
str += '/'+i;
|
||||
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
|
||||
})
|
||||
})
|
||||
key: k,
|
||||
index: k,
|
||||
name: i,
|
||||
path: str.substr(1),
|
||||
type:
|
||||
filePath && filePath.length > 0
|
||||
? filePath[k]
|
||||
? filePath[k].type
|
||||
: type
|
||||
: type,
|
||||
});
|
||||
});
|
||||
const { projectsId } = this.props.match.params;
|
||||
//点击直接跳转页面 加载一次路由
|
||||
this.props.history.push(`/projects/${projectsId}/coders?url=${str.substr(1)}`);
|
||||
}else{
|
||||
this.props.history.push(
|
||||
`/projects/${projectsId}/coders?url=${str.substr(1)}`
|
||||
);
|
||||
} else {
|
||||
list.push({
|
||||
index:0,
|
||||
name,path,type
|
||||
})
|
||||
index: 0,
|
||||
name,
|
||||
path,
|
||||
type,
|
||||
});
|
||||
}
|
||||
this.setState({
|
||||
filePath:list
|
||||
})
|
||||
}
|
||||
filePath: list,
|
||||
});
|
||||
};
|
||||
|
||||
// 获取子目录
|
||||
getFileDetail=(path,ref)=>{
|
||||
getFileDetail = (path, ref) => {
|
||||
const { projectsId } = this.props.match.params;
|
||||
const { branch } = this.state;
|
||||
const url =`/repositories/${projectsId}/sub_entries.json`;
|
||||
const url = `/repositories/${projectsId}/sub_entries.json`;
|
||||
|
||||
axios.get(url,{
|
||||
params:{
|
||||
|
|
@ -201,32 +214,34 @@ class CoderRootDirectory extends Component{
|
|||
this.renderData(entries);
|
||||
}
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
};
|
||||
|
||||
renderData=(data)=>{
|
||||
renderData = (data) => {
|
||||
const rootList = [];
|
||||
const readMeContent = [];
|
||||
const readMeFile = [];
|
||||
data && data.map((item,key)=>{
|
||||
rootList.push({
|
||||
key,
|
||||
message:item.commit && item.commit.message,
|
||||
...item
|
||||
})
|
||||
if(item.name === 'README.md'){
|
||||
readMeContent.push({...item})
|
||||
readMeFile.push({...item})
|
||||
}
|
||||
})
|
||||
data &&
|
||||
data.map((item, key) => {
|
||||
rootList.push({
|
||||
key,
|
||||
message: item.commit && item.commit.message,
|
||||
...item,
|
||||
});
|
||||
if (item.name === "README.md") {
|
||||
readMeContent.push({ ...item });
|
||||
readMeFile.push({ ...item });
|
||||
}
|
||||
});
|
||||
this.setState({
|
||||
rootList:rootList,
|
||||
rootList: rootList,
|
||||
readMeContent,
|
||||
readMeFile
|
||||
})
|
||||
}
|
||||
readMeFile,
|
||||
});
|
||||
};
|
||||
|
||||
// 点击跳转到子目录
|
||||
goToSubRoot=(path,type)=>{
|
||||
|
|
@ -235,52 +250,65 @@ class CoderRootDirectory extends Component{
|
|||
})
|
||||
const { projectsId } = this.props.match.params;
|
||||
this.props.history.push(`/projects/${projectsId}/coders?url=${path}`);
|
||||
}
|
||||
};
|
||||
|
||||
// readme文件内容
|
||||
renderReadMeContent=(readMeContent, permission)=>{
|
||||
const { fileDetail,readMeFile } = this.state;
|
||||
if(fileDetail){return;}
|
||||
if(readMeContent && readMeContent.length > 0){
|
||||
return(
|
||||
renderReadMeContent = (readMeContent, permission) => {
|
||||
const { fileDetail, readMeFile } = this.state;
|
||||
if (fileDetail) {
|
||||
return;
|
||||
}
|
||||
if (readMeContent && readMeContent.length > 0) {
|
||||
return (
|
||||
<div className="commonBox">
|
||||
<div className="commonBox-title">
|
||||
<span className="mr10"><i className="iconfont icon-xinjianjianliwodejianli font-20 color-grey-9 fl mt3"></i></span>
|
||||
<span className="commonBox-title-read">{readMeContent[0].name}</span>
|
||||
{
|
||||
permission ?
|
||||
<a onClick={()=>this.ChangeFile(readMeFile[0],false)} className="ml20 pull-right"><i className="iconfont icon-bianji2 font-20 color-blue"></i></a>
|
||||
: ""
|
||||
}
|
||||
<span className="mr10">
|
||||
<i className="iconfont icon-xinjianjianliwodejianli font-20 color-grey-9 fl mt3"></i>
|
||||
</span>
|
||||
<span className="commonBox-title-read">
|
||||
{readMeContent[0].name}
|
||||
</span>
|
||||
{permission ? (
|
||||
<a
|
||||
onClick={() => this.ChangeFile(readMeFile[0], false)}
|
||||
className="ml20 pull-right"
|
||||
>
|
||||
<i className="iconfont icon-bianji2 font-20 color-blue"></i>
|
||||
</a>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</div>
|
||||
<div className="commonBox-info">
|
||||
{
|
||||
readMeContent[0].content ?
|
||||
<RenderHtml className="break_word_comments" value={readMeContent[0].content} />
|
||||
:
|
||||
{readMeContent[0].content ? (
|
||||
<RenderHtml
|
||||
className="break_word_comments"
|
||||
value={readMeContent[0].content}
|
||||
/>
|
||||
) : (
|
||||
<span>暂无~</span>
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 选择分支
|
||||
changeBranch=(value)=>{
|
||||
changeBranch = (value) => {
|
||||
this.setState({
|
||||
branch:value,
|
||||
isSpin: true
|
||||
})
|
||||
branch: value,
|
||||
isSpin: true,
|
||||
});
|
||||
let { search } = this.props.history.location;
|
||||
if(search && search.indexOf("?url=")>-1){
|
||||
let url =search.split("?url=")[1];
|
||||
if (search && search.indexOf("?url=") > -1) {
|
||||
let url = search.split("?url=")[1];
|
||||
this.setState({
|
||||
filePath:url
|
||||
})
|
||||
filePath: url,
|
||||
});
|
||||
this.getFileDetail(url, value);
|
||||
}else{
|
||||
this.getProjectRoot( value );
|
||||
} else {
|
||||
this.getProjectRoot(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -306,60 +334,99 @@ class CoderRootDirectory extends Component{
|
|||
<i className={ item.type === "file" ? "iconfont icon-wenjia font-15 color-green-file mr5":"iconfont icon-wenjianjia1 color-green-file font-15 mr5"}></i>{text}
|
||||
</a>
|
||||
),
|
||||
},{
|
||||
dataIndex:"commit",
|
||||
width:"60%",
|
||||
render:(text,item)=>
|
||||
(
|
||||
item.commit && item.commit.message ? <span className="task-hide" style={{display:'block',maxWidth:"670px"}}>{item.commit.message}</span> :""
|
||||
)
|
||||
},{
|
||||
dataIndex:"commit",
|
||||
width:"10%",
|
||||
className:"edu-txt-right",
|
||||
render:(text,item)=>(
|
||||
item.commit && item.commit.time_from_now ? <a title={item.commit.created_at} className="mr12" style={{cursor:"default",color:"#888"}}>{item.commit.time_from_now}</a> :""
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
dataIndex: "commit",
|
||||
width: "60%",
|
||||
render: (text, item) =>
|
||||
item.commit && item.commit.message ? (
|
||||
<span
|
||||
className="task-hide"
|
||||
style={{ display: "block", maxWidth: "670px" }}
|
||||
>
|
||||
{item.commit.message}
|
||||
</span>
|
||||
) : (
|
||||
""
|
||||
),
|
||||
},
|
||||
{
|
||||
dataIndex: "commit",
|
||||
width: "10%",
|
||||
className: "edu-txt-right",
|
||||
render: (text, item) =>
|
||||
item.commit && item.commit.time_from_now ? (
|
||||
<a
|
||||
title={item.commit.created_at}
|
||||
className="mr12"
|
||||
style={{ cursor: "default", color: "#888" }}
|
||||
>
|
||||
{item.commit.time_from_now}
|
||||
</a>
|
||||
) : (
|
||||
""
|
||||
),
|
||||
},
|
||||
];
|
||||
const title = () =>{
|
||||
if(branchLastCommit){
|
||||
return(
|
||||
const title = () => {
|
||||
if (branchLastCommit) {
|
||||
return (
|
||||
<div className="f-wrap-alignCenter">
|
||||
{
|
||||
lastCommitAuthor ?
|
||||
<React.Fragment>
|
||||
{
|
||||
lastCommitAuthor.login ?
|
||||
<Link to={`/users/${lastCommitAuthor.login}/projects`} className="show-user-link">
|
||||
<img src={getImageUrl(`images/${lastCommitAuthor.image_url}`)} className="radius mr10" width="32" height="32" alt=""/>
|
||||
<span className="mr15">{lastCommitAuthor.name}</span>
|
||||
</Link>:
|
||||
{lastCommitAuthor ? (
|
||||
<React.Fragment>
|
||||
{lastCommitAuthor.login ? (
|
||||
<Link
|
||||
to={`/users/${lastCommitAuthor.login}/projects`}
|
||||
className="show-user-link"
|
||||
>
|
||||
<img
|
||||
src={getImageUrl(`images/${lastCommitAuthor.image_url}`)}
|
||||
className="radius mr10"
|
||||
width="32"
|
||||
height="32"
|
||||
alt=""
|
||||
/>
|
||||
<span className="mr15">{lastCommitAuthor.name}</span>
|
||||
}
|
||||
</React.Fragment>
|
||||
:""
|
||||
}
|
||||
<span className="color-blue flex-1 hide-1">{branchLastCommit.message}</span>
|
||||
</Link>
|
||||
) : (
|
||||
<span className="mr15">{lastCommitAuthor.name}</span>
|
||||
)}
|
||||
</React.Fragment>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
<span className="color-blue flex-1 hide-1">
|
||||
{branchLastCommit.message}
|
||||
</span>
|
||||
<span>{branchLastCommit.time_from_now}</span>
|
||||
<span className="commitKey">{truncateCommitId(branchLastCommit.sha)}</span>
|
||||
<span className="commitKey">
|
||||
{truncateCommitId(branchLastCommit.sha)}
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
}else{
|
||||
);
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const downloadUrl = ()=>(
|
||||
const downloadUrl = () => (
|
||||
<Menu>
|
||||
{zip_url && <Menu.Item><a href={zip_url}>ZIP</a></Menu.Item> }
|
||||
{tar_url && <Menu.Item><a href={tar_url}>TAR.GZ</a></Menu.Item> }
|
||||
{zip_url && (
|
||||
<Menu.Item>
|
||||
<a href={zip_url}>ZIP</a>
|
||||
</Menu.Item>
|
||||
)}
|
||||
{tar_url && (
|
||||
<Menu.Item>
|
||||
<a href={tar_url}>TAR.GZ</a>
|
||||
</Menu.Item>
|
||||
)}
|
||||
</Menu>
|
||||
)
|
||||
);
|
||||
|
||||
const urlRoot = filePath === undefined ? '':`/${filePath}`;
|
||||
const urlRoot = filePath === undefined ? "" : `/${filePath}`;
|
||||
let array = filePath && filePath.split("/");
|
||||
return(
|
||||
return (
|
||||
<Spin spinning={isSpin}>
|
||||
<div className="main">
|
||||
<div className="f-wrap-between mb20">
|
||||
|
|
@ -371,13 +438,17 @@ class CoderRootDirectory extends Component{
|
|||
changeBranch={this.changeBranch}
|
||||
></SelectBranch>
|
||||
|
||||
{
|
||||
filePath &&
|
||||
{filePath && (
|
||||
<span className="ml20 font-16">
|
||||
<a onClick={()=>this.returnMain(branch)} className="color-blue">{ projectDetail && projectDetail.identifier }</a>
|
||||
{
|
||||
array && array.map((item,key)=>{
|
||||
return(
|
||||
<a
|
||||
onClick={() => this.returnMain(branch)}
|
||||
className="color-blue"
|
||||
>
|
||||
{projectDetail && projectDetail.identifier}
|
||||
</a>
|
||||
{array &&
|
||||
array.map((item, key) => {
|
||||
return (
|
||||
<React.Fragment>
|
||||
{
|
||||
key === array.length-1 ?
|
||||
|
|
@ -386,39 +457,63 @@ class CoderRootDirectory extends Component{
|
|||
<a onClick={()=>this.returnUlr(`${key === 0 ? `${item}` :`${array[key-1]}/${item}`}`)} className="color-blue subFileName">{item}</a>
|
||||
}
|
||||
</React.Fragment>
|
||||
)
|
||||
})
|
||||
}
|
||||
</span>
|
||||
}
|
||||
);
|
||||
})}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="f-wrap-alignCenter">
|
||||
{
|
||||
subFileType && (isManager || isDeveloper) &&
|
||||
<p className="mr30">
|
||||
<Link className="color-blue" to={`/projects/${projectsId}/coders/${branch}/newfile${urlRoot}`} >新建文件</Link>
|
||||
</p>
|
||||
}
|
||||
{
|
||||
projectDetail && projectDetail.clone_url && <CloneAddress http_url={projectDetail.clone_url} downloadUrl={downloadUrl} showNotification={this.props.showNotification}></CloneAddress>
|
||||
}
|
||||
{subFileType && (isManager || isDeveloper) && (
|
||||
<div>
|
||||
<span>
|
||||
<Button
|
||||
type="link"
|
||||
href={`/projects/${projectsId}/coders/${branch}/uploadfile${urlRoot}`}
|
||||
>
|
||||
<span className="color-green">上传文件</span>
|
||||
</Button>
|
||||
</span>
|
||||
<span className="mr30">
|
||||
<Button
|
||||
type="link"
|
||||
href={`/projects/${projectsId}/coders/${branch}/newfile${urlRoot}`}
|
||||
>
|
||||
<span className="color-blue">新建文件</span>
|
||||
</Button>
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{projectDetail && projectDetail.clone_url && (
|
||||
<CloneAddress
|
||||
http_url={projectDetail.clone_url}
|
||||
downloadUrl={downloadUrl}
|
||||
showNotification={this.props.showNotification}
|
||||
></CloneAddress>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{/* 主目录列表 */}
|
||||
{
|
||||
rootList &&
|
||||
<RootTable columns = {columns} data={rootList} title={() => title()}></RootTable>
|
||||
}
|
||||
{rootList && (
|
||||
<RootTable
|
||||
columns={columns}
|
||||
data={rootList}
|
||||
title={() => title()}
|
||||
></RootTable>
|
||||
)}
|
||||
{/* 子目录列表、文件 */}
|
||||
{
|
||||
fileDetail && fileDetail.length>0 &&
|
||||
<CoderRootFileDetail detail = {fileDetail[0]} {...this.props} {...this.state} readOnly={this.state.readOnly}></CoderRootFileDetail>
|
||||
}
|
||||
{fileDetail && fileDetail.length > 0 && (
|
||||
<CoderRootFileDetail
|
||||
detail={fileDetail[0]}
|
||||
{...this.props}
|
||||
{...this.state}
|
||||
readOnly={this.state.readOnly}
|
||||
></CoderRootFileDetail>
|
||||
)}
|
||||
{/* readme.txt (isManager || isDeveloper)*/}
|
||||
{ this.renderReadMeContent(readMeContent,(isManager || isDeveloper)) }
|
||||
{this.renderReadMeContent(readMeContent, isManager || isDeveloper)}
|
||||
</div>
|
||||
</Spin>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
export default CoderRootDirectory;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ const FileNew = Loadable({
|
|||
loader: () => import('../Newfile/Index'),
|
||||
loading: Loading,
|
||||
})
|
||||
const UploadFile = Loadable({
|
||||
loader: () => import('../Newfile/upload_file'),
|
||||
loading: Loading,
|
||||
})
|
||||
const Setting = Loadable({
|
||||
loader: () => import('../Settings/Index'),
|
||||
loading: Loading,
|
||||
|
|
@ -446,6 +450,11 @@ class Detail extends Component {
|
|||
(props) => (<FileNew {...this.props} {...props} {...this.state} {...common}/>)
|
||||
}
|
||||
></Route>
|
||||
<Route path="/projects/:projectsId/coders/:branch/uploadfile"
|
||||
render={
|
||||
(props) => (<UploadFile {...this.props} {...props} {...this.state} {...common}/>)
|
||||
}
|
||||
></Route>
|
||||
<Route path="/projects/:projectsId/coders/:branch/newfile"
|
||||
render={
|
||||
(props) => (<FileNew {...this.props} {...props} {...this.state} {...common}/>)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class IndexItem extends Component {
|
|||
: ""
|
||||
}
|
||||
{
|
||||
item.mirror_url && item.mirror_url.length > 0 &&
|
||||
item.type && item.type !== 0 &&
|
||||
<span className="ml5">
|
||||
<i className="iconfont icon-banbenku font-18 color-green" />
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -124,8 +124,6 @@ class Index extends Component {
|
|||
})}
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<Meditor
|
||||
{...this.props}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ class UserSubmitComponent extends Component {
|
|||
super(props);
|
||||
this.state = {
|
||||
submitType: "0",
|
||||
filename: ""
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -20,18 +21,26 @@ class UserSubmitComponent extends Component {
|
|||
});
|
||||
};
|
||||
|
||||
// 命名文件
|
||||
changeFileName = (e) => {
|
||||
this.setState({
|
||||
filename: e.target.value,
|
||||
});
|
||||
console.log("99999", e.target.value)
|
||||
};
|
||||
|
||||
// 提交变更
|
||||
subMitFrom = () => {
|
||||
const { filepath, content } = this.props;
|
||||
const { filepath, content,editor_type } = this.props;
|
||||
const { branch, projectsId } = this.props.match.params;
|
||||
const { submitType } = this.state;
|
||||
let path = filepath.substr(1);
|
||||
const { submitType, filename } = this.state;
|
||||
let path = editor_type === "upload" ? filepath : filepath.substr(1);
|
||||
this.props.form.validateFieldsAndScroll((err, values) => {
|
||||
if (!err) {
|
||||
const url = `/repositories/${projectsId}/create_file.json`;
|
||||
axios
|
||||
.post(url, {
|
||||
filepath: path,
|
||||
filepath: filename ? filename : path,
|
||||
branch: branch,
|
||||
new_branch: submitType === "1" ? values.branchname : undefined,
|
||||
content,
|
||||
|
|
@ -88,13 +97,14 @@ class UserSubmitComponent extends Component {
|
|||
};
|
||||
|
||||
render() {
|
||||
const { submitType } = this.state;
|
||||
const { submitType,filename } = this.state;
|
||||
const { getFieldDecorator } = this.props.form;
|
||||
|
||||
const { branch, projectsId } = this.props.match.params;
|
||||
|
||||
const { current_user, filepath, projectDetail } = this.props;
|
||||
const { editor_type } = this.props;
|
||||
console.log("88888", filepath)
|
||||
|
||||
const changeSubmitBranch = () => {
|
||||
if (submitType === "1") {
|
||||
|
|
@ -143,16 +153,26 @@ class UserSubmitComponent extends Component {
|
|||
<div className="userScrew">
|
||||
<div className="screwPanel">
|
||||
<Form>
|
||||
<Form.Item style={{display: "none"}}>
|
||||
<Form.Item style={{display: editor_type === "upload" ? "block" : "none"}}>
|
||||
{getFieldDecorator("path", {
|
||||
rules: [],
|
||||
})(
|
||||
// <Input
|
||||
// placeholder={`/${
|
||||
// projectDetail && projectDetail.identifier
|
||||
// }${filepath}`}
|
||||
// readOnly
|
||||
// />
|
||||
<div className="setInputAddon">
|
||||
<Input
|
||||
placeholder={`/${
|
||||
addonBefore={`/${
|
||||
projectDetail && projectDetail.identifier
|
||||
}${filepath}`}
|
||||
readOnly
|
||||
}/`}
|
||||
value={filename ? filename: filepath}
|
||||
onChange={this.changeFileName}
|
||||
placeholder="文件路径..."
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
|
|
@ -188,7 +208,7 @@ class UserSubmitComponent extends Component {
|
|||
<div className="mt20 text-center">
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={editor_type === "new" ? this.subMitFrom : this.UpdateFile}
|
||||
onClick={editor_type === "edit" ? this.UpdateFile : this.subMitFrom}
|
||||
className="mr30"
|
||||
>
|
||||
提交变更
|
||||
|
|
|
|||
|
|
@ -77,4 +77,10 @@
|
|||
}
|
||||
}
|
||||
.grid-item{display: grid; align-items: center; grid-template-columns: max-content 1fr;}
|
||||
.text-right{text-align: right;}
|
||||
.text-right{text-align: right;}
|
||||
.upload-file-repo{
|
||||
height: 200px;
|
||||
padding-bottom: 20px;
|
||||
width: 100%;
|
||||
display: inline-block;
|
||||
}
|
||||
|
|
@ -33,8 +33,8 @@ class m_editor extends Component {
|
|||
folding: true,
|
||||
foldingStrategy: "indentation", // 代码可分小段折叠
|
||||
automaticLayout: true, // 自适应布局
|
||||
overviewRulerBorder: false, // 不要滚动条的边框
|
||||
scrollBeyondLastLine: false, // 取消代码后面一大段空白
|
||||
// overviewRulerBorder: false, // 不要滚动条的边框
|
||||
// scrollBeyondLastLine: false, // 取消代码后面一大段空白
|
||||
minimap: {
|
||||
// 不要小地图
|
||||
enabled: false,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
import React, { Component } from "react";
|
||||
// import Meditor from "./m_editor";
|
||||
import Top from "../Main/DetailTop";
|
||||
import "./index.css";
|
||||
// import { Input, Select } from "antd";
|
||||
import UserSubmitComponent from "./UserSubmitComponent";
|
||||
import Upload from "../Upload/read";
|
||||
import UploadImg from "../Images/upload.png";
|
||||
|
||||
class UploadFile extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
editorValue: "",
|
||||
filename: "",
|
||||
fileList: undefined,
|
||||
attachment_clean: true,
|
||||
};
|
||||
}
|
||||
|
||||
// 获取上传后的文件id数组
|
||||
UploadFunc = (fileList) => {
|
||||
this.setState({
|
||||
filename: fileList.fileName,
|
||||
editorValue: fileList.fileContent,
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
const { pathname } = this.props.location;
|
||||
const { filename, editorValue, attachment_clean } = this.state;
|
||||
const urlroot = pathname.split("uploadfile/")[1];
|
||||
const file_path = !urlroot ? `${filename}` : `${urlroot}/${filename}`;
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Top {...this.props} {...this.state} />
|
||||
<div className="main">
|
||||
<p className="pb15 bor-bottom-greyE font-16 color-grey-3 mb20">
|
||||
上传文件
|
||||
</p>
|
||||
<div className="upload-file-repo">
|
||||
<Upload
|
||||
className="commentStyle"
|
||||
isComplete={attachment_clean}
|
||||
load={this.UploadFunc}
|
||||
icon={
|
||||
<img
|
||||
src={UploadImg}
|
||||
width="58"
|
||||
alt=""
|
||||
style={{ marginBottom: 15 }}
|
||||
/>
|
||||
}
|
||||
size={5}
|
||||
showNotification={this.props.showNotification}
|
||||
{...this.props}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<UserSubmitComponent
|
||||
{...this.props}
|
||||
{...this.state}
|
||||
filepath={file_path}
|
||||
content={editorValue}
|
||||
editor_type={"upload"}
|
||||
></UserSubmitComponent>
|
||||
</div>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
export default UploadFile;
|
||||
|
|
@ -98,12 +98,10 @@ class Index extends Component {
|
|||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Dragger {...upload} className={this.props.className}>
|
||||
<Dragger {...upload} className={this.props.className}>
|
||||
{ icon || <Icon type="inbox" />}
|
||||
<p className="ant-upload-text">拖动文件或<span className="color-blue">点击此处上传</span></p>
|
||||
</Dragger>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,106 @@
|
|||
import React, { Component } from "react";
|
||||
import { Upload, Icon } from "antd";
|
||||
import { getUploadActionUrl, appendFileSizeToUploadFileAll } from "educoder";
|
||||
|
||||
import axios from "axios";
|
||||
const { Dragger } = Upload;
|
||||
class Read extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
fileList: undefined,
|
||||
fileContent: undefined,
|
||||
fileName: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
onAttachmentRemove = (file) => {
|
||||
this.setState({
|
||||
fileList: undefined,
|
||||
fileContent: undefined,
|
||||
fileName: undefined,
|
||||
});
|
||||
};
|
||||
|
||||
handleChange = (info) => {
|
||||
let reader = new FileReader();
|
||||
reader.readAsText(info.fileList[0].originFileObj, "UTF-8");
|
||||
reader.onload = (e) => {
|
||||
this.state.fileContent = e.target.result;
|
||||
this.props.load && this.props.load(this.state);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
beforeUpload = (file) => {
|
||||
const forbidden_type = [
|
||||
"jpg",
|
||||
"jpeg",
|
||||
"png",
|
||||
"ico",
|
||||
"bmp",
|
||||
"gif",
|
||||
"pdf",
|
||||
"csv",
|
||||
"xlsx",
|
||||
"xls",
|
||||
"tif",
|
||||
"svg",
|
||||
"psd",
|
||||
"cdr",
|
||||
"webp",
|
||||
];
|
||||
const { fileList } = this.state;
|
||||
const { size } = this.props;
|
||||
const isLt100M = file.size / 1024 / 1024 < size;
|
||||
const file_type = file.type.split("/").slice(-1)[0];
|
||||
if (fileList && fileList.length > 0) {
|
||||
this.props.showNotification("文件已存在, 请删除后再上传");
|
||||
} else if (!isLt100M) {
|
||||
this.props.showNotification(`文件大小必须小于${size}MB!`);
|
||||
} else if (file_type && forbidden_type.indexOf(file_type) !== -1) {
|
||||
this.props.showNotification(`不支持${file_type}类型`);
|
||||
} else {
|
||||
this.setState({
|
||||
fileList: [file],
|
||||
fileName: file.name,
|
||||
})
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
render() {
|
||||
//判断是否已经提交,如已提交评论则上一条评论数据清除
|
||||
const { icon, size } = this.props;
|
||||
const { fileList, fileName } = this.state;
|
||||
const upload = {
|
||||
name: "file",
|
||||
fileList: fileList,
|
||||
onChange: this.handleChange,
|
||||
onRemove: this.onAttachmentRemove,
|
||||
beforeUpload: this.beforeUpload
|
||||
};
|
||||
|
||||
return (
|
||||
<Dragger {...upload} className={this.props.className}>
|
||||
{fileName ? (
|
||||
<p className="ant-upload-text">{fileName}</p>
|
||||
) : (
|
||||
<div>
|
||||
{icon || <Icon type="inbox" />}
|
||||
<p className="ant-upload-text">
|
||||
拖动文件或<span className="color-blue">点击此处上传</span>
|
||||
</p>
|
||||
<p className="mt10">
|
||||
暂仅支持文件格式,不支持图片,excel等不可以txt读取的文件
|
||||
</p>
|
||||
<p className="mt10">
|
||||
文件名请使用英文且不得超过{size}MB
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</Dragger>
|
||||
);
|
||||
}
|
||||
}
|
||||
export default Read;
|
||||
|
|
@ -59,8 +59,9 @@ class FocusButton extends Component {
|
|||
|
||||
render() {
|
||||
const { is_watch, isSpin,fontClass,starText,is_block } = this.state;
|
||||
|
||||
return (
|
||||
<Button block={is_block} loading={isSpin} onClick={() => this.focusFunc(is_watch)}>
|
||||
<Button type={is_watch ? "default" : "primary"} ghost={!is_watch} block={is_block} loading={isSpin} onClick={() => this.focusFunc(is_watch)}>
|
||||
{is_watch ? (
|
||||
<span className="">
|
||||
<i className="iconfont icon-shixing font-15 text-yellow mr-4"></i>
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ class UserList extends Component {
|
|||
<div className={`pull-left ${userClass}`} key={key}>
|
||||
<div className="pbt25 grid-item mlr10 border-b-line">
|
||||
<div>
|
||||
<Link
|
||||
to={`/users/${item.login}/projects`}
|
||||
<a
|
||||
href={`/users/${item.login}`}
|
||||
className="show-user-link"
|
||||
>
|
||||
<img
|
||||
|
|
@ -26,16 +26,16 @@ class UserList extends Component {
|
|||
src={getImageUrl(`images/${item.image_url}`)}
|
||||
alt=""
|
||||
/>
|
||||
</Link>
|
||||
</a>
|
||||
</div>
|
||||
<div className="ml12">
|
||||
<div>
|
||||
<Link
|
||||
to={`/users/${item.login}/projects`}
|
||||
<a
|
||||
href={`/users/${item.login}`}
|
||||
className="font-16 text-primary hide-1 task-hide max-w-200"
|
||||
>
|
||||
{item.name}
|
||||
</Link>
|
||||
</a>
|
||||
</div>
|
||||
<div className="font-12 text-gray grid-item pb5">
|
||||
<i className="iconfont icon-shijian user-join-time"></i>
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@ import React, { Component } from "react";
|
|||
import { Link } from "react-router-dom";
|
||||
|
||||
import axios from "axios";
|
||||
import Upload from "../Upload/Index";
|
||||
import UploadImg from "../Images/upload.png";
|
||||
// import Upload from "../Upload/Index";
|
||||
// import UploadImg from "../Images/upload.png";
|
||||
import { getImageUrl } from "educoder";
|
||||
import { List } from "antd";
|
||||
// import { List } from "antd";
|
||||
import Attachments from "../Upload/attachment";
|
||||
import MDEditor from "../../modules/tpm/challengesnew/tpm-md-editor";
|
||||
import RenderHtml from "../../components/render-html";
|
||||
import new_comment from "./new"
|
||||
// import new_comment from "./new"
|
||||
import "./order.css";
|
||||
|
||||
class comments extends Component {
|
||||
|
|
|
|||
|
|
@ -133,6 +133,9 @@ class Infos extends Component {
|
|||
<Tag color="#FF6E21">{user && user.user_identity}</Tag>
|
||||
</div>
|
||||
)}
|
||||
<div className="text-center mt15 font-16 fwb">
|
||||
{user && user.username}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{user && current_user && user.login === current_user.login && (
|
||||
|
|
@ -170,7 +173,7 @@ class Infos extends Component {
|
|||
className={`with50 text-center pull-left ${route_type === "watch_users" ? "text-primary" : ""}`}
|
||||
onClick={() =>this.route_link("watch_users")}
|
||||
>
|
||||
<div>我关注的</div>
|
||||
<div>{current_user && user && user.login === current_user.login ? "我关注的" : "TA关注的"}</div>
|
||||
<span>{user && user.watching_count}</span>
|
||||
</Link>
|
||||
<Link
|
||||
|
|
@ -178,7 +181,7 @@ class Infos extends Component {
|
|||
onClick={() =>this.route_link("fan_users")}
|
||||
className={`with50 text-center pull-left ${route_type === "fan_users" ? "text-primary" : ""}`}
|
||||
>
|
||||
<div>关注我的</div>
|
||||
<div>{current_user && user && user.login === current_user.login ? "关注我的" : "关注TA的"}</div>
|
||||
<span>{user && user.watched_count}</span>
|
||||
</Link>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -410,8 +410,13 @@ class LoginDialog extends Component {
|
|||
this.setState({
|
||||
isRender:false
|
||||
})
|
||||
this.props.Modifyloginvalue();
|
||||
window.location.reload();
|
||||
this.props.Modifyloginvalue();
|
||||
console.log("login_url",this.props.location.pathname)
|
||||
if(!this.props.location.pathname || this.props.location.pathname === ""){
|
||||
this.props.history.push(`/users/${response.data && response.data.login}`)
|
||||
}else{
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -933,10 +933,10 @@ class NewHeader extends Component {
|
|||
mygetHelmetapi2 && mygetHelmetapi2.new_course && mygetHelmetapi2.new_course.my_courses &&
|
||||
<li><a href={`${mygetHelmetapi2.new_course.my_courses}`} target="_blank">我的课程</a></li>
|
||||
}
|
||||
{
|
||||
{/* {
|
||||
mygetHelmetapi2 && mygetHelmetapi2.new_course && mygetHelmetapi2.new_course.my_projects &&
|
||||
<li><Link to={`/users/${this.props.current_user.login}/projects`} >我的项目</Link></li>
|
||||
}
|
||||
} */}
|
||||
|
||||
{
|
||||
mygetHelmetapi2 && mygetHelmetapi2.new_course && mygetHelmetapi2.new_course.my_organ &&
|
||||
|
|
|
|||
Loading…
Reference in New Issue