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

PXD-1312 feat(search): Enable search function for data dictionary view #434

Merged
merged 33 commits into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1331ef2
feat(search): import search library, and link to autocomplete
qingyashu Dec 6, 2018
22a6e7a
feat(node): highlight matched nodes
qingyashu Dec 7, 2018
88b7a1f
feat(history): show search result and add to history
qingyashu Dec 10, 2018
ced16c1
feat(popup): add popup search result
qingyashu Dec 11, 2018
54f1423
Merge branch 'master' into feat/dd-search
qingyashu Dec 18, 2018
72e81dd
fix(search): add more for search overlay result, and some tests
qingyashu Dec 18, 2018
d4f9fea
fix(lint): eslint
qingyashu Dec 18, 2018
23daa9f
fix(search): if start typing, clear all current highlighted nodes
qingyashu Dec 18, 2018
a48134e
fix(fuse): bug in fuse sometimes return wrong indices, filter out them
qingyashu Dec 18, 2018
0b8f736
fix(typo): fix typo
qingyashu Dec 18, 2018
8cd54b5
fix(style): some style improvement
qingyashu Dec 18, 2018
cd39f09
fix(types): fix a bug that only showed one highlighted type
qingyashu Dec 18, 2018
cd50e63
fix(improve): improve according to review and design check
qingyashu Dec 20, 2018
8bc3d88
fix(half-fade): make node and edge half faded effect
qingyashu Dec 20, 2018
a89827d
fix(emphasize-node): add half-faded effect for search result
qingyashu Dec 20, 2018
5e4daab
fix(test): fix test
qingyashu Dec 20, 2018
8d383c8
fix(improve): more improve on UI
qingyashu Dec 20, 2018
c05ca62
Merge branch 'master' into feat/dd-search
qingyashu Dec 20, 2018
2a4fb57
fix(border): remove border for gray bar
qingyashu Dec 21, 2018
a2766c9
fix(search): improve search, and some little style change
qingyashu Dec 21, 2018
f77e6aa
fix(search): output error if keyword too shor or too long
qingyashu Dec 21, 2018
974a990
fix(clear): fix bugs on clear result button, and according to comments
qingyashu Jan 9, 2019
7c63077
Merge branch 'master' into feat/dd-search
qingyashu Jan 9, 2019
d3e7b6f
fix(review): fix according to review
qingyashu Jan 23, 2019
28a44d1
fix(autocomplete): sort autocomplete items according to string distance
qingyashu Jan 23, 2019
e6070ef
fix(package): add stringsimilarity package
qingyashu Jan 23, 2019
601ee34
Merge branch 'master' into feat/dd-search
qingyashu Jan 23, 2019
ae401eb
Merge branch 'master' into feat/dd-search
qingyashu Jan 28, 2019
e1104b5
fix(version): ui-component version to .22
qingyashu Jan 29, 2019
c2a910d
fix(review): fix some test and others according to review comments
qingyashu Jan 29, 2019
02ab6df
fix(typo): typo typo
qingyashu Jan 29, 2019
e37d375
Merge branch 'master' into feat/dd-search
qingyashu Jan 29, 2019
9916178
fix(NaN): fix console error about NaN
qingyashu Jan 30, 2019
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
234 changes: 104 additions & 130 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"d3-zoom": "^1.7.3",
"fast-csv": "^2.4.0",
"file-saver": "^1.3.3",
"fuse.js": "^3.3.0",
"graphiql": "^0.11.11",
"graphql": "^0.12.3",
"history": "^4.7.2",
Expand Down Expand Up @@ -70,6 +71,7 @@
"redux-thunk": "^2.2.0",
"relay-compiler": "^1.6.0",
"relay-runtime": "^1.6.0",
"string-similarity": "^3.0.0",
"style-loader": "^0.21.0",
"styled-components": "^3.2.6",
"svg-fill-loader": "^0.0.8",
Expand Down Expand Up @@ -101,6 +103,7 @@
"html-webpack-plugin": "^3.2.0",
"jest": "^21.2.1",
"jest-fetch-mock": "^1.2.1",
"jest-localstorage-mock": "^2.3.0",
"mock-local-storage": "^1.0.5",
"prettier": "^1.4.4",
"react-hot-loader": "^1.3.0",
Expand All @@ -120,7 +123,8 @@
"automock": false,
"setupFiles": [
"./src/shim.js",
"./src/setupJest.js"
"./src/setupJest.js",
"jest-localstorage-mock"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
Expand Down
2 changes: 1 addition & 1 deletion src/DataDictionary/DataDictionary.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@
.data-dictionary__switch-button--active {
background-color: var(--g3-color__base-blue);
color: var(--g3-color__white);
}
}
30 changes: 24 additions & 6 deletions src/DataDictionary/DataDictionary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@ import PropTypes from 'prop-types';
import ReduxDataDictionaryTable from './table/DataDictionaryTable';
import ReduxDataModelStructure from './DataModelStructure';
import DataDictionaryGraph from './graph/DataDictionaryGraph/.';
import ReduxDictionarySearcher from './search/DictionarySearcher/.';
import ReduxDictionarySearchHistory from './search/DictionarySearchHistory/.';
import './DataDictionary.css';

class DataDictionary extends React.Component {
constructor(props) {
super(props);
this.dictionarySearcherRef = React.createRef();
}

setGraphView = (isGraphView) => {
this.props.onSetGraphView(isGraphView);
}
};

handleClickSearchHistoryItem = (keyword) => {
this.dictionarySearcherRef.current.getWrappedInstance().launchSearchFromOutside(keyword);
};

handleClearSearchResult = () => {
this.dictionarySearcherRef.current.getWrappedInstance().launchClearSearchFromOutside();
};

render() {
return (
Expand All @@ -32,10 +47,11 @@ class DataDictionary extends React.Component {
Table View
</span>
</div>
<div className='data-dictionary__model-structure'>
<ReduxDataModelStructure />
</div>
<div className='data-dictionary__search' />
<ReduxDictionarySearcher ref={this.dictionarySearcherRef} />
<ReduxDataModelStructure />
<ReduxDictionarySearchHistory
onClickSearchHistoryItem={this.handleClickSearchHistoryItem}
/>
<div className='data-dictionary__search-history' />
</div>
<div
Expand All @@ -45,7 +61,9 @@ class DataDictionary extends React.Component {
<ReduxDataDictionaryTable />
</div>
<div className={`data-dictionary__graph ${this.props.isGraphView ? '' : 'data-dictionary__graph--hidden'}`}>
<DataDictionaryGraph />
<DataDictionaryGraph
onClearSearchResult={this.handleClearSearchResult}
/>
</div>
</div>
</div>
Expand Down
56 changes: 43 additions & 13 deletions src/DataDictionary/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,18 @@ export const setGraphLegend = legendItems => ({
legendItems,
});

export const setHoveringNode = (node, hoveringNodeSVGElement) => ({
export const hoverNode = nodeID => ({
type: 'GRAPH_UPDATE_HOVERING_NODE',
node,
hoveringNodeSVGElement,
nodeID,
});

export const setHighlightingNode = (node, highlightingNodeSVGElement) => ({
type: 'GRAPH_UPDATE_HIGHLIGHTING_NODE',
node,
highlightingNodeSVGElement,
export const clickNode = nodeID => ({
type: 'GRAPH_CLICK_NODE',
nodeID,
});

export const setSecondHighlightingNodeID = nodeID => ({
type: 'GRAPH_SECOND_HIGHLIGHTING_NODE',
nodeID,
export const resetGraphHighlight = () => ({
type: 'GRAPH_RESET_HIGHLIGHT',
});

export const setOverlayPropertyTableHidden = isHidden => ({
Expand All @@ -76,8 +73,41 @@ export const setNeedReset = needReset => ({
needReset,
});

export const setHighlightingNodeSVGElement = highlightingNodeSVGElement => ({
type: 'GRAPH_HIGHLIGHTING_NODE_SVG_ELEMENT_UPDATED',
highlightingNodeSVGElement,
export const setIsSearching = isSearching => ({
type: 'SEARCH_SET_IS_SEARCHING_STATUS',
isSearching,
});

export const setSearchResult = (searchResult, searchResultSummary) => ({
type: 'SEARCH_RESULT_UPDATED',
searchResult,
searchResultSummary,
});

export const clearSearchHistoryItems = () => ({
type: 'SEARCH_CLEAR_HISTORY',
});

export const addSearchHistoryItem = searchHistoryItem => ({
type: 'SEARCH_HISTORY_ITEM_CREATED',
searchHistoryItem,
});

export const setGraphNodesSVGElements = graphNodesSVGElements => ({
type: 'GRAPH_NODES_SVG_ELEMENTS_UPDATED',
graphNodesSVGElements,
});

export const clearSearchResult = () => ({
type: 'SEARCH_RESULT_CLEARED',
});

export const saveCurrentSearchKeyword = keyword => ({
type: 'SEARCH_SAVE_CURRENT_KEYWORD',
keyword,
});

export const setHighlightingMatchedNodeOpened = opened => ({
type: 'GRAPH_MATCHED_NODE_OPENED',
opened,
});
10 changes: 10 additions & 0 deletions src/DataDictionary/graph/ActionLayer/ActionLayer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.action-layer {
position: absolute;
top: 0;
left: 0;
}

.action-layer__clear-search {
margin-left: 60px;
margin-top: 15px;
}
42 changes: 42 additions & 0 deletions src/DataDictionary/graph/ActionLayer/ActionLayer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import PropTypes from 'prop-types';
import Button from '@gen3/ui-component/dist/components/Button';
import './ActionLayer.css';

/**
* A layer over the graph.
* Put action buttons here.
*/
class ActionLayer extends React.Component {
handleClearSearch = () => {
this.props.onClearSearchResult();
}

render() {
return (
<div className='action-layer'>
{
this.props.isSearchMode && (
<Button
className='action-layer__clear-search'
onClick={this.handleClearSearch}
label='Clear Search Result'
/>
)
}
</div>
);
}
}

ActionLayer.propTypes = {
isSearchMode: PropTypes.bool,
onClearSearchResult: PropTypes.func,
};

ActionLayer.defaultProps = {
isSearchMode: false,
onClearSearchResult: () => {},
};

export default ActionLayer;
12 changes: 12 additions & 0 deletions src/DataDictionary/graph/ActionLayer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { connect } from 'react-redux';
import ActionLayer from './ActionLayer';

const ReduxActionLayer = (() => {
const mapStateToProps = state => ({
isSearchMode: state.ddgraph.isSearchMode,
});

return connect(mapStateToProps)(ActionLayer);
})();

export default ReduxActionLayer;
1 change: 1 addition & 0 deletions src/DataDictionary/graph/Canvas/Canvas.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
position: absolute;
top: 15px;
left: 15px;
z-index: 1;
}

.canvas__zoom-button {
Expand Down
3 changes: 1 addition & 2 deletions src/DataDictionary/graph/Canvas/Canvas.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class Canvas extends React.Component {

handleCanvasUpdate = () => {
const canvasBoundingRect = this.canvasElement.current.getBoundingClientRect();
window.canvasElem = this.canvasElement.current;
this.props.onCanvasBoundingBoxUpdate(canvasBoundingRect);
}

Expand Down Expand Up @@ -197,7 +196,7 @@ Canvas.propTypes = {

Canvas.defaultProps = {
minZoom: 0.1,
maxZoom: 5,
maxZoom: 10,
topLeftTranslateLimit: [-Infinity, -Infinity],
bottomRightTranslateLimit: [+Infinity, +Infinity],
onClickBlankSpace: () => {},
Expand Down
2 changes: 1 addition & 1 deletion src/DataDictionary/graph/Canvas/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { clickBlankSpace, setCanvasBoundingRect, setNeedReset } from '../../action.js';
import { clickBlankSpace, setCanvasBoundingRect, setNeedReset } from '../../action';
import Canvas from './Canvas';

const ReduxCanvas = (() => {
Expand Down
11 changes: 11 additions & 0 deletions src/DataDictionary/graph/DataDictionaryGraph/index.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import ReduxGraphCalculator from '../GraphCalculator/.';
import ReduxLegend from '../Legend/.';
import ReduxCanvas from '../Canvas/.';
import ReduxGraphDrawer from '../GraphDrawer/.';
import ReduxNodeTooltip from '../NodeTooltip/.';
import ReduxNodePopup from '../NodePopup/.';
import ReduxOverlayPropertyTable from '../OverlayPropertyTable/.';
import ReduxActionLayer from '../ActionLayer/.';

class DataDictionaryGraph extends React.Component {
render() {
Expand All @@ -19,9 +21,18 @@ class DataDictionaryGraph extends React.Component {
<ReduxNodeTooltip />
<ReduxNodePopup />
<ReduxOverlayPropertyTable />
<ReduxActionLayer onClearSearchResult={this.props.onClearSearchResult} />
</React.Fragment>
);
}
}

DataDictionaryGraph.propTypes = {
onClearSearchResult: PropTypes.func,
};

DataDictionaryGraph.defaultProps = {
onClearSearchResult: () => {},
};

export default DataDictionaryGraph;
22 changes: 13 additions & 9 deletions src/DataDictionary/graph/GraphCalculator/GraphCalculator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ class GraphCalculator extends React.Component {
}

componentDidMount() {
calculateGraphLayout(
this.props.dictionary,
this.props.countsSearch,
this.props.linksSearch,
).then((layoutResult) => {
this.props.onGraphLayoutCalculated(layoutResult);
const legendItems = getAllTypes(layoutResult.nodes);
this.props.onGraphLegendCalculated(legendItems);
});
if (!this.props.layoutInitialized) {
calculateGraphLayout(
this.props.dictionary,
this.props.countsSearch,
this.props.linksSearch,
).then((layoutResult) => {
this.props.onGraphLayoutCalculated(layoutResult);
const legendItems = getAllTypes(layoutResult.nodes);
this.props.onGraphLegendCalculated(legendItems);
});
}
}

componentWillUpdate(nextProps) {
Expand Down Expand Up @@ -137,6 +139,7 @@ GraphCalculator.propTypes = {
secondHighlightingNodeID: PropTypes.string,
onPathRelatedToSecondHighlightingNodeCalculated: PropTypes.func,
onDataModelStructureCalculated: PropTypes.func,
layoutInitialized: PropTypes.bool,
};

GraphCalculator.defaultProps = {
Expand All @@ -153,6 +156,7 @@ GraphCalculator.defaultProps = {
onSecondHighlightingNodeCandidateIDsCalculated: () => {},
onPathRelatedToSecondHighlightingNodeCalculated: () => {},
onDataModelStructureCalculated: () => {},
layoutInitialized: false,
};

export default GraphCalculator;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import Viz from 'viz.js';
import { Module, render } from 'viz.js/full.render';
import _ from 'underscore';
import { createNodesAndEdges, createDotStrinByNodesEdges } from '../../../GraphUtils/utils';
import { truncateLines, graphStyleConfig } from '../../utils';
import {
truncateLines,
graphStyleConfig,
} from '../../utils';
import {
getAllChildrenNodeIDs,
getAllChildrenLinks,
Expand Down
3 changes: 2 additions & 1 deletion src/DataDictionary/graph/GraphCalculator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
setSecondHighlightingNodeCandidateIDs,
setPathRelatedToSecondHighlightingNode,
setDataModelStructure,
} from '../../action.js';
} from '../../action';

const ReduxGraphCalculator = (() => {
const mapStateToProps = state => ({
Expand All @@ -18,6 +18,7 @@ const ReduxGraphCalculator = (() => {
nodes: state.ddgraph.nodes,
edges: state.ddgraph.edges,
secondHighlightingNodeID: state.ddgraph.secondHighlightingNodeID,
layoutInitialized: state.ddgraph.layoutInitialized,
});

const mapDispatchToProps = dispatch => ({
Expand Down
1 change: 1 addition & 0 deletions src/DataDictionary/graph/GraphDrawer/GraphDrawer.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
:root {
--opacity--faded: 0.1;
--opacity--half-faded: 0.5;
}
Loading