From 60f3cb2420642094e4772fbb2d4ab6deb0d1c9e9 Mon Sep 17 00:00:00 2001 From: urgetolearn Date: Sat, 14 Sep 2024 01:03:26 +0530 Subject: [PATCH] added "start a local network" section Signed-off-by: urgetolearn --- extension.js | 21 +++++++++++++++++++-- package.json | 18 ++++++++++++++++++ src/fabricsamples.js | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 src/fabricsamples.js diff --git a/extension.js b/extension.js index 7568602..735f818 100644 --- a/extension.js +++ b/extension.js @@ -7,14 +7,31 @@ const fs = require("fs"); const { TreeViewProvider } = require("./src/treeview"); const { createConnectionProfileWebview } = require("./src/webview"); +const fabricsamples = require('./src/fabricsamples'); + function activate(context) { + const hyperledgerProvider = new fabricsamples(); + vscode.window.registerTreeDataProvider('start-local-network', hyperledgerProvider); const treeViewProviderFabric = new TreeViewProvider( "fabric-network", context ); const treeViewProviderDesc = new TreeViewProvider("network-desc", context); const treeViewProviderWallet = new TreeViewProvider("wallets", context); - + const disposable1 = vscode.commands.registerCommand( + "myview.button1", + function () { + vscode.window.showInformationMessage("Stop Network!"); + console.log("Button1"); + } + ); + const disposable2 = vscode.commands.registerCommand( + "myview.button2", + function () { + vscode.window.showInformationMessage("Start Network!"); + console.log("Button2"); + } + ); vscode.window.createTreeView("fabric-network", { treeDataProvider: treeViewProviderFabric, }); @@ -341,7 +358,7 @@ function extractWalletDetails(walletData) { return null; } -function deactivate() {} +function deactivate() { } module.exports = { activate, diff --git a/package.json b/package.json index 0a75c0f..70eca93 100644 --- a/package.json +++ b/package.json @@ -83,6 +83,16 @@ "command": "wallets.uploadWallet", "when": "view == wallets", "group": "navigation" + }, + { + "command": "myview.button1", + "when": "view == start-local-network", + "group": "navigation" + }, + { + "command": "myview.button2", + "when": "view == start-local-network", + "group": "navigation" } ], "view/item/context": [ @@ -174,6 +184,14 @@ "title": "Delete Wallet", "category": "Wallets", "icon": "$(trash)" + }, + { + "command": "myview.button1", + "title": "🔴" + }, + { + "command": "myview.button2", + "title": "🟢" } ] }, diff --git a/src/fabricsamples.js b/src/fabricsamples.js new file mode 100644 index 0000000..23a5b3d --- /dev/null +++ b/src/fabricsamples.js @@ -0,0 +1,34 @@ +const vscode = require('vscode'); + +class fabricsamples { + constructor() { + // Define the tree structure + this.treeData = [ + { + label: "Fabric Sample", + collapsibleState: vscode.TreeItemCollapsibleState.Collapsed, // Collapsible node + + } + ]; + } + + getTreeItem(element) { + const treeItem = new vscode.TreeItem( + element.label, + element.collapsibleState + ); + return treeItem; + } + + getChildren(element) { + if (element) { + // Return children for the given element + return element.children || []; + } else { + // Return top-level items (i.e., Start a Local Network) + return this.treeData; + } + } +} + +module.exports = fabricsamples;