diff --git a/src/forge/Component/FileName/index.jsx b/src/forge/Component/FileName/index.jsx
index 1933cf91..b22caec5 100644
--- a/src/forge/Component/FileName/index.jsx
+++ b/src/forge/Component/FileName/index.jsx
@@ -3,7 +3,7 @@ import { Input } from 'antd';
import './index.scss';
function FileName({
-onChangeFile,addonBefore , name , empty , onEmpty
+onChangeFile,addonBefore , name , empty , onEmpty , readOnly
}){
const [ defaultUrl , setDefaultUrl ] = useState(undefined);
const [ newUrl , setNewUrl ] = useState([]);
@@ -115,6 +115,7 @@ onChangeFile,addonBefore , name , empty , onEmpty
onKeyUp={keyUpFun}
onChange={changeValue}
style={{width:"220px",borderColor:empty===true ? "red":"grey"}}
+ disabled={readOnly}
/>
{empty &&
-
+
{projectsType && projectsType === "mirror" ? "导入" : "新建"}项目
-
+ {
+ (licenseList && licenseList.length>0 && state) ?
+
+ :
+
+ }
@@ -69,13 +148,14 @@ function Index(props){
{...props}
filepath={`${file_path}`}
language = {language}
- content={""}
+ content={content}
readOnly={false}
editor_type="new"
descName={filename ? `Add ${filename}`:""}
checkName={checkName}
onEmpty={(e)=>setEmpty(e)}
empty={empty}
+ state={state}
filename={filename}
>
diff --git a/src/forge/Newfile/UserSubmitComponent.js b/src/forge/Newfile/UserSubmitComponent.js
index 808679ac..c10e5de5 100644
--- a/src/forge/Newfile/UserSubmitComponent.js
+++ b/src/forge/Newfile/UserSubmitComponent.js
@@ -69,7 +69,7 @@ class UserSubmitComponent extends Component {
// 提交变更
subMitFrom = () => {
- const { filepath, content, editor_type , checkName , onEmpty , checkContent} = this.props;
+ const { filepath, content, editor_type , checkName , onEmpty , checkContent , state , projectDetail} = this.props;
const { branch, projectsId , owner } = this.props.match.params;
const { submitType, filename , empty } = this.state;
if(editor_type==="upload" && checkContent && !content){
@@ -99,13 +99,25 @@ class UserSubmitComponent extends Component {
this.setState({ isSpin: false });
if (result.data && result.data.name) {
this.props.showNotification("文件新建成功!");
+ const { getDetail } = this.props;
if(submitType === "1"){
- const { getDetail } = this.props;
getDetail && getDetail();
}
- window.scrollTo(0,0);
- let url = `/${owner}/${projectsId}${values.branchname ? `/tree/${turnbar(values.branchname)}`: (branch ? `/tree/${turnbar(branch)}` : "")}`;
- this.props.history.push(url);
+ // 存在state是代表创建自定义许可证
+ if(state){
+ const url = `/${owner}/${projectsId}.json`;
+ const { name , identifier } = projectDetail;
+ axios.put(url,{name,identifier,license_id:parseInt(state)===-1?0:state }).then(res=>{
+ getDetail && getDetail();
+ window.scrollTo(0,0);
+ let url = `/${owner}/${projectsId}${values.branchname ? `/tree/${turnbar(values.branchname)}`: (branch ? `/tree/${turnbar(branch)}` : "")}`;
+ this.props.history.push(url);
+ }).catch(error=>{})
+ }else{
+ window.scrollTo(0,0);
+ let url = `/${owner}/${projectsId}${values.branchname ? `/tree/${turnbar(values.branchname)}`: (branch ? `/tree/${turnbar(branch)}` : "")}`;
+ this.props.history.push(url);
+ }
}
})
.catch((error) => {
diff --git a/src/forge/Newfile/m_editor.js b/src/forge/Newfile/m_editor.js
index f0450b63..e9e7b154 100644
--- a/src/forge/Newfile/m_editor.js
+++ b/src/forge/Newfile/m_editor.js
@@ -6,7 +6,6 @@ import 'codemirror/mode/clike/clike';
import 'codemirror/mode/css/css';
import UserSubmitComponent from "./UserSubmitComponent";
import CloudIDE from "./cloudIDE";
-import { Base64 } from "js-base64";
import "./index.css";
import "./editor.css";
@@ -35,7 +34,7 @@ class m_editor extends Component {
render() {
const { editorValue, changeValue } = this.state;
- const { readOnly, editorType,onEmpty,filename,empty, currentBranch, descName, checkName, detail, match: { params },filepath, ideTheme , md } = this.props;
+ const { readOnly, editorType,onEmpty,filename,empty, currentBranch, descName, checkName, detail, match: { params },filepath, state , projectDetail} = this.props;
const editor_options = {
lineNumbers: "on",
lineWrapping: true, //强制换行
@@ -87,6 +86,8 @@ class m_editor extends Component {
empty={empty}
filename={filename}
changeValueFlag={this.props.content !== changeValue}
+ state={state}
+ projectDetail={projectDetail}
>
)}
diff --git a/src/forge/Settings/Setting.js b/src/forge/Settings/Setting.js
index be7eebe8..59c05d0f 100644
--- a/src/forge/Settings/Setting.js
+++ b/src/forge/Settings/Setting.js
@@ -7,6 +7,8 @@ import { Link } from 'react-router-dom';
import axios from "axios";
import "./setting.scss";
import { unInstallMarketBot } from "../../softbot/api";
+import DorpChooseMenus from '../Component/licenseModal/dorpChooseMenus';
+
const { TextArea } = Input;
const { Option } = Select;
@@ -46,6 +48,7 @@ class Setting extends Component {
return;
}
}
+
componentDidMount = () => {
this.updateDocumentTitle();
this.getCategory();
@@ -63,18 +66,39 @@ class Setting extends Component {
}
getLanguage = () => {
+ this.getInfo();
+ };
+ getLanguage = (id) => {
const url = `/project_languages.json`;
- axios
- .get(url)
- .then((result) => {
- if (result) {
- let LanguageList = this.setOptionsList(result.data.project_languages);
- this.setState({
- LanguageList,
- });
+ axios.get(url).then((result) => {
+ if (result) {
+ let data = result.data.project_languages;
+ this.setState({LanguageList:data});
+ if(id){
+ let filters = data.filter(i=>i.id === id);
+ if(filters && filters.length > 0){
+ this.props.form.setFieldsValue({project_language_id:filters[0].name})
+ }
}
- })
- .catch((error) => {});
+ }
+ })
+ .catch((error) => {});
+ };
+
+ getCategory = (id) => {
+ const url = `/project_categories.json`;
+ axios.get(url).then((result) => {
+ if (result) {
+ let data = result.data.project_categories;
+ this.setState({CategoryList:data});
+ if(id){
+ let filters = data.filter(i=>i.id === id);
+ if(filters && filters.length > 0){
+ this.props.form.setFieldsValue({project_category_id:filters[0].name})
+ }
+ }
+ }
+ }).catch((error) => {});
};
getInfo = () => {
@@ -85,13 +109,15 @@ class Setting extends Component {
.then((result) => {
if (result) {
const { project_units } = this.state;
+ const { project_name ,project_description , project_identifier } = result.data;
let units = result.data.project_units;
units.push(...project_units);
-
this.props.form.setFieldsValue({
- ...result.data,
+ project_name ,project_description , private:result.data.private , project_identifier ,
project_units:units
});
+ this.getCategory(result.data.project_category_id);
+ this.getLanguage(result.data.project_language_id);
this.setState({
projectName:result.data.project_name,
private_check: result.data.private,
@@ -108,23 +134,6 @@ class Setting extends Component {
});
};
- getCategory = () => {
- const url = `/project_categories.json`;
- axios
- .get(url)
- .then((result) => {
- if (result) {
- let CategoryList = this.setOptionsList(
- result.data.project_categories
- );
- this.setState({
- CategoryList,
- });
- }
- })
- .catch((error) => {});
- };
-
setOptionsList = (data) => {
let list = undefined;
if (data && data.length > 0) {
@@ -163,17 +172,17 @@ class Setting extends Component {
update=(values)=>{
const { projectsId , owner } = this.props.match.params;
- const { private_check , project_units } = this.state;
- const {project_language_id, project_category_id, pr_view_admin} = values;
+ const { private_check , project_units , project_language_id , project_category_id} = this.state;
+ const {pr_view_admin} = values;
const url = `/${owner}/${projectsId}.json`;
axios.patch(url, {
name: values.project_name,
description: values.project_description,
private: private_check,
identifier:values.project_identifier,
- project_language_id,
- project_category_id,
- pr_view_admin
+ pr_view_admin,
+ ...values,
+ project_language_id , project_category_id
}).then((result) => {
if (result) {
this.props.showNotification(`仓库信息修改成功!`);
@@ -272,6 +281,17 @@ class Setting extends Component {
})
}
+
+ getValue=(values,typeName)=>{
+ const {id,name} = values;
+ this.setState({
+ [`${typeName}`]:id
+ })
+ this.props.form.setFieldsValue({
+ [`${typeName}`]:name
+ })
+ }
+
render() {
const { getFieldDecorator } = this.props.form;
const { projectsId , owner } = this.props.match.params;
@@ -295,7 +315,7 @@ class Setting extends Component {