Skip to content

Commit 9c243f2

Browse files
authored
Add 'Reveal in Explorer' command for pushed/not pushed components (#2064)
* Add 'Reveal in Explorer' command for pushed/not pushed components This PR fixes #2011. Signed-off-by: Denis Golovin dgolovin@redhat.com
1 parent 7940bd8 commit 9c243f2

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

package.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,10 @@
782782
"title": "Open Add CRC Cluster Wizard",
783783
"category": "OpenShift"
784784
},
785+
{
786+
"command": "openshift.component.revealContextInExplorer",
787+
"title": "Reveal in Explorer"
788+
},
785789
{
786790
"command": "openshift.component.test",
787791
"title": "Test",
@@ -1054,6 +1058,10 @@
10541058
{
10551059
"command": "openshift.component.watch.showLog",
10561060
"when": "false"
1061+
},
1062+
{
1063+
"command": "openshift.component.revealContextInExplorer",
1064+
"when": "false"
10571065
}
10581066
],
10591067
"view/title": [
@@ -1320,19 +1328,24 @@
13201328
"group": "c4@6"
13211329
},
13221330
{
1323-
"command": "openshift.component.delete",
1324-
"when": "view == openshiftProjectExplorer && viewItem == componentNoContext",
1331+
"command": "openshift.component.revealContextInExplorer",
1332+
"when": "view == openshiftProjectExplorer && viewItem == component || viewItem == componentNotPushed",
13251333
"group": "c5@1"
13261334
},
1335+
{
1336+
"command": "openshift.component.delete",
1337+
"when": "view == openshiftProjectExplorer && viewItem == componentNoContext || ",
1338+
"group": "c6@1"
1339+
},
13271340
{
13281341
"command": "openshift.component.delete",
13291342
"when": "view == openshiftProjectExplorer && viewItem == component",
1330-
"group": "c5@1"
1343+
"group": "c6@1"
13311344
},
13321345
{
13331346
"command": "openshift.component.delete",
13341347
"when": "view == openshiftProjectExplorer && viewItem == componentNotPushed",
1335-
"group": "c5@1"
1348+
"group": "c6@1"
13361349
},
13371350
{
13381351
"command": "openshift.service.create",

src/componentsView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { Command } from './odo/command';
1414
import { EnvInfo } from './odo/env';
1515
import { vsCommand } from './vscommand';
1616

17-
1817
export interface WorkspaceEntry {
1918
uri: vsc.Uri;
2019
type: vsc.FileType;
@@ -133,6 +132,7 @@ export class ComponentsTreeDataProvider extends BaseTreeDataProvider<Entry> {
133132
await vsc.commands.executeCommand('revealInExplorer', context.contextUri);
134133
}
135134
}
135+
136136
createTreeView(id: string): vsc.TreeView<Entry> {
137137
if (!this.treeView) {
138138
this.treeView = vsc.window.createTreeView(id, {

src/openshift/component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,12 @@ export class Component extends OpenShiftItem {
976976
await Component.odo.executeInTerminal(Command.testComponent(), component.contextPath.fsPath, `OpenShift: Test '${component.getName()}' Component`);
977977
}
978978

979+
@vsCommand('openshift.component.revealContextInExplorer')
980+
public static async revealContextInExplorer(context: OpenShiftComponent): Promise<void> {
981+
await commands.executeCommand('workbench.view.explorer');
982+
await commands.executeCommand('revealInExplorer', context.contextPath);
983+
}
984+
979985
@vsCommand('openshift.component.import')
980986
// @clusterRequired() - not required because available only from context menu in application explorer
981987
static async import(component: OpenShiftObject): Promise<string | null> {

test/unit/openshift/component.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ suite('OpenShift/Component', () => {
7070
getApps = sandbox.stub(OpenShiftItem, 'getApplicationNames').resolves([appItem]);
7171
sandbox.stub(OpenShiftItem, 'getComponentNames').resolves([componentItem]);
7272
sandbox.stub(OpenShiftItem, 'getServiceNames').resolves([serviceItem]);
73-
commandStub = sandbox.stub(vscode.commands, 'executeCommand');
73+
commandStub = sandbox.stub(vscode.commands, 'executeCommand').resolves();
7474
sandbox.stub()
7575
});
7676

@@ -92,6 +92,15 @@ suite('OpenShift/Component', () => {
9292
});
9393
});
9494

95+
suite('reveal in explorer', () => {
96+
97+
test('called revealInExplorer with component\'s context', async () => {
98+
await Component.revealContextInExplorer(componentItem);
99+
expect(commandStub).calledWith('revealInExplorer', componentItem.contextPath);
100+
});
101+
102+
});
103+
95104
suite('create', () => {
96105
const componentType = new ComponentTypeAdapter(ComponentKind.S2I, 'nodejs', 'latest', 'builder,nodejs');
97106
const version = 'latest';

0 commit comments

Comments
 (0)