diff --git a/spug_web/src/pages/deploy/request/Ext1Form.js b/spug_web/src/pages/deploy/request/Ext1Form.js index 8d0001e..cc75eb1 100644 --- a/spug_web/src/pages/deploy/request/Ext1Form.js +++ b/spug_web/src/pages/deploy/request/Ext1Form.js @@ -1,6 +1,6 @@ import React from 'react'; import { observer } from 'mobx-react'; -import { Modal, Form, Input, Select, Col, Button, Tag, message } from 'antd'; +import { Modal, Form, Input, Select, Col, Button, Tag, Icon, message } from 'antd'; import hostStore from 'pages/host/store'; import http from 'libs/http'; import store from './store'; @@ -36,21 +36,30 @@ class Ext1Form extends React.Component { _initExtra1 = () => { const {git_type, versions: {branches, tags}} = this.state; - let extra1 = undefined; + let [extra1, extra2] = [undefined, undefined]; if (git_type === 'branch') { if (branches) { - extra1 = lds.get(Object.keys(branches), 0) + extra1 = lds.get(Object.keys(branches), 0); + extra2 = lds.get(branches[extra1], '0.id') } } else { if (tags) { extra1 = lds.get(Object.keys(tags), 0) } } - this.setState({extra1}) + this.setState({extra1, extra2}) }; switchType = (v) => { - this.setState({git_type: v}, this._initExtra1) + this.setState({git_type: v, extra1: null}, this._initExtra1) + }; + + switchExtra1 = (v) => { + let {git_type, extra2, versions: {branches}} = this.state; + if (git_type === 'branch') { + extra2 = lds.get(branches[v], '0.id') + } + this.setState({extra1: v, extra2}) }; handleSubmit = () => { @@ -69,7 +78,7 @@ class Ext1Form extends React.Component { }, () => this.setState({loading: false})) }; - handleChange = (id, v) => { + handleChange = (id) => { const host_ids = this.state.host_ids; const index = host_ids.indexOf(id); if (index === -1) { @@ -82,7 +91,7 @@ class Ext1Form extends React.Component { render() { const info = store.record; - const {host_ids, git_type, extra1, fetching, versions: {branches, tags}} = this.state; + const {host_ids, git_type, extra1, extra2, fetching, versions: {branches, tags}} = this.state; const {getFieldDecorator} = this.props.form; return ( Branch Tag - {git_type === 'branch' ? ( Object.keys(branches || {}).map(b => {b}) ) : ( @@ -122,20 +126,20 @@ class Ext1Form extends React.Component { - - + + {fetching ? : + + } {git_type === 'branch' && ( - {getFieldDecorator('extra2')( - - )} + )} @@ -145,7 +149,7 @@ class Ext1Form extends React.Component { {info['host_ids'].map(id => ( - this.handleChange(id, v)}> + this.handleChange(id)}> {lds.get(hostStore.idMap, `${id}.name`)}({lds.get(hostStore.idMap, `${id}.hostname`)}:{lds.get(hostStore.idMap, `${id}.port`)}) ))}