Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc274710

Browse files
committed
Add search filter to the tree views and enhance the refresh process
1 parent2c7974c commitc274710

File tree

3 files changed

+59
-5
lines changed

3 files changed

+59
-5
lines changed

‎package.json‎

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@
204204
{
205205
"command":"coder.createWorkspace",
206206
"title":"Create Workspace",
207+
"category":"Coder",
207208
"when":"coder.authenticated",
208209
"icon":"$(add)"
209210
},
@@ -226,7 +227,8 @@
226227
},
227228
{
228229
"command":"coder.refreshWorkspaces",
229-
"title":"Coder: Refresh Workspace",
230+
"title":"Refresh Workspace",
231+
"category":"Coder",
230232
"icon":"$(refresh)",
231233
"when":"coder.authenticated"
232234
},
@@ -241,13 +243,33 @@
241243
"title":"Coder: Open App Status",
242244
"icon":"$(robot)",
243245
"when":"coder.authenticated"
246+
},
247+
{
248+
"command":"coder.searchMyWorkspaces",
249+
"title":"Search",
250+
"category":"Coder",
251+
"icon":"$(search)"
252+
},
253+
{
254+
"command":"coder.searchAllWorkspaces",
255+
"title":"Search",
256+
"category":"Coder",
257+
"icon":"$(search)"
244258
}
245259
],
246260
"menus": {
247261
"commandPalette": [
248262
{
249263
"command":"coder.openFromSidebar",
250264
"when":"false"
265+
},
266+
{
267+
"command":"coder.searchMyWorkspaces",
268+
"when":"false"
269+
},
270+
{
271+
"command":"coder.searchAllWorkspaces",
272+
"when":"false"
251273
}
252274
],
253275
"view/title": [
@@ -262,12 +284,22 @@
262284
{
263285
"command":"coder.createWorkspace",
264286
"when":"coder.authenticated && view == myWorkspaces",
265-
"group":"navigation"
287+
"group":"navigation@1"
266288
},
267289
{
268290
"command":"coder.refreshWorkspaces",
269291
"when":"coder.authenticated && view == myWorkspaces",
270-
"group":"navigation"
292+
"group":"navigation@2"
293+
},
294+
{
295+
"command":"coder.searchMyWorkspaces",
296+
"when":"coder.authenticated && view == myWorkspaces",
297+
"group":"navigation@3"
298+
},
299+
{
300+
"command":"coder.searchAllWorkspaces",
301+
"when":"coder.authenticated && view == allWorkspaces",
302+
"group":"navigation@3"
271303
}
272304
],
273305
"view/item/context": [

‎src/extension.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ import { Remote } from "./remote";
1616
import{toSafeHost}from"./util";
1717
import{WorkspaceProvider,WorkspaceQuery}from"./workspacesProvider";
1818

19+
constMY_WORKSPACES_TREE_ID="myWorkspaces";
20+
constALL_WORKSPACES_TREE_ID="myWorkspaces";
21+
1922
exportasyncfunctionactivate(ctx:vscode.ExtensionContext):Promise<void>{
2023
// The Remote SSH extension's proposed APIs are used to override the SSH host
2124
// name in VS Code itself. It's visually unappealing having a lengthy name!
@@ -88,15 +91,15 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
8891

8992
// createTreeView, unlike registerTreeDataProvider, gives us the tree view API
9093
// (so we can see when it is visible) but otherwise they have the same effect.
91-
constmyWsTree=vscode.window.createTreeView("myWorkspaces",{
94+
constmyWsTree=vscode.window.createTreeView(MY_WORKSPACES_TREE_ID,{
9295
treeDataProvider:myWorkspacesProvider,
9396
});
9497
myWorkspacesProvider.setVisibility(myWsTree.visible);
9598
myWsTree.onDidChangeVisibility((event)=>{
9699
myWorkspacesProvider.setVisibility(event.visible);
97100
});
98101

99-
constallWsTree=vscode.window.createTreeView("allWorkspaces",{
102+
constallWsTree=vscode.window.createTreeView(ALL_WORKSPACES_TREE_ID,{
100103
treeDataProvider:allWorkspacesProvider,
101104
});
102105
allWorkspacesProvider.setVisibility(allWsTree.visible);
@@ -308,6 +311,12 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
308311
"coder.viewLogs",
309312
commands.viewLogs.bind(commands),
310313
);
314+
vscode.commands.registerCommand("coder.searchMyWorkspaces",async()=>
315+
showTreeViewSearch(MY_WORKSPACES_TREE_ID),
316+
);
317+
vscode.commands.registerCommand("coder.searchAllWorkspaces",async()=>
318+
showTreeViewSearch(ALL_WORKSPACES_TREE_ID),
319+
);
311320

312321
// Since the "onResolveRemoteAuthority:ssh-remote" activation event exists
313322
// in package.json we're able to perform actions before the authority is
@@ -436,3 +445,8 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
436445
}
437446
}
438447
}
448+
449+
asyncfunctionshowTreeViewSearch(id:string):Promise<void>{
450+
awaitvscode.commands.executeCommand(`${id}.focus`);
451+
awaitvscode.commands.executeCommand("list.find");
452+
}

‎src/workspacesProvider.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ export class WorkspaceProvider
261261
// yet.
262262
appStatuses.push(
263263
newAppStatusTreeItem({
264+
id:status.id,
264265
name:status.message,
265266
command:app.command,
266267
workspace_name:element.workspace.name,
@@ -334,6 +335,7 @@ class AgentMetadataTreeItem extends vscode.TreeItem {
334335
metadataEvent.result.collected_at,
335336
).toLocaleString();
336337

338+
this.id=metadataEvent.description.key;
337339
this.tooltip="Collected at "+collected_at;
338340
this.contextValue="coderAgentMetadata";
339341
}
@@ -342,13 +344,15 @@ class AgentMetadataTreeItem extends vscode.TreeItem {
342344
classAppStatusTreeItemextendsvscode.TreeItem{
343345
constructor(
344346
publicreadonlyapp:{
347+
id:string;
345348
name:string;
346349
url?:string;
347350
command?:string;
348351
workspace_name?:string;
349352
},
350353
){
351354
super("",vscode.TreeItemCollapsibleState.None);
355+
this.id=app.id;
352356
this.description=app.name;
353357
this.contextValue="coderAppStatus";
354358

@@ -368,6 +372,7 @@ type CoderOpenableTreeItemType =
368372

369373
exportclassOpenableTreeItemextendsvscode.TreeItem{
370374
constructor(
375+
id:string,
371376
label:string,
372377
tooltip:string,
373378
description:string,
@@ -378,6 +383,7 @@ export class OpenableTreeItem extends vscode.TreeItem {
378383
contextValue:CoderOpenableTreeItemType,
379384
){
380385
super(label,collapsibleState);
386+
this.id=id;
381387
this.contextValue=contextValue;
382388
this.tooltip=tooltip;
383389
this.description=description;
@@ -396,6 +402,7 @@ export class AgentTreeItem extends OpenableTreeItem {
396402
watchMetadata=false,
397403
){
398404
super(
405+
agent.id,// id
399406
agent.name,// label
400407
`Status:${agent.status}`,// tooltip
401408
agent.status,// description
@@ -433,6 +440,7 @@ export class WorkspaceTreeItem extends OpenableTreeItem {
433440
constdetail=`Template:${workspace.template_display_name||workspace.template_name} • Status:${status}`;
434441
constagents=extractAgents(workspace.latest_build.resources);
435442
super(
443+
workspace.id,
436444
label,
437445
detail,
438446
workspace.latest_build.status,// description

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp