-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from zalmoxisus/logs
[WIP] Refactoring
- Loading branch information
Showing
43 changed files
with
1,447 additions
and
412 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { | ||
LIFTED_ACTION, MONITOR_ACTION, SELECT_INSTANCE, SELECT_MONITOR, | ||
TOGGLE_SYNC, TOGGLE_SLIDER, TOGGLE_DISPATCHER, GET_REPORT_REQUEST, | ||
SHOW_NOTIFICATION, CLEAR_NOTIFICATION | ||
} from '../constants/actionTypes'; | ||
import { RECONNECT } from '../constants/socketActionTypes'; | ||
|
||
export function liftedDispatch(action) { | ||
if (action.type[0] === '@') return { type: MONITOR_ACTION, action }; | ||
return { type: LIFTED_ACTION, message: 'DISPATCH', action }; | ||
} | ||
|
||
export function selectInstance(event, index, selected) { | ||
return { type: SELECT_INSTANCE, selected }; | ||
} | ||
|
||
export function selectMonitor(event, index, value) { | ||
return { type: SELECT_MONITOR, monitor: value }; | ||
} | ||
|
||
export function importState(state) { | ||
return { type: LIFTED_ACTION, message: 'IMPORT', state }; | ||
} | ||
|
||
export function dispatchRemotely(action) { | ||
return { type: LIFTED_ACTION, message: 'ACTION', action }; | ||
} | ||
|
||
export function toggleSync() { | ||
return { type: TOGGLE_SYNC }; | ||
} | ||
|
||
export function toggleSlider() { | ||
return { type: TOGGLE_SLIDER }; | ||
} | ||
|
||
export function toggleDispatcher() { | ||
return { type: TOGGLE_DISPATCHER }; | ||
} | ||
|
||
export function saveSocketSettings(isCustom, options) { | ||
return { type: RECONNECT, isCustom, options }; | ||
} | ||
|
||
export function showNotification(message) { | ||
return { type: SHOW_NOTIFICATION, notification: { type: 'ERROR', message } }; | ||
} | ||
|
||
export function clearNotification() { | ||
return { type: CLEAR_NOTIFICATION }; | ||
} | ||
|
||
export function getReport(report) { | ||
return { type: GET_REPORT_REQUEST, report }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React, { Component, PropTypes } from 'react'; | ||
import { bindActionCreators } from 'redux'; | ||
import { connect } from 'react-redux'; | ||
import * as themes from 'redux-devtools-themes'; | ||
import { clearNotification } from '../actions'; | ||
|
||
class Notification extends Component { | ||
static propTypes = { | ||
notification: PropTypes.shape({ | ||
message: PropTypes.string, | ||
type: PropTypes.string | ||
}), | ||
clearNotification: PropTypes.func.isRequired | ||
}; | ||
|
||
shouldComponentUpdate(nextProps) { | ||
return nextProps.notification !== this.props.notification; | ||
} | ||
|
||
render() { | ||
if (!this.props.notification) return null; | ||
const theme = themes.nicinabox; | ||
const buttonStyle = { | ||
color: theme.base06, backgroundColor: theme.base00, | ||
margin: '0', background: '#DC2424' | ||
}; | ||
const containerStyle = { | ||
color: theme.base06, background: '#FC2424', | ||
padding: '5px 10px', minHeight: '20px', display: 'flex' | ||
}; | ||
return ( | ||
<div style={containerStyle}> | ||
<div style={{ flex: '1', alignItems: 'center' }}> | ||
<p style={{ margin: '0px' }}>{this.props.notification.message}</p> | ||
</div> | ||
<div style={{ alignItems: 'center' }}> | ||
<button | ||
onClick={this.props.clearNotification} | ||
style={buttonStyle} | ||
>×</button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
function mapStateToProps(state) { | ||
return { | ||
notification: state.notification | ||
}; | ||
} | ||
|
||
function mapDispatchToProps(dispatch) { | ||
return { | ||
clearNotification: bindActionCreators(clearNotification, dispatch) | ||
}; | ||
} | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(Notification); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.