MCPcopy
hub / github.com/wavetermdev/waveterm / treeReducer

Method treeReducer

frontend/layout/lib/layoutModel.ts:615–702  ·  view source on GitHub ↗

* Perform an action against the layout tree state. * @param action The action to perform.

(action: LayoutTreeAction, setState = true)

Source from the content-addressed store, hash-verified

613 * @param action The action to perform.
614 */
615 treeReducer(action: LayoutTreeAction, setState = true) {
616 switch (action.type) {
617 case LayoutTreeActionType.ComputeMove:
618 this.setter(
619 this.pendingTreeAction.throttledValueAtom,
620 computeMoveNode(this.treeState, action as LayoutTreeComputeMoveNodeAction)
621 );
622 break;
623 case LayoutTreeActionType.Move:
624 moveNode(this.treeState, action as LayoutTreeMoveNodeAction);
625 break;
626 case LayoutTreeActionType.InsertNode:
627 insertNode(this.treeState, action as LayoutTreeInsertNodeAction);
628 if ((action as LayoutTreeInsertNodeAction).focused) {
629 FocusManager.getInstance().requestNodeFocus();
630 }
631 break;
632 case LayoutTreeActionType.InsertNodeAtIndex:
633 insertNodeAtIndex(this.treeState, action as LayoutTreeInsertNodeAtIndexAction);
634 if ((action as LayoutTreeInsertNodeAtIndexAction).focused) {
635 FocusManager.getInstance().requestNodeFocus();
636 }
637 break;
638 case LayoutTreeActionType.DeleteNode:
639 deleteNode(this.treeState, action as LayoutTreeDeleteNodeAction);
640 break;
641 case LayoutTreeActionType.Swap:
642 swapNode(this.treeState, action as LayoutTreeSwapNodeAction);
643 break;
644 case LayoutTreeActionType.ResizeNode:
645 resizeNode(this.treeState, action as LayoutTreeResizeNodeAction);
646 break;
647 case LayoutTreeActionType.SetPendingAction: {
648 const pendingAction = (action as LayoutTreeSetPendingAction).action;
649 if (pendingAction) {
650 this.setter(this.pendingTreeAction.throttledValueAtom, pendingAction);
651 } else {
652 console.warn("No new pending action provided");
653 }
654 break;
655 }
656 case LayoutTreeActionType.ClearPendingAction:
657 this.setter(this.pendingTreeAction.throttledValueAtom, undefined);
658 break;
659 case LayoutTreeActionType.CommitPendingAction: {
660 const pendingAction = this.getter(this.pendingTreeAction.currentValueAtom);
661 if (!pendingAction) {
662 console.error("unable to commit pending action, does not exist");
663 break;
664 }
665 this.treeReducer(pendingAction);
666 this.setter(this.pendingTreeAction.throttledValueAtom, undefined);
667 break;
668 }
669 case LayoutTreeActionType.FocusNode:
670 focusNode(this.treeState, action as LayoutTreeFocusNodeAction);
671 FocusManager.getInstance().requestNodeFocus();
672 break;

Callers 14

handleBackendActionMethod · 0.95
focusNodeMethod · 0.95
magnifyNodeToggleMethod · 0.95
closeNodeMethod · 0.95
onDropMethod · 0.95
onResizeMoveMethod · 0.95
onResizeEndMethod · 0.95
TileLayoutComponentFunction · 0.80
TileLayout.tsxFile · 0.80

Calls 15

updateTreeMethod · 0.95
persistToBackendMethod · 0.95
computeMoveNodeFunction · 0.90
moveNodeFunction · 0.90
insertNodeFunction · 0.90
insertNodeAtIndexFunction · 0.90
deleteNodeFunction · 0.90
swapNodeFunction · 0.90
resizeNodeFunction · 0.90
focusNodeFunction · 0.90
magnifyNodeToggleFunction · 0.90
clearTreeFunction · 0.90

Tested by

no test coverage detected