From f319491eb770bdf0c95e428c53002358c5745fcd Mon Sep 17 00:00:00 2001 From: Isaac Poole <55164207+isfopo@users.noreply.github.com> Date: Tue, 9 Jul 2024 23:39:28 -0400 Subject: [PATCH 1/3] removes log --- src/helpers/parse.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/helpers/parse.ts b/src/helpers/parse.ts index 0e1d25e..e25ae28 100644 --- a/src/helpers/parse.ts +++ b/src/helpers/parse.ts @@ -31,8 +31,6 @@ export const parseEnvironmentContent = (lines: string): EnvironmentContent => { value = value.replace(/\\r/g, "\r"); } - console.log(parseArg(match[3], "options")); - // Add to object obj[key] = { value, From b5c4222321bd7228c5af4d0aa5a5a407b52d9b2d Mon Sep 17 00:00:00 2001 From: Isaac Poole <55164207+isfopo@users.noreply.github.com> Date: Wed, 10 Jul 2024 08:43:38 -0400 Subject: [PATCH 2/3] flips bool on button --- package.json | 17 +++++++++++++++-- src/EnvironmentTreeviewProvider.ts | 7 +++++-- src/extension.ts | 9 +++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index eb89ec8..4e33e79 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,14 @@ "light": "assets/light/edit.svg", "dark": "assets/dark/edit.svg" } + }, + { + "command": "environments.flip", + "title": "Flip", + "icon": { + "light": "assets/light/boolean.svg", + "dark": "assets/dark/boolean.svg" + } } ], "menus": { @@ -49,7 +57,12 @@ "view/item/context": [ { "command": "environments.edit", - "when": "view == environments-sidebar && viewItem == keyValue", + "when": "view == environments-sidebar && viewItem == keyValue-string", + "group": "inline" + }, + { + "command": "environments.flip", + "when": "view == environments-sidebar && viewItem == keyValue-bool", "group": "inline" } ] @@ -109,4 +122,4 @@ "webpack": "^5.92.1", "webpack-cli": "^5.1.4" } -} +} \ No newline at end of file diff --git a/src/EnvironmentTreeviewProvider.ts b/src/EnvironmentTreeviewProvider.ts index 0f1c442..1822f61 100644 --- a/src/EnvironmentTreeviewProvider.ts +++ b/src/EnvironmentTreeviewProvider.ts @@ -5,6 +5,10 @@ import type { EnvironmentContent, EnvironmentKeyValue } from "./types"; export class EnvironmentTreeviewProvider implements vscode.TreeDataProvider { + flip(element: EnvironmentKeyValueTreeItem) { + this.edit(element, element.value.value === "true" ? "false" : "true"); + this.refresh(); + } private _onDidChangeTreeData: vscode.EventEmitter< vscode.TreeItem | undefined | void > = new vscode.EventEmitter(); @@ -107,12 +111,11 @@ export class EnvironmentKeyValueTreeItem extends vscode.TreeItem { public readonly key: string, public readonly value: EnvironmentKeyValue, public readonly parent: EnvironmentFileTreeItem, - public readonly type: EnvironmentValueType = EnvironmentValueType.string, public readonly collapsibleState: vscode.TreeItemCollapsibleState = vscode .TreeItemCollapsibleState.None ) { super(key, collapsibleState); - this.contextValue = "keyValue"; + this.contextValue = `keyValue-${this.value.type}`; this.tooltip = this.value.value; this.description = this.value.value; } diff --git a/src/extension.ts b/src/extension.ts index 325e5f7..788bbef 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -65,6 +65,15 @@ export function activate(context: vscode.ExtensionContext) { } } ); + + vscode.commands.registerCommand( + "environments.flip", + async (element: EnvironmentKeyValueTreeItem) => { + if (element.value.type === "bool") { + treeDataProvider.flip(element); + } + } + ); } // this method is called when your extension is deactivated From 5c769890f7da3055eae5e3bf3867b8ebc6a7b97f Mon Sep 17 00:00:00 2001 From: Isaac Poole <55164207+isfopo@users.noreply.github.com> Date: Wed, 10 Jul 2024 09:00:15 -0400 Subject: [PATCH 3/3] uses icon refs --- assets/dark/boolean.svg | 1 - assets/dark/dependency.svg | 1 - assets/dark/document.svg | 1 - assets/dark/edit.svg | 1 - assets/dark/folder.svg | 1 - assets/dark/number.svg | 1 - assets/dark/refresh.svg | 1 - assets/dark/string.svg | 1 - assets/light/boolean.svg | 1 - assets/light/dependency.svg | 1 - assets/light/document.svg | 1 - assets/light/edit.svg | 1 - assets/light/folder.svg | 1 - assets/light/number.svg | 1 - assets/light/refresh.svg | 1 - assets/light/string.svg | 1 - package.json | 15 +++------------ 17 files changed, 3 insertions(+), 28 deletions(-) delete mode 100644 assets/dark/boolean.svg delete mode 100644 assets/dark/dependency.svg delete mode 100644 assets/dark/document.svg delete mode 100755 assets/dark/edit.svg delete mode 100644 assets/dark/folder.svg delete mode 100644 assets/dark/number.svg delete mode 100644 assets/dark/refresh.svg delete mode 100644 assets/dark/string.svg delete mode 100644 assets/light/boolean.svg delete mode 100644 assets/light/dependency.svg delete mode 100644 assets/light/document.svg delete mode 100755 assets/light/edit.svg delete mode 100644 assets/light/folder.svg delete mode 100644 assets/light/number.svg delete mode 100644 assets/light/refresh.svg delete mode 100644 assets/light/string.svg diff --git a/assets/dark/boolean.svg b/assets/dark/boolean.svg deleted file mode 100644 index d85957b..0000000 --- a/assets/dark/boolean.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/dark/dependency.svg b/assets/dark/dependency.svg deleted file mode 100644 index 2bcd336..0000000 --- a/assets/dark/dependency.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/dark/document.svg b/assets/dark/document.svg deleted file mode 100644 index 46a9f38..0000000 --- a/assets/dark/document.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/dark/edit.svg b/assets/dark/edit.svg deleted file mode 100755 index da956cb..0000000 --- a/assets/dark/edit.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/dark/folder.svg b/assets/dark/folder.svg deleted file mode 100644 index 13b18d1..0000000 --- a/assets/dark/folder.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/dark/number.svg b/assets/dark/number.svg deleted file mode 100644 index 421c491..0000000 --- a/assets/dark/number.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/dark/refresh.svg b/assets/dark/refresh.svg deleted file mode 100644 index d79fdaa..0000000 --- a/assets/dark/refresh.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/dark/string.svg b/assets/dark/string.svg deleted file mode 100644 index e08a57f..0000000 --- a/assets/dark/string.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/light/boolean.svg b/assets/light/boolean.svg deleted file mode 100644 index b5b64b6..0000000 --- a/assets/light/boolean.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/light/dependency.svg b/assets/light/dependency.svg deleted file mode 100644 index 39bd11c..0000000 --- a/assets/light/dependency.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/light/document.svg b/assets/light/document.svg deleted file mode 100644 index 949a376..0000000 --- a/assets/light/document.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/light/edit.svg b/assets/light/edit.svg deleted file mode 100755 index ecde924..0000000 --- a/assets/light/edit.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/light/folder.svg b/assets/light/folder.svg deleted file mode 100644 index 3d64ae7..0000000 --- a/assets/light/folder.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/light/number.svg b/assets/light/number.svg deleted file mode 100644 index 7b02665..0000000 --- a/assets/light/number.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/light/refresh.svg b/assets/light/refresh.svg deleted file mode 100644 index e034574..0000000 --- a/assets/light/refresh.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/light/string.svg b/assets/light/string.svg deleted file mode 100644 index 943e69c..0000000 --- a/assets/light/string.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/package.json b/package.json index 4e33e79..261ac59 100644 --- a/package.json +++ b/package.json @@ -24,26 +24,17 @@ { "command": "environments.refresh", "title": "Refresh", - "icon": { - "light": "assets/light/refresh.svg", - "dark": "assets/dark/refresh.svg" - } + "icon": "$(refresh)" }, { "command": "environments.edit", "title": "Edit", - "icon": { - "light": "assets/light/edit.svg", - "dark": "assets/dark/edit.svg" - } + "icon": "$(edit)" }, { "command": "environments.flip", "title": "Flip", - "icon": { - "light": "assets/light/boolean.svg", - "dark": "assets/dark/boolean.svg" - } + "icon": "$(sync)" } ], "menus": {