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

Fix/focus mode modular pipeline highlight #1107

Merged
merged 7 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,16 @@ export function toggleFocusMode(modularPipeline) {
modularPipeline,
};
}

export const TOGGLE_HOVERED_FOCUS_MODE = 'TOGGLE_HOVERED_FOCUS_MODE';

/**
* Update the value of the of the currently-active hovered node from focus mode
* @param {string|null} nodeHovered The node's unique identifier
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param {string|null} nodeHovered The node's unique identifier
* @param {string|null} hoveredFocusMode The node's unique identifier

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check my last commit for this fix. Thanks

*/
export function toggleHoveredFocusMode(hoveredFocusMode) {
return {
type: TOGGLE_HOVERED_FOCUS_MODE,
hoveredFocusMode,
};
}
8 changes: 8 additions & 0 deletions src/components/flowchart/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const drawNodes = function (changed) {
inputOutputDataNodes,
nodes,
focusMode,
hoveredFocusMode,
} = this.props;

const isInputOutputNode = (nodeID) =>
Expand Down Expand Up @@ -260,6 +261,13 @@ export const drawNodes = function (changed) {
);
}

if (changed('nodes', 'nodeActive', 'hoveredFocusMode')) {
allNodes.classed(
'pipeline-node--faded',
(node) => hoveredFocusMode && !nodeActive[node.id]
);
}

if (changed('nodes')) {
allNodes
.transition('update-nodes')
Expand Down
5 changes: 5 additions & 0 deletions src/components/flowchart/flowchart.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ export class FlowChart extends Component {
drawNodes.call(this, changed);
}

if (changed('nodes', 'nodeActive', 'hoveredFocusMode')) {
drawNodes.call(this, changed);
}

if (changed('edges', 'nodes', 'layers', 'chartSize', 'clickedNode')) {
this.resetView();
} else {
Expand Down Expand Up @@ -682,6 +686,7 @@ export const mapStateToProps = (state, ownProps) => ({
focusMode: state.visible.modularPipelineFocusMode,
graphSize: state.graph.size || emptyGraphSize,
hoveredParameters: state.hoveredParameters,
hoveredFocusMode: state.hoveredFocusMode,
layers: getLayers(state),
linkedNodes: getLinkedNodes(state),
nodes: state.graph.nodes || emptyNodes,
Expand Down
1 change: 1 addition & 0 deletions src/components/flowchart/flowchart.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ describe('FlowChart', () => {
edges: expect.any(Array),
graphSize: expect.any(Object),
hoveredParameters: expect.any(Boolean),
hoveredFocusMode: expect.any(Boolean),
layers: expect.any(Array),
linkedNodes: expect.any(Object),
nodeActive: expect.any(Object),
Expand Down
12 changes: 11 additions & 1 deletion src/components/node-list/node-list-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import VisibleIcon from '../icons/visible';
import InvisibleIcon from '../icons/invisible';
import FocusModeIcon from '../icons/focus-mode';
import { getNodeActive } from '../../selectors/nodes';
import { toggleHoveredFocusMode } from '../../actions';

// The exact fixed height of a row as measured by getBoundingClientRect()
export const nodeListRowHeight = 32;
Expand Down Expand Up @@ -67,6 +68,7 @@ const NodeListRow = memo(
invisibleIcon = InvisibleIcon,
focusModeIcon = FocusModeIcon,
rowType,
onToggleHoveredFocusMode,
}) => {
const isModularPipeline = type === 'modularPipeline';
const FocusIcon = isModularPipeline ? focusModeIcon : null;
Expand Down Expand Up @@ -198,6 +200,8 @@ const NodeListRow = memo(
}
)}
onClick={(e) => e.stopPropagation()}
onMouseEnter={() => onToggleHoveredFocusMode(true)}
onMouseLeave={() => onToggleHoveredFocusMode(false)}
>
<input
id={id + '-focus'}
Expand Down Expand Up @@ -236,6 +240,12 @@ const NodeListRow = memo(
shouldMemo
);

export const mapDispatchToProps = (dispatch) => ({
onToggleHoveredFocusMode: (active) => {
dispatch(toggleHoveredFocusMode(active));
},
});

export const mapStateToProps = (state, ownProps) => ({
...ownProps,
active:
Expand All @@ -244,4 +254,4 @@ export const mapStateToProps = (state, ownProps) => ({
: getNodeActive(state)[ownProps.id] || false,
});

export default connect(mapStateToProps)(NodeListRow);
export default connect(mapStateToProps, mapDispatchToProps)(NodeListRow);
6 changes: 6 additions & 0 deletions src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
UPDATE_ZOOM,
TOGGLE_IGNORE_LARGE_WARNING,
TOGGLE_PRETTY_NAME,
TOGGLE_HOVERED_FOCUS_MODE,
} from '../actions';
import { TOGGLE_PARAMETERS_HOVERED } from '../actions';

Expand Down Expand Up @@ -81,6 +82,11 @@ const combinedReducer = combineReducers({
TOGGLE_IGNORE_LARGE_WARNING,
'ignoreLargeWarning'
),
hoveredFocusMode: createReducer(
false,
TOGGLE_HOVERED_FOCUS_MODE,
'hoveredFocusMode'
),
});

const rootReducer = (state, action) =>
Expand Down
1 change: 1 addition & 0 deletions src/store/normalize-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const createInitialPipelineState = () => ({
enabled: {},
},
hoveredParameters: false,
hoveredFocusMode: false,
});

/**
Expand Down