/** * 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 { BuildOutlined, DownSquareOutlined, ExclamationCircleOutlined, OrderedListOutlined, UpSquareOutlined, PlusOutlined } from '@ant-design/icons'; import { Table, Modal, Tag, Divider, message } from 'antd'; import { http, hasPermission } from 'libs'; import { Action, TableCard, AuthButton } from "components"; import CloneConfirm from './CloneConfirm'; import store from './store'; import envStore from 'pages/config/environment/store'; import lds from 'lodash'; function ComTable() { function handleClone(e, id) { e.stopPropagation(); let cloneObj = null; Modal.confirm({ icon: , title: '选择克隆对象', content: cloneObj = v[1]}/>, onOk: () => { if (!cloneObj) { message.error('请选择目标应用及环境') return Promise.reject() } const info = JSON.parse(cloneObj); info.env_id = undefined; store.showExtForm(null, id, info, true) }, }) } function handleDelete(e, text) { e.stopPropagation(); Modal.confirm({ title: '删除确认', content: `确定要删除应用【${text['name']}】?`, onOk: () => { return http.delete('/api/app/', {params: {id: text.id}}) .then(() => { message.success('删除成功'); store.fetchRecords() }) } }) } function handleDeployDelete(text) { Modal.confirm({ title: '删除确认', content: `删除发布配置将会影响基于该配置所创建发布申请的发布和回滚功能,确定要删除【${lds.get(envStore.idMap, `${text.env_id}.name`)}】的发布配置?`, onOk: () => { return http.delete('/api/app/deploy/', {params: {id: text.id}}) .then(() => { message.success('删除成功'); store.loadDeploys(text.app_id) }) } }) } function handleSort(e, info, sort) { e.stopPropagation(); store.fetching = true; http.patch('/api/app/', {id: info.id, sort}) .then(store.fetchRecords, () => store.fetching = false) } function handleExpand(expanded, row) { if (expanded && !row.isLoaded) { store.loadDeploys(row.id) } } function expandedRowRender(record) { return ( value === '1' ? : }/> lds.get(envStore.idMap, `${value}.name`)}/> `${value.length} 台`}/> value ? 开启 : 关闭}/> {hasPermission('deploy.app.config|deploy.app.edit') && ( ( store.showAutoDeploy(info)}>Webhook {hasPermission('deploy.app.edit') ? ( store.showExtForm(e, record.id, info)}>编辑 ) : hasPermission('deploy.app.config') ? ( store.showExtForm(e, record.id, info, false, true)}>查看 ) : null} handleDeployDelete(info)}>删除 )}/> )}
) } return ( } onClick={() => store.showForm()}>新建 ]} pagination={{ showSizeChanger: true, showLessItems: true, hideOnSinglePage: true, showTotal: total => `共 ${total} 条`, pageSizeOptions: ['10', '20', '50', '100'] }}> (
handleSort(e, info, 'up')} style={{cursor: 'pointer', color: '#1890ff'}}/> handleSort(e, info, 'down')} style={{cursor: 'pointer', color: '#1890ff'}}/>
)}/> {hasPermission('deploy.app.edit|deploy.app.del') && ( ( store.showExtForm(e, info.id)}>新建发布 handleClone(e, info.id)}>克隆发布 store.showForm(e, info)}>编辑 handleDelete(e, info)}>删除 )}/> )}
) } export default observer(ComTable)