Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"onCommand:openshift.component.followLog.palette",
"onCommand:openshift.component.delete",
"onCommand:openshift.component.push",
"onCommand:openshift.component.last.push",
"onCommand:openshift.component.push.palette",
"onCommand:openshift.component.watch",
"onCommand:openshift.component.watch.palette",
Expand Down Expand Up @@ -248,6 +249,11 @@
"title": "Push Component",
"category": "OpenShift"
},
{
"command": "openshift.component.last.push",
"title": "Repeat last push command",
"category": "OpenShift"
},
{
"command": "openshift.component.watch",
"title": "Watch",
Expand Down Expand Up @@ -345,6 +351,23 @@
"category": "OpenShift"
}
],
"keybindings": [
{
"command": "openshift.explorer.login",
"key": "alt+shift+l",
"mac": "ctrl+shift+l"
},
{
"command": "openshift.explorer.refresh",
Comment thread
sudhirverma marked this conversation as resolved.
Outdated
"key": "alt+shift+r",
"mac": "ctrl+shift+r"
},
{
"command": "openshift.component.last.push",
"key": "alt+shift+p",
"mac": "ctrl+shift+p"
}
],
"viewsContainers": {
"activitybar": [
{
Expand Down
1 change: 1 addition & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export async function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand('openshift.component.create.binary', (context) => execute(Component.createFromBinary, context)),
vscode.commands.registerCommand('openshift.component.delete.palette', (context) => execute(Component.del, context)),
vscode.commands.registerCommand('openshift.component.push', (context) => execute(Component.push, context)),
vscode.commands.registerCommand('openshift.component.last.push', (context) => execute(Component.lastPush, context)),
vscode.commands.registerCommand('openshift.component.push.palette', (context) => execute(Component.push, context)),
vscode.commands.registerCommand('openshift.component.watch', (context) => execute(Component.watch, context)),
vscode.commands.registerCommand('openshift.component.watch.palette', (context) => execute(Component.watch, context)),
Expand Down
21 changes: 20 additions & 1 deletion src/openshift/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { V1ServicePort, V1Service } from '@kubernetes/client-node';
import { isURL } from 'validator';
import { Refs, Ref, Type } from '../util/refs';
import { Delayer } from '../util/async';
import { contextGlobalState } from '../extension';

export class Component extends OpenShiftItem {

Expand Down Expand Up @@ -148,13 +149,31 @@ export class Component extends OpenShiftItem {
);
}

static getPushCmd(): Thenable< string | undefined> {
return contextGlobalState.globalState.get('PUSH');
}

static setPushCmd(component: string, application: string, project: string): Thenable<void> {
return contextGlobalState.globalState.update('PUSH', Command.pushComponent(project, application, component));
}

static async push(context: OpenShiftObject): Promise<string> {
const component = await Component.getOpenShiftCmdData(context,
"In which Project you want to push the changes",
"In which Application you want to push the changes",
"For which Component you want to push the changes");
if (!component) return null;
Component.odo.executeInTerminal(Command.pushComponent(component.getParent().getParent().getName(), component.getParent().getName(), component.getName()));
Component.setPushCmd(component.getName(), component.getParent().getName(), component.getParent().getParent().getName());
Component.odo.executeInTerminal(Command.pushComponent(component.getParent().getParent().getName(), component.getParent().getName(), component.getName()))
}

static async lastPush() {
const getPushCmd = await Component.getPushCmd();
if (getPushCmd) {
Component.odo.executeInTerminal(getPushCmd);
} else {
throw Error('No existing push command found');
}
}

static async watch(context: OpenShiftObject): Promise<void> {
Expand Down
11 changes: 11 additions & 0 deletions test/openshift/component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as Util from '../../src/util/async';
import { Refs } from '../../src/util/refs';
import { OpenShiftItem } from '../../src/openshift/openshiftItem';
import pq = require('proxyquire');
import { contextGlobalState } from '../../src/extension';

const expect = chai.expect;
chai.use(sinonChai);
Expand Down Expand Up @@ -664,12 +665,15 @@ suite('OpenShift/Component', () => {
});

suite('push', () => {
let getpushStub;

setup(() => {
quickPickStub = sandbox.stub(vscode.window, 'showQuickPick');
quickPickStub.onFirstCall().resolves(projectItem);
quickPickStub.onSecondCall().resolves(appItem);
quickPickStub.onThirdCall().resolves(componentItem);
getpushStub = sandbox.stub(Component, 'getPushCmd').resolves(undefined);
sandbox.stub(Component, 'setPushCmd');
});

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

expect(termStub).calledOnceWith(Command.pushComponent(projectItem.getName(), appItem.getName(), componentItem.getName()));
});

test('works from keybinding', async () => {
getpushStub.resolves(`odo push ${componentItem.getName()} --app ${appItem.getName()} --project ${projectItem.getName()}`);
await Component.push(null);

expect(termStub).calledOnceWith(Command.pushComponent(projectItem.getName(), appItem.getName(), componentItem.getName()));
});
});

suite('watch', () => {
Expand Down