add import repo 30%

dev
Bosn 7 years ago
parent a8a3e240c3
commit 3acb5caf32

@ -2,6 +2,10 @@ export const addRepository = (repository, onResolved) => ({ type: 'REPOSITORY_AD
export const addRepositorySucceeded = (repository) => ({ type: 'REPOSITORY_ADD_SUCCEEDED', repository })
export const addRepositoryFailed = (message) => ({ type: 'REPOSITORY_ADD_FAILED', message })
export const importRepository = (data, onResolved) => { { type: 'REPOSITORY_IMPORT', onResolved } }
export const importRepositorySucceeded = () => ({ type: 'REPOSITORY_IMPORT_SUCCEEDED' })
export const importRepositoryFailed = (message) => ({ type: 'REPOSITORY_IMPORT_FAILED', message })
export const updateRepository = (repository, onResolved) => ({ type: 'REPOSITORY_UPDATE', repository, onResolved })
export const updateRepositorySucceeded = (repository) => ({ type: 'REPOSITORY_UPDATE_SUCCEEDED', repository })
export const updateRepositoryFailed = (message) => ({ type: 'REPOSITORY_UPDATE_FAILED', message })

@ -0,0 +1,77 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { Link } from 'react-router-dom'
import RadioList from '../utils/RadioList'
import { SmartTextarea } from '../utils'
import './ImportRepositoryForm.css'
class ImportRepositoryForm extends Component {
static contextTypes = {
rmodal: PropTypes.object.isRequired
}
static propTypes = {
orgId: PropTypes.number.isRequired
}
constructor (props) {
super(props)
this.state = {
orgId: props.orgId,
version: 1
}
}
render () {
const { rmodal } = this.context
return (
<section className='ImportRepositoryForm'>
<div className='rmodal-header'>
<span className='rmodal-title'>{this.props.title}</span>
</div>
<form className='form-horizontal' onSubmit={this.handleSubmit} >
<div className='rmodal-body'>
<div className='form-group row'>
<label className='col-sm-2 control-label'>版本</label>
<div className='col-sm-10'>
<RadioList data={[{ 'label': 'RAP1', 'value': 1 }, { 'label': 'RAP2(开发中...)', 'value': 2 }]}
curVal={this.state.version} name='version' disabled />
</div>
</div>
<div>
<div className='form-group row'>
<label className='col-sm-2 control-label'>文档URL</label>
<div className='col-sm-10'>
<input name='projectId' value={this.state.projectId} onChange={e => this.setState({ projectId: e.target.value })}
className='form-control' placeholder='如' spellCheck='false' autoFocus='true'
required data-parsley-maxlength='256' />
</div>
</div>
<div className='form-group row mb0'>
<label className='col-sm-2 control-label' />
<div className='col-sm-10'>
<button type='submit' className='btn btn-success w140 mr20'>提交</button>
<Link to='' onClick={e => { e.preventDefault(); rmodal.close() }} className='mr10'>取消</Link>
</div>
</div>
</div>
</div>
</form>
</section>
)
}
componentDidUpdate () {
this.context.rmodal.reposition()
}
handleSubmit = (e) => {
console.log(this.state)
e.preventDefault()
}
}
//
const mapStateToProps = (state) => ({
})
const mapDispatchToProps = ({})
export default connect(
mapStateToProps,
mapDispatchToProps
)(ImportRepositoryForm)

@ -0,0 +1,3 @@
.ImportRepositoryForm
.rmodal-body
width: 800px;

@ -4,9 +4,10 @@ import { Spin, RModal, Pagination } from '../utils'
import RepositoryList from './RepositoryList'
import RepositoryForm from './RepositoryForm'
import ImportRepositoryForm from './ImportRepositoryForm'
import { addRepository, updateRepository, deleteRepository } from '../../actions/repository'
import { GoRepo } from 'react-icons/lib/go'
import { GoRepo, GoMoveRight } from 'react-icons/lib/go'
export const contextTypes = {
store: PropTypes.object
@ -43,7 +44,10 @@ export class CreateButton extends Component {
}
constructor (props) {
super(props)
this.state = { create: !!props.create }
this.state = {
create: !!props.create,
import: !!props.import
}
}
render () {
let { organization } = this.props
@ -53,9 +57,15 @@ export class CreateButton extends Component {
<button className='RepositoryCreateButton btn btn-success' onClick={e => this.setState({ create: true })}>
<GoRepo /> 新建仓库
</button>
<button className='RepositoryCreateButton btn btn-secondary ml8' onClick={e => this.setState({ import: true })}>
<GoMoveRight /> 导入仓库
</button>
<RModal when={this.state.create} onClose={e => this.setState({ create: false })} onResolve={this.handleUpdate}>
<RepositoryForm title='新建仓库' organization={organization} />
</RModal>
<RModal when={this.state.import} onClose={e => this.setState({ import: false })} onResolve={this.handleUpdate}>
<ImportRepositoryForm title='导入仓库' orgId={organization.id} />
</RModal>
</span>
)
}

@ -14,8 +14,10 @@ class RadioList extends React.Component {
}
handleChange (e) {
this.setState({ curVal: e.target.value === 'true' })
this.props.onChange(e.target.value)
if (e.target.value !== this.state.curVal) {
this.setState({ curVal: e.target.value })
this.props.onChange && this.props.onChange(e.target.value)
}
}
render () {
@ -24,9 +26,9 @@ class RadioList extends React.Component {
<div className='ctl-radio-list'>
{
this.props.data.map(item =>
<label className='label' key={item.value}>
<input className='input'type='radio' name={that.props.name} value={item.value}
checked={this.state.curVal === item.value} onChange={e => that.handleChange(e)} />
<label className='label mr8' key={item.value}>
<input className='input' type='radio' name={that.props.name} value={item.value} disabled={that.props.disabled}
checked={this.state.curVal == item.value} data-log={typeof this.state.curVal + '|' + typeof item.value} onChange={e => that.handleChange(e)} />
{item.label}
</label>)
}

Loading…
Cancel
Save