mirror of https://github.com/openspug/spug
A web update
parent
19bd5a11cc
commit
550c74ae89
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { observer } from 'mobx-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 hostStore from 'pages/host/store';
|
||||||
import http from 'libs/http';
|
import http from 'libs/http';
|
||||||
import store from './store';
|
import store from './store';
|
||||||
|
@ -36,21 +36,30 @@ class Ext1Form extends React.Component {
|
||||||
|
|
||||||
_initExtra1 = () => {
|
_initExtra1 = () => {
|
||||||
const {git_type, versions: {branches, tags}} = this.state;
|
const {git_type, versions: {branches, tags}} = this.state;
|
||||||
let extra1 = undefined;
|
let [extra1, extra2] = [undefined, undefined];
|
||||||
if (git_type === 'branch') {
|
if (git_type === 'branch') {
|
||||||
if (branches) {
|
if (branches) {
|
||||||
extra1 = lds.get(Object.keys(branches), 0)
|
extra1 = lds.get(Object.keys(branches), 0);
|
||||||
|
extra2 = lds.get(branches[extra1], '0.id')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tags) {
|
if (tags) {
|
||||||
extra1 = lds.get(Object.keys(tags), 0)
|
extra1 = lds.get(Object.keys(tags), 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.setState({extra1})
|
this.setState({extra1, extra2})
|
||||||
};
|
};
|
||||||
|
|
||||||
switchType = (v) => {
|
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 = () => {
|
handleSubmit = () => {
|
||||||
|
@ -69,7 +78,7 @@ class Ext1Form extends React.Component {
|
||||||
}, () => this.setState({loading: false}))
|
}, () => this.setState({loading: false}))
|
||||||
};
|
};
|
||||||
|
|
||||||
handleChange = (id, v) => {
|
handleChange = (id) => {
|
||||||
const host_ids = this.state.host_ids;
|
const host_ids = this.state.host_ids;
|
||||||
const index = host_ids.indexOf(id);
|
const index = host_ids.indexOf(id);
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
|
@ -82,7 +91,7 @@ class Ext1Form extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const info = store.record;
|
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;
|
const {getFieldDecorator} = this.props.form;
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
|
@ -106,12 +115,7 @@ class Ext1Form extends React.Component {
|
||||||
<Select.Option value="branch">Branch</Select.Option>
|
<Select.Option value="branch">Branch</Select.Option>
|
||||||
<Select.Option value="tag">Tag</Select.Option>
|
<Select.Option value="tag">Tag</Select.Option>
|
||||||
</Select>
|
</Select>
|
||||||
<Select
|
<Select style={{width: 320}} placeholder="请稍等" value={extra1} onChange={this.switchExtra1}>
|
||||||
value={extra1}
|
|
||||||
style={{width: 320}}
|
|
||||||
loading={fetching}
|
|
||||||
placeholder="请稍等"
|
|
||||||
onChange={v => this.setState({extra1: v})}>
|
|
||||||
{git_type === 'branch' ? (
|
{git_type === 'branch' ? (
|
||||||
Object.keys(branches || {}).map(b => <Select.Option key={b} value={b}>{b}</Select.Option>)
|
Object.keys(branches || {}).map(b => <Select.Option key={b} value={b}>{b}</Select.Option>)
|
||||||
) : (
|
) : (
|
||||||
|
@ -122,20 +126,20 @@ class Ext1Form extends React.Component {
|
||||||
</Select>
|
</Select>
|
||||||
</Input.Group>
|
</Input.Group>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={4} offset={1}>
|
<Col span={4} offset={1} style={{textAlign: 'center'}}>
|
||||||
<Button type="link" icon="sync" disabled={fetching} onClick={this.fetchVersions}>刷新</Button>
|
{fetching ? <Icon type="loading" style={{fontSize: 18, color: '#1890ff'}}/> :
|
||||||
|
<Button type="link" icon="sync" disabled={fetching} onClick={this.fetchVersions}>刷新</Button>
|
||||||
|
}
|
||||||
</Col>
|
</Col>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
{git_type === 'branch' && (
|
{git_type === 'branch' && (
|
||||||
<Form.Item required label="选择Commit ID">
|
<Form.Item required label="选择Commit ID">
|
||||||
{getFieldDecorator('extra2')(
|
<Select value={extra2} placeholder="请选择" onChange={v => this.setState({extra2: v})}>
|
||||||
<Select placeholder="请选择">
|
{extra1 ? branches[extra1].map(item => (
|
||||||
{extra1 ? branches[extra1].map(item => (
|
<Select.Option
|
||||||
<Select.Option
|
key={item.id}>{item.id.substr(0, 6)} {item['date']} {item['author']} {item['message']}</Select.Option>
|
||||||
key={item.id}>{item.id.substr(0, 6)} {item['date']} {item['author']} {item['message']}</Select.Option>
|
)) : null}
|
||||||
)): null}
|
</Select>
|
||||||
</Select>
|
|
||||||
)}
|
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
<Form.Item label="备注信息">
|
<Form.Item label="备注信息">
|
||||||
|
@ -145,7 +149,7 @@ class Ext1Form extends React.Component {
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item required label="发布目标主机">
|
<Form.Item required label="发布目标主机">
|
||||||
{info['host_ids'].map(id => (
|
{info['host_ids'].map(id => (
|
||||||
<Tag.CheckableTag key={id} checked={host_ids.includes(id)} onChange={v => this.handleChange(id, v)}>
|
<Tag.CheckableTag key={id} checked={host_ids.includes(id)} onChange={() => this.handleChange(id)}>
|
||||||
{lds.get(hostStore.idMap, `${id}.name`)}({lds.get(hostStore.idMap, `${id}.hostname`)}:{lds.get(hostStore.idMap, `${id}.port`)})
|
{lds.get(hostStore.idMap, `${id}.name`)}({lds.get(hostStore.idMap, `${id}.hostname`)}:{lds.get(hostStore.idMap, `${id}.port`)})
|
||||||
</Tag.CheckableTag>
|
</Tag.CheckableTag>
|
||||||
))}
|
))}
|
||||||
|
|
Loading…
Reference in New Issue