Skip to content

Commit 13f49b7

Browse files
authored
Add refresh and collapse all support (#26)
1 parent 5912f2f commit 13f49b7

File tree

5 files changed

+134
-3
lines changed

5 files changed

+134
-3
lines changed

package.json

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,47 @@
222222
"command": "portfolioInstruments.undeprecate",
223223
"title": "%portfolioInstruments.undeprecate%",
224224
"category": "Portfolio Instruments"
225+
},
226+
{
227+
"command": "portfolioInstruments.refresh",
228+
"title": "%portfolioInstruments.refresh%",
229+
"category": "Portfolio Instruments",
230+
"icon": "$(refresh)"
231+
},
232+
{
233+
"command": "portfolioInstruments.refreshSnapshots",
234+
"title": "%portfolioInstruments.refreshSnapshots%",
235+
"category": "Portfolio Instruments",
236+
"icon": "$(refresh)"
237+
},
238+
{
239+
"command": "portfolioInstruments.refreshAccounts",
240+
"title": "%portfolioInstruments.refreshAccounts%",
241+
"category": "Portfolio Instruments",
242+
"icon": "$(refresh)"
243+
},
244+
{
245+
"command": "portfolioInstruments.refreshHoldings",
246+
"title": "%portfolioInstruments.refreshHoldings%",
247+
"category": "Portfolio Instruments",
248+
"icon": "$(refresh)"
249+
},
250+
{
251+
"command": "portfolioInstruments.refreshBenchmarks",
252+
"title": "%portfolioInstruments.refreshBenchmarks%",
253+
"category": "Portfolio Instruments",
254+
"icon": "$(refresh)"
255+
},
256+
{
257+
"command": "portfolioInstruments.refreshSnapshot",
258+
"title": "%portfolioInstruments.refreshSnapshot%",
259+
"category": "Portfolio Instruments"
260+
},
261+
{
262+
"command": "portfolioInstruments.collapseAll",
263+
"title": "%portfolioInstruments.collapseAll%",
264+
"category": "Portfolio Instruments",
265+
"icon": "$(collapse-all)"
225266
}
226267
],
227268
"configuration": [
@@ -388,6 +429,26 @@
388429
{
389430
"command": "portfolioInstruments.undeprecate",
390431
"when": "never"
432+
},
433+
{
434+
"command": "portfolioInstruments.refreshSnapshots",
435+
"when": "never"
436+
},
437+
{
438+
"command": "portfolioInstruments.refreshAccounts",
439+
"when": "never"
440+
},
441+
{
442+
"command": "portfolioInstruments.refreshHoldings",
443+
"when": "never"
444+
},
445+
{
446+
"command": "portfolioInstruments.refreshBenchmarks",
447+
"when": "never"
448+
},
449+
{
450+
"command": "portfolioInstruments.refreshSnapshot",
451+
"when": "never"
391452
}
392453
],
393454
"view/item/context": [
@@ -506,6 +567,11 @@
506567
"when": "view =~ /portfolioInstruments.main/i && viewItem =~ /snapshotItem/i",
507568
"group": "1@1"
508569
},
570+
{
571+
"command": "portfolioInstruments.refreshSnapshot",
572+
"when": "view =~ /portfolioInstruments.main/i && viewItem =~ /snapshotItem/i",
573+
"group": "z@0"
574+
},
509575
{
510576
"command": "portfolioInstruments.updateMaturationStart",
511577
"when": "view =~ /portfolioInstruments.main/i && viewItem =~ /snapshotMaturationStartItem/i",
@@ -580,18 +646,48 @@
580646
"command": "portfolioInstruments.undeprecate",
581647
"when": "view =~ /portfolioInstruments.main/i && viewItem =~ /benchmarkDeprecatedItem/i",
582648
"group": "1@1"
649+
},
650+
{
651+
"command": "portfolioInstruments.refreshSnapshots",
652+
"when": "view =~ /portfolioInstruments.main/i && viewItem =~ /snapshotsItem/i",
653+
"group": "z@0"
654+
},
655+
{
656+
"command": "portfolioInstruments.refreshAccounts",
657+
"when": "view =~ /portfolioInstruments.main/i && viewItem =~ /accountsItem/i",
658+
"group": "z@0"
659+
},
660+
{
661+
"command": "portfolioInstruments.refreshHoldings",
662+
"when": "view =~ /portfolioInstruments.main/i && viewItem =~ /holdingsItem/i",
663+
"group": "z@0"
664+
},
665+
{
666+
"command": "portfolioInstruments.refreshBenchmarks",
667+
"when": "view =~ /portfolioInstruments.main/i && viewItem =~ /benchmarksItem/i",
668+
"group": "z@0"
583669
}
584670
],
585671
"view/title": [
586672
{
587673
"command": "portfolioInstruments.login",
588674
"when": "view == portfolioInstruments.main",
589-
"group": "navigation"
675+
"group": "navigation@1"
590676
},
591677
{
592678
"command": "portfolioInstruments.logoutAll",
593679
"when": "view == portfolioInstruments.main",
594-
"group": "navigation"
680+
"group": "navigation@2"
681+
},
682+
{
683+
"command": "portfolioInstruments.collapseAll",
684+
"when": "view == portfolioInstruments.main",
685+
"group": "navigation@3"
686+
},
687+
{
688+
"command": "portfolioInstruments.refresh",
689+
"when": "view == portfolioInstruments.main",
690+
"group": "navigation@4"
595691
}
596692
]
597693
}

package.nls.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,12 @@
4040
"portfolioInstruments.updateRebalanceSettings": "Update Rebalance Threshold...",
4141
"portfolioInstruments.plotSnapshots": "Plot Snapshots...",
4242
"portfolioInstruments.viewProperties": "View Properties",
43-
"portfolioInstruments.undeprecate": "Restore..."
43+
"portfolioInstruments.undeprecate": "Restore...",
44+
"portfolioInstruments.refresh": "Refresh",
45+
"portfolioInstruments.refreshSnapshots": "Refresh",
46+
"portfolioInstruments.refreshAccounts": "Refresh",
47+
"portfolioInstruments.refreshHoldings": "Refresh",
48+
"portfolioInstruments.refreshBenchmarks": "Refresh",
49+
"portfolioInstruments.refreshSnapshot": "Refresh",
50+
"portfolioInstruments.collapseAll": "Collapse All"
4451
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { commands } from "vscode";
2+
import { CommandContext } from "../registerCommand";
3+
4+
export async function collapseAll(_context: CommandContext): Promise<void> {
5+
await commands.executeCommand('workbench.actions.treeView.portfolioInstruments.main.collapseAll');
6+
}

src/commands/refresh/refresh.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ext } from "../../extensionVariables";
2+
import { CommandContext } from "../registerCommand";
3+
import { PiExtTreeItem } from "../../tree/PiExtTreeDataProvider";
4+
5+
export async function refresh(_context: CommandContext): Promise<void> {
6+
ext.portfolioInstrumentsTdp.refresh();
7+
}
8+
9+
export async function refreshNode(_context: CommandContext, node: PiExtTreeItem): Promise<void> {
10+
ext.portfolioInstrumentsTdp.refresh(node);
11+
}

src/commands/registerCommands.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import { updateSnapshotValue } from "./snapshotValues/updateSnapshotValue/update
3636
import { viewProperties } from "./viewProperties/viewProperties";
3737
import { toggleShowDeprecatedResources } from "./toggleShowDeprecatedResources/toggleShowDeprecatedResources";
3838
import { undeprecate } from "./undeprecate/undeprecate";
39+
import { refresh, refreshNode } from "./refresh/refresh";
40+
import { collapseAll } from "./refresh/collapseAll";
3941

4042
export function registerCommands() {
4143
// Auth
@@ -92,4 +94,13 @@ export function registerCommands() {
9294
registerCommand('portfolioInstruments.setApiEndpoint', setApiEndpoint);
9395
registerCommand('portfolioInstruments.toggleShowDeprecatedResources', toggleShowDeprecatedResources);
9496
registerCommand('portfolioInstruments.undeprecate', undeprecate);
97+
98+
// Refresh
99+
registerCommand('portfolioInstruments.refresh', refresh);
100+
registerCommand('portfolioInstruments.refreshSnapshots', refreshNode);
101+
registerCommand('portfolioInstruments.refreshAccounts', refreshNode);
102+
registerCommand('portfolioInstruments.refreshHoldings', refreshNode);
103+
registerCommand('portfolioInstruments.refreshBenchmarks', refreshNode);
104+
registerCommand('portfolioInstruments.refreshSnapshot', refreshNode);
105+
registerCommand('portfolioInstruments.collapseAll', collapseAll);
95106
}

0 commit comments

Comments
 (0)