Skip to content

Commit

Permalink
moving safecomposeID to state
Browse files Browse the repository at this point in the history
  • Loading branch information
jlampar committed Jun 11, 2018
1 parent 92d561c commit bf6c4e9
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 5 deletions.
17 changes: 16 additions & 1 deletion apps/xprof_gui/priv/src/actions/CollectingActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import {
getStatus,
} from '../selectors';
import { setCallsControl, getCalleesForFunctions } from './';
import { determineNextData, determineNextCalls, roll } from '../utils';
import {
determineNextData,
determineNextCalls,
roll,
safecomposeID,
} from '../utils';

export const updateListMonitoringFunctions = monitoredCollection => ({
type: types.UPDATE_MONITORED_FUNCTIONS,
Expand Down Expand Up @@ -39,8 +44,17 @@ const updateSize = (property, value) => ({

export const getMonitoredFunctions = () => async (dispatch, getState) => {
const state = getState();
const ids = getIDs(state);
const identifiedFunctions = Object.keys(ids);
const monitoredCollection = getAllMonitored(state);

monitoredCollection.forEach((monitored) => {
if (!identifiedFunctions.includes(monitored.query)) {
const id = safecomposeID(monitored.query);
ids[monitored.query] = id;
}
});

const { json, error } = await XProf.getAllMonitoredFunctions();
if (error) {
console.log('ERROR: ', error);
Expand All @@ -61,6 +75,7 @@ export const getMonitoredFunctions = () => async (dispatch, getState) => {
{},
);

dispatch(updateIDs(ids));
dispatch(getCalleesForFunctions(newMonitoredCollection));
dispatch(setCallsControl(newControls));
dispatch(updateListMonitoringFunctions(json));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import PropTypes from 'prop-types';
import React from 'react';
import GridGraph from '../GridGraph';
import LineGraph from '../LineGraph';
import { GRAPH_TYPE } from '../../../constants/GraphTypes';
import { GRAPH_INITIAL_SIZE } from '../../../constants';
import { GRAPH_INITIAL_SIZE, GRAPH_TYPE } from '../../../constants';

const defaultProps = {
size: GRAPH_INITIAL_SIZE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import PropTypes from 'prop-types';
import React from 'react';
import { Graph, GraphPanelHeading } from '../';
import { GRAPH_INITIAL_SIZE } from '../../../constants';
import { safecomposeID } from '../../../utils';

const defaultProps = {
dps: [],
Expand Down Expand Up @@ -30,6 +29,7 @@ const propTypes = {
calleeClick: PropTypes.func.isRequired,
setSize: PropTypes.func.isRequired,
size: PropTypes.shape(PropTypes.any),
ids: PropTypes.shape(PropTypes.any).isRequired,
};

const GraphPanel = ({
Expand All @@ -46,8 +46,9 @@ const GraphPanel = ({
calleeClick,
setSize,
size,
ids,
}) => {
const monitoredID = safecomposeID(monitored.query);
const monitoredID = ids[monitored.query];
return (
<div className="panel panel-default">
<GraphPanelHeading
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const propTypes = {
calleeClick: PropTypes.func.isRequired,
setSize: PropTypes.func.isRequired,
size: PropTypes.shape(PropTypes.any),
ids: PropTypes.shape(PropTypes.any).isRequired,
};

class Monitoring extends React.Component {
Expand Down Expand Up @@ -59,6 +60,7 @@ class Monitoring extends React.Component {
calleeClick,
setSize,
size,
ids,
} = this.props;
return (
<div>
Expand All @@ -77,6 +79,7 @@ class Monitoring extends React.Component {
calleeClick={calleeClick}
setSize={setSize}
size={size}
ids={ids}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
getFunctionCalleesVisibility,
getFunctionGraphVisibility,
getSize,
getIDs,
} from '../../selectors';

const MonitoringContainer = props => <Monitoring {...props} />;
Expand All @@ -32,6 +33,7 @@ const mapStateToProps = (state, ownProps) => ({
),
panelVisibility: getFunctionGraphVisibility(state, ownProps.monitored.query),
size: getSize(state),
ids: getIDs(state),
});

const mapDispatchToProps = {
Expand Down
6 changes: 6 additions & 0 deletions apps/xprof_gui/priv/src/reducers/monitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const initialState = {
data: {},
panel: {},
callees: {},
ids: {},
size: {
width: 0,
height: 0,
Expand Down Expand Up @@ -37,6 +38,11 @@ const monitoring = (state = initialState, action) => {
[action.property]: action.value,
},
};
case types.ASSIGN_GRAPH_ID:
return {
...state,
ids: action.ids,
};
default:
return state;
}
Expand Down

0 comments on commit bf6c4e9

Please sign in to comment.