Added control to reset local view state

This commit is contained in:
jpellizzari
2016-12-09 14:33:14 -08:00
parent 5c3ea83846
commit edf94a4da8
4 changed files with 49 additions and 4 deletions

View File

@@ -11,6 +11,7 @@ import { doControlRequest, getAllNodes, getNodesDelta, getNodeDetails,
getTopologies, deletePipe } from '../utils/web-api-utils';
import { getActiveTopologyOptions,
getCurrentTopologyUrl } from '../utils/topology-utils';
import { storageSet } from '../utils/storage-utils';
const log = debug('scope:app-actions');
@@ -665,3 +666,10 @@ export function route(urlState) {
);
};
}
export function resetLocalViewState() {
return (dispatch) => {
dispatch({type: ActionTypes.RESET_LOCAL_VIEW_STATE});
storageSet('scopeViewState', '');
};
}

View File

@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
import { searchableFieldsSelector } from '../selectors/chartSelectors';
import { CANVAS_MARGINS } from '../constants/styles';
import { hideHelp } from '../actions/app-actions';
import { hideHelp, resetLocalViewState } from '../actions/app-actions';
const GENERAL_SHORTCUTS = [
@@ -149,7 +149,7 @@ function renderFieldsPanel(currentTopologyName, searchableFields) {
}
function HelpPanel({currentTopologyName, searchableFields, onClickClose}) {
function HelpPanel({currentTopologyName, searchableFields, onClickClose, onClickReset}) {
return (
<div className="help-panel-wrapper">
<div className="help-panel" style={{marginTop: CANVAS_MARGINS.top}}>
@@ -161,8 +161,19 @@ function HelpPanel({currentTopologyName, searchableFields, onClickClose}) {
{renderSearchPanel()}
{renderFieldsPanel(currentTopologyName, searchableFields)}
</div>
<div className="help-panel-controls">
<span
title="Reset view state"
className="fa fa-trash-o"
onClick={onClickReset}
/>
</div>
<div className="help-panel-tools">
<span title="Close details" className="fa fa-close" onClick={onClickClose} />
<span
title="Close details"
className="fa fa-close"
onClick={onClickClose}
/>
</div>
</div>
</div>
@@ -178,4 +189,7 @@ function mapStateToProps(state) {
}
export default connect(mapStateToProps, { onClickClose: hideHelp })(HelpPanel);
export default connect(mapStateToProps, {
onClickClose: hideHelp,
onClickReset: resetLocalViewState
})(HelpPanel);

View File

@@ -45,6 +45,7 @@ const ACTION_TYPES = [
'RECEIVE_TOPOLOGIES',
'RECEIVE_API_DETAILS',
'RECEIVE_ERROR',
'RESET_LOCAL_VIEW_STATE',
'ROUTE_TOPOLOGY',
'SELECT_METRIC',
'SHOW_HELP',

View File

@@ -624,11 +624,13 @@ h2 {
position: relative;
}
&-tools {
position: absolute;
top: 6px;
right: 8px;
> span {
.btn-opacity;
padding: 4px 5px;
@@ -1586,6 +1588,26 @@ h2 {
border-color: rgba(131, 131, 172, 0.6);
}
}
}
&-controls {
border: 1px solid #fff;
border-radius: 10%;
position: absolute;
left: 100px;
top: 95%;
font-size: 20px;
width: 30px;
height: 30px;
transition: all 0.2s ease-in-out;
line-height: 30px;
text-align: center;
&:hover {
cursor: pointer;
border: 1px solid #d0d0d0;
}
}