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 support for removing nodes in SceneGraph Inspector #578

Merged
merged 1 commit into from
Jun 12, 2024
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
6 changes: 5 additions & 1 deletion webviews/src/ExtensionIntermediary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -249,6 +249,10 @@ class ODCIntermediary {
return this.sendOdcMessage<ReturnType<typeof rta.odc.removeNodeChildren>>(RequestType.removeNodeChildren, args, options);
}

public async removeNode(args: RemoveNodeArgs, options?: RequestOptions) {
return this.sendOdcMessage<ReturnType<typeof rta.odc.removeNode>>(RequestType.removeNode, args, options);
}

public async focusNode(args: FocusNodeArgs, options?: RequestOptions) {
return this.sendOdcMessage<ReturnType<typeof rta.odc.focusNode>>(RequestType.focusNode, args, options);
}
Expand Down
21 changes: 20 additions & 1 deletion webviews/src/views/SceneGraphInspectorView/Branch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -177,6 +178,18 @@
keyPath: treeNode.keyPath
});
}

async function removeNode() {
await odc.removeNode({
keyPath: treeNode.keyPath
});
dispatch('nodeRemoved', treeNode);
}

function onChildNodeRemoved(event: CustomEvent<TreeNode>) {
const removedChildTreeNode = event.detail;
treeNode.children = treeNode.children.filter(child => child.keyPath !== removedChildTreeNode.keyPath);
}
</script>

<style>
Expand Down Expand Up @@ -271,6 +284,11 @@
</span>
</div>
<div class="actions">
{#if treeNode.parentRef >= 0}
<span title="Remove Node" class="icon-button" on:click|stopPropagation={removeNode}>
<Trash />
</span>
{/if}
{#if treeNode.visible !== undefined}
<span title="Focus Node" class="icon-button" on:click|stopPropagation={focusNode}>
<Issues />
Expand Down Expand Up @@ -300,6 +318,7 @@
on:openNode
on:treeNodeFocused
on:childExpanded={onChildExpanded}
on:nodeRemoved={onChildNodeRemoved}
depth={depth + 1}
treeNode={treeNodeChild}
selectTreeNode={selectTreeNode}
Expand Down