From 19bd5a11cc01708d95ae011c668b4237b295358e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E4=BA=8C=E7=8C=9B?= Date: Mon, 16 Dec 2019 00:52:06 +0800 Subject: [PATCH] A web update --- spug_web/src/pages/deploy/request/Ext1Form.js | 83 ++++++++++++++++--- 1 file changed, 72 insertions(+), 11 deletions(-) diff --git a/spug_web/src/pages/deploy/request/Ext1Form.js b/spug_web/src/pages/deploy/request/Ext1Form.js index 4fa0bc5..8d0001e 100644 --- a/spug_web/src/pages/deploy/request/Ext1Form.js +++ b/spug_web/src/pages/deploy/request/Ext1Form.js @@ -12,11 +12,47 @@ class Ext1Form extends React.Component { super(props); this.state = { loading: false, - type: null, + fetching: true, + git_type: 'branch', + extra1: undefined, + extra2: undefined, + versions: {}, host_ids: store.record['host_ids'].concat() } } + componentDidMount() { + this.fetchVersions() + } + + fetchVersions = () => { + this.setState({fetching: true}); + http.get(`/api/app/${store.record.id}/versions/`) + .then(res => { + this.setState({versions: res}, this._initExtra1); + }) + .finally(() => this.setState({fetching: false})) + }; + + _initExtra1 = () => { + const {git_type, versions: {branches, tags}} = this.state; + let extra1 = undefined; + if (git_type === 'branch') { + if (branches) { + extra1 = lds.get(Object.keys(branches), 0) + } + } else { + if (tags) { + extra1 = lds.get(Object.keys(tags), 0) + } + } + this.setState({extra1}) + }; + + switchType = (v) => { + this.setState({git_type: v}, this._initExtra1) + }; + handleSubmit = () => { if (this.state.host_ids.length === 0) { return message.error('请至少选择一个要发布的目标主机') @@ -46,7 +82,7 @@ class Ext1Form extends React.Component { render() { const info = store.record; - const {host_ids} = this.state; + const {host_ids, git_type, extra1, fetching, versions: {branches, tags}} = this.state; const {getFieldDecorator} = this.props.form; return ( store.ext1Visible = false} confirmLoading={this.state.loading} onOk={this.handleSubmit}> -
+ {getFieldDecorator('name', {initialValue: info['name']})( )} - + - {getFieldDecorator('name', {initialValue: info['name']})( - + Branch + Tag - )} + + - + + {git_type === 'branch' && ( + + {getFieldDecorator('extra2')( + + )} + + )} {getFieldDecorator('desc', {initialValue: info['desc']})(