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 id search to dataflow viewer #1379

Merged
merged 3 commits into from
Nov 29, 2023
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
2 changes: 1 addition & 1 deletion src/components/input-panel/spec-editor/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class Editor extends React.PureComponent<Props> {
prevProps.editorRef && prevProps.editorRef.deltaDecorations(prevProps.decorations, []);
}

if (this.props.parse) {
if (this.editor && this.props.parse) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what this is, but i couldn't get the editor to run local without it?

this.editor.focus();
this.editor.layout();
this.updateSpec(this.props.value, this.props.configEditorString);
Expand Down
21 changes: 21 additions & 0 deletions src/features/dataflow/Sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
width: 250px;
gap: 10px;
}

.sidebar fieldset {
overflow: hidden;
border-color: var(--light-gray-color);
Expand Down Expand Up @@ -53,3 +54,23 @@
.type-filter {
flex-shrink: 0;
}

.sidebar .id-filter {
padding-bottom: 20px;
flex-shrink: 0;
}

.sidebar .id-filter > div {
display: flex;
height: 30px;
}

.sidebar .id-filter > div input {
width: 70px;
height: 100%;
}

.sidebar .id-filter > div button {
width: 100%;
height: 100%;
}
33 changes: 32 additions & 1 deletion src/features/dataflow/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ import {useDispatch} from 'react-redux';
import {useAppSelector} from '../../hooks';
import {resetPulses, sortedPulsesSelector, pulsesEmptySelector} from './pulsesSlice';
import './Sidebar.css';
import {selectedPulseSelector, selectedTypesSelector, setSelectedPulse, setSelectedType} from './selectionSlice';
import {
setSelectedElements,
selectedPulseSelector,
selectedTypesSelector,
setSelectedPulse,
setSelectedType,
} from './selectionSlice';
import {GraphType, types} from './utils/graph';

export function Sidebar() {
return (
<div className="sidebar">
<Types />
<Id />
<Pulses />
</div>
);
Expand Down Expand Up @@ -42,6 +49,30 @@ function Type({type, label, selected}: {type: GraphType; label: string; selected
);
}

function Id() {
const [searchTerm, setSearchTerm] = React.useState<string | null>(null);
const dispatch = useDispatch();
return (
<fieldset className="id-filter">
<legend>Filter by ID</legend>
<div>
<input type="search" title="Pulse Id Search" onChange={(e) => setSearchTerm(e.target.value)} />
<button
onClick={() => {
if (!searchTerm) {
return;
}
dispatch(setSelectedElements({nodes: [searchTerm], edges: []}));
setSearchTerm(null);
}}
>
Search
</button>
</div>
</fieldset>
);
}

function Pulses() {
return (
<fieldset>
Expand Down
4 changes: 4 additions & 0 deletions src/features/dataflow/utils/allRelated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export function allRelated({nodes, edges}: Graph, selected: Elements): Set<strin
// Mark the compound node relations as visited
// and add their immediate parents to the queue
const node = nodes[id];
// if the user inputs an invalid node, just ignore it
if (node === undefined) {
continue;
}
const parents = node.parent !== undefined ? [node.parent] : [];
const relatedCompound = [...parents, ...node.children];
relatedCompound.forEach((i) => processed.add(i));
Expand Down
Loading