Skip to content

Commit 7b47334

Browse files
committed
keybinding for push, login and refresh command
1 parent 2531a3f commit 7b47334

File tree

3 files changed

+39
-13
lines changed

3 files changed

+39
-13
lines changed

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -348,18 +348,18 @@
348348
"keybindings": [
349349
{
350350
"command": "openshift.explorer.login",
351-
"key": "ctrl+shift+l",
352-
"mac": "cmd+shift+l"
351+
"key": "alt+shift+l",
352+
"mac": "ctrl+shift+l"
353353
},
354354
{
355355
"command": "openshift.explorer.refresh",
356-
"key": "ctrl+shift+r",
357-
"mac": "cmd+shift+r"
356+
"key": "alt+shift+r",
357+
"mac": "ctrl+shift+r"
358358
},
359359
{
360-
"command": "openshift.component.push.palette",
361-
"key": "ctrl+shift+p",
362-
"mac": "cmd+shift+p"
360+
"command": "openshift.component.push",
361+
"key": "alt+shift+p",
362+
"mac": "ctrl+shift+p"
363363
}
364364
],
365365
"viewsContainers": {

src/openshift/component.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { V1ServicePort, V1Service } from '@kubernetes/client-node';
1414
import { isURL } from 'validator';
1515
import { Refs, Ref, Type } from '../util/refs';
1616
import { Delayer } from '../util/async';
17+
import { contextGlobalState } from '../extension';
1718

1819
export class Component extends OpenShiftItem {
1920

@@ -148,13 +149,27 @@ export class Component extends OpenShiftItem {
148149
);
149150
}
150151

152+
static getPushCmd(): Thenable< string | undefined> {
153+
return contextGlobalState.globalState.get('PUSH');
154+
}
155+
156+
static setPushCmd(component, application, project): Thenable<void> {
157+
return contextGlobalState.globalState.update('PUSH', `odo push ${component} --app ${application} --project ${project}`);
158+
}
159+
151160
static async push(context: OpenShiftObject): Promise<string> {
152-
const component = await Component.getOpenShiftCmdData(context,
153-
"In which Project you want to push the changes",
154-
"In which Application you want to push the changes",
155-
"For which Component you want to push the changes");
156-
if (!component) return null;
157-
Component.odo.executeInTerminal(Command.pushComponent(component.getParent().getParent().getName(), component.getParent().getName(), component.getName()));
161+
const getPushCmd = await Component.getPushCmd();
162+
if (getPushCmd && !context) {
163+
Component.odo.executeInTerminal(getPushCmd);
164+
} else {
165+
const component = await Component.getOpenShiftCmdData(context,
166+
"In which Project you want to push the changes",
167+
"In which Application you want to push the changes",
168+
"For which Component you want to push the changes");
169+
if (!component) return null;
170+
Component.setPushCmd(component.getName(), component.getParent().getName(), component.getParent().getParent().getName());
171+
Component.odo.executeInTerminal(Command.pushComponent(component.getParent().getParent().getName(), component.getParent().getName(), component.getName()));
172+
}
158173
}
159174

160175
static async watch(context: OpenShiftObject): Promise<void> {

test/openshift/component.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import * as Util from '../../src/util/async';
1717
import { Refs } from '../../src/util/refs';
1818
import { OpenShiftItem } from '../../src/openshift/openshiftItem';
1919
import pq = require('proxyquire');
20+
import { contextGlobalState } from '../../src/extension';
2021

2122
const expect = chai.expect;
2223
chai.use(sinonChai);
@@ -664,12 +665,15 @@ suite('OpenShift/Component', () => {
664665
});
665666

666667
suite('push', () => {
668+
let getpushStub;
667669

668670
setup(() => {
669671
quickPickStub = sandbox.stub(vscode.window, 'showQuickPick');
670672
quickPickStub.onFirstCall().resolves(projectItem);
671673
quickPickStub.onSecondCall().resolves(appItem);
672674
quickPickStub.onThirdCall().resolves(componentItem);
675+
getpushStub = sandbox.stub(Component, 'getPushCmd').resolves(undefined);
676+
sandbox.stub(Component, 'setPushCmd');
673677
});
674678

675679
test('returns null when cancelled', async () => {
@@ -690,6 +694,13 @@ suite('OpenShift/Component', () => {
690694

691695
expect(termStub).calledOnceWith(Command.pushComponent(projectItem.getName(), appItem.getName(), componentItem.getName()));
692696
});
697+
698+
test('works from keybinding', async () => {
699+
getpushStub.resolves(`odo push ${componentItem.getName()} --app ${appItem.getName()} --project ${projectItem.getName()}`);
700+
await Component.push(null);
701+
702+
expect(termStub).calledOnceWith(Command.pushComponent(projectItem.getName(), appItem.getName(), componentItem.getName()));
703+
});
693704
});
694705

695706
suite('watch', () => {

0 commit comments

Comments
 (0)