Skip to content

Commit d44f957

Browse files
feat: Add protect & unprotect workunit to WU context menu
Signed-off-by: David de Hilster <[email protected]>
1 parent 4ee1e25 commit d44f957

File tree

3 files changed

+27
-209
lines changed

3 files changed

+27
-209
lines changed

package.json

+14-112
Original file line numberDiff line numberDiff line change
@@ -402,64 +402,16 @@
402402
"enablement": "viewItem =~ /ECLWUNodeComplete/"
403403
},
404404
{
405-
"command": "hpccPlatform.setStateCompiled",
405+
"command": "hpccPlatform.protectWU",
406406
"category": "ECL",
407-
"title": "%Compiled%"
408-
},
409-
{
410-
"command": "hpccPlatform.setStateRunning",
411-
"category": "ECL",
412-
"title": "%Running%"
413-
},
414-
{
415-
"command": "hpccPlatform.setStateCompleted",
416-
"category": "ECL",
417-
"title": "%Completed%"
418-
},
419-
{
420-
"command": "hpccPlatform.setStateFailed",
421-
"category": "ECL",
422-
"title": "%Failed%"
423-
},
424-
{
425-
"command": "hpccPlatform.setStateArchived",
426-
"category": "ECL",
427-
"title": "%Archived%"
428-
},
429-
{
430-
"command": "hpccPlatform.setStateAborting",
431-
"category": "ECL",
432-
"title": "%Aborting%"
433-
},
434-
{
435-
"command": "hpccPlatform.setStateAborted",
436-
"category": "ECL",
437-
"title": "%Aborted%"
438-
},
439-
{
440-
"command": "hpccPlatform.setStateBlocked",
441-
"category": "ECL",
442-
"title": "%Blocked%"
443-
},
444-
{
445-
"command": "hpccPlatform.setStateSubmitted",
446-
"category": "ECL",
447-
"title": "%Submitted%"
448-
},
449-
{
450-
"command": "hpccPlatform.setStateScheduled",
451-
"category": "ECL",
452-
"title": "%Scheduled%"
453-
},
454-
{
455-
"command": "hpccPlatform.setStateCompiling",
456-
"category": "ECL",
457-
"title": "%Compiling%"
407+
"title": "%Protect Workunit%",
408+
"enablement": "viewItem =~ /ECLWUNodeComplete/"
458409
},
459410
{
460-
"command": "hpccPlatform.setStateWaiting",
411+
"command": "hpccPlatform.unprotectWU",
461412
"category": "ECL",
462-
"title": "%Waiting%"
413+
"title": "%Unprotect Workunit%",
414+
"enablement": "viewItem =~ /ECLWUNodeComplete/"
463415
},
464416
{
465417
"command": "hpccPlatform.refresh",
@@ -712,63 +664,7 @@
712664
}
713665
}
714666
],
715-
"submenus": [
716-
{
717-
"id": "setState",
718-
"label": "Set State"
719-
}
720-
],
721667
"menus": {
722-
"setState": [
723-
{
724-
"command": "hpccPlatform.setStateCompiled",
725-
"group": "set@01"
726-
},
727-
{
728-
"command": "hpccPlatform.setStateRunning",
729-
"group": "set@02"
730-
},
731-
{
732-
"command": "hpccPlatform.setStateCompleted",
733-
"group": "set@03"
734-
},
735-
{
736-
"command": "hpccPlatform.setStateFailed",
737-
"group": "set@04"
738-
},
739-
{
740-
"command": "hpccPlatform.setStateArchived",
741-
"group": "set@05"
742-
},
743-
{
744-
"command": "hpccPlatform.setStateAborting",
745-
"group": "set@06"
746-
},
747-
{
748-
"command": "hpccPlatform.setStateAborted",
749-
"group": "set@07"
750-
},
751-
{
752-
"command": "hpccPlatform.setStateBlocked",
753-
"group": "set@08"
754-
},
755-
{
756-
"command": "hpccPlatform.setStateSubmitted",
757-
"group": "set@09"
758-
},
759-
{
760-
"command": "hpccPlatform.setStateScheduled",
761-
"group": "set@10"
762-
},
763-
{
764-
"command": "hpccPlatform.setStateCompiling",
765-
"group": "set@11"
766-
},
767-
{
768-
"command": "hpccPlatform.setStateWaiting",
769-
"group": "set@12"
770-
}
771-
],
772668
"explorer/context": [
773669
{
774670
"when": "resourceLangId == ecl && resourceExtname == .ecl",
@@ -971,8 +867,14 @@
971867
"group": "3action@920"
972868
},
973869
{
974-
"submenu": "setState",
975-
"group": "3action@950"
870+
"when": "view == hpccPlatform && viewItem =~ /ECLWUNodeUnprotected/",
871+
"command": "hpccPlatform.protectWU",
872+
"group": "3action@930"
873+
},
874+
{
875+
"when": "view == hpccPlatform && viewItem =~ /ECLWUNodeProtected/",
876+
"command": "hpccPlatform.unprotectWU",
877+
"group": "3action@940"
976878
},
977879
{
978880
"command": "hpccResources.bundles.homepage",

package.nls.json

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
"Ping interval (secs, -1 to disable)": "Ping interval (secs, -1 to disable)",
8080
"Pinned launch configurations": "Pinned launch configurations",
8181
"Private": "Private",
82+
"Protect": "Protect",
83+
"Protect Workunit": "Protect Workunit",
8284
"Public": "Public",
8385
"Refresh": "Refresh",
8486
"Refresh Tree": "Refresh Tree",
@@ -123,6 +125,7 @@
123125
"Terminal": "Terminal",
124126
"Uninstall": "Uninstall",
125127
"Uninstall Bundle": "Uninstall Bundle",
128+
"Unprotect Workunit": "Unprotect Workunit",
126129
"User ID": "User ID",
127130
"User password": "User password",
128131
"Verify ECL Digital Signature": "Verify ECL Digital Signature",

src/ecl/eclWatchTree.ts

+10-97
Original file line numberDiff line numberDiff line change
@@ -93,52 +93,12 @@ export class ECLWatchTree extends Tree {
9393
wuNode.delete();
9494
});
9595

96-
vscode.commands.registerCommand("hpccPlatform.setStateCompiled", (wuNode: ECLWUNode) => {
97-
wuNode.setStateCompiled();
96+
vscode.commands.registerCommand("hpccPlatform.protectWU", (wuNode: ECLWUNode) => {
97+
wuNode.protect();
9898
});
9999

100-
vscode.commands.registerCommand("hpccPlatform.setStateRunning", (wuNode: ECLWUNode) => {
101-
wuNode.setStateRunning();
102-
});
103-
104-
vscode.commands.registerCommand("hpccPlatform.setStateCompleted", (wuNode: ECLWUNode) => {
105-
wuNode.setStateCompleted();
106-
});
107-
108-
vscode.commands.registerCommand("hpccPlatform.setStateFailed", (wuNode: ECLWUNode) => {
109-
wuNode.setStateFailed();
110-
});
111-
112-
vscode.commands.registerCommand("hpccPlatform.setStateArchived", (wuNode: ECLWUNode) => {
113-
wuNode.setStateArchived();
114-
});
115-
116-
vscode.commands.registerCommand("hpccPlatform.setStateAborting", (wuNode: ECLWUNode) => {
117-
wuNode.setStateAborting();
118-
});
119-
120-
vscode.commands.registerCommand("hpccPlatform.setStateAborted", (wuNode: ECLWUNode) => {
121-
wuNode.setStateAborted();
122-
});
123-
124-
vscode.commands.registerCommand("hpccPlatform.setStateBlocked", (wuNode: ECLWUNode) => {
125-
wuNode.setStateBlocked();
126-
});
127-
128-
vscode.commands.registerCommand("hpccPlatform.setStateSubmitted", (wuNode: ECLWUNode) => {
129-
wuNode.setStateSubmitted();
130-
});
131-
132-
vscode.commands.registerCommand("hpccPlatform.setStateScheduled", (wuNode: ECLWUNode) => {
133-
wuNode.setStateScheduled();
134-
});
135-
136-
vscode.commands.registerCommand("hpccPlatform.setStateCompiling", (wuNode: ECLWUNode) => {
137-
wuNode.setStateCompiling();
138-
});
139-
140-
vscode.commands.registerCommand("hpccPlatform.setStateWait", (wuNode: ECLWUNode) => {
141-
wuNode.setStateWait();
100+
vscode.commands.registerCommand("hpccPlatform.unprotectWU", (wuNode: ECLWUNode) => {
101+
wuNode.unprotect();
142102
});
143103

144104
}
@@ -448,60 +408,12 @@ export class ECLWUNode extends Item<ECLWatchTree> {
448408
this._wu.abort().then(() => this._tree.refresh(this));
449409
}
450410

451-
setState(stateID: WUStateID) {
452-
const service = new WorkunitsService({ baseUrl: this._wu.BaseUrl });
453-
return service.WUUpdate({
454-
Wuid: this._wu.Wuid,
455-
State: stateID as unknown as string
456-
}).then(() => this._tree.refresh());
457-
}
458-
459-
setStateCompiled() {
460-
this.setState(WUStateID.Compiled);
461-
}
462-
463-
setStateRunning() {
464-
this.setState(WUStateID.Running);
465-
}
466-
467-
setStateCompleted() {
468-
this.setState(WUStateID.Completed);
469-
}
470-
471-
setStateFailed() {
472-
this.setState(WUStateID.Failed);
473-
}
474-
475-
setStateArchived() {
476-
this.setState(WUStateID.Archived);
477-
}
478-
479-
setStateAborting() {
480-
this.setState(WUStateID.Aborting);
481-
}
482-
483-
setStateAborted() {
484-
this.setState(WUStateID.Aborted);
485-
}
486-
487-
setStateBlocked() {
488-
this.setState(WUStateID.Blocked);
489-
}
490-
491-
setStateSubmitted() {
492-
this.setState(WUStateID.Submitted);
493-
}
494-
495-
setStateScheduled() {
496-
this.setState(WUStateID.Scheduled);
497-
}
498-
499-
setStateCompiling() {
500-
this.setState(WUStateID.Compiling);
411+
protect() {
412+
this._wu.protect().then(() => this._tree.refresh());
501413
}
502414

503-
setStateWait() {
504-
this.setState(WUStateID.Wait);
415+
unprotect() {
416+
this._wu.unprotect().then(() => this._tree.refresh());
505417
}
506418

507419
delete() {
@@ -525,7 +437,8 @@ export class ECLWUNode extends Item<ECLWatchTree> {
525437
}
526438

527439
contextValue(): string {
528-
return this._wu.isComplete() ? "ECLWUNodeComplete" : "ECLWUNode";
440+
const prot = this._wu.Protected ? ",ECLWUNodeProtected" : ",ECLWUNodeUnprotected";
441+
return this._wu.isComplete() ? `ECLWUNodeComplete${prot}` : `ECLWUNode${prot}`;
529442
}
530443
}
531444

0 commit comments

Comments
 (0)