forked from Gitlink/forgeplus-react
开源许可证
This commit is contained in:
parent
a880b36fc9
commit
2997ff8517
|
|
@ -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 && <p className="color-red ml20">请输入文件名称</p>}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
import React,{useEffect,useState,useRef} from 'react';
|
||||
import { Input } from 'antd';
|
||||
import Drop from '../../Issues/Component/drop';
|
||||
import "./index.scss";
|
||||
import ListItem from './list';
|
||||
|
||||
/***
|
||||
* list:下拉内容列表
|
||||
* name:所用内容名字,新建页面:.gitignore、许可证、类别、语言,项目基本设置:类别、语言
|
||||
* value:选中id
|
||||
* getValue:点击确定
|
||||
* idname:下拉内容定位的父元素
|
||||
*/
|
||||
function DorpChooseMenus({list,name,value,getValue,idname}){
|
||||
const dropRef = useRef(null);
|
||||
const [ choose , setChoose ] = useState(undefined);
|
||||
const [ defaultValue , setDefaultValue ] = useState(undefined);
|
||||
|
||||
useEffect(()=>{
|
||||
if(value){
|
||||
setChoose({name:value});
|
||||
setDefaultValue(value)
|
||||
}
|
||||
},value)
|
||||
|
||||
const panel=()=>{
|
||||
return(
|
||||
<div>
|
||||
<ListItem list={list} size="small" onChooseFunc={chooseFunc} defaultValue={value}/>
|
||||
<a onClick={sureFunc} className={choose ? 'sureDrop active':"sureDrop"}>确定</a>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
function chooseFunc(value){
|
||||
setChoose(value);
|
||||
}
|
||||
|
||||
function sureFunc(){
|
||||
getValue(choose);
|
||||
dropRef.current && dropRef.current.clearVisible(false);
|
||||
}
|
||||
return(
|
||||
<Drop
|
||||
overlay={panel()}
|
||||
overlayClassName={"alllists"}
|
||||
placement={"bottomLeft"}
|
||||
ref={dropRef}
|
||||
idname={idname}
|
||||
>
|
||||
<Input placeholder={name} value={defaultValue}/>
|
||||
</Drop>
|
||||
)
|
||||
}
|
||||
export default DorpChooseMenus;
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
|
|
@ -0,0 +1,57 @@
|
|||
import { Modal } from "antd";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import LicenseImg from './img/license.png';
|
||||
import "./index.scss";
|
||||
import axios from 'axios';
|
||||
import ListItem from './list';
|
||||
|
||||
function Index({visible,onCancel,createDefaultLicense}){
|
||||
const [ list , setList ] = useState(undefined);
|
||||
const [ choose , setChoose ] = useState(undefined);
|
||||
useEffect(()=>{
|
||||
visible && getLicenses();
|
||||
},[visible])
|
||||
|
||||
|
||||
const getLicenses = () => {
|
||||
const url = `/licenses.json`;
|
||||
axios.get(url).then((result) => {
|
||||
if (result) {
|
||||
setList(result.data.licenses);
|
||||
}
|
||||
}).catch((error) => { })
|
||||
}
|
||||
|
||||
function chooseFunc(value){
|
||||
setChoose(value);
|
||||
}
|
||||
|
||||
|
||||
return(
|
||||
<Modal
|
||||
title="请选择开源许可证"
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
footer={null}
|
||||
width={870}
|
||||
>
|
||||
<div className="licenseBox">
|
||||
<div className="licenseDesc">
|
||||
<p className="font-18" style={{color:"#1B3485"}}>了解开源许可证</p>
|
||||
<div className="licImg">
|
||||
<img src={LicenseImg}/>
|
||||
</div>
|
||||
<p className="licWord mt25">开源许可证是您软件源代码使用、修改及分发的法律约定,明确了他人使用项目的权利与限制,常见的有MIT、Apache 2.0、GPL等。</p>
|
||||
<p className="licWord mt20">请从推荐列表中选择适合的协议,或根据高级项目需求自定义创建您的许可证。</p>
|
||||
<a className="licCreate" onClick={()=>createDefaultLicense(-1)}>创建自定义许可证</a>
|
||||
</div>
|
||||
|
||||
<div className="licenseData">
|
||||
<ListItem list={list} onChooseFunc={chooseFunc}/>
|
||||
<a className={choose ? "licUse active":"licUse"} onClick={()=>createDefaultLicense(choose && choose.id)}>使用该许可证</a>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
export default Index
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
.licenseBox{
|
||||
display: flex;
|
||||
.licenseDesc{
|
||||
background: #FBFCFF;
|
||||
border-radius: 11px 11px 11px 11px;
|
||||
border: 1px solid rgba(70,106,255,0.33);
|
||||
width: 38%;
|
||||
padding:20px;
|
||||
margin-right: 20px;
|
||||
.licImg{
|
||||
background: #F7F9FF;
|
||||
border-radius: 0px 0px 0px 0px;
|
||||
border: 1px dashed rgba(70,106,255,0.3);
|
||||
padding:24px 30px;
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
img{
|
||||
height: 122px;
|
||||
}
|
||||
}
|
||||
.licWord{
|
||||
color: #4C4D5A;
|
||||
line-height: 26px;
|
||||
}
|
||||
.licCreate{
|
||||
display: block;
|
||||
height: 36px;
|
||||
line-height: 36px;
|
||||
background: #F7F9FF;
|
||||
border-radius: 7px 7px 7px 7px;
|
||||
border: 1px solid #466AFF;
|
||||
color: #466AFF;
|
||||
text-align: center;
|
||||
margin-top: 25px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.licenseData{
|
||||
flex: 1;
|
||||
}
|
||||
.licList{
|
||||
margin-top: 20px;
|
||||
height: 394px;
|
||||
overflow-y: auto;
|
||||
clear: both;
|
||||
width: 100%;
|
||||
li{
|
||||
height: 36px;
|
||||
line-height: 36px;
|
||||
background: rgba(126,135,172,0.08);
|
||||
border-radius: 4px 4px 4px 4px;
|
||||
width: 48.5%;
|
||||
margin-right: 3%;
|
||||
text-align: center;
|
||||
margin-bottom: 15px!important;
|
||||
float: left;
|
||||
cursor: pointer;
|
||||
&:nth-child(2n){
|
||||
margin-right: 0px;
|
||||
}
|
||||
&.active{
|
||||
color: #fff;
|
||||
background-color: #466AFF;
|
||||
}
|
||||
}
|
||||
&.small{
|
||||
height: 200px;
|
||||
li{
|
||||
width: 22.5%;
|
||||
&:nth-child(2n){
|
||||
margin-right: 3%;
|
||||
}
|
||||
&:nth-child(4n){
|
||||
margin-right: 0px;
|
||||
}
|
||||
}
|
||||
.none_panels{
|
||||
padding:0px;
|
||||
min-height: 200px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.licUse{
|
||||
display: block;
|
||||
height: 36px;
|
||||
line-height: 36px;
|
||||
border-radius: 4px 4px 4px 4px;
|
||||
font-size: 15px;
|
||||
color: #fff!important;
|
||||
text-align: center;
|
||||
margin-top: 38px;
|
||||
background-color: #c0c0c0;
|
||||
cursor: default;
|
||||
&.active{
|
||||
background: #466AFF;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
.dropspan{
|
||||
display: block;
|
||||
}
|
||||
|
||||
.alllists{
|
||||
background-color: #fff;
|
||||
box-shadow: 2px 4px 15px rgba(0, 0, 0, 0.1);
|
||||
padding:20px!important;
|
||||
width: 80%;
|
||||
}
|
||||
.sureDrop{
|
||||
width: 200px;
|
||||
height: 36px;
|
||||
background: #c0c0c0;
|
||||
border-radius: 4px;
|
||||
line-height: 36px;
|
||||
color: #fff!important;
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-size: 15px;
|
||||
margin:20px auto 0px;
|
||||
cursor: default;
|
||||
&.active{
|
||||
background: #466AFF;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import Search from './img/search.png';
|
||||
import Nodata from "../../Nodata";
|
||||
import { Input } from 'antd';
|
||||
import "./index.scss";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {list} param1 列表
|
||||
* @param {onChooseFunc} param2 选中后调用父级方法
|
||||
* @param {size} param3 一行显示4个,默认显示2个
|
||||
* @param {defaultValue} param4 默认选中的---name
|
||||
* @returns
|
||||
*/
|
||||
function List({list,onChooseFunc,size,defaultValue}){
|
||||
const [ value , setValue ] = useState(undefined);
|
||||
const [ active , setActive ] = useState(undefined);
|
||||
const [ copylist , setCopyList ] = useState(undefined);
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
if(list && list.length>0){
|
||||
setCopyList(list);
|
||||
if(defaultValue){
|
||||
let getMIT = list.filter(i=>i.name === defaultValue);
|
||||
getMIT && getMIT.length > 0 && setActive(getMIT[0].id);
|
||||
}
|
||||
}
|
||||
},[list && list.length,defaultValue])
|
||||
|
||||
|
||||
function searchFunc(search){
|
||||
let filters = list && list.filter(i=>i.name.toLowerCase().indexOf(search.toLowerCase()) > -1);
|
||||
setCopyList(filters);
|
||||
}
|
||||
return(
|
||||
<React.Fragment>
|
||||
<Input placeholder="输入关键词进行搜索" suffix={<img src={Search} width={"19px"} />} value={value} onChange={(e)=>{setValue(e.target.value);searchFunc(e.target.value)}}/>
|
||||
<ul className={`licList ${size}`}>
|
||||
{ copylist && copylist.length>0 && copylist.map((i,k)=>{
|
||||
return <li className={active === i.id ?"active":""} onClick={()=>{setActive(i.id);onChooseFunc(i)}}>{i.name}</li>
|
||||
})
|
||||
}
|
||||
{
|
||||
copylist && copylist.length === 0 && <Nodata _html="暂无数据"/>
|
||||
}
|
||||
</ul>
|
||||
</React.Fragment>
|
||||
)
|
||||
}
|
||||
export default List;
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
import React,{useState, useEffect, useRef, useImperativeHandle,forwardRef} from 'react';
|
||||
import { Dropdown } from 'antd';
|
||||
import { findDOMNode } from 'react-dom';
|
||||
import "../index.scss";
|
||||
|
||||
function Drop({overlay , children , placement, overlayClassName},ref){
|
||||
function Drop({overlay , children , placement, overlayClassName,idname},ref){
|
||||
const [ visible , setVisible ] = useState(false);
|
||||
const refFa = useRef(null);
|
||||
const refBox = useRef(null);
|
||||
|
|
@ -35,6 +36,7 @@ function Drop({overlay , children , placement, overlayClassName},ref){
|
|||
placement={placement}
|
||||
visible={visible}
|
||||
overlay={<div ref={refFa}>{overlay}</div>}
|
||||
getPopupContainer={(trigger) => idname ? document.getElementById(idname) :trigger.parentNode}
|
||||
trigger={['click']}
|
||||
overlayClassName={overlayClassName}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { Link } from 'react-router-dom';
|
|||
import { connect } from 'react-redux';
|
||||
import { truncateCommitId } from "../common/util";
|
||||
import CloneAddress from '../Branch/CloneAddress';
|
||||
|
||||
import CheckProfile from '../Component/ProfileModal/Profile';
|
||||
import SelectBranch from '../Branch/Select';
|
||||
import User from '../Component/User';
|
||||
import axios from 'axios';
|
||||
|
|
@ -21,12 +21,12 @@ import DrawerPanel from '../Component/DrawerPanel';
|
|||
import UpdateDescModal from './sub/UpdateDescModal';
|
||||
import Nodata from '../Nodata';
|
||||
import Invite from './sub/Invite';
|
||||
import CheckProfile from '../Component/ProfileModal/Profile';
|
||||
import RenderHtml from '../../components/render-html';
|
||||
import Loadable from 'react-loadable';
|
||||
import Loading from '../../Loading';
|
||||
import ProjectPortrait from '../Component/projectPortrait';
|
||||
import imNoneImg from './img/importNone.png';
|
||||
import LicenseModal from '../Component/licenseModal/index';
|
||||
import moment from 'moment';
|
||||
|
||||
const ProjectCompass = Loadable({
|
||||
|
|
@ -77,6 +77,7 @@ function CoderDepot(props){
|
|||
const [ pullsFlag , setPullsFlag ] = useState(true);
|
||||
const [ issuesFlag , setIssuesFlag ] = useState(true);
|
||||
const [ releaseVersions , setReleaseVersions] = useState(undefined);
|
||||
const [ licenseVisible ,setLicenseVisible] = useState(false);
|
||||
|
||||
const owner = props.match.params.owner;
|
||||
const projectsId = props.match.params.projectsId;
|
||||
|
|
@ -308,6 +309,7 @@ function CoderDepot(props){
|
|||
)
|
||||
}
|
||||
|
||||
|
||||
function getPathUrl(array,index){
|
||||
if(array && array.length>0 && index){
|
||||
let str = "";
|
||||
|
|
@ -404,6 +406,16 @@ function CoderDepot(props){
|
|||
props.showLoginDialog(`/${owner}/${projectsId}/issues/new`);
|
||||
}
|
||||
}
|
||||
// 创建自定义许可证
|
||||
function createDefaultLicense(id){
|
||||
if(props.checkIfLogin()===false){
|
||||
props.showLoginDialog()
|
||||
return false;
|
||||
}
|
||||
let b = branchName || defaultBranch;
|
||||
let checkvalue = turnbar(b);
|
||||
props.history.push({pathname:`/${owner}/${projectsId}/${checkvalue}/newfile${treeValue === undefined ? "" : `/${treeValue}`}`,state:`${id}`})
|
||||
}
|
||||
|
||||
// 如果项目是fork的项目,pr自动指向源仓库,否则指向本仓库默认分支
|
||||
function compare() {
|
||||
|
|
@ -423,6 +435,7 @@ function CoderDepot(props){
|
|||
return(
|
||||
<div className='WhiteBack'>
|
||||
{mirror_status ===0 && <UpdateDescModal desc={desc} website={website} lesson_url={lesson_url} topicsInfo={topics} visible={openModal} onCancel={()=>setOpenModal(false)} onOk={okUpdate}/> }
|
||||
<LicenseModal visible={licenseVisible} onCancel={()=>{setLicenseVisible(false)}} createDefaultLicense={createDefaultLicense}/>
|
||||
<Spin spinning={isSpin}>
|
||||
{
|
||||
((dirInfo || fileInfo) && mirror_status===0 ) &&
|
||||
|
|
@ -663,10 +676,15 @@ function CoderDepot(props){
|
|||
<span>{projectDetail && projectDetail.size}</span>
|
||||
</div>
|
||||
{
|
||||
projectDetail && projectDetail.license_name &&
|
||||
<div className="pinfos">
|
||||
projectDetail && projectDetail.license_id !== 0 &&
|
||||
<div className={projectDetail.license_name ? "pinfos" :"color-grey-6"}>
|
||||
<i className="iconfont icon-xieyiicon font-16 mr10"></i>
|
||||
<Link to={`/${owner}/${projectsId}/tree/${turnbar(branchName || defaultBranch)}/LICENSE`} className="color-grey-6">{projectDetail.license_name}</Link>
|
||||
{
|
||||
projectDetail.license_name ?
|
||||
<Link to={`/${owner}/${projectsId}/tree/${turnbar(branchName || defaultBranch)}/LICENSE`} className="color-grey-6">{projectDetail.license_name}</Link>
|
||||
:
|
||||
<span>暂无数据,点击<a className='color-blue' onClick={()=>{setLicenseVisible(true)}}>选择并创建许可证</a></span>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { Input , Form , Select , Checkbox , Button , Spin , AutoComplete, Modal
|
|||
import { Base64 } from 'js-base64';
|
||||
import { AlignCenter } from '../Component/layout';
|
||||
import { withTranslation } from 'react-i18next';
|
||||
import DorpChooseMenus from '../Component/licenseModal/dorpChooseMenus';
|
||||
|
||||
import '../css/index.scss';
|
||||
import './new.scss'
|
||||
|
|
@ -76,6 +77,8 @@ class Index extends Component {
|
|||
this.getOwner();
|
||||
//判断是否为删除新建项目失败后返回,并执行对应逻辑
|
||||
this.isDeleteProjectBack();
|
||||
// 获取开源许可证
|
||||
this.getLicenses();
|
||||
}
|
||||
componentDidUpdate=(prevPros)=>{
|
||||
this.updateDocumentTitle();
|
||||
|
|
@ -123,7 +126,7 @@ class Index extends Component {
|
|||
const url = `/project_categories.json`
|
||||
axios.get(url).then((result) => {
|
||||
if (result) {
|
||||
this.setOptionsList(result.data.project_categories, 'project_category');
|
||||
// this.setOptionsList(result.data.project_categories, 'project_category');
|
||||
this.setState({
|
||||
CategoryList: result.data.project_categories
|
||||
})
|
||||
|
|
@ -135,7 +138,7 @@ class Index extends Component {
|
|||
const url = `/project_languages.json`
|
||||
axios.get(url).then((result) => {
|
||||
if (result) {
|
||||
this.setOptionsList(result.data.project_languages, 'project_language')
|
||||
// this.setOptionsList(result.data.project_languages, 'project_language')
|
||||
this.setState({
|
||||
LanguageList: result.data.project_languages
|
||||
})
|
||||
|
|
@ -147,7 +150,7 @@ class Index extends Component {
|
|||
const url = `/ignores.json`
|
||||
axios.get(url).then((result) => {
|
||||
if (result) {
|
||||
this.setOptionsList(result.data.ignores, 'ignore');
|
||||
// this.setOptionsList(result.data.ignores, 'ignore');
|
||||
this.setState({
|
||||
GitignoreList: result.data.ignores
|
||||
})
|
||||
|
|
@ -159,14 +162,13 @@ class Index extends Component {
|
|||
const url = `/licenses.json`
|
||||
axios.get(url).then((result) => {
|
||||
if (result) {
|
||||
this.setOptionsList(result.data.licenses, 'license');
|
||||
let data = result.data.licenses;
|
||||
this.setState({
|
||||
LicensesList: result.data.licenses
|
||||
LicensesList: data
|
||||
})
|
||||
}
|
||||
}).catch((error) => { })
|
||||
}
|
||||
|
||||
isDeleteProjectBack = () => {
|
||||
let mirror_status = this.props.history.location.mirror_status;
|
||||
if (mirror_status === 2 && sessionStorage.newProjectValue) {
|
||||
|
|
@ -264,28 +266,6 @@ class Index extends Component {
|
|||
})
|
||||
}
|
||||
|
||||
ChangePlatform = (value, e, name, list) => {
|
||||
this.setOptionsList(list, name, value)
|
||||
this.setState({
|
||||
[name + "_id"]: e.key,
|
||||
[name + "_name"]: value,
|
||||
})
|
||||
}
|
||||
|
||||
blurCategory = (value, list, name) => {
|
||||
let filter = list && list.filter(item => item.name === value);
|
||||
if (!filter || filter.length === 0) {
|
||||
this.props.form.setFieldsValue({
|
||||
[name]: undefined
|
||||
})
|
||||
this.setState({
|
||||
[name + "_name"]: undefined,
|
||||
[name + "_id"]: undefined
|
||||
})
|
||||
this.setOptionsList(list, name);
|
||||
}
|
||||
}
|
||||
|
||||
checkId = (rule, value, callback, list, title) => {
|
||||
let filter = list.filter(item => item.name === value);
|
||||
if(!value){
|
||||
|
|
@ -358,14 +338,6 @@ class Index extends Component {
|
|||
this.getGitignore();
|
||||
}
|
||||
}
|
||||
showLicenseFunc =(e)=>{
|
||||
const { LicensesList } = this.state;
|
||||
this.setState({licenseFlag:e.target.checked})
|
||||
if(e.target.checked && (!LicensesList || (LicensesList && LicensesList.length===0))){
|
||||
// 获取开源许可证
|
||||
this.getLicenses();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
blurFunc=(rule, value, callback)=>{
|
||||
|
|
@ -430,6 +402,24 @@ class Index extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
showLicenseFunc =(e)=>{
|
||||
const { LicensesList } = this.state;
|
||||
this.setState({
|
||||
licenseFlag:e.target.checked
|
||||
})
|
||||
}
|
||||
|
||||
getValue=(values,typeName)=>{
|
||||
const {id,name} = values
|
||||
if(id){
|
||||
this.setState({
|
||||
[typeName + "_id"]: id
|
||||
})
|
||||
this.props.form.setFieldsValue({
|
||||
[`${typeName}`]:name
|
||||
})
|
||||
}
|
||||
}
|
||||
render() {
|
||||
const { getFieldDecorator } = this.props.form;
|
||||
// 项目类型:deposit-托管项目,mirror-镜像项目
|
||||
|
|
@ -465,7 +455,7 @@ class Index extends Component {
|
|||
} = this.state;
|
||||
return (
|
||||
<div className="main back-white" style={{padding:"0px",border:"none"}}>
|
||||
<div className="newPanel">
|
||||
<div className="newPanel" id="newPanel">
|
||||
<div className="newPanel_title">{projectsType && projectsType === "mirror" ? "导入" : "新建"}项目</div>
|
||||
<Spin spinning={isSpin}>
|
||||
<Form>
|
||||
|
|
@ -655,14 +645,7 @@ class Index extends Component {
|
|||
validator: (rule, value, callback) => this.checkId(rule, value, callback, GitignoreList, 'gitignore')
|
||||
}],
|
||||
})(
|
||||
<AutoComplete
|
||||
placeholder="请选择gitignore,用来定义哪些文件不需要添加到版本管理中"
|
||||
onChange={(value, e) => this.ChangePlatform(value, e, 'ignore', GitignoreList)}
|
||||
className="plateAutoComplete"
|
||||
onBlur={(value) => this.blurCategory(value, GitignoreList, "ignore")}
|
||||
>
|
||||
{ignore_list}
|
||||
</AutoComplete>
|
||||
<DorpChooseMenus idname={"newPanel"} name={"请选择gitignore,用来定义哪些文件不需要添加到版本管理中"} list={GitignoreList} getValue={(value)=>this.getValue(value,"ignore")}/>
|
||||
)}
|
||||
</Form.Item>
|
||||
}
|
||||
|
|
@ -674,7 +657,7 @@ class Index extends Component {
|
|||
)}
|
||||
</Form.Item>
|
||||
{ licenseFlag &&
|
||||
<Form.Item>
|
||||
<Form.Item className="privatePart">
|
||||
{getFieldDecorator('license', {
|
||||
rules: [{
|
||||
required: licenseFlag, message: '请选择开源许可证'
|
||||
|
|
@ -682,14 +665,7 @@ class Index extends Component {
|
|||
validator: (rule, value, callback) => this.checkId(rule, value, callback, LicensesList, '开源许可证')
|
||||
}],
|
||||
})(
|
||||
<AutoComplete
|
||||
placeholder="请选择开源许可证"
|
||||
onChange={(value, e) => this.ChangePlatform(value, e, 'license', LicensesList)}
|
||||
className="plateAutoComplete"
|
||||
onBlur={(value) => this.blurCategory(value, LicensesList, "license")}
|
||||
>
|
||||
{license_list}
|
||||
</AutoComplete>
|
||||
<DorpChooseMenus idname={"newPanel"} name={"请选择开源许可证"} list={LicensesList} getValue={(value)=>this.getValue(value,"license")}/>
|
||||
)}
|
||||
</Form.Item>
|
||||
}
|
||||
|
|
@ -721,9 +697,7 @@ class Index extends Component {
|
|||
)}
|
||||
</Form.Item>
|
||||
{categoreFlag &&
|
||||
<Form.Item
|
||||
className="privatePart"
|
||||
>
|
||||
<Form.Item className="privatePart">
|
||||
{getFieldDecorator('project_category', {
|
||||
rules: [{
|
||||
required: categoreFlag, message: '请选择项目类别',
|
||||
|
|
@ -731,20 +705,11 @@ class Index extends Component {
|
|||
validator: (rule, value, callback) => this.checkId(rule, value, callback, CategoryList, '项目类别')
|
||||
}],
|
||||
})(
|
||||
<AutoComplete
|
||||
placeholder="请选择项目类别"
|
||||
onChange={(value, e) => this.ChangePlatform(value, e, 'project_category', CategoryList)}
|
||||
className="plateAutoComplete"
|
||||
onBlur={(value) => this.blurCategory(value, CategoryList, "project_category")}
|
||||
>
|
||||
{project_category_list}
|
||||
</AutoComplete>
|
||||
<DorpChooseMenus idname={"newPanel"} name={"请选择项目类别"} list={CategoryList} getValue={(value)=>this.getValue(value,"project_category")}/>
|
||||
)}
|
||||
</Form.Item>
|
||||
}
|
||||
<Form.Item
|
||||
className="privatePart"
|
||||
>
|
||||
<Form.Item className="privatePart">
|
||||
{getFieldDecorator('languageFlag')(
|
||||
<Checkbox checked={languageFlag} onChange={(e)=>this.showLanguageFunc(e)}>项目语言</Checkbox>
|
||||
)}
|
||||
|
|
@ -758,14 +723,7 @@ class Index extends Component {
|
|||
validator: (rule, value, callback) => this.checkId(rule, value, callback, LanguageList, '项目语言')
|
||||
}],
|
||||
})(
|
||||
<AutoComplete
|
||||
placeholder="请选择项目语言"
|
||||
onChange={(value, e) => this.ChangePlatform(value, e, 'project_language', LanguageList)}
|
||||
className="plateAutoComplete"
|
||||
onBlur={(value) => this.blurCategory(value, LanguageList, "project_language")}
|
||||
>
|
||||
{project_language_list}
|
||||
</AutoComplete>
|
||||
<DorpChooseMenus idname={"newPanel"} name={"请选择项目语言"} list={LanguageList} getValue={(value)=>this.getValue(value,"project_language")}/>
|
||||
)}
|
||||
</Form.Item>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
.newPanel{
|
||||
border:1px solid #eaeaea;
|
||||
border-radius: 4px;
|
||||
position: relative;
|
||||
}
|
||||
.newPanel_title{
|
||||
height: 3rem;
|
||||
|
|
|
|||
|
|
@ -2,18 +2,25 @@ import React, { useEffect , useState } from "react";
|
|||
import Meditor from "./m_editor";
|
||||
import "./index.css";
|
||||
import { returnbar } from 'educoder';
|
||||
import { Select } from "antd";
|
||||
import FileLanguage from '../Component/FileLanguage';
|
||||
import FP from '../Component/FileName/index';
|
||||
import axios from 'axios';
|
||||
const { Option } = Select;
|
||||
|
||||
|
||||
function Index(props){
|
||||
const [ filename , setFileName ] = useState("");
|
||||
const [ language , setLanguage ] = useState("");
|
||||
const [ checkName , setCheckName ] = useState(false);
|
||||
const [ licenseList ,setLicenseList ] = useState([])
|
||||
const [ licenseId ,setLicenseId ] = useState([])
|
||||
const [ content ,setContent ] = useState("");
|
||||
const [ chooseName ,setChooseName ] = useState("");
|
||||
const [ empty , setEmpty ] = useState(false);
|
||||
|
||||
const {projectDetail} = props;
|
||||
const { pathname } = props && props.location;
|
||||
const { pathname , state } = props && props.location;
|
||||
const urlroot = pathname.split("newfile/")[1];
|
||||
const file_path = urlroot ? `/${urlroot}/` :"/";
|
||||
|
||||
|
|
@ -21,6 +28,55 @@ function Index(props){
|
|||
updateDocumentTitle();
|
||||
},[projectDetail])
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
if(state){
|
||||
getLicenseList();
|
||||
setLicenseId(parseInt(state))
|
||||
if(parseInt(state) !== -1){
|
||||
getLinceseById(state);
|
||||
}
|
||||
}
|
||||
},[state])
|
||||
|
||||
useEffect(()=>{
|
||||
if(licenseList && licenseList.length>0 && licenseId){
|
||||
let filters = licenseList.filter(i=>i.id === licenseId);
|
||||
let name = filters && filters.length === 1 ? filters[0].name : -1
|
||||
setChooseName(name);
|
||||
}
|
||||
},[licenseId,licenseList.splice()])
|
||||
|
||||
// 根据license id查询详情
|
||||
const getLinceseById=(id)=>{
|
||||
let url =`/licenses/${id}.json`;
|
||||
axios.get(url).then(res=>{
|
||||
if(res && res.data){
|
||||
setContent(res.data.content)
|
||||
}
|
||||
}).catch(error=>{})
|
||||
}
|
||||
// 获取license列表
|
||||
const getLicenseList=()=>{
|
||||
let url =`/licenses.json`;
|
||||
axios.get(url).then(res=>{
|
||||
if(res && res.data){
|
||||
setLicenseList(res.data.licenses)
|
||||
}
|
||||
}).catch(error=>{})
|
||||
}
|
||||
// 选择许可证
|
||||
const selectFunc=(e,item)=>{
|
||||
const { key } = item;
|
||||
setLicenseId(parseInt(key));
|
||||
props.history.push({state:key})
|
||||
if(key && parseInt(key) !== -1){
|
||||
getLinceseById(key);
|
||||
}else{
|
||||
setContent(undefined)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 更新网页标题
|
||||
function updateDocumentTitle(){
|
||||
|
|
@ -57,11 +113,34 @@ function Index(props){
|
|||
addonBefore={`${ projectDetail && projectDetail.identifier }${returnbar(file_path)}`}
|
||||
onChangeFile={onChangeFile}
|
||||
empty={empty}
|
||||
name={(Boolean(state) ? "LICENSE" :"")}
|
||||
onEmpty={(e)=>setEmpty(e)}
|
||||
readOnly={Boolean(state)}
|
||||
/>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<FileLanguage language={language} select_language={select_language}></FileLanguage>
|
||||
{
|
||||
(licenseList && licenseList.length>0 && state) ?
|
||||
<Select
|
||||
style={{width:200}}
|
||||
showSearch
|
||||
placeholder="请选择许可证"
|
||||
filterOption={(input, option) =>
|
||||
option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
||||
}
|
||||
onSelect={selectFunc}
|
||||
value={chooseName}
|
||||
>
|
||||
<Option value={-1} key={-1}>创建自定义许可证</Option>
|
||||
{
|
||||
licenseList.map((i,k)=>{
|
||||
return <Option value={i.name} key={i.id}>{i.name}</Option>
|
||||
})
|
||||
}
|
||||
</Select>
|
||||
:
|
||||
<FileLanguage language={language} select_language={select_language}></FileLanguage>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div className="editorBorder">
|
||||
|
|
@ -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}
|
||||
></Meditor>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
></UserSubmitComponent>
|
||||
</div>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
<Spin spinning={loading}>
|
||||
<WhiteBack>
|
||||
<Title>基本设置</Title>
|
||||
<Form className="baseForm" style={{marginLeft: '30px'}}>
|
||||
<Form className="baseForm" id="baseForm" style={{marginLeft: '30px'}}>
|
||||
<Form.Item label="项目名称">
|
||||
{getFieldDecorator("project_name", {
|
||||
rules: [
|
||||
|
|
@ -358,20 +378,22 @@ class Setting extends Component {
|
|||
{getFieldDecorator("project_category_id", {
|
||||
rules: [],
|
||||
})(
|
||||
<Select>
|
||||
<Option key={0} value={""}>未选择项目类别</Option>
|
||||
{CategoryList}
|
||||
</Select>
|
||||
// <Select>
|
||||
// <Option key={0} value={""}>未选择项目类别</Option>
|
||||
// {CategoryList}
|
||||
// </Select>
|
||||
<DorpChooseMenus idname={"baseForm"} name={"请选择项目类别"} list={CategoryList} getValue={(value)=>this.getValue(value,"project_category_id")}/>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item label="项目语言">
|
||||
{getFieldDecorator("project_language_id", {
|
||||
rules: [],
|
||||
})(
|
||||
<Select>
|
||||
<Option key={0} value={""}>未选择项目语言</Option>
|
||||
{LanguageList}
|
||||
</Select>
|
||||
// <Select>
|
||||
// <Option key={0} value={""}>未选择项目语言</Option>
|
||||
// {LanguageList}
|
||||
// </Select>
|
||||
<DorpChooseMenus idname={"baseForm"} name={"请选择项目类别"} list={LanguageList} getValue={(value)=>this.getValue(value,"project_language_id")}/>
|
||||
)}
|
||||
</Form.Item>
|
||||
<span className="mb15">访问权限:</span>
|
||||
|
|
|
|||
Loading…
Reference in New Issue