23e878501ae5532d1b053a60078a79786b69df86
[osm/riftware.git] /
1 /*
2  * STANDARD_RIFT_IO_COPYRIGHT
3  */
4
5 import AppHeader from 'widgets/header/header.jsx';
6 import ConfigAgentAccount from './configAgentAccount.jsx';
7 import ConfigAgentAccountStore from './configAgentAccountStore';
8 import AccountSidebar from '../account_sidebar/accountSidebar.jsx';
9 import React from 'react';
10 import '../launchpad_cloud_account/cloud-account.css';
11 export default class LaunchpadConfigAgentAccount extends React.Component {
12     constructor(props) {
13         super(props);
14         this.configName = this.props.routeParams.name;
15         this.state = ConfigAgentAccountStore.getState();
16         ConfigAgentAccountStore.getCatalog();
17         ConfigAgentAccountStore.listen(this.updateState);
18         if(this.configName && this.configName != 'create') {
19             ConfigAgentAccountStore.getConfigAgentAccount(this.configName)
20             this.state.isEdit = true;
21         } else {
22             this.state.isLoading = false;
23             this.state.isEdit = false;
24         }
25     }
26     componentWillReceiveProps(props) {
27         let cn = props.routeParams.name;
28         if(cn && (cn != 'create')) {
29             this.sdnName = cn;
30             ConfigAgentAccountStore.getConfigAgentAccount(this.configName);
31             this.setState({isEdit: true});
32         } else {
33             ConfigAgentAccountStore.resetAccount();
34             this.setState({isEdit: false});
35         }
36     }
37     componentWillMount() {
38         ConfigAgentAccountStore.resetAccount();
39     }
40     componentWillUnmount() {
41         ConfigAgentAccountStore.unlisten(this.updateState);
42     }
43     updateState = (state) => {
44         this.setState(state);
45     }
46     render() {
47         let html;
48         let body;
49         let title = "Launchpad: Add Config Agent Account";
50         if (this.props.edit) {
51             title = "Launchpad: Edit Config Agent Account";
52         }
53         if (this.props.isDashboard) {
54             body = (<div>Edit or Create a New Accounts</div>);
55         } else {
56              body = <ConfigAgentAccount {...this.props}  edit={this.state.isEdit} />
57         }
58         html = (<div>
59                   <AppHeader title={title} isLoading={this.state.isLoading} />
60                     <div className="flex">
61                       <AccountSidebar/>
62                       {body}
63                     </div>
64               </div>);
65         return html;
66     }
67 }