Skip to content

Commit 28d3138

Browse files
committed
wip: getting there
1 parent 4ed9847 commit 28d3138

File tree

4 files changed

+62
-21
lines changed

4 files changed

+62
-21
lines changed

media/dependency.svg

Lines changed: 1 addition & 0 deletions
Loading

src/commands.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ export class Commands {
180180
} else {
181181
selected = opened[0]
182182
}
183+
// TODO figure out why we'e getting
184+
// Failed to parse remote port from server output
185+
// [16:01:51.489] Resolver error: Error:
186+
console.log("here are the values", remoteAuthority, selected.folderUri.path)
183187

184188
await vscode.commands.executeCommand(
185189
"vscode.openFolder",

src/extension.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,11 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
1616

1717
// Register TreeDataProvider
1818
const dataObject = {
19-
label: "level one",
19+
label: "Workspaces",
2020
children: [
2121
{
2222
label: "level two a",
23-
children: [
24-
{
25-
label: "level three",
26-
children: [],
27-
},
28-
],
23+
children: [],
2924
},
3025
{
3126
label: "level two b",

src/outline.ts

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,71 @@
1+
import { getWorkspaces } from "coder/site/src/api/api"
2+
import * as path from "path"
13
import * as vscode from "vscode"
24

35
export class OutlineProvider implements vscode.TreeDataProvider<any> {
4-
constructor(private outline: any, private context: vscode.ExtensionContext) {
5-
console.log(outline)
6-
}
6+
constructor(private outline: any, private context: vscode.ExtensionContext) {}
77

8-
getTreeItem(item: any): vscode.TreeItem {
9-
return new vscode.TreeItem(
10-
item.label,
11-
item.children.length > 0 ? vscode.TreeItemCollapsibleState.Expanded : vscode.TreeItemCollapsibleState.None,
12-
)
8+
getTreeItem(element: Workspace): vscode.TreeItem {
9+
return element
1310
}
1411

15-
getChildren(element?: any): Thenable<[]> {
12+
async getChildren(element?: Workspace): Promise<Workspace[]> {
1613
// TODO - make request to get requests
1714
// then resolve with workspaces as children
1815
// otherwise resolve with empty array
16+
// TODO create dummy data and show those
17+
const workspaces = await getWorkspaces({
18+
q: "owner:me",
19+
}).catch(() => {
20+
return
21+
})
1922

20-
// TODO - if error, what do we do?
23+
if (workspaces) {
24+
const items: Workspace[] = workspaces.workspaces.map((workspace) => {
25+
return new Workspace(
26+
`${workspace.name}`,
27+
vscode.TreeItemCollapsibleState.None,
28+
`${workspace.latest_build.status !== "running" ? "circle-outline" : "circle-filled"}`,
29+
{
30+
command: "coder.open",
31+
title: "",
32+
arguments: [workspace.owner_name, workspace.name],
33+
},
34+
)
35+
})
2136

22-
// TODO - if you login does it refresh the view?
23-
// same thing with logout
24-
if (element) {
25-
return Promise.resolve(element.children)
37+
return Promise.resolve(items)
2638
} else {
2739
return Promise.resolve([])
2840
}
41+
42+
// TODO - if error, what do we do?
43+
44+
// TODO - if you login does it refresh the view?
45+
// same thing with logout
46+
// if (element) {
47+
// return Promise.resolve(element.children)
48+
// } else {
49+
// return Promise.resolve(this.outline)
50+
// }
51+
}
52+
}
53+
54+
export class Workspace extends vscode.TreeItem {
55+
constructor(
56+
public readonly label: string,
57+
public readonly collapsibleState: vscode.TreeItemCollapsibleState,
58+
public readonly iconId: vscode.ThemeIcon["id"],
59+
public readonly command?: vscode.Command,
60+
) {
61+
super(label, collapsibleState)
62+
63+
this.tooltip = `${this.label}`
64+
}
65+
66+
// this.iconId iconPath = this.iconId
67+
iconPath = {
68+
light: path.join(__filename, "..", "..", "media", "dependency.svg"),
69+
dark: path.join(__filename, "..", "..", "media", "dependency.svg"),
2970
}
3071
}

0 commit comments

Comments
 (0)