外围贡献者

This commit is contained in:
caishi 2020-12-28 20:42:12 +08:00
parent 4e7a2fa3d7
commit 2ecdd73c7f
17 changed files with 263 additions and 72 deletions

View File

@ -58,7 +58,7 @@ export function initAxiosInterceptors(props) {
// TODO 避免重复的请求 https://github.com/axios/axios#cancellation
var
proxy = "http://localhost:3000";
proxy = "http://39.105.176.215:49999";
proxy = "https://testforgeplus.trustie.net";
const requestMap = {};
window.setfalseInRequestMap = function (keyName) {

View File

@ -68,7 +68,7 @@ export function appendFileSizeToUploadFile(item) {
return `${item.title}${uploadNameSizeSeperator}${item.filesize}`
}
export function appendFileSizeToUploadFileAll(fileList) {
return fileList.map(item => {
return fileList && fileList.map(item => {
if (item.name.indexOf(uploadNameSizeSeperator) == -1) {
return Object.assign({}, item, { name: `${item.name}${uploadNameSizeSeperator}${bytesToSize(item.size)}` })
}

View File

@ -4,23 +4,13 @@ import { Link, Route, Switch } from 'react-router-dom';
import { Content } from '../Component/layout';
import '../css/index.scss'
import './list.css';
import SpecialModal from './SpecialModal';
import Loadable from 'react-loadable';
import Loading from '../../Loading';
import axios from 'axios';
import img_1 from '../Images/1.png';
import img_2 from '../Images/2.png';
import img_3 from '../Images/3.png';
import img_6 from '../Images/6.png';
import img_7 from '../Images/7.png';
import img_parise from '../Images/parise.png';
import img_focus from '../Images/focus.png';
import img_parised from '../Images/parised.png';
import img_focused from '../Images/focused.png';
import img_fork from '../Images/fork.png';
import img_milepost from '../Images/milepost.png';
const Setting = Loadable({
loader: () => import('../Settings/Index'),
loading: Loading,
@ -172,7 +162,9 @@ class Detail extends Component {
defaultBranch:undefined,
// 非本平台项目
platform:false
platform:false,
visible:false,
user_apply_signatures:[]
}
}
@ -198,6 +190,14 @@ class Detail extends Component {
open_devops:result.data.open_devops,
platform:result.data.platform && result.data.platform !== 'educoder'
})
let signa = result.data.user_apply_signatures && result.data.user_apply_signatures[0];
if(result.data.is_secret && (signa && signa.status !== "passed")){
this.setState({
visible:true,
is_secret:result.data.is_secret,
user_apply_signatures:signa
})
}
// 工作流:两种状态进入的链接不同
const pathname = this.props.history.location.pathname;
@ -378,13 +378,24 @@ class Detail extends Component {
})
}
hideModal=()=>{
this.setState({
visible:false
})
}
sureModal=()=>{
this.hideModal();
this.props.history.push('/projects');
}
render() {
const { projectDetail, watchers_count, praises_count,
forked_count, firstSync , secondSync ,
isManager, watched, praised,
project , open_devops , platform , defaultBranch } = this.state;
project , open_devops , platform , defaultBranch , project_id , user_apply_signatures , visible } = this.state;
const url = this.props.history.location.pathname;
const urlArr = url.split("/");
const urlFlag = (urlArr.length === 3);
@ -411,6 +422,7 @@ class Detail extends Component {
}
return (
<div>
<SpecialModal {...this.props} visible={visible} hideModal={this.sureModal} user_apply_signatures={user_apply_signatures} project_id={project_id} sureModal={this.sureModal}></SpecialModal>
<div className="detailHeader-wrapper">
<div className="normal">
<div className="f-wrap-between pb15" style={{ position: "relative" }}>
@ -503,7 +515,7 @@ class Detail extends Component {
<ul className="headerMenu-wrapper">
<li className={pathname==="about" ? "active" : ""}>
<Link to={{ pathname: `/projects/${owner}/${projectsId}/about`, state }}>
<i className={(pathname==="" || urlFlag) ? "iconfont icon-zhuye1 color-blue mr5 font-14":"iconfont icon-zhuye1 color-white font-14 mr5"}></i>
<i className={ pathname === "about" ? "iconfont icon-zhuye1 color-blue mr5 font-14":"iconfont icon-zhuye1 color-white font-14 mr5"}></i>
<span>主页</span>
</Link>
</li>

View File

@ -1,7 +1,6 @@
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { Menu, Input , Spin, Pagination , Popover , Select } from 'antd';
import { getUrl } from 'educoder';
import { Menu, Input , Spin, Pagination , Popover } from 'antd';
import '../css/index.scss'
import './list.css';
import './Index.scss';
@ -37,8 +36,8 @@ class Index extends Component {
}
componentDidMount = () => {
const { page, limit, search, sort, project_type, category_id , languageId } = this.state;
this.getListData(page, limit, search, sort, project_type, category_id , languageId);
const { page,search, sort, project_type, category_id , languageId } = this.state;
this.getListData(page,search, sort, project_type, category_id , languageId);
this.getType();
@ -73,14 +72,14 @@ class Index extends Component {
}
// 获取列表
getListData = (page, limit, search, sort, project_type, category_id,languageId) => {
getListData = (page,search, sort, project_type, category_id,languageId) => {
const { current_user } = this.props;
const url = `/projects.json`;
axios.get(url, {
params: {
user_id: current_user && current_user.user_id,
page,
limit,
limit:15,
search,
sort_by: sort,
project_type,
@ -131,8 +130,8 @@ class Index extends Component {
search: undefined
})
this.setTypeList(list, type)
const { page, limit, sort, category_id , languageId } = this.state;
this.getListData(page, limit, undefined, sort, type, category_id , languageId);
const { page,sort, category_id , languageId } = this.state;
this.getListData(page,undefined, sort, type, category_id , languageId);
}
// 获取类型
@ -167,8 +166,8 @@ class Index extends Component {
page: 1
});
this.setCategoryList(list, id)
const { limit, sort, project_type , languageId } = this.state;
this.getListData(1, limit, undefined, sort, project_type, id , languageId);
const { sort, project_type , languageId } = this.state;
this.getListData(1,undefined, sort, project_type, id , languageId);
}
// 排序
@ -179,8 +178,8 @@ class Index extends Component {
search: undefined,
isSpin: true
})
const { limit, project_type, category_id , languageId } = this.state;
this.getListData(1, limit, undefined, e.key, project_type, category_id , languageId);
const {project_type, category_id , languageId } = this.state;
this.getListData(1,undefined, e.key, project_type, category_id , languageId);
}
// 搜索
@ -192,8 +191,8 @@ class Index extends Component {
project_type: undefined,
sort: "updated_on"
})
const { limit, sort, category_id , languageId } = this.state;
this.getListData(1, limit, value, sort, undefined, category_id , languageId);
const {sort, category_id , languageId } = this.state;
this.getListData(1,value, sort, undefined, category_id , languageId);
}
changeSearchValue = (e) => {
this.setState({
@ -205,8 +204,8 @@ class Index extends Component {
this.setState({
page
})
const { limit, search, sort, project_type, category_id , languageId } = this.state;
this.getListData(page, limit, search, sort, project_type, category_id , languageId);
const {search, sort, project_type, category_id , languageId } = this.state;
this.getListData(page,search, sort, project_type, category_id , languageId);
}
getoDetail=(login,identifier)=>{
@ -219,8 +218,8 @@ class Index extends Component {
isSpin:true,
languageId:e === 0 ?undefined:e
})
const { page, limit, sort , project_type , category_id } = this.state;
this.getListData(page, limit, undefined, sort, project_type, category_id ,e === 0 ?undefined:e);
const { page,sort , project_type , category_id } = this.state;
this.getListData(page, undefined, sort, project_type, category_id ,e === 0 ?undefined:e);
}
menu =()=> {
@ -329,7 +328,7 @@ class Index extends Component {
</Popover>
</div>
</div>
<ListItem {...this.props} {...this.state} projects={projectsList}></ListItem>
<ListItem {...this.props} {...this.state} projects={projectsList} getListData={this.getListData}></ListItem>
{this.pagination(total,limit,page)}
</Spin>
</div>

View File

@ -71,4 +71,16 @@
text-align: right;
}
}
}
.singleBtn{
display: inline-block;
.ant-upload-list-item{
position: absolute;
bottom: 0px;
width: 100%;
left: 0px;
.ant-upload-list-item-name{
text-align: left;
}
}
}

View File

@ -6,23 +6,58 @@ import '../css/index.scss';
import Nodata from '../Nodata';
import './list.css';
import img_parise from '../Images/parise.png';
import SpecialModal from './SpecialModal';
class IndexItem extends Component {
constructor(props){
super(props);
this.state={
visible:false,
user_apply_signatures:[],
project_id:undefined
}
}
TurnToDetail = (login, url) => {
this.props.history.push({
pathname: url,
state: login
})
}
projectHref=(link , user_apply_signatures,project_id,is_secret)=>{
let signa = user_apply_signatures && user_apply_signatures[0];
if(is_secret && (signa && signa.status !== "passed")){
this.setState({
visible:true,
user_apply_signatures:user_apply_signatures.length>0 ? user_apply_signatures[0] : undefined,
project_id
})
}else{
this.props.history.push(link);
}
}
hideModal=()=>{
this.setState({
visible:false
})
}
sureModal=()=>{
this.hideModal();
const { getListData } = this.props;
getListData && getListData(1);
}
render() {
const { projects } = this.props;
const { visible , user_apply_signatures , project_id } = this.state;
const renderList = (
projects && projects.length > 0 ? projects.map((item, key) => {
return (
<div className="p-r-Item" key={key}>
{
item.platform === "educoder" ?
<a href="javascript:void(0)" style={{cursor:"default"}} className="show-user-link">
<a style={{cursor:"default"}} className="show-user-link">
<img className="p-r-photo" alt="" src={item.author && item.author.image_url} ></img>
</a>
:
@ -32,7 +67,7 @@ class IndexItem extends Component {
}
<div className="p-r-Infos">
<div className="p-r-name">
<Link to={`/projects/${item.author.login}/${item.identifier}`} className="hide-1 color-grey-3 font-18 task-hide fwt-500 " style={{ whiteSpace: "wrap", display: 'flex', width: 400 }}>
<a onClick={()=>this.projectHref(`/projects/${item.author.login}/${item.identifier}`,item.user_apply_signatures, item.id,item.is_secret)} className="hide-1 color-grey-3 font-18 task-hide fwt-500 " style={{ whiteSpace: "wrap", display: 'flex', width: 400 }}>
{item.author.name}/{item.name}
{
item.forked_from_project_id ?
@ -51,7 +86,7 @@ class IndexItem extends Component {
<i className="iconfont icon-jingxiang font-18 color-green" />
</span>:""
}
</Link>
</a>
<span className="p-r-tags">
<span className="pariseTag"><img src={img_parise} alt="" className="pariseImg" /> {item.praises_count}</span>
<span><i className="iconfont icon-fork mr3 font-16" style={{ color: "#1B8FFF" }} />fork {item.forked_count}</span>
@ -74,6 +109,7 @@ class IndexItem extends Component {
)
return (
<div className="project-list minH-670">
<SpecialModal {...this.props} visible={visible} hideModal={this.hideModal} user_apply_signatures={user_apply_signatures} project_id={project_id} sureModal={this.sureModal}></SpecialModal>
{renderList}
</div>
)

View File

@ -0,0 +1,45 @@
import React , { useEffect , useState } from 'react';
import { Modal } from 'antd';
import UploadSingle from '../Upload/single';
import './Index.scss';
import axios from 'axios';
import { getUrl } from 'educoder';
function SpecialModal({ visible , hideModal , sureModal , showNotification , user_apply_signatures , project_id }){
const [ id ,setId ] = useState(undefined);
function loadFunc(id){
setId(id);
}
function sure(){
if(!user_apply_signatures || (user_apply_signatures && user_apply_signatures.status !== "waiting")){
const url = `/apply_signatures.json`;
axios.post(url,{
attachment_id:id,
project_id:project_id
}).then(result=>{
if(result && result.data.id){
showNotification("已提交文件,正在等待审核!");
sureModal();
}
})
}else{
sureModal();
}
}
return(
<Modal title="提示" visible={visible} closable={false} onCancel={hideModal} onOk={sure}>
{
!user_apply_signatures || (user_apply_signatures && user_apply_signatures.status !== "waiting") ?
<div style={{width:"420px",textAlign:'center',margin:"0 auto",paddingBottom:"30px",position:"relative"}}>
<div>该项目为私有项目请先<a href={getUrl(`/api/apply_signatures/template_file`)} className="color-blue">下载</a>开源协议,阅读并填写<br/>相关信息后将协议<UploadSingle size={"5"} load={loadFunc} showNotification={showNotification} className={'singleBtn'}><span className="color-blue" style={{cursor:"pointer"}}>上传</span></UploadSingle>,平台审核通过后即可进入当前项目</div>
</div>
:
<p style={{textAlign:'center'}}>您上传的文件正在审核中,通过后才能访问当前项目</p>
}
</Modal>
)
}
export default SpecialModal;

View File

@ -220,6 +220,7 @@
text-align: center;
height: 40px;
line-height: 28px;
border:1px solid transparent;
}
.headerMenu-wrapper{
font-size: 16px;

View File

@ -38,7 +38,9 @@ class Index extends Component {
project_language_name: undefined,
project_category_name: undefined,
license_name: undefined,
ignore_name: undefined
ignore_name: undefined,
licenseForDisabled:undefined
}
}
componentDidMount = () => {
@ -114,7 +116,7 @@ class Index extends Component {
_data = data.filter(item => item.name.toLowerCase().indexOf(name.toLowerCase()) > -1);
}
let list = _data && _data.map((item) => (
<Option key={item.id} value={item.name}>
<Option key={item.id} value={item.name} onClick={()=>this.selectSerect(item.is_secret)}>
{item.name}
</Option>
));
@ -124,6 +126,17 @@ class Index extends Component {
}
}
selectSerect=(flag)=>{
if(flag){
this.props.form.setFieldsValue({
private:true
})
}
this.setState({
licenseForDisabled:flag
})
}
subMitFrom = () => {
this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
@ -168,7 +181,8 @@ class Index extends Component {
}
ChangePlatform = (value, e, name, list) => {
this.setOptionsList(list, name, value)
this.setOptionsList(list, name, value);
this.setState({
[name + "_id"]: e.key,
[name + "_name"]: value,
@ -249,6 +263,7 @@ class Index extends Component {
project_category_list,
license_list,
ignore_list,
licenseForDisabled,
mirrorCheck
} = this.state;
@ -434,8 +449,8 @@ class Index extends Component {
style={{ margin: "0px" }}
className="privatePart"
>
{getFieldDecorator('private')(
<Checkbox value="limit">将项目设为私有<span className="ml15 font-13 color-grey-9">(只有项目所有人或拥有权限的项目成员才能看到)</span></Checkbox>
{getFieldDecorator('private',{valuePropName:"checked"})(
<Checkbox value="limit" disabled={licenseForDisabled}>将项目设为私有<span className="ml15 font-13 color-grey-9">(只有项目所有人或拥有权限的项目成员才能看到)</span></Checkbox>
)}
</Form.Item >
{

View File

@ -290,8 +290,10 @@ class Collaborator extends Component {
return "text-green";
} else if (role === "Developer") {
return "text-primary";
} else {
} else if(role === "Reporter"){
return "text-yellow";
}else{
return "text-gray";
}
};
const member_roles = (item) => {
@ -302,7 +304,11 @@ class Collaborator extends Component {
<label className={get_color(item.role)}>
{operation && operation[0].name}
</label>
) : (
) :
item.is_apply_signature ?
<label className="text-grey">外围贡献者</label>
:
(
<Dropdown overlay={setRoles(`${item.id}`)} placement={"bottomCenter"}>
<span className={get_color(item.role)}>
{operation && operation[0].name}

View File

@ -15,6 +15,7 @@ class Setting extends Component {
CategoryList: undefined,
LanguageList: undefined,
private_check: undefined,
is_secret:false
};
}
@ -52,10 +53,11 @@ class Setting extends Component {
.then((result) => {
if (result) {
this.props.form.setFieldsValue({
...result.data,
...result.data
});
this.setState({
private_check: result.data.private,
is_secret:result.data.is_secret
});
}
})
@ -152,7 +154,7 @@ class Setting extends Component {
render() {
const { getFieldDecorator } = this.props.form;
const { CategoryList, LanguageList, private_check } = this.state;
const { CategoryList, LanguageList, private_check , is_secret } = this.state;
return (
<div>
<WhiteBack style={{paddingBottom:"20px"}}>
@ -177,6 +179,7 @@ class Setting extends Component {
<Checkbox
checked={private_check}
onChange={this.changePrivate}
disabled={is_secret}
>
将仓库设为私有
</Checkbox>

View File

@ -151,6 +151,9 @@
.text-yellow{color: #FF6E21 !important;}
.text-delete{color: #BBBBBB; }
.text-delete:hover{color: #db2828; }
.text-grey{
color: #999;
}
.new-tag-div{
padding: 15px;
height: 75px;

View File

@ -1,5 +1,5 @@
import React, { Component } from "react";
import { Upload, Button, Icon } from 'antd';
import { Upload , Icon } from 'antd';
import { getUploadActionUrl, appendFileSizeToUploadFileAll } from 'educoder';
import axios from 'axios';
@ -45,8 +45,7 @@ class Index extends Component {
deleteAttachment = (file) => {
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
axios.delete(url, {
}).then((response) => {
axios.delete(url).then((response) => {
if (response.data) {
if (response.data.status === 0) {
this.setState((state) => {

View File

@ -0,0 +1,78 @@
import React, { useEffect , useState } from "react";
import { Upload } from 'antd';
import { getUploadActionUrl, appendFileSizeToUploadFileAll } from 'educoder';
import axios from 'axios';
function Single({ children , showNotification , className , load , size }) {
const [ fileList , setFileList ] = useState(undefined);
//
function onAttachmentRemove(file){
if (!file.percent || file.percent === 100) {
deleteAttachment(file);
return false;
}
}
function deleteAttachment(file){
let uid = file.response ? file.response.id : file.uid;
const url = `/attachments/${uid}.json`
axios.delete(url).then((response) => {
if (response.data && response.data.status === 0) {
let list = fileList.filter(item=> item.response && item.response.id !== uid);
setFileList(list);
fileIdList(list);
}
}).catch(error=>{});
}
function handleChange(info){
if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
let fileList = [info.file];
let list = appendFileSizeToUploadFileAll(fileList);
setFileList(list);
if ( info.file.status === 'done') {
let f = info.fileList && info.fileList.length>0 && info.fileList[info.fileList.length-1];
if(f && f.response && f.response.status === -1){
showNotification(f.response.message)
setFileList(f);
}
fileIdList(fileList);
}
}
}
function fileIdList(fileList){
let l = fileList && fileList.length > 0 && fileList[0];
let array = [l && l.response && l.response.id];
load && load(array);
}
function beforeUpload(file){
if(!size) return;
const isLt100M = file.size / 1024 / 1024 < size;
if (!isLt100M) {
this.props.showNotification(`文件大小必须小于${size}MB!`);
}
return isLt100M;
}
//
const upload = {
name: 'file',
fileList: fileList,
action: `${getUploadActionUrl()}`,
onChange: handleChange,
onRemove: onAttachmentRemove,
beforeUpload: beforeUpload
};
return (
<Upload {...upload} className={className}>
{children}
</Upload>
)
}
export default Single;

View File

@ -1,21 +0,0 @@
1.请求URL https://code.ihub.org.cn/api/v1/mirrors/create.json
2.请求方式: POST
3.参数:
{
"image_url": "xxx.git", #必填,且后缀必为.git,
"language": "Ruby", #必填,如数据库不存在,则会创建新的记录
}
4. 返回值: {
"status": 1,
"message": "同步成功项目ID===1806"
}
5. 返回值说明: 仅有当有返回值且返回值的status 的值为1 才是创建成功,其余均为创建失败

View File

@ -62,6 +62,9 @@
.text-yellow{
color: #FFA802 !important
}
.text-grey{
color: #999;
}
.text-gray {
color: #888888;
}

View File

@ -159,7 +159,7 @@ form{
background-color: #fff;
.list-affix{
min-height: 20px;
max-height: 60vh;
max-height: 180px;
overflow-y: auto;
}
& li{