Skip to content

Commit

Permalink
Add search by id
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnuttandrew committed Nov 25, 2023
1 parent dd19c65 commit e204a4f
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 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,28 @@ 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>
<input title="Pulse Id Search" onChange={(e) => setSearchTerm(e.target.value)} />
<button
onClick={() => {
if (!searchTerm) {
return;
}
dispatch(setSelectedElements({nodes: [searchTerm], edges: []}));
setSearchTerm(null);
}}
>
Search
</button>
</fieldset>
);
}

function Pulses() {
return (
<fieldset>
Expand Down

0 comments on commit e204a4f

Please sign in to comment.