From 973d34599c4a38bff24a4cf157513239ef17ebbc Mon Sep 17 00:00:00 2001 From: Brian Leighty Date: Wed, 12 Jun 2024 16:04:09 -0400 Subject: [PATCH] Add support for removing nodes in SceneGraph Inspector (#578) Co-authored-by: Brian Leighty --- webviews/src/ExtensionIntermediary.ts | 6 +++++- .../SceneGraphInspectorView/Branch.svelte | 21 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/webviews/src/ExtensionIntermediary.ts b/webviews/src/ExtensionIntermediary.ts index 88f6518e..d841167f 100644 --- a/webviews/src/ExtensionIntermediary.ts +++ b/webviews/src/ExtensionIntermediary.ts @@ -4,7 +4,7 @@ import { RequestType } from 'roku-test-automation/client/dist/types/OnDeviceComp import type { VscodeCommand } from '../../src/commands/VscodeCommand'; import type { ViewProviderEvent } from '../../src/viewProviders/ViewProviderEvent'; import { ViewProviderCommand } from '../../src/viewProviders/ViewProviderCommand'; -import type { DeleteEntireRegistrySectionsArgs, DeleteNodeReferencesArgs, DeleteRegistrySectionsArgs, FindNodesAtLocationArgs, GetFocusedNodeArgs, GetNodesInfoArgs, GetNodesWithPropertiesArgs, GetValueArgs, GetValuesArgs, HasFocusArgs, IsInFocusChainArgs, OnFieldChangeOnceArgs, ReadRegistryArgs, RequestOptions, SetValueArgs, StoreNodeReferencesArgs, WriteRegistryArgs, GetVolumeListArgs, GetDirectoryListingArgs, StatPathArgs, RenameFileArgs, DeleteFileArgs, CreateDirectoryArgs, RemoveNodeChildrenArgs, FocusNodeArgs } from 'roku-test-automation'; +import type { DeleteEntireRegistrySectionsArgs, DeleteNodeReferencesArgs, DeleteRegistrySectionsArgs, FindNodesAtLocationArgs, GetFocusedNodeArgs, GetNodesInfoArgs, GetNodesWithPropertiesArgs, GetValueArgs, GetValuesArgs, HasFocusArgs, IsInFocusChainArgs, OnFieldChangeOnceArgs, ReadRegistryArgs, RequestOptions, SetValueArgs, StoreNodeReferencesArgs, WriteRegistryArgs, GetVolumeListArgs, GetDirectoryListingArgs, StatPathArgs, RenameFileArgs, DeleteFileArgs, CreateDirectoryArgs, RemoveNodeArgs, RemoveNodeChildrenArgs, FocusNodeArgs } from 'roku-test-automation'; class ExtensionIntermediary { private inflightRequests = {}; @@ -249,6 +249,10 @@ class ODCIntermediary { return this.sendOdcMessage>(RequestType.removeNodeChildren, args, options); } + public async removeNode(args: RemoveNodeArgs, options?: RequestOptions) { + return this.sendOdcMessage>(RequestType.removeNode, args, options); + } + public async focusNode(args: FocusNodeArgs, options?: RequestOptions) { return this.sendOdcMessage>(RequestType.focusNode, args, options); } diff --git a/webviews/src/views/SceneGraphInspectorView/Branch.svelte b/webviews/src/views/SceneGraphInspectorView/Branch.svelte index cf37c4e7..d1b699af 100644 --- a/webviews/src/views/SceneGraphInspectorView/Branch.svelte +++ b/webviews/src/views/SceneGraphInspectorView/Branch.svelte @@ -3,10 +3,11 @@ import throttle from 'just-throttle'; import { odc } from '../../ExtensionIntermediary'; import { utils } from '../../utils'; - import { Eye, EyeClosed, DebugBreakpointDataUnverified, Move, Issues } from 'svelte-codicons'; + import { Eye, EyeClosed, DebugBreakpointDataUnverified, Move, Issues, Trash } from 'svelte-codicons'; import Chevron from '../../shared/Chevron.svelte'; import type { TreeNodeWithBase } from '../../shared/types'; import { createEventDispatcher } from 'svelte'; + import type { TreeNode } from 'roku-test-automation'; const dispatch = createEventDispatcher(); export let treeNode: TreeNodeWithBase; @@ -177,6 +178,18 @@ keyPath: treeNode.keyPath }); } + + async function removeNode() { + await odc.removeNode({ + keyPath: treeNode.keyPath + }); + dispatch('nodeRemoved', treeNode); + } + + function onChildNodeRemoved(event: CustomEvent) { + const removedChildTreeNode = event.detail; + treeNode.children = treeNode.children.filter(child => child.keyPath !== removedChildTreeNode.keyPath); + }