/**
* Copyright (c) OpenSpug Organization. https://github.com/openspug/spug
* Copyright (c)
* Released under the AGPL-3.0 License.
*/
import React from 'react';
import { observer } from 'mobx-react';
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
import { Form, Input, Button, message, Divider, Alert, Select } from 'antd';
import { ACEditor } from 'components';
import styles from './index.module.css';
import { http, cleanCommand } from 'libs';
import Tips from './Tips';
import store from './store';
import lds from 'lodash';
@observer
class Ext2Setup2 extends React.Component {
constructor(props) {
super(props);
this.helpMap = {
'0': null,
'1': '相对于输入的本地路径的文件路径,仅将匹配到文件传输至要发布的目标主机。',
'2': '支持模糊匹配,如果路径以 / 开头则基于输入的本地路径匹配,匹配到文件将不会被传输。'
}
this.state = {
loading: false,
}
}
handleSubmit = () => {
this.setState({loading: true});
const info = store.deploy;
info['app_id'] = store.app_id;
info['extend'] = '2';
info['host_actions'] = info['host_actions'].filter(x => (x.title && x.data) || (x.title && (x.src || x.src_mode === '1') && x.dst));
info['server_actions'] = info['server_actions'].filter(x => x.title && x.data);
http.post('/api/app/deploy/', info)
.then(res => {
message.success('保存成功');
store.ext2Visible = false;
store.loadDeploys(store.app_id)
}, () => this.setState({loading: false}))
};
render() {
const server_actions = store.deploy['server_actions'];
const host_actions = store.deploy['host_actions'];
return (
,
执行的命令内可以使用发布申请中设置的环境变量 SPUG_RELEASE,一般可用于标记一次发布的版本号或提交ID等,在执行的脚本内通过使用 $SPUG_RELEASE
获取其值来执行相应操作。
,
{Tips}。
]}/>
)}
{server_actions.map((item, index) => (
item['title'] = e.target.value}
placeholder="请输入"/>
item['data'] = cleanCommand(v)}
placeholder="请输入要执行的动作"/>
{!store.isReadOnly && (
server_actions.splice(index, 1)}>
移除
)}
))}
{!store.isReadOnly && (
)}
{host_actions.map((item, index) => (
))}
{!store.isReadOnly && (
)}
)
}
}
export default Ext2Setup2