Skip to content

Commit f5d4067

Browse files
committed
feat: ♻️ add statusbar item for deployment summary
1 parent f1d524c commit f5d4067

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@
147147
}
148148
]
149149
},
150+
"statusBar": [
151+
{
152+
"id": "deploymentReportStatus",
153+
"alignment": "right",
154+
"priority": 100,
155+
"command": "vscode-solidity-inspector.statusBar.generateDeploymentReport",
156+
"text": "$(file-code) Deployment summary",
157+
"tooltip": "View Deployment results in a table format"
158+
}
159+
],
150160
"grammars": [
151161
{
152162
"language": "tree",

src/commands/deployment-report.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const fs = require("fs");
33
const Table = require('cli-table3');
44
const { networkMap } = require("../helpers");
55

6+
const EXTENSION_PREFIX = "vscode-solidity-inspector";
7+
68
function compressHash(txHash) {
79
const first5 = txHash.substring(0, 5);
810
const last5 = txHash.substring(txHash.length - 5);
@@ -117,4 +119,24 @@ async function generateDeploymentReportContextMenu(clickedFile, selectedFiles) {
117119
}
118120
}
119121

120-
module.exports = { generateDeploymentReportActiveFile, generateDeploymentReportContextMenu };
122+
function statusBarItem() {
123+
// Add status bar item
124+
const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100);
125+
statusBarItem.command = EXTENSION_PREFIX + '.statusBar.generateDeploymentReport';
126+
statusBarItem.text = '$(file-code) Deployment Summary';
127+
statusBarItem.tooltip = 'View Deployment results in a table format';
128+
statusBarItem.show();
129+
130+
// Register the command for the status bar item
131+
vscode.commands.registerCommand(EXTENSION_PREFIX + '.statusBar.generateDeploymentReport', async () => {
132+
const activeEditor = vscode.window.activeTextEditor;
133+
if (activeEditor && activeEditor.document.fileName.endsWith('.json')) {
134+
await generateDeploymentReportActiveFile(activeEditor);
135+
} else {
136+
vscode.window.showInformationMessage('Please open a JSON file to view the deployment report.');
137+
}
138+
return statusBarItem;
139+
});
140+
}
141+
142+
module.exports = { generateDeploymentReportActiveFile, generateDeploymentReportContextMenu, statusBarItem };

src/extension.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const {
3232
} = require("./commands/highlight-unused-imports")
3333

3434
const {
35-
generateDeploymentReportActiveFile, generateDeploymentReportContextMenu
35+
generateDeploymentReportActiveFile, generateDeploymentReportContextMenu, statusBarItem
3636
} = require("./commands/deployment-report");
3737

3838
const { treeFilesCodeActionProvider, treeFilesDiagnosticCollection } = require("./commands/parse-tree");
@@ -169,6 +169,8 @@ function onActivate(context) {
169169
// Activate separator
170170
activateSeparator(context);
171171

172+
// Add status bar item to generate deployment summary
173+
context.subscriptions.push(statusBarItem());
172174
}
173175

174176

0 commit comments

Comments
 (0)