Skip to content

Commit e36e338

Browse files
committed
amends
1 parent ec13774 commit e36e338

File tree

4 files changed

+36
-28
lines changed

4 files changed

+36
-28
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"localstackActivityBar": [
6363
{
6464
"id": "localstack.instances",
65-
"name": "Instances",
65+
"name": "LocalStack",
6666
"icon": "resources/icons/localstack.svg"
6767
}
6868
]

resources/icons/codicon-combine.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

resources/icons/codicon-plug.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/plugins/app-inspector-webview.ts

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import {
1212
TreeItemCollapsibleState,
1313
Uri,
1414
} from "vscode";
15-
import type { ProviderResult, TreeDataProvider, Event } from "vscode";
15+
import type {
16+
ProviderResult,
17+
TreeDataProvider,
18+
Event,
19+
WebviewPanel,
20+
} from "vscode";
1621

1722
import { createPlugin } from "../plugins.ts";
1823
import type {
@@ -23,23 +28,28 @@ import type {
2328
export default createPlugin(
2429
"app-inspector-webview",
2530
({ context, outputChannel, localStackStatusTracker }) => {
31+
let appInspectorPanel: WebviewPanel | undefined;
2632
context.subscriptions.push(
2733
commands.registerCommand("localstack.openAppInspector", async () => {
34+
if (appInspectorPanel) {
35+
appInspectorPanel.reveal();
36+
return;
37+
}
38+
2839
const panel = window.createWebviewPanel(
29-
"webviewOpener",
40+
"localStackAppInspector",
3041
`App Inspector`,
3142
ViewColumn.Active,
3243
{
3344
enableScripts: true,
3445
retainContextWhenHidden: true,
3546
},
3647
);
48+
appInspectorPanel = panel;
3749

38-
panel.iconPath = Uri.joinPath(
39-
context.extensionUri,
40-
// "resources/icons/codicon-plug.svg",
41-
"resources/icons/codicon-combine.svg",
42-
);
50+
panel.onDidDispose(() => {
51+
appInspectorPanel = undefined;
52+
});
4353

4454
const appInspectorDist = path.resolve(
4555
import.meta.dirname,
@@ -71,7 +81,7 @@ export default createPlugin(
7181
}),
7282
);
7383

74-
const provider = new ExampleTreeDataProvider({
84+
const provider = new InstancesTreeDataProvider({
7585
localStackStatusTracker,
7686
});
7787

@@ -82,51 +92,49 @@ export default createPlugin(
8292
},
8393
);
8494

85-
class ExampleTreeItem extends TreeItem {
86-
children?: ExampleTreeItem[];
95+
class InstancesTreeItem extends TreeItem {
96+
children?: InstancesTreeItem[];
8797
}
8898

89-
interface ExampleTreeDataProviderOptions {
99+
interface InstancesTreeDataProviderOptions {
90100
localStackStatusTracker: LocalStackStatusTracker;
91101
}
92102

93-
class ExampleTreeDataProvider implements TreeDataProvider<ExampleTreeItem> {
103+
class InstancesTreeDataProvider implements TreeDataProvider<InstancesTreeItem> {
94104
readonly #onDidChangeTreeData = new EventEmitter<
95105
// biome-ignore lint/suspicious/noConfusingVoidType: void is required by Event
96-
ExampleTreeItem | undefined | void
106+
InstancesTreeItem | undefined | void
97107
>();
98108

99109
// biome-ignore lint/suspicious/noConfusingVoidType: void is required by Event
100-
readonly onDidChangeTreeData: Event<ExampleTreeItem | undefined | void> =
110+
readonly onDidChangeTreeData: Event<InstancesTreeItem | undefined | void> =
101111
this.#onDidChangeTreeData.event;
102112

103-
#rootItems: ExampleTreeItem[] = [];
113+
#rootItems: InstancesTreeItem[] = [];
104114

105-
constructor(options: ExampleTreeDataProviderOptions) {
106-
const appInspectorItem = new ExampleTreeItem(
115+
constructor(options: InstancesTreeDataProviderOptions) {
116+
const appInspectorItem = new InstancesTreeItem(
107117
"App Inspector",
108118
TreeItemCollapsibleState.None,
109119
);
110-
appInspectorItem.description = "Click to open ↗";
111-
appInspectorItem.iconPath = new ThemeIcon("combine");
120+
appInspectorItem.description = "Click to open";
112121
appInspectorItem.command = {
113122
title: "Open App Inspector",
114123
command: "localstack.openAppInspector",
115124
};
116125

117-
const instanceItem = new ExampleTreeItem(
118-
"localhost.localstack.cloud",
126+
const instanceItem = new InstancesTreeItem(
127+
"localhost.localstack.cloud:4566",
119128
TreeItemCollapsibleState.Expanded,
120129
);
121130
instanceItem.children = [
122131
(() => {
123-
const item = new ExampleTreeItem(
132+
const item = new InstancesTreeItem(
124133
"Status",
125134
TreeItemCollapsibleState.None,
126135
);
127136
options.localStackStatusTracker.onChange((status) => {
128137
item.description = status;
129-
item.iconPath = getLocalStackStatusThemeIcon(status);
130138
this.#onDidChangeTreeData.fire(item);
131139
});
132140

@@ -143,15 +151,17 @@ class ExampleTreeDataProvider implements TreeDataProvider<ExampleTreeItem> {
143151
});
144152
}
145153

146-
getChildren(element?: ExampleTreeItem): ProviderResult<ExampleTreeItem[]> {
154+
getChildren(
155+
element?: InstancesTreeItem,
156+
): ProviderResult<InstancesTreeItem[]> {
147157
if (element) {
148158
return element.children;
149159
}
150160

151161
return this.#rootItems;
152162
}
153163

154-
getTreeItem(element: ExampleTreeItem): TreeItem {
164+
getTreeItem(element: InstancesTreeItem): TreeItem {
155165
return element;
156166
}
157167
}

0 commit comments

Comments
 (0)