Skip to content

Commit 2f010cc

Browse files
committed
::coffee:: wip
1 parent 7022f0f commit 2f010cc

File tree

5 files changed

+54
-18
lines changed

5 files changed

+54
-18
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
/.vscode-test/
55
/.nyc_output/
66
/coverage/
7-
*.vsix
7+
*.vsix
8+
yarn-error.log

package.json

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
"id": "coderRemote",
4545
"name": "Workspaces",
4646
"visibility": "visible",
47-
"icon": "media/logo.svg",
48-
"contextualTitle": "Coder Remote"
47+
"icon": "media/logo.svg"
4948
}
5049
]
5150
},
@@ -69,6 +68,14 @@
6968
"command": "coder.open",
7069
"title": "Coder: Open Workspace"
7170
},
71+
{
72+
"command": "coder.createWorkspace",
73+
"title": "Create Workspace"
74+
},
75+
{
76+
"command": "coder.removeWorkspace",
77+
"title": "Remove Workspace"
78+
},
7279
{
7380
"command": "coder.workspace.update",
7481
"title": "Coder: Update Workspace",
@@ -79,19 +86,23 @@
7986
"view/title": [
8087
{
8188
"command": "coder.logout",
82-
"when": "coder.authenticated"
89+
"when": "coder.authenticated && view == coderRemote"
8390
},
8491
{
8592
"command": "coder.createWorkspace",
86-
"when": "coder.authenticated",
93+
"when": "coder.authenticated && view == coderRemote",
8794
"group": "navigation"
8895
}
8996
],
9097
"view/item/context": [
9198
{
9299
"command": "coder.open",
93-
"when": "coder.authenticated",
100+
"when": "coder.authenticated && viewItem.label !== 'My Workspaces' && view == coderRemote",
94101
"group": "inline"
102+
},
103+
{
104+
"command": "coder.removeWorkspace",
105+
"when": "coder.authenticated"
95106
}
96107
]
97108
}

src/commands.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ export class Commands {
101101
})
102102
}
103103

104+
public async createWorkspace(): Promise<void> {
105+
const uri = this.storage.getURL() + "/templates"
106+
await vscode.commands.executeCommand("vscode.open", uri)
107+
}
108+
104109
public async open(...args: string[]): Promise<void> {
105110
let workspaceOwner: string
106111
let workspaceName: string

src/extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
8080
vscode.commands.registerCommand("coder.logout", commands.logout.bind(commands))
8181
vscode.commands.registerCommand("coder.open", commands.open.bind(commands))
8282
vscode.commands.registerCommand("coder.workspace.update", commands.updateWorkspace.bind(commands))
83+
vscode.commands.registerCommand("coder.createWorkspace", commands.createWorkspace.bind(commands))
8384

8485
// Since the "onResolveRemoteAuthority:ssh-remote" activation event exists
8586
// in package.json we're able to perform actions before the authority is

src/workspacesProvider.ts

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,42 @@ import { getWorkspaces } from "coder/site/src/api/api"
22
import * as path from "path"
33
import * as vscode from "vscode"
44

5-
export class WorkspaceProvider implements vscode.TreeDataProvider<Dependency> {
6-
getTreeItem(element: Dependency): vscode.TreeItem {
5+
export class WorkspaceProvider implements vscode.TreeDataProvider<TreeItem> {
6+
getTreeItem(element: TreeItem): vscode.TreeItem {
77
return element
88
}
99

10-
getChildren(): Thenable<Dependency[]> {
11-
return getWorkspaces({
12-
q: "owner:me",
13-
}).then((workspaces) => {
14-
const exampleWorkspaces = [{ name: "example1" }, { name: "example2" }]
15-
return [...workspaces.workspaces, ...exampleWorkspaces].map(
16-
(workspace) => new Dependency(workspace.name, vscode.TreeItemCollapsibleState.None),
17-
)
18-
})
10+
getChildren(element?: TreeItem): Thenable<TreeItem[]> {
11+
if (!element) {
12+
return Promise.resolve([
13+
new TreeItem("My Workspaces", vscode.TreeItemCollapsibleState.Expanded),
14+
new TreeItem("All Workspaces", vscode.TreeItemCollapsibleState.None),
15+
])
16+
}
17+
if (element.label === "My Workspaces") {
18+
return getWorkspaces({
19+
q: "owner:me",
20+
}).then((workspaces) => {
21+
return workspaces.workspaces.map(
22+
(workspace) => new TreeItem(workspace.name, vscode.TreeItemCollapsibleState.None),
23+
)
24+
})
25+
}
26+
if (element.label === "All Workspaces") {
27+
return getWorkspaces({
28+
q: "owner:all",
29+
}).then((workspaces) => {
30+
const exampleWorkspaces = [{ name: "example1" }, { name: "example2" }]
31+
return [...workspaces.workspaces, ...exampleWorkspaces].map(
32+
(workspace) => new TreeItem(workspace.name, vscode.TreeItemCollapsibleState.None),
33+
)
34+
})
35+
}
36+
return Promise.resolve([])
1937
}
2038
}
2139

22-
class Dependency extends vscode.TreeItem {
40+
class TreeItem extends vscode.TreeItem {
2341
constructor(public readonly label: string, public readonly collapsibleState: vscode.TreeItemCollapsibleState) {
2442
super(label, collapsibleState)
2543
this.tooltip = `${this.label}`

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy