mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-19 04:26:39 +00:00
@@ -69,10 +69,10 @@ export default defineConfig({
|
||||
component: './Workload/Deployment',
|
||||
},
|
||||
{
|
||||
name: 'Task',
|
||||
name: 'Containerized',
|
||||
icon: 'smile',
|
||||
path: '/Workload/Task',
|
||||
component: './Workload/Task',
|
||||
path: '/Workload/Containerized',
|
||||
component: './Workload/Containerized',
|
||||
},
|
||||
{
|
||||
name: 'Detail',
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// function getFakeCaptcha(req, res) {
|
||||
// return res.json("captcha-xxx");
|
||||
// } // 代码中会兼容本地 service mock 以及部署站点的静态数据
|
||||
|
||||
export default {
|
||||
// 支持值为 Object 和 Array
|
||||
'GET /api/envs/default/apps': [
|
||||
{
|
||||
created: '2020-08-13 14:53:02 +0800 CST',
|
||||
name: 'poc2040',
|
||||
status: 'UNKNOWN',
|
||||
traits: ['manualscaler'],
|
||||
workload: 'ContainerizedWorkload',
|
||||
},
|
||||
{
|
||||
created: '2020-08-13 14:53:02 +0800 CST',
|
||||
name: 'poc2042',
|
||||
status: 'True',
|
||||
traits: ['manualscaler', 'manualscaler1'],
|
||||
workload: 'ContainerizedWorkload',
|
||||
},
|
||||
{
|
||||
created: '2020-08-13 14:53:02 +0800 CST',
|
||||
name: 'poc2042',
|
||||
status: 'False',
|
||||
traits: ['manualscaler', 'manualscaler1'],
|
||||
workload: 'ContainerizedWorkload',
|
||||
},
|
||||
],
|
||||
};
|
||||
Generated
-27415
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,84 @@
|
||||
import { Menu, Dropdown, Button, message } from 'antd';
|
||||
import { DownOutlined } from '@ant-design/icons';
|
||||
import React from 'react';
|
||||
import { connect } from 'dva';
|
||||
|
||||
@connect(() => ({}))
|
||||
export default class WorkSpaceDropDown extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
workSpaceName: '',
|
||||
envs: [],
|
||||
};
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
const envs = await this.props.dispatch({
|
||||
type: 'envs/getEnvs', // applist对应models层的命名空间namespace
|
||||
});
|
||||
if (envs) {
|
||||
const { name = 'test' } = envs.find((a) => {
|
||||
return a.current === '*';
|
||||
});
|
||||
this.setState({
|
||||
envs,
|
||||
workSpaceName: name,
|
||||
});
|
||||
this.props.dispatch({
|
||||
type: 'globalData/currentEnv',
|
||||
payload: {
|
||||
currentEnv: name,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
handleMenuClick = async (e) => {
|
||||
// 发送切换envs的接口
|
||||
const switchResult = await this.props.dispatch({
|
||||
type: 'envs/switchEnv',
|
||||
payload: {
|
||||
currentEnv: e.key,
|
||||
},
|
||||
});
|
||||
if (switchResult) {
|
||||
message.success(switchResult);
|
||||
}
|
||||
this.setState(
|
||||
{
|
||||
workSpaceName: e.key,
|
||||
},
|
||||
() => {
|
||||
// 值切换存储
|
||||
this.props.dispatch({
|
||||
type: 'globalData/currentEnv',
|
||||
payload: {
|
||||
currentEnv: e.key,
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const menu = (
|
||||
<Menu onClick={this.handleMenuClick}>
|
||||
{/* <Menu.Item key="default">default</Menu.Item>
|
||||
<Menu.Item key="am-system">oam-system</Menu.Item>
|
||||
<Menu.Item key="linkerd">linkerd</Menu.Item>
|
||||
<Menu.Item key="rio-system">rio-system</Menu.Item> */}
|
||||
{this.state.envs.map((item) => {
|
||||
return <Menu.Item key={item.name}>{item.name}</Menu.Item>;
|
||||
})}
|
||||
</Menu>
|
||||
);
|
||||
return (
|
||||
<Dropdown overlay={menu}>
|
||||
<Button style={{ marginTop: '10px' }}>
|
||||
{this.state.workSpaceName} <DownOutlined />
|
||||
</Button>
|
||||
</Dropdown>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user