diff --git a/public/react/src/forge/Main/CoderRootDirectory.js b/public/react/src/forge/Main/CoderRootDirectory.js
index 1f37811a7..e812d66d9 100644
--- a/public/react/src/forge/Main/CoderRootDirectory.js
+++ b/public/react/src/forge/Main/CoderRootDirectory.js
@@ -18,7 +18,6 @@ import axios from 'axios';
* filePath:点击目录时当前目录的路径
* subfileType:保存当前点击目录的文件类型(显示目录列表时才显示新建文件,如果点击的是文件就不显示新建文件按钮)
* readMeContent:根目录下面的readme文件内容
- * current_path:当前文件路径
*/
class CoderRootDirectory extends Component{
constructor(props){
@@ -30,7 +29,6 @@ class CoderRootDirectory extends Component{
http_url:undefined,
subFileType:"",
readMeContent:undefined,
- current_path:undefined,
branchList:undefined,
fileDetail:undefined,
@@ -72,8 +70,7 @@ class CoderRootDirectory extends Component{
this.renderUrl(arr.name,arr.path,arr.type);
this.getFileDetail(arr);
this.setState({
- subFileType:arr.type,
- current_path:arr.path
+ subFileType:arr.type
})
}
@@ -189,7 +186,7 @@ class CoderRootDirectory extends Component{
})
}
render(){
- const { rootList , branch ,filePath , fileDetail , subFileType , readMeContent , current_path } = this.state;
+ const { rootList , branch ,filePath , fileDetail , subFileType , readMeContent } = this.state;
const { branchLastCommit , http_url , isManager , isDeveloper } = this.props;
const { projectsId } = this.props.match.params;
@@ -287,7 +284,7 @@ class CoderRootDirectory extends Component{
{
fileDetail &&
-
+
}
{/* readme.txt */}
diff --git a/public/react/src/forge/Main/CoderRootFileDetail.js b/public/react/src/forge/Main/CoderRootFileDetail.js
index 666d3d15a..782abd550 100644
--- a/public/react/src/forge/Main/CoderRootFileDetail.js
+++ b/public/react/src/forge/Main/CoderRootFileDetail.js
@@ -17,10 +17,19 @@ class CoderRootFileDetail extends Component{
constructor(props){
super(props);
this.state={
- readOnly:true
+ readOnly:true,
+ value:undefined
}
}
+ componentDidMount=()=>{
+ const { detail } = this.props;
+
+ this.setState({
+ value:detail.content
+ })
+ }
+
EditFile=()=>{
this.setState({
readOnly:false
@@ -32,19 +41,52 @@ class CoderRootFileDetail extends Component{
})
}
+ // 编辑文件
+ changeContent=(e)=>{
+ this.setState({
+ value:e
+ })
+ }
+
deleteFile=()=>{
- const { current_path , current_user , branch}= this.props;
+ const { current_user , branch , detail }= this.props;
const { projectsId } = this.props.match.params;
- const url = `/api/${current_user.login}/${projectsId}/contents/files/delete.json`;
+ const url = `/${current_user.login}/${projectsId}/contents/files/delete.json`;
axios.delete(url,{
params:{
- filepath:current_path,
+ filepath:detail.path,
branch
}
}).then(result=>{
if(result){
+ this.props.showNotification("删除成功!");
+ this.props.history.push(`/projects/${projectsId}`);
+ }
+ }).catch(error=>{
+ console.log(error);
+ })
+ }
+
+
+ // 确认修改文件
+ UpdateFile=()=>{
+ const { current_user , branch , detail}= this.props;
+ const { projectsId } = this.props.match.params;
+ const { value } = this.state;
+ const url =`/${current_user.login}/${projectsId}/contents/files/update.json`;
+ axios.put(url,{
+ filepath:detail.path,
+ branch,
+ content:value,
+ sha:detail.sha,
+ }).then(result=>{
+ if(result){
+ this.props.showNotification("修改成功!");
+ this.setState({
+ readOnly:true
+ })
}
}).catch(error=>{
console.log(error);
@@ -53,8 +95,7 @@ class CoderRootFileDetail extends Component{
render(){
const { detail } = this.props;
-
- const { readOnly } = this.state;
+ const { readOnly ,value } = this.state;
return(
@@ -66,7 +107,7 @@ class CoderRootFileDetail extends Component{
:
-
+
}
@@ -78,7 +119,8 @@ class CoderRootFileDetail extends Component{