3 * Copyright 2016 RIFT.IO Inc
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 import React, {Component} from 'react';
19 import DashboardCard from 'widgets/dashboard_card/dashboard_card.jsx'
20 import SshKeyCard from './sshKeyCard.jsx';
21 import SshKeyStore from './sshKeyStore.js';
22 import SkyquakeComponent from 'widgets/skyquake_container/skyquakeComponent.jsx';
23 import '../../node_modules/open-iconic/font/css/open-iconic.css';
24 // import 'style/base.scss';
27 class SshKeys extends Component {
30 this.Store = this.props.flux.stores.hasOwnProperty('SshKeyStore') ? this.props.flux.stores.SshKeyStore : this.props.flux.createStore(SshKeyStore);
31 this.state = this.Store.getState();
32 this.Store.listen(this.handleUpdate);
34 componentWillMount() {
35 this.Store.getSshKey();
37 componentWillUnmount() {
38 this.Store.unlisten(this.handleUpdate);
40 handleUpdate = (state) => {
45 let Store = self.Store;
46 // return <div>test</div>
48 <div className="sshKeyCards">
50 self.state.data && self.state.data.keys.map(function(k, i) {
51 let sshKey = self.state.data.entities[k];
53 <SshKeyCard key={i} name={sshKey.name} value={sshKey.key}
54 editMode={sshKey.isEditable}
55 editKey= {Store.editSshKeyPair(sshKey.name)}
56 updateSshKeyPair={Store.updateSshKeyPair}
57 cancelEditSshKeyPair={Store.cancelEditSshKeyPair}
58 saveEditSshKeyPair={Store.saveEditSshKeyPair}
59 updateEditSshKeyPair={Store.updateEditSshKeyPair}
60 deleteKey={Store.deleteSshKeyPair(sshKey.name)}
65 <SshKeyCard name={this.state.newKey.name} value={ this.state.newKey.key}
67 updateSshKeyPair={Store.updateNewKeyValue}
68 saveEditSshKeyPair={Store.saveEditSshKeyPair}
75 export default SkyquakeComponent(SshKeys);