Skip to content

Commit

Permalink
style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Apr 29, 2017
1 parent 71500e7 commit a29145e
Show file tree
Hide file tree
Showing 36 changed files with 1,433 additions and 1,426 deletions.
4 changes: 2 additions & 2 deletions client/redux/store.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {createStore, applyMiddleware} from 'redux';
import reducers from './reducers';
import {createStore, applyMiddleware} from 'redux'
import reducers from './reducers'
import {createThunkReplyMiddleware} from 'Redux/middlewares'

export default createStore(
Expand Down
14 changes: 7 additions & 7 deletions client/storage/Favorites.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict';
'use strict'

import Immutable from 'immutable';
import { ipcRenderer } from 'electron';
import Immutable from 'immutable'
import {ipcRenderer} from 'electron'

export function get() {
return JSON.parse(localStorage.getItem('favorites')) || [];
return JSON.parse(localStorage.getItem('favorites')) || []
}

export function set(favorites) {
localStorage.setItem('favorites', JSON.stringify(favorites));
localStorage.setItem('favorites', JSON.stringify(favorites))

ipcRenderer.send('dispatch', 'reloadFavorites');
return favorites;
ipcRenderer.send('dispatch', 'reloadFavorites')
return favorites
}
12 changes: 6 additions & 6 deletions client/storage/Patterns.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';
'use strict'

import Immutable from 'immutable';
import { ipcRenderer } from 'electron';
import Immutable from 'immutable'
import {ipcRenderer} from 'electron'

export function get() {
return JSON.parse(localStorage.getItem('patternStore')) || {}
}

export function set(patterns) {
localStorage.setItem('patternStore', JSON.stringify(patterns));
ipcRenderer.send('dispatch', 'reloadPatternStore');
return patterns;
localStorage.setItem('patternStore', JSON.stringify(patterns))
ipcRenderer.send('dispatch', 'reloadPatternStore')
return patterns
}
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
'use strict';
'use strict'

import React from 'react';
import store from 'Redux/store';
import Immutable from 'immutable';
import {remote} from 'electron';
import fs from 'fs';
import React from 'react'
import store from 'Redux/store'
import Immutable from 'immutable'
import {remote} from 'electron'
import fs from 'fs'

require('./index.scss');
require('./index.scss')

class Config extends React.Component {
constructor() {
super();
super()
this.state = {
data: new Immutable.Map()
};
}
}

getProp(property) {
if (this.state.data.has(property)) {
return this.state.data.get(property);
return this.state.data.get(property)
}
return this.props.favorite ? this.props.favorite.get(property) : '';
return this.props.favorite ? this.props.favorite.get(property) : ''
}

setProp(property, value) {
this.setState({
data: typeof property === 'string' ? this.state.data.set(property, value) : this.state.data.merge(property),
changed: this.props.favorite ? true : false
});
changed: Boolean(this.props.favorite)
})
}

componentWillReceiveProps(nextProps) {
if (!this.props.connect && nextProps.connect) {
this.connect();
this.connect()
}
if (this.props.favorite || nextProps.favorite) {
const leaving = !this.props.favorite || !nextProps.favorite ||
(this.props.favorite.get('key') !== nextProps.favorite.get('key'));
(this.props.favorite.get('key') !== nextProps.favorite.get('key'))
if (leaving) {
this.setState({ changed: false, data: new Immutable.Map() });
this.setState({changed: false, data: new Immutable.Map()})
}
}
}

connect() {
const {favorite, connectToRedis} = this.props
const data = this.state.data;
const config = favorite ? favorite.merge(data).toJS() : data.toJS();
config.host = config.host || 'localhost';
config.port = config.port || '6379';
config.sshPort = config.sshPort || '22';
const data = this.state.data
const config = favorite ? favorite.merge(data).toJS() : data.toJS()
config.host = config.host || 'localhost'
config.port = config.port || '6379'
config.sshPort = config.sshPort || '22'
connectToRedis(config)
this.save();
this.save()
}

handleChange(property, e) {
let value = e.target.value;
let value = e.target.value
if (property === 'ssh' || property === 'ssl') {
value = e.target.checked;
value = e.target.checked
}
this.setProp(property, value);
this.setProp(property, value)
}

duplicate() {
if (this.props.favorite) {
const data = Object.assign(this.props.favorite.toJS(), this.state.data.toJS());
delete data.key;
this.props.onDuplicate(data);
const data = Object.assign(this.props.favorite.toJS(), this.state.data.toJS())
delete data.key
this.props.onDuplicate(data)
} else {
const data = this.state.data.toJS();
const data = this.state.data.toJS()
data.name = 'Quick Connect'
this.props.onDuplicate(data);
this.props.onDuplicate(data)
}
}

save() {
if (this.props.favorite && this.state.changed) {
this.props.onSave(this.state.data.toJS());
this.setState({ changed: false, data: new Immutable.Map() });
this.props.onSave(this.state.data.toJS())
this.setState({changed: false, data: new Immutable.Map()})
}
}

Expand All @@ -94,14 +94,14 @@ class Config extends React.Component {
<button
className={'icon icon-dot-3 ssh-key'}
onClick={() => {
const win = remote.getCurrentWindow();
const win = remote.getCurrentWindow()
const files = remote.require('dialog').showOpenDialog(win, {
properties: ['openFile']
});
})
if (files && files.length) {
const file = files[0];
const content = fs.readFileSync(file, 'utf8');
this.setProp({ [id]: content, [`${id}File`]: file });
const file = files[0]
const content = fs.readFileSync(file, 'utf8')
this.setProp({[id]: content, [`${id}File`]: file})
}
}}
></button>
Expand All @@ -110,8 +110,8 @@ class Config extends React.Component {

render() {
return <div>
<div className="nt-box" style={ { width: 500, margin: '60px auto 0' } }>
<div className="nt-form-row" style={ { display: this.props.favorite ? 'block' : 'none' } }>
<div className="nt-box" style={ {width: 500, margin: '60px auto 0'} }>
<div className="nt-form-row" style={ {display: this.props.favorite ? 'block' : 'none'} }>
<label htmlFor="name">Name:</label>
<input type="text" id="name" value={this.getProp('name')} onChange={this.handleChange.bind(this, 'name')} placeholder="Bookmark name" />
</div>
Expand All @@ -131,7 +131,7 @@ class Config extends React.Component {
<label htmlFor="ssh">SSL:</label>
<input type="checkbox" id="ssl" onChange={this.handleChange.bind(this, 'ssl')} checked={this.getProp('ssl')} />
</div>
<div style={ { display: this.getProp('ssl') ? 'block' : 'none' } }>
<div style={ {display: this.getProp('ssl') ? 'block' : 'none'} }>
{this.renderCertInput('Private Key', 'tlskey')}
{this.renderCertInput('Certificate', 'tlscert')}
{this.renderCertInput('CA', 'tlsca')}
Expand All @@ -140,7 +140,7 @@ class Config extends React.Component {
<label htmlFor="ssh">SSH Tunnel:</label>
<input type="checkbox" id="ssh" onChange={this.handleChange.bind(this, 'ssh')} checked={this.getProp('ssh')} />
</div>
<div style={ { display: this.getProp('ssh') ? 'block' : 'none' } }>
<div style={ {display: this.getProp('ssh') ? 'block' : 'none'} }>
<div className="nt-form-row">
<label htmlFor="sshHost">SSH Host:</label>
<input type="text" id="sshHost" onChange={this.handleChange.bind(this, 'sshHost')} value={this.getProp('sshHost')} placeholder="" />
Expand All @@ -154,7 +154,7 @@ class Config extends React.Component {
<input
type={this.getProp('sshKeyFile') ? 'text' : 'password' }
id="sshPassword"
readOnly={this.getProp('sshKey') ? true : false}
readOnly={Boolean(this.getProp('sshKey'))}
onChange={this.handleChange.bind(this, 'sshPassword')}
value={this.getProp('sshKeyFile') || this.getProp('sshPassword')}
placeholder=""
Expand All @@ -166,22 +166,22 @@ class Config extends React.Component {
this.setProp({
sshKey: false,
sshKeyFile: false
});
return;
})
return
}
const win = remote.getCurrentWindow();
const win = remote.getCurrentWindow()
const files = remote.require('dialog').showOpenDialog(win, {
properties: ['openFile']
});
})
if (files && files.length) {
const file = files[0];
const content = fs.readFileSync(file, 'utf8');
this.setProp({ sshKey: content, sshKeyFile: file });
const file = files[0]
const content = fs.readFileSync(file, 'utf8')
this.setProp({sshKey: content, sshKeyFile: file})
}
}}
></button>
</div>
<div className="nt-form-row" style={{ display: this.getProp('sshKey') && this.getProp('sshKey').indexOf('ENCRYPTED') > -1 ? 'block' : 'none' }}>
<div className="nt-form-row" style={{display: this.getProp('sshKey') && this.getProp('sshKey').indexOf('ENCRYPTED') > -1 ? 'block' : 'none'}}>
<label htmlFor="sshKeyPassphrase">SSH Key Passphrase:</label>
<input type="password" id="sshKeyPassphrase" onChange={this.handleChange.bind(this, 'sshKeyPassphrase')} value={this.getProp('sshKeyPassphrase')} />
</div>
Expand All @@ -191,21 +191,21 @@ class Config extends React.Component {
</div>
</div>
</div>
<div className="nt-button-group nt-button-group--pull-right" style={ { width: 500, margin: '10px auto 0', paddingBottom: 10 } }>
<div className="nt-button-group nt-button-group--pull-right" style={ {width: 500, margin: '10px auto 0', paddingBottom: 10} }>
<button className="nt-button" style={
{ float: 'left' }
{float: 'left'}
} onClick={() => {
this.duplicate();
this.duplicate()
}}>{ this.props.favorite ? 'Duplicate' : 'Add to Favorite' }</button>
<button className="nt-button" style={ { display: this.state.changed ? 'inline-block' : 'none' } } onClick={() => {
this.save();
<button className="nt-button" style={ {display: this.state.changed ? 'inline-block' : 'none'} } onClick={() => {
this.save()
}}>Save Changes</button>
<button disabled={this.props.connectStatus ? true : false } ref="connectButton" className="nt-button nt-button--primary" onClick={() => {
this.connect();
<button disabled={Boolean(this.props.connectStatus) } ref="connectButton" className="nt-button nt-button--primary" onClick={() => {
this.connect()
}}>{ this.props.connectStatus || (this.state.changed ? 'Save and Connect' : 'Connect') }</button>
</div>
</div>;
</div>
}
}

export default Config;
export default Config
Loading

0 comments on commit a29145e

Please sign in to comment.