Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add control to reset local view state #2080

Merged
merged 2 commits into from
Jan 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"node": true
},
"rules": {
"no-debugger" : 1,
"comma-dangle": 0,
"global-require": 0,
"import/no-extraneous-dependencies": [
Expand Down
16 changes: 16 additions & 0 deletions client/app/scripts/actions/app-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -665,3 +666,18 @@ export function route(urlState) {
);
};
}

export function resetLocalViewState() {
return (dispatch) => {
dispatch({type: ActionTypes.RESET_LOCAL_VIEW_STATE});
storageSet('scopeViewState', '');
window.location.href = window.location.href.split('#')[0];
};
}

export function toggleTroubleshootingMenu(ev) {
if (ev) { ev.preventDefault(); ev.stopPropagation(); }
return {
type: ActionTypes.TOGGLE_TROUBLESHOOTING_MENU
};
}
6 changes: 5 additions & 1 deletion client/app/scripts/components/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Logo from './logo';
import Footer from './footer';
import Sidebar from './sidebar';
import HelpPanel from './help-panel';
import TroubleshootingMenu from './troubleshooting-menu';
import Search from './search';
import Status from './status';
import Topologies from './topologies';
Expand Down Expand Up @@ -99,7 +100,7 @@ class App extends React.Component {

render() {
const { gridMode, showingDetails, showingHelp, showingMetricsSelector,
showingNetworkSelector } = this.props;
showingNetworkSelector, showingTroubleshootingMenu } = this.props;
const isIframe = window !== window.top;

return (
Expand All @@ -108,6 +109,8 @@ class App extends React.Component {

{showingHelp && <HelpPanel />}

{showingTroubleshootingMenu && <TroubleshootingMenu />}

{showingDetails && <Details />}

<div className="header">
Expand Down Expand Up @@ -146,6 +149,7 @@ function mapStateToProps(state) {
searchQuery: state.get('searchQuery'),
showingDetails: state.get('nodeDetails').size > 0,
showingHelp: state.get('showingHelp'),
showingTroubleshootingMenu: state.get('showingTroubleshootingMenu'),
showingMetricsSelector: state.get('availableCanvasMetrics').count() > 0,
showingNetworkSelector: state.get('availableNetworks').count() > 0,
showingTerminal: state.get('controlPipes').size > 0,
Expand Down
20 changes: 7 additions & 13 deletions client/app/scripts/components/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Plugins from './plugins';
import { getUpdateBufferSize } from '../utils/update-buffer-utils';
import { contrastModeUrl, isContrastMode } from '../utils/contrast-utils';
import { clickDownloadGraph, clickForceRelayout, clickPauseUpdate,
clickResumeUpdate, toggleHelp } from '../actions/app-actions';
clickResumeUpdate, toggleHelp, toggleTroubleshootingMenu } from '../actions/app-actions';
import { basePathSlash } from '../utils/web-api-utils';

class Footer extends React.Component {
Expand Down Expand Up @@ -76,21 +76,14 @@ class Footer extends React.Component {
title={forceRelayoutTitle}>
<span className="fa fa-refresh" />
</a>
<a
className="footer-icon" onClick={this.props.clickDownloadGraph}
title="Save canvas as SVG (does not include search highlighting)">
<span className="fa fa-download" />
</a>
<a className="footer-icon" href="api/report" download title="Save raw data as JSON">
<span className="fa fa-code" />
</a>
<a className="footer-icon" href={otherContrastModeUrl} title={otherContrastModeTitle}>
<span className="fa fa-adjust" />
</a>
<a
className="footer-icon" title="Report an issue"
href="https://gitreports.com/issue/weaveworks/scope"
target="_blank" rel="noopener noreferrer">
onClick={this.props.toggleTroubleshootingMenu}
className="footer-icon" title="Open troubleshooting menu"
href=""
>
<span className="fa fa-bug" />
</a>
<a className="footer-icon" onClick={this.props.toggleHelp} title="Show help">
Expand Down Expand Up @@ -119,6 +112,7 @@ export default connect(
clickForceRelayout,
clickPauseUpdate,
clickResumeUpdate,
toggleHelp
toggleHelp,
toggleTroubleshootingMenu
}
)(Footer);
10 changes: 8 additions & 2 deletions client/app/scripts/components/help-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ function HelpPanel({currentTopologyName, searchableFields, onClickClose}) {
{renderFieldsPanel(currentTopologyName, searchableFields)}
</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>
Expand All @@ -178,4 +182,6 @@ function mapStateToProps(state) {
}


export default connect(mapStateToProps, { onClickClose: hideHelp })(HelpPanel);
export default connect(mapStateToProps, {
onClickClose: hideHelp
})(HelpPanel);
93 changes: 93 additions & 0 deletions client/app/scripts/components/troubleshooting-menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import React from 'react';
import { connect } from 'react-redux';

import {
toggleTroubleshootingMenu,
resetLocalViewState,
clickDownloadGraph
} from '../actions/app-actions';

class DebugMenu extends React.Component {
constructor(props, context) {
super(props, context);

this.handleClickReset = this.handleClickReset.bind(this);
}

handleClickReset(ev) {
ev.preventDefault();
this.props.resetLocalViewState();
}

render() {
return (
<div className="troubleshooting-menu-wrapper">
<div className="troubleshooting-menu">
<div className="troubleshooting-menu-content">
<h3>Debugging/Troubleshooting</h3>
<div className="troubleshooting-menu-item">
<a
className="footer-icon"
href="api/report"
download
title="Save raw data as JSON"
>
<span className="fa fa-code" />
<span className="description">
Save raw data as JSON
</span>
</a>
</div>
<div className="troubleshooting-menu-item">
<a
href=""
className="footer-icon"
onClick={this.props.clickDownloadGraph}
title="Save canvas as SVG (does not include search highlighting)"
>
<span className="fa fa-download" />
<span className="description">
Save canvas as SVG (does not include search highlighting)
</span>
</a>
</div>
<div className="troubleshooting-menu-item">
<a
href=""
className="footer-icon"
title="Reset view state"
onClick={this.handleClickReset}
>
<span className="fa fa-undo" />
<span className="description">Reset your local view state and reload the page</span>
</a>
</div>
<div className="troubleshooting-menu-item">
<a
className="footer-icon" title="Report an issue"
href="https://gitreports.com/issue/weaveworks/scope"
target="_blank" rel="noopener noreferrer"
>
<span className="fa fa-bug" />
<span className="description">Report a bug</span>
</a>
</div>
<div className="help-panel-tools">
<span
title="Close menu"
className="fa fa-close"
onClick={this.props.toggleTroubleshootingMenu}
/>
</div>
</div>
</div>
</div>
);
}
}

export default connect(null, {
toggleTroubleshootingMenu,
resetLocalViewState,
clickDownloadGraph
})(DebugMenu);
3 changes: 2 additions & 1 deletion client/app/scripts/constants/action-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ const ACTION_TYPES = [
'RECEIVE_TOPOLOGIES',
'RECEIVE_API_DETAILS',
'RECEIVE_ERROR',
'RESET_LOCAL_VIEW_STATE',
'ROUTE_TOPOLOGY',
'SELECT_METRIC',
'SHOW_HELP',
'SET_EXPORTING_GRAPH',

'SELECT_NETWORK',
'TOGGLE_TROUBLESHOOTING_MENU',
'PIN_NETWORK',
'UNPIN_NETWORK',
'SHOW_NETWORKS',
Expand Down
9 changes: 9 additions & 0 deletions client/app/scripts/reducers/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const initialState = makeMap({
selectedNetwork: null,
selectedNodeId: null,
showingHelp: false,
showingTroubleshootingMenu: false,
showingNetworks: false,
topologies: makeList(),
topologiesLoaded: false,
Expand Down Expand Up @@ -190,6 +191,10 @@ export function rootReducer(state = initialState, action) {
if (state.get('showingHelp')) {
state = state.set('showingHelp', false);
}

if (state.get('showingTroubleshootingMenu')) {
state = state.set('showingTroubleshootingMenu', false);
}
return closeAllNodeDetails(state);
}

Expand Down Expand Up @@ -705,6 +710,10 @@ export function rootReducer(state = initialState, action) {
return action.fn(state);
}

case ActionTypes.TOGGLE_TROUBLESHOOTING_MENU: {
return state.set('showingTroubleshootingMenu', !state.get('showingTroubleshootingMenu'));
}

default: {
return state;
}
Expand Down
42 changes: 40 additions & 2 deletions client/app/styles/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,13 @@ h2 {
position: relative;
}


&-tools {
position: absolute;
top: 6px;
right: 8px;


> span {
.btn-opacity;
padding: 4px 5px;
Expand Down Expand Up @@ -1586,12 +1588,12 @@ h2 {
border-color: rgba(131, 131, 172, 0.6);
}
}
}

}

&-main {
padding: 12px 36px 36px 36px;
display: flex;
padding: 12px 36px 36px 36px;
flex-direction: row;
align-items: stretch;

Expand Down Expand Up @@ -1834,3 +1836,39 @@ h2 {
}
}
}

.troubleshooting-menu {
display: flex;
position: relative;

&-wrapper {
height: 100%;
width: 100%;
align-items: center;
display: flex;
justify-content: center;
position: absolute;
}

&-content {
position: relative;
background-color: @white;
padding: 20px;
.shadow-2;
z-index: 2048;
}

&-item {
height: 40px;
}

.fa {
width: 20px;
text-align: center;
margin-right: 10px;
}

.fa-close {
width: 25px;
}
}