diff --git a/src/forge/Main/CoderRootDirectory.js b/src/forge/Main/CoderRootDirectory.js
index 0ca78352..b71f215a 100644
--- a/src/forge/Main/CoderRootDirectory.js
+++ b/src/forge/Main/CoderRootDirectory.js
@@ -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 (
- {
- readMeContent[0].content ?
-
- :
+ {readMeContent[0].content ? (
+
+ ) : (
暂无~
- }
+ )}
- )
+ );
}
- }
+ };
// 选择分支
- 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{
{text}
),
- },{
- dataIndex:"commit",
- width:"60%",
- render:(text,item)=>
- (
- item.commit && item.commit.message ? {item.commit.message} :""
- )
- },{
- dataIndex:"commit",
- width:"10%",
- className:"edu-txt-right",
- render:(text,item)=>(
- item.commit && item.commit.time_from_now ? {item.commit.time_from_now} :""
- )
- }
+ },
+ {
+ dataIndex: "commit",
+ width: "60%",
+ render: (text, item) =>
+ item.commit && item.commit.message ? (
+
+ {item.commit.message}
+
+ ) : (
+ ""
+ ),
+ },
+ {
+ dataIndex: "commit",
+ width: "10%",
+ className: "edu-txt-right",
+ render: (text, item) =>
+ item.commit && item.commit.time_from_now ? (
+
+ {item.commit.time_from_now}
+
+ ) : (
+ ""
+ ),
+ },
];
- const title = () =>{
- if(branchLastCommit){
- return(
+ const title = () => {
+ if (branchLastCommit) {
+ return (
- {
- lastCommitAuthor ?
-
- {
- lastCommitAuthor.login ?
-
-
- {lastCommitAuthor.name}
- :
+ {lastCommitAuthor ? (
+
+ {lastCommitAuthor.login ? (
+
+
{lastCommitAuthor.name}
- }
-
- :""
- }
- {branchLastCommit.message}
+
+ ) : (
+ {lastCommitAuthor.name}
+ )}
+
+ ) : (
+ ""
+ )}
+
+ {branchLastCommit.message}
+
{branchLastCommit.time_from_now}
-
{truncateCommitId(branchLastCommit.sha)}
+
+ {truncateCommitId(branchLastCommit.sha)}
+
- )
- }else{
+ );
+ } else {
return undefined;
}
- }
+ };
- const downloadUrl = ()=>(
+ const downloadUrl = () => (
- )
+ );
- const urlRoot = filePath === undefined ? '':`/${filePath}`;
+ const urlRoot = filePath === undefined ? "" : `/${filePath}`;
let array = filePath && filePath.split("/");
- return(
+ return (
- {
- subFileType && (isManager || isDeveloper) &&
-
- 新建文件
-
- }
- {
- projectDetail && projectDetail.clone_url &&
- }
+ {subFileType && (isManager || isDeveloper) && (
+
+
+
+
+
+
+
+
+ )}
+ {projectDetail && projectDetail.clone_url && (
+
+ )}
{/* 主目录列表 */}
- {
- rootList &&
- title()}>
- }
+ {rootList && (
+ title()}
+ >
+ )}
{/* 子目录列表、文件 */}
- {
- fileDetail && fileDetail.length>0 &&
-
- }
+ {fileDetail && fileDetail.length > 0 && (
+
+ )}
{/* readme.txt (isManager || isDeveloper)*/}
- { this.renderReadMeContent(readMeContent,(isManager || isDeveloper)) }
+ {this.renderReadMeContent(readMeContent, isManager || isDeveloper)}
- )
+ );
}
}
export default CoderRootDirectory;
diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js
index 6137f081..e2faab22 100644
--- a/src/forge/Main/Detail.js
+++ b/src/forge/Main/Detail.js
@@ -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) => ()
}
>
+ ()
+ }
+ >
()
diff --git a/src/forge/Main/IndexItem.js b/src/forge/Main/IndexItem.js
index c579aa75..97229c5f 100644
--- a/src/forge/Main/IndexItem.js
+++ b/src/forge/Main/IndexItem.js
@@ -33,7 +33,7 @@ class IndexItem extends Component {
: ""
}
{
- item.mirror_url && item.mirror_url.length > 0 &&
+ item.type && item.type !== 0 &&
diff --git a/src/forge/Newfile/Index.js b/src/forge/Newfile/Index.js
index 1c09015d..a3016171 100644
--- a/src/forge/Newfile/Index.js
+++ b/src/forge/Newfile/Index.js
@@ -124,8 +124,6 @@ class Index extends Component {
})}
-
-
{
+ 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 {
+
{getFieldDecorator("path", {
rules: [],
})(
+ //
+
+
)}
@@ -188,7 +208,7 @@ class UserSubmitComponent extends Component {