fix issues

pull/330/head
vapao 2021-06-03 16:37:14 +08:00
parent 5f828b30ad
commit 7750e40069
7 changed files with 15 additions and 133 deletions

View File

@ -1,6 +1,7 @@
import React, { useState, useEffect } from 'react';
import { observer } from 'mobx-react';
import { Drawer, Descriptions, Table, Button } from 'antd';
import { AuthDiv } from 'components';
import { http } from 'libs';
import store from './store';
@ -35,10 +36,12 @@ export default observer(function (props) {
visible={props.visible}
onClose={() => store.detailVisible = false}
footer={(
<div style={{display: 'flex', justifyContent: 'flex-end', alignItems: 'flex-end'}}>
<AuthDiv
auth="deploy.repository.del"
style={{display: 'flex', justifyContent: 'flex-end', alignItems: 'flex-end'}}>
<span style={{color: '#999', fontSize: 12}}>Tips: 已关联发布申请的构建版本无法删除</span>
<Button danger loading={loading} disabled={requests.length > 0} onClick={handleDelete}>删除</Button>
</div>
</AuthDiv>
)}>
<Descriptions column={1} title={<span style={{fontSize: 22}}>基本信息</span>}>
<Descriptions.Item label="应用">{record.app_name}</Descriptions.Item>

View File

@ -45,7 +45,7 @@ function ComTable() {
onReload={store.fetchRecords}
actions={[
<AuthButton
auth="config.env.add"
auth="deploy.repository.add"
type="primary"
icon={<PlusOutlined/>}
onClick={store.showForm}>新建</AuthButton>
@ -68,12 +68,12 @@ function ComTable() {
{hasPermission('deploy.repository.detail|deploy.repository.build|deploy.repository.log') && (
<Table.Column width={180} title="操作" render={info => (
<Action>
<Action.Button auth="deploy.repository.detail" onClick={() => store.showDetail(info)}>详情</Action.Button>
<Action.Button auth="deploy.repository.view" onClick={() => store.showDetail(info)}>详情</Action.Button>
<Action.Button
auth="deploy.repository.build"
loading={loading === info.id}
onClick={() => handleRebuild(info)}>构建</Action.Button>
<Action.Button auth="deploy.repository.log" onClick={() => store.showConsole(info)}>日志</Action.Button>
<Action.Button auth="deploy.repository.build" onClick={() => store.showConsole(info)}>日志</Action.Button>
</Action>
)}/>
)}

View File

@ -52,7 +52,7 @@ export default observer(function () {
return (
<Modal
visible
width={600}
width={700}
maskClosable={false}
title={`${store.record.id ? '编辑' : '新建'}发布申请`}
onCancel={() => store.ext1Visible = false}

View File

@ -73,7 +73,7 @@ export default observer(function () {
return (
<Modal
visible
width={600}
width={700}
maskClosable={false}
title={`${store.record.id ? '编辑' : '新建'}发布申请`}
onCancel={() => store.ext2Visible = false}

View File

@ -44,6 +44,8 @@ export default observer(function (props) {
<Table
rowKey="id"
dataSource={props.app_host_ids.map(id => ({id}))}
pagination={false}
scroll={{y: 480}}
onRow={record => {
return {
onClick: () => handleClickRow(record)

View File

@ -1,123 +0,0 @@
/**
* Copyright (c) OpenSpug Organization. https://github.com/openspug/spug
* Copyright (c) <spug.dev@gmail.com>
* Released under the AGPL-3.0 License.
*/
import React from 'react';
import { observer } from 'mobx-react';
import { SyncOutlined } from '@ant-design/icons';
import { Modal, Table, Input, Button, Select } from 'antd';
import { SearchForm } from 'components';
import store from '../../host/store';
@observer
class HostSelector extends React.Component {
constructor(props) {
super(props);
this.state = {
selectedRows: []
}
}
componentDidMount() {
if (store.records.length === 0) {
store.fetchRecords()
}
}
handleClick = (record) => {
const {selectedRows} = this.state;
const index = selectedRows.indexOf(record);
if (index > -1) {
selectedRows.splice(index, 1)
} else {
selectedRows.push(record)
}
this.setState({selectedRows});
};
handleSubmit = () => {
this.props.onOk(this.state.selectedRows);
this.props.onCancel()
};
columns = [{
title: '类别',
dataIndex: 'zone',
}, {
title: '主机名称',
dataIndex: 'name',
ellipsis: true
}, {
title: '连接地址',
dataIndex: 'hostname',
}, {
title: '端口',
dataIndex: 'port'
}, {
title: '备注',
dataIndex: 'desc',
ellipsis: true
}];
render() {
const {selectedRows} = this.state;
let data = store.permRecords;
if (store.f_name) {
data = data.filter(item => item['name'].toLowerCase().includes(store.f_name.toLowerCase()))
}
if (store.f_zone) {
data = data.filter(item => item['zone'].toLowerCase().includes(store.f_zone.toLowerCase()))
}
const dataIds = data.map(x => x.id);
return (
<Modal
visible
width={1000}
title="选择执行主机"
onCancel={this.props.onCancel}
onOk={this.handleSubmit}
maskClosable={false}>
<SearchForm>
<SearchForm.Item span={8} title="主机类别">
<Select allowClear placeholder="请选择" value={store.f_zone} onChange={v => store.f_zone = v}>
{store.zones.map(item => (
<Select.Option value={item} key={item}>{item}</Select.Option>
))}
</Select>
</SearchForm.Item>
<SearchForm.Item span={8} title="主机别名">
<Input allowClear value={store.f_name} onChange={e => store.f_name = e.target.value} placeholder="请输入"/>
</SearchForm.Item>
<SearchForm.Item span={4} title="已选">
{selectedRows.length}
</SearchForm.Item>
<SearchForm.Item span={4}>
<Button type="primary" icon={<SyncOutlined />} onClick={store.fetchRecords}>刷新</Button>
</SearchForm.Item>
</SearchForm>
<Table
rowKey="id"
rowSelection={{
selectedRowKeys: selectedRows.map(item => item.id),
onChange: (_, rows) => {
let tmp = selectedRows.filter(x => !dataIds.includes(x.id))
this.setState({selectedRows: tmp.concat(rows)})
}
}}
dataSource={data}
loading={store.isFetching}
onRow={record => {
return {
onClick: () => this.handleClick(record)
}
}}
pagination={false}
scroll={{y: 480}}
columns={this.columns}/>
</Modal>
)
}
}
export default HostSelector

View File

@ -73,9 +73,9 @@ export default [{
label: '构建仓库',
perms: [
{key: 'view', label: '查看构建'},
{key: 'detail', label: '构建详情'},
{key: 'build', label: '构建仓库'},
{key: 'log', label: '构建日志'},
{key: 'add', label: '新建版本'},
{key: 'build', label: '执行构建'},
{key: 'del', label: '删除版本'},
]
},{
key: 'request',