forgeplus-react/src/modules/tpm/shixunchild/Repository/RepositoryCombinePath.js

107 lines
3.3 KiB
JavaScript
Raw Normal View History

2020-03-16 14:12:11 +08:00
import React, { Component } from 'react';
import axios from 'axios';
import { trace_collapse, WordsBtn } from 'educoder'
import { message, Input } from 'antd';
2020-04-28 17:23:34 +08:00
import Repositoryfile from "./Repositoryfile";
2020-03-16 14:12:11 +08:00
const $ = window.$;
class RepositoryCombinePath extends Component {
constructor(props) {
super(props)
this.state = {
value: this.props.secret_dir_path || '',
2020-04-28 17:23:34 +08:00
newvalue:'',
2020-03-16 14:12:11 +08:00
isEdit: false,
}
}
2020-04-28 17:23:34 +08:00
onSave = (value) => {
2020-03-16 14:12:11 +08:00
const { shixunId, pathArray } = this.props;
const url = `/shixuns/${shixunId}/set_secret_dir.json`
2020-04-28 17:23:34 +08:00
2020-03-16 14:12:11 +08:00
axios.post(url, {
2020-04-28 17:23:34 +08:00
secret_dir_path:value
2020-03-16 14:12:11 +08:00
}
).then((response) => {
if (response.data) {
2020-04-28 17:23:34 +08:00
this.setState({
newvalue:value
})
// message.success('保存成功');
2020-03-16 14:12:11 +08:00
}
})
}
2020-04-28 17:23:34 +08:00
// onChange = (e) => {
// const { value } = e.target;
// this.setState({ value })
// }
// onEdit = () => {
// this.setState({isEdit: true}, () => {
// window.$('.combinePathEditRow input')[0].focus()
// });
// }
Selectfiledirectory=()=>{
this.setState({
visibles:true
})
2020-03-16 14:12:11 +08:00
}
2020-04-28 17:23:34 +08:00
hideNewFolder=()=>{
this.setState({
visibles:false
})
2020-03-16 14:12:11 +08:00
}
2020-04-28 17:23:34 +08:00
2020-03-16 14:12:11 +08:00
render() {
const { fileContent, match, saveCode } = this.props;
2020-04-28 17:23:34 +08:00
const { newvalue, value } = this.state;
2020-03-16 14:12:11 +08:00
return (
2020-04-28 17:23:34 +08:00
<div className="combinePathEditRow">
2020-03-16 14:12:11 +08:00
<style>{`
.combinePathEditRow {
margin: 4px 0;
}
.combinePathEditRow input {
flex: 0 0 300px;
border: none;
}
.combinePathEditRow .wordsBtn {
margin-left: 24px;
}
`}</style>
2020-04-28 17:23:34 +08:00
{this.state.visibles===true?<Repositoryfile
titles={"选择文件目录"}
evaluationvisible={this.state.visibles}
hideNewFolder={this.hideNewFolder}
{...this.state}
{...this.props}
RepositoryCombinePath={true}
selectupfilspath={(value)=>this.onSave(value)}
/>:""}
<div className={"mt2"}>合并版本库路径</div>
<div className={"df"}>
{/*<span className={"mt2"}> {!isEdit?"源路径:":"目标路径:"}</span><span><Input disabled={!isEdit} value={value} onChange={this.onChange}></Input></span>*/}
<span className={"mt3"}> <span>源路径</span><span>{value}</span></span> <span><i className={"iconfont icon-youjiang color-grey-8 ml20"}></i></span>
<span className={"mt4 ml20"}> <span>目标路径</span><span>{newvalue}</span></span>
<WordsBtn className="wordsBtn mt4" onClick={this.Selectfiledirectory} style="blue">选择文件目录</WordsBtn>
{/*{isEdit && <WordsBtn className="wordsBtn" onClick={this.onSave} style="blue">保存</WordsBtn>}*/}
</div>
2020-03-16 14:12:11 +08:00
</div>
);
}
}
export default RepositoryCombinePath;