Merge branch 'develop' of http://git.trustie.net/jasder/forgeplus-react into develop

This commit is contained in:
sylor_huang@126.com 2020-04-17 17:58:13 +08:00
commit 3ae009255e
6 changed files with 143 additions and 112 deletions

View File

@ -226,26 +226,26 @@ export function initAxiosInterceptors(props) {
// let timestamp=railsgettimes(proxy);
// console.log(timestamp)
// `https://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp`
railsgettimes( `${proxy}/api/main/first_stamp.json`);
let newopens=md5(opens+timestamp)
config.url = `${proxy}${url}`;
if (config.url.indexOf('?') == -1) {
config.url = `${config.url}?debug=${debugType}&randomcode=${timestamp}&client_key=${newopens}`;
} else {
config.url = `${config.url}&debug=${debugType}&randomcode=${timestamp}&client_key=${newopens}`;
}
// railsgettimes( `${proxy}/api/main/first_stamp.json`);
// let newopens=md5(opens+timestamp)
config.url = `${proxy}${url}`;
if (config.url.indexOf('?') == -1) {
config.url = `${config.url}?debug=${debugType}`;
} else {
config.url = `${config.url}&debug=${debugType}`;
}
} else {
// 加api前缀
// railsgettimes(`http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp`);
railsgettimes( `/api/main/first_stamp.json`);
let newopens=md5(opens+timestamp)
// railsgettimes( `/api/main/first_stamp.json`);
// let newopens=md5(opens+timestamp)
config.url = url;
if (config.url.indexOf('?') == -1) {
config.url = `${config.url}?randomcode=${timestamp}&client_key=${newopens}`;
} else {
config.url = `${config.url}&randomcode=${timestamp}&client_key=${newopens}`;
}
// if (config.url.indexOf('?') == -1) {
// config.url = `${config.url}?randomcode=${timestamp}&client_key=${newopens}`;
// } else {
// config.url = `${config.url}&randomcode=${timestamp}&client_key=${newopens}`;
// }
}
setpostcookie();
}

View File

@ -28,7 +28,7 @@ class CoderRootDirectory extends Component{
this.state={
address:"http",
branch:"master",
filePath:[],
filePath:undefined,
http_url:undefined,
subFileType:"",
readMeContent:undefined,
@ -40,7 +40,7 @@ class CoderRootDirectory extends Component{
fileDetail:undefined,
branchLastCommit:undefined,
rootData:undefined,
rootList:undefined,
readOnly: true
}
}
@ -50,18 +50,49 @@ class CoderRootDirectory extends Component{
})
}
componentDidMount=()=>{
componentDidMount=()=>{
this.Init();
}
componentDidUpdate=(prevState)=>{
const {location} = this.props;
const prevlocation = prevState && prevState.location;
if(location !== prevlocation){
this.setState({
isSpin:true
})
this.Init();
}
}
Init=()=>{
let { search } = this.props.history.location;
let branchName = undefined;
if(search && search.indexOf("branch")>-1){
branchName = search.split("=")[1];
branchName = search.split("branch=")[1];
this.setState({
branch:branchName
})
}
const { branch } = this.state;
this.getProjectRoot(branchName || branch);
const { pathname } = this.props.location;
if(pathname && pathname.indexOf("/filesurl/")>-1){
let url =pathname.split("filesurl/")[1];
this.setState({
filePath:url
})
this.getFileDetail(url);
}else{
const { branch } = this.state;
this.getProjectRoot( branchName || branch);
}
}
// 页面地址返回到主目录
returnMain=(branch)=>{
const { projectsId } = this.props.match.params;
this.props.history.push(`/projects/${projectsId}/coders`);
this.getProjectRoot(branch);
}
// 获取根目录
@ -76,14 +107,14 @@ class CoderRootDirectory extends Component{
if(result){
if(result && result.data && result.data.length > 0){
this.setState({
filePath:[],
filePath:undefined,
fileDetail:undefined,
isSpin: false
})
this.renderData(result.data);
}
this.setState({
rootData:result.data,
rootList:result.data,
subFileType: "dir"
})
}
@ -92,11 +123,9 @@ class CoderRootDirectory extends Component{
}
ChangeFile=(arr,readOnly)=>{
console.log("atrr", arr)
this.renderUrl(arr.name,arr.path,arr.type);
const { projectsId } = this.props.match.params;
//点击直接跳转页面 加载一次路由
this.getFileDetail(arr);
this.props.history.push(`/projects/${projectsId}/coders/filesurl/${arr.path}`);
this.setState({
subFileType:arr.type,
readOnly: readOnly
@ -118,6 +147,9 @@ class CoderRootDirectory extends Component{
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/filesurl/${str.substr(1)}`);
}else{
list.push({
index:0,
@ -130,30 +162,30 @@ class CoderRootDirectory extends Component{
}
// 获取子目录
getFileDetail=(arr)=>{
getFileDetail=(path)=>{
const { projectsId } = this.props.match.params;
const { branch } = this.state;
const url =`/repositories/${projectsId}/sub_entries.json`;
axios.get(url,{
params:{
filepath:arr.path,
filepath:path,
ref:branch
}
}).then((result)=>{
if(result && result.data && result.data.length > 0){
if(arr.type==="file"){
// 当前返回的子目录只有一条数据,且这条数据返回的是文件类型
if(result.data.length === 1 && result.data[0].type === "file"){
this.setState({
fileDetail:result.data[0],
rootList:undefined
fileDetail:result.data,
rootList:undefined,
isSpin:false
})
}else{
if(arr.type===""){
this.props.showNotification('该文件夹下已无文件')
return
}
this.setState({
fileDetail:undefined
fileDetail:undefined,
rootList:result.data,
isSpin:false
})
this.renderData(result.data)
}
@ -184,6 +216,12 @@ class CoderRootDirectory extends Component{
})
}
// 点击跳转到子目录
goToSubRoot=(path)=>{
const { projectsId } = this.props.match.params;
this.props.history.push(`/projects/${projectsId}/coders/filesurl/${path}`);
}
// readme文件内容
renderReadMeContent=(readMeContent, permission)=>{
const { fileDetail,readMeFile } = this.state;
@ -217,7 +255,6 @@ class CoderRootDirectory extends Component{
changeBranch=(value)=>{
const { branchList } = this.props;
let branchLastCommit = branchList && branchList.length >0 && branchList.filter(item=>item.name === value)[0];
this.setState({
branch:branchLastCommit && branchLastCommit.name,
@ -225,20 +262,21 @@ class CoderRootDirectory extends Component{
http_url:branchLastCommit && branchLastCommit.http_url,
isSpin: true
})
this.getProjectRoot(branchLastCommit.name);
this.Init();
}
render(){
const { rootList , branch ,filePath , fileDetail , subFileType , readMeContent, isSpin , rootData } = this.state;
const { rootList , branch ,filePath , fileDetail , subFileType , readMeContent, isSpin } = this.state;
const { branchLastCommit , http_url , isManager , isDeveloper } = this.props;
const { projectsId } = this.props.match.params;
const columns = [
{
dataIndex: 'name',
width:"100%",
render: (text,item) => (
<a onClick={()=>this.ChangeFile(item,true)}>
<a onClick={()=>this.goToSubRoot(item.path)}>
<i className={ item.type === "file" ? "iconfont icon-zuoye font-15 color-blue mr5":"iconfont icon-wenjian font-15 color-blue mr5"}></i>{text}
</a>
),
@ -279,77 +317,72 @@ class CoderRootDirectory extends Component{
}
}
const urlRoot = filePath && filePath.length > 0 ? `/${filePath[filePath.length - 1].path}` : "";
const urlRoot = `/${filePath}`;
const { projectDetail } = this.props;
let array = filePath && filePath.split("/");
return(
<React.Fragment>
{
rootData &&
<React.Fragment>
{
rootData.length > 0 ?
<div>
<Top { ...this.props } {...this.state} />
<div className="f-wrap-between mt20">
<div className="f-wrap-alignCenter">
<SelectBranch branch={branch} changeBranch={this.changeBranch} {...this.props} {...this.state}></SelectBranch>
{
filePath && filePath.length > 0 &&
<span className="ml20 font-16">
<a onClick={()=>this.getProjectRoot(branch)} className="color-blue">{ projectDetail && projectDetail.identifier }</a>
{
filePath.map((item,key)=>{
return(
<React.Fragment>
{
key === filePath.length-1 ?
<span className="color-grey-6 subFileName" key={key}>{item.name}</span>
:
<a onClick={()=>this.ChangeFile(item,true)} className="color-blue subFileName" key={key}>{item.name}</a>
}
</React.Fragment>
)
})
}
</span>
}
</div>
<div className="f-wrap-alignCenter">
{
subFileType !== "file" && (isManager || isDeveloper) &&
<p className="addFile mr30">
<Link to={`/projects/${projectsId}/coders/${branch}/newfile${urlRoot}`} >新建文件</Link>
{/* <Link to={``}>上传文件</Link> */}
</p>
}
{
filePath && filePath.length === 0 && <CloneAddress http_url={http_url} downloadUrl={downloadUrl} showNotification={this.props.showNotification}></CloneAddress>
}
</div>
<Spin spinning={isSpin}>
{(rootList && rootList.length > 0) || (fileDetail && fileDetail.length > 0) ?
<div>
<Top { ...this.props } {...this.state} />
<div className="f-wrap-between mt20">
<div className="f-wrap-alignCenter">
<SelectBranch branch={branch} changeBranch={this.changeBranch} {...this.props} {...this.state}></SelectBranch>
{
filePath &&
<span className="ml20 font-16">
<a onClick={()=>this.returnMain(branch)} className="color-blue">{ projectDetail && projectDetail.identifier }</a>
{
array && array.map((item,key)=>{
return(
<React.Fragment>
{
key === array.length-1 ?
<span className="color-grey-6 subFileName" key={key}>{item}</span>
:
key === 0?
<Link to={`/projects/${projectsId}/coders/filesurl/${item}`} className="color-blue subFileName" key={key}>{item}</Link>
:
<Link to={`/projects/${projectsId}/coders/filesurl/${array[key-1]}/${item}`} className="color-blue subFileName" key={key}>{item}</Link>
}
</React.Fragment>
)
})
}
</span>
}
</div>
<Spin spinning={isSpin}>
{/* 文件夹-子目录列表 */}
<div className="f-wrap-alignCenter">
{
rootList && <RootTable columns = {columns} data={rootList} title={() => title()}></RootTable>
subFileType !== "file" && (isManager || isDeveloper) &&
<p className="addFile mr30">
<Link to={`/projects/${projectsId}/coders/${branch}/newfile${urlRoot}`} >新建文件</Link>
</p>
}
{
fileDetail &&
<CoderRootFileDetail detail = {fileDetail} {...this.props} {...this.state} readOnly={this.state.readOnly}></CoderRootFileDetail>
filePath && filePath.length === 0 && <CloneAddress http_url={http_url} downloadUrl={downloadUrl} showNotification={this.props.showNotification}></CloneAddress>
}
{/* readme.txt */}
{ this.renderReadMeContent(readMeContent,(isManager || isDeveloper)) }
</Spin>
</div>
</div>
:
<NullData {...this.props} {...this.state} http_url={http_url} ></NullData>
}
</React.Fragment>
{/* 主目录列表 */}
{
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>
}
{/* readme.txt (isManager || isDeveloper)*/}
{ this.renderReadMeContent(readMeContent,(isManager || isDeveloper)) }
</div>
:
<NullData {...this.props} {...this.state} http_url={http_url} ></NullData>
}
</React.Fragment>
</Spin>
)
}
}

View File

@ -152,13 +152,6 @@ class CoderRootFileDetail extends Component{
</div>
:
<CodeMirror ref="editor" value={detail.content} onChange={this.updateCode} options={options} />
// <Editor
// height="300px"
// theme={"vs-dark"}
// value={value}
// onChange={this.changeContent}
// readOnly={readOnly}
// />
}
</div>
</div>

View File

@ -505,6 +505,11 @@ class Detail extends Component{
(props) => (<MergeIndexDetail {...this.props} {...props} {...this.state}/>)
}
></Route>
<Route path="/projects/:projectsId/coders/filesurl"
render={
(props) => (<CoderRootIndex {...this.props} {...props} {...this.state}/>)
}
></Route>
<Route path="/projects/:projectsId/coders"
render={
(props) => (<CoderRootIndex {...this.props} {...props} {...this.state}/>)

View File

@ -26,7 +26,7 @@ class IndexItem extends Component{
<img className="p-r-photo" alt="" src={getImageUrl(`images/${item.author && item.author.image_url}`)} ></img>
<div className="p-r-Infos">
<div className="p-r-name">
<Link to={`/projects/${item.id}/${item.author && item.author.login}/coder`} className="hide-1 color-grey-3 font-18 task-hide " style={{whiteSpace:"wrap",display:'flex',width:400}}>
<Link to={`/projects/${item.id}/coders`} className="hide-1 color-grey-3 font-18 task-hide " style={{whiteSpace:"wrap",display:'flex',width:400}}>
{item.author.name}/{item.name}
{
item.forked_from_project_id ?

View File

@ -1438,7 +1438,7 @@ submittojoinclass=(value)=>{
{this.props.user&&this.props.user.login? <div className="fl mr30 edu-menu-panel headIcon">
{ user===undefined?"":user.login===""?"": <a
href={`${mygetHelmetapi2.new_course.tiding_url}`}
href={`${mygetHelmetapi2 && mygetHelmetapi2.new_course && mygetHelmetapi2.new_course.tiding_url}`}
style={{position:'relative'}} target="_blank"
>
<i className="iconfont icon-xiaoxilingdang color-white"></i>