diff --git a/spug_web/src/pages/deploy/app/Table.js b/spug_web/src/pages/deploy/app/Table.js
index d7b8a09..4877081 100644
--- a/spug_web/src/pages/deploy/app/Table.js
+++ b/spug_web/src/pages/deploy/app/Table.js
@@ -15,46 +15,33 @@ import {
} from '@ant-design/icons';
import { Table, Modal, Tag, Divider, message } from 'antd';
import { http, hasPermission } from 'libs';
-import store from './store';
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';
-@observer
-class ComTable extends React.Component {
- constructor(props) {
- super(props);
- this.cloneObj = null;
- }
-
- componentDidMount() {
- store.fetchRecords();
- if (envStore.records.length === 0) {
- envStore.fetchRecords()
- }
- }
-
- handleClone = (e, id) => {
+function ComTable() {
+ function handleClone(e, id) {
e.stopPropagation();
- this.cloneObj = null;
+ let cloneObj = null;
Modal.confirm({
icon: ,
title: '选择克隆对象',
- content: this.cloneObj = v[1]}/>,
+ content: cloneObj = v[1]}/>,
onOk: () => {
- if (!this.cloneObj) {
+ if (!cloneObj) {
message.error('请选择目标应用及环境')
return Promise.reject()
}
- const info = JSON.parse(this.cloneObj);
+ const info = JSON.parse(cloneObj);
info.env_id = undefined;
store.showExtForm(null, id, info, true)
},
})
- };
+ }
- handleDelete = (e, text) => {
+ function handleDelete(e, text) {
e.stopPropagation();
Modal.confirm({
title: '删除确认',
@@ -67,9 +54,9 @@ class ComTable extends React.Component {
})
}
})
- };
+ }
- handleDeployDelete = (text) => {
+ function handleDeployDelete(text) {
Modal.confirm({
title: '删除确认',
content: `删除发布配置将会影响基于该配置所创建发布申请的发布和回滚功能,确定要删除【${lds.get(envStore.idMap, `${text.env_id}.name`)}】的发布配置?`,
@@ -81,20 +68,22 @@ class ComTable extends React.Component {
})
}
})
- };
+ }
- handleSort = (e, info, sort) => {
+ function handleSort(e, info, sort) {
e.stopPropagation();
store.fetching = true;
http.patch('/api/app/', {id: info.id, sort})
.then(store.fetchRecords, () => store.fetching = false)
- };
+ }
- expandedRowRender = (record) => {
- if (!record.isLoaded) {
- store.loadDeploys(record.id)
+ function handleExpand(expanded, row) {
+ if (expanded && !row.isLoaded) {
+ store.loadDeploys(row.id)
}
+ }
+ function expandedRowRender(record) {
return (
store.showExtForm(e, record.id, info, false, true)}>查看
store.showExtForm(e, record.id, info)}>编辑
- this.handleDeployDelete(info)}>删除
+ handleDeployDelete(info)}>删除
)}/>
)}
)
- };
-
- render() {
- return (
- }
- onClick={() => store.showForm()}>新建
- ]}
- pagination={{
- showSizeChanger: true,
- showLessItems: true,
- hideOnSinglePage: true,
- showTotal: total => `共 ${total} 条`,
- pageSizeOptions: ['10', '20', '50', '100']
- }}>
- (
-
-
this.handleSort(e, info, 'up')}
- style={{cursor: 'pointer', color: '#1890ff'}}/>
-
- this.handleSort(e, info, 'down')}
- style={{cursor: 'pointer', color: '#1890ff'}}/>
-
- )}/>
-
-
-
- {hasPermission('deploy.app.edit|deploy.app.del') && (
- (
-
- store.showExtForm(e, info.id)}>新建发布
- this.handleClone(e, info.id)}>克隆发布
- store.showForm(e, info)}>编辑
- this.handleDelete(e, 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 ComTable
+export default observer(ComTable)
diff --git a/spug_web/src/pages/deploy/app/index.js b/spug_web/src/pages/deploy/app/index.js
index 3c66ebc..9c0d193 100644
--- a/spug_web/src/pages/deploy/app/index.js
+++ b/spug_web/src/pages/deploy/app/index.js
@@ -3,7 +3,7 @@
* Copyright (c)
* Released under the AGPL-3.0 License.
*/
-import React from 'react';
+import React, { useEffect } from 'react';
import { observer } from 'mobx-react';
import { Input } from 'antd';
import { SearchForm, AuthDiv, Breadcrumb } from 'components';
@@ -13,8 +13,15 @@ import Ext1Form from './Ext1Form';
import Ext2Form from './Ext2Form';
import AddSelect from './AddSelect';
import store from './store';
+import envStore from 'pages/config/environment/store';
export default observer(function () {
+ useEffect(() => {
+ store.fetchRecords();
+ if (envStore.records.length === 0) {
+ envStore.fetchRecords()
+ }
+ }, [])
return (
diff --git a/spug_web/src/pages/deploy/app/store.js b/spug_web/src/pages/deploy/app/store.js
index 6c84051..96ce5e3 100644
--- a/spug_web/src/pages/deploy/app/store.js
+++ b/spug_web/src/pages/deploy/app/store.js
@@ -5,6 +5,7 @@
*/
import { observable, computed, toJS } from 'mobx';
import http from 'libs/http';
+import lds from 'lodash';
class Store {
@observable records = {};
@@ -40,6 +41,7 @@ class Store {
.then(res => {
const tmp = {};
for (let item of res) {
+ Object.assign(item, lds.pick(this.records[`a${item.id}`], ['isLoaded', 'deploys']));
tmp[`a${item.id}`] = item
}
this.records = tmp