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

Introduce metadataPanel prop in Kedro-Viz react component #1965

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 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 RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Please follow the established format:
- Enable/disable preview for all the datasets when publishing Kedro-Viz from UI. (#1895)
- Display published URLs. (#1907)
- Conditionally move session store and stats file to .viz directory. (#1915)
- Introduce `metadataPanel` in `display` prop in Kedro-Viz react component. (#1965)

## Bug fixes and other changes

Expand Down
1 change: 1 addition & 0 deletions src/components/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ App.propTypes = {
sidebar: PropTypes.bool,
miniMap: PropTypes.bool,
expandAllPipelines: PropTypes.bool,
metadataPanel: PropTypes.bool,
}),
};

Expand Down
6 changes: 4 additions & 2 deletions src/components/flowchart-wrapper/flowchart-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const FlowChartWrapper = ({
pipelines,
sidebarVisible,
activePipeline,
displayMetadataPanel,
}) => {
const history = useHistory();
const { pathname, search } = useLocation();
Expand Down Expand Up @@ -309,7 +310,7 @@ export const FlowChartWrapper = ({
return (
<div className="kedro-pipeline">
<Sidebar />
<MetaData />
{displayMetadataPanel && <MetaData />}
<PipelineWarning
errorMessage={errorMessage}
invalidUrl={isInvalidUrl}
Expand All @@ -321,7 +322,7 @@ export const FlowChartWrapper = ({
return (
<div className="kedro-pipeline">
<Sidebar />
<MetaData />
{displayMetadataPanel && <MetaData />}
<div className="pipeline-wrapper">
<PipelineWarning />
<FlowChart />
Expand Down Expand Up @@ -366,6 +367,7 @@ export const mapStateToProps = (state) => ({
pipelines: state.pipeline.ids,
activePipeline: state.pipeline.active,
sidebarVisible: state.visible.sidebar,
displayMetadataPanel: state.display.metadataPanel,
});

export const mapDispatchToProps = (dispatch) => ({
Expand Down
31 changes: 26 additions & 5 deletions src/components/flowchart/flowchart.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import classnames from 'classnames';
import { select } from 'd3-selection';
import { updateChartSize, updateZoom } from '../../actions';
import { toggleSingleModularPipelineExpanded } from '../../actions/modular-pipelines';
import { loadNodeData, toggleNodeHovered } from '../../actions/nodes';
import {
loadNodeData,
toggleNodeHovered,
toggleNodeClicked,
} from '../../actions/nodes';
import {
getNodeActive,
getNodeSelected,
Expand Down Expand Up @@ -446,11 +450,24 @@ export class FlowChart extends Component {
* @param {Object} node Datum for a single node
*/
handleNodeClick = (event, node) => {
if (node.type === 'modularPipeline') {
this.props.onClickToExpandModularPipeline(node.id);
const { type, id } = node;
const {
onClickToExpandModularPipeline,
displayMetadataPanel,
onLoadNodeData,
toSelectedNode,
onToggleNodeClicked,
} = this.props;

if (type === 'modularPipeline') {
onClickToExpandModularPipeline(id);
} else {
this.props.onLoadNodeData(node.id);
this.props.toSelectedNode(node);
if (displayMetadataPanel) {
onLoadNodeData(id);
toSelectedNode(node);
} else {
onToggleNodeClicked(id);
}
}
event.stopPropagation();
};
Expand Down Expand Up @@ -690,6 +707,7 @@ export const mapStateToProps = (state, ownProps) => ({
chartSize: getChartSize(state),
chartZoom: getChartZoom(state),
displayGlobalToolbar: state.display.globalToolbar,
displayMetadataPanel: state.display.metadataPanel,
edges: state.graph.edges || emptyEdges,
focusMode: state.visible.modularPipelineFocusMode,
graphSize: state.graph.size || emptyGraphSize,
Expand Down Expand Up @@ -718,6 +736,9 @@ export const mapDispatchToProps = (dispatch, ownProps) => ({
onLoadNodeData: (nodeClicked) => {
dispatch(loadNodeData(nodeClicked));
},
onToggleNodeClicked: (id) => {
dispatch(toggleNodeClicked(id));
},
onToggleNodeHovered: (nodeHovered) => {
dispatch(toggleNodeHovered(nodeHovered));
},
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 @@ -486,6 +486,7 @@ describe('FlowChart', () => {
inputOutputDataEdges: expect.any(Object),
focusMode: expect.any(Object),
displayGlobalToolbar: expect.any(Boolean),
displayMetadataPanel: expect.any(Boolean),
};
expect(mapStateToProps(mockState.spaceflights)).toEqual(expectedResult);
});
Expand Down
5 changes: 3 additions & 2 deletions src/selectors/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getNodeLabel, getNodeFullName, getNodeName } from './nodes';
import { prettifyName, stripNamespace } from '../utils';

const getClickedNode = (state) => state.node.clicked;
const getDisplayMetadataPanel = (state) => state.display.metadataPanel;
/**
* Comparison for sorting alphabetically by name, otherwise by value
*/
Expand All @@ -12,8 +13,8 @@ const sortAlpha = (a, b) => (a.name || a).localeCompare(b.name || b);
* Returns true if metadata sidebar is visible
*/
export const getVisibleMetaSidebar = createSelector(
[getClickedNode],
(nodeClicked) => Boolean(nodeClicked)
[getClickedNode, getDisplayMetadataPanel],
(nodeClicked, metadataPanel) => (metadataPanel ? Boolean(nodeClicked) : false)
);

/**
Expand Down
1 change: 1 addition & 0 deletions src/store/initial-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const createInitialState = () => ({
sidebar: true,
miniMap: true,
expandAllPipelines: false,
metadataPanel: true,
},
zoom: {},
runsMetadata: {},
Expand Down
Loading