(flow: Flow)
| 376 | |
| 377 | /** Select a range of flows with shift + click. */ |
| 378 | export function selectRange(flow: Flow) { |
| 379 | return (dispatch: AppDispatch, getState: () => RootState) => { |
| 380 | const { flows } = getState(); |
| 381 | const prev = flows.selected[flows.selected.length - 1]; |
| 382 | |
| 383 | const thisIndex = flows._viewIndex.get(flow.id); |
| 384 | const prevIndex = flows._viewIndex.get(prev?.id); |
| 385 | if (thisIndex === undefined || prevIndex === undefined) { |
| 386 | return dispatch(select([flow])); |
| 387 | } |
| 388 | let newSelection: Flow[]; |
| 389 | if (thisIndex <= prevIndex) { |
| 390 | newSelection = flows.view.slice(thisIndex, prevIndex + 1); |
| 391 | } else { |
| 392 | newSelection = flows.view.slice(prevIndex + 1, thisIndex + 1); |
| 393 | newSelection.push(prev); // Keep this at the end if the user shift-clicks again. |
| 394 | } |
| 395 | return dispatch(select(newSelection)); |
| 396 | }; |
| 397 | } |
no test coverage detected
searching dependent graphs…