Skip to content

Commit a6c7e4c

Browse files
authored
Merge a0ea78c into a4ce8ac
2 parents a4ce8ac + a0ea78c commit a6c7e4c

20 files changed

Lines changed: 4114 additions & 70 deletions

packages/zowe-explorer-api/__mocks__/vscode.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,15 @@ export enum QuickPickItemKind {
153153
Default = 0,
154154
}
155155

156+
/**
157+
* A location in the editor at which progress notifications can be shown.
158+
*/
159+
export enum ProgressLocation {
160+
SourceControl = 1,
161+
Window = 10,
162+
Notification = 15,
163+
}
164+
156165
/**
157166
* Represents a tab within a {@link TabGroup group of tabs}.
158167
* Tabs are merely the graphical representation within the editor area.
@@ -496,6 +505,17 @@ export namespace window {
496505
};
497506
}
498507

508+
export function showInputBox(_options?: any): Thenable<string | undefined> {
509+
return Promise.resolve(undefined);
510+
}
511+
512+
export function withProgress<R>(
513+
_options: { location: any; title?: string; cancellable?: boolean },
514+
task: (progress: { report: (value: { increment?: number; message?: string }) => void }, token: any) => Thenable<R>
515+
): Thenable<R> {
516+
return task({ report: () => {} }, { isCancellationRequested: false, onCancellationRequested: () => ({ dispose: () => {} }) }) as Thenable<R>;
517+
}
518+
499519
/**
500520
* Options to configure the behavior of the message.
501521
*

packages/zowe-explorer-ftp-extension/__mocks__/@zowe/zowe-explorer-api.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ export namespace Gui {
5252
export function warningMessage() {
5353
return undefined;
5454
}
55+
56+
export function setStatusBarMessage(_text: string, _timeoutOrThenable?: number | Promise<any>): { dispose(): void } {
57+
return { dispose: () => {} };
58+
}
5559
}
5660

5761
export class ZoweVsCodeExtension {

packages/zowe-explorer/src/trees/shared/SharedInit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export class SharedInit {
195195

196196
// Zowe Native registrations
197197
const zoweExplorerApi = ZoweExplorerApiRegister.getInstance().getExplorerExtenderApi();
198-
context.subscriptions.push(...zowex.registerCommands(context, zoweExplorerApi));
198+
context.subscriptions.push(...zowex.Utilities.registerCommands(context, zoweExplorerApi));
199199
context.subscriptions.push(zowex.SshClientCache.initialize(zoweExplorerApi.getProfilesCache()));
200200
zowex.handleNativeSshSettings(context);
201201

packages/zowex-for-zowe-explorer/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@
3333
"lint:test": "eslint --format stylish \"tests/**/*.ts\"",
3434
"madge": "madge -c --no-color --no-spinner --exclude __mocks__ --extensions js,ts src/",
3535
"package": "echo 'zowex: nothing to package.'",
36-
"oldtest": "vitest run --coverage",
37-
"oldtest:ui": "vitest --ui --coverage",
38-
"oldtest:watch": "vitest --watch",
3936
"test": "vitest run --coverage",
37+
"test:ui": "vitest --ui --coverage",
38+
"test:watch": "vitest --watch",
4039
"watch": "tsc --watch -p ./"
4140
},
4241
"dependencies": {

packages/zowex-for-zowe-explorer/src/Utilities.ts

Lines changed: 76 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -18,71 +18,87 @@ import { SshClientCache } from "./SshClientCache";
1818
import { SshErrorHandler } from "./SshErrorHandler";
1919
import { deployWithProgress } from "./ServerDeployment";
2020

21-
export function registerCommands(context: vscode.ExtensionContext, zoweExplorerApi: IApiExplorerExtender): vscode.Disposable[] {
22-
const profCache = zoweExplorerApi.getProfilesCache();
23-
return [
24-
vscode.commands.registerCommand(`zowe.zowex.connect`, async (profName?: string) => {
25-
imperative.Logger.getAppLogger().trace("Running connect command for profile %s", profName);
26-
const vscePromptApi = new VscePromptApi(await profCache.getProfileInfo());
27-
const profile = await vscePromptApi.promptForProfile(profName, { prioritizeProjectLevelConfig: false });
28-
if (!profile?.profile) {
29-
return;
30-
}
31-
const defaultServerPath = ConfigUtils.getServerPath(profile.profile);
32-
const deployDirectory = await vscePromptApi.promptForDeployDirectory(profile.profile.host, defaultServerPath);
33-
if (!deployDirectory) {
34-
return;
35-
}
21+
export class Utilities {
22+
public static registerCommands(_context: vscode.ExtensionContext, zoweExplorerApi: IApiExplorerExtender): vscode.Disposable[] {
23+
return [
24+
vscode.commands.registerCommand(`zowe.zowex.connect`, async (profName?: string) => {
25+
await Utilities.connectCallback(zoweExplorerApi, profName);
26+
}),
27+
vscode.commands.registerCommand(`zowe.zowex.restart`, async (profName?: string) => {
28+
await Utilities.restartCallback(zoweExplorerApi, profName);
29+
}),
30+
vscode.commands.registerCommand(`zowe.zowex.uninstall`, async (profName?: string) => {
31+
await Utilities.uninstallCallback(zoweExplorerApi, profName);
32+
}),
33+
];
34+
}
3635

37-
const sshSession = ZSshUtils.buildSession(profile.profile);
38-
const deployStatus = await deployWithProgress(sshSession, deployDirectory);
39-
if (!deployStatus) {
40-
return;
41-
}
36+
private static async connectCallback(zoweExplorerApi: IApiExplorerExtender, profName?: string): Promise<void> {
37+
imperative.Logger.getAppLogger().trace("Running connect command for profile %s", profName);
38+
const profCache = zoweExplorerApi.getProfilesCache();
39+
const vscePromptApi = new VscePromptApi(await profCache.getProfileInfo());
40+
const profile = await vscePromptApi.promptForProfile(profName, { prioritizeProjectLevelConfig: false });
41+
if (!profile?.profile) {
42+
return;
43+
}
44+
const defaultServerPath = ConfigUtils.getServerPath(profile.profile);
45+
const deployDirectory = await vscePromptApi.promptForDeployDirectory(profile.profile.host, defaultServerPath);
46+
if (!deployDirectory) {
47+
return;
48+
}
4249

43-
await ConfigUtils.showSessionInTree(profile.name!, true, zoweExplorerApi);
44-
const infoMsg = `Installed Zowe Remote SSH server on ${(profile.profile.host as string) ?? profile.name}`;
45-
imperative.Logger.getAppLogger().info(infoMsg);
46-
await Gui.showMessage(infoMsg);
47-
}),
48-
vscode.commands.registerCommand(`zowe.zowex.restart`, async (profName?: string) => {
49-
imperative.Logger.getAppLogger().trace("Running restart command for profile %s", profName);
50-
const vscePromptApi = new VscePromptApi(await profCache.getProfileInfo());
51-
const profile = await vscePromptApi.promptForProfile(profName, { prioritizeProjectLevelConfig: false, disableCreateNewProfile: true });
52-
if (!profile?.profile) {
53-
return;
54-
}
50+
const sshSession = ZSshUtils.buildSession(profile.profile);
51+
const deployStatus = await deployWithProgress(sshSession, deployDirectory);
52+
if (!deployStatus) {
53+
return;
54+
}
5555

56-
await SshClientCache.inst.connect(profile, { restart: true, retryRequests: false });
56+
await ConfigUtils.showSessionInTree(profile.name!, true, zoweExplorerApi);
57+
const infoMsg = `Installed Zowe Remote SSH server on ${(profile.profile.host as string) ?? profile.name}`;
58+
imperative.Logger.getAppLogger().info(infoMsg);
59+
await Gui.showMessage(infoMsg);
60+
}
5761

58-
imperative.Logger.getAppLogger().info(`Restarted Zowe Remote SSH server on ${(profile.profile?.host as string) ?? profile.name}`);
59-
const statusMsg = Gui.setStatusBarMessage("Restarted Zowe Remote SSH server");
60-
setTimeout(() => {
61-
statusMsg.dispose();
62-
// eslint-disable-next-line no-magic-numbers
63-
}, 5000);
64-
}),
65-
vscode.commands.registerCommand(`zowe.zowex.uninstall`, async (profName?: string) => {
66-
imperative.Logger.getAppLogger().trace("Running uninstall command for profile %s", profName);
67-
const vscePromptApi = new VscePromptApi(await profCache.getProfileInfo());
68-
const profile = await vscePromptApi.promptForProfile(profName, { prioritizeProjectLevelConfig: false, disableCreateNewProfile: true });
69-
if (!profile?.profile) {
70-
return;
71-
}
62+
private static async restartCallback(zoweExplorerApi: IApiExplorerExtender, profName?: string): Promise<void> {
63+
imperative.Logger.getAppLogger().trace("Running restart command for profile %s", profName);
64+
const profCache = zoweExplorerApi.getProfilesCache();
65+
const vscePromptApi = new VscePromptApi(await profCache.getProfileInfo());
66+
const profile = await vscePromptApi.promptForProfile(profName, { prioritizeProjectLevelConfig: false, disableCreateNewProfile: true });
67+
if (!profile?.profile) {
68+
return;
69+
}
7270

73-
SshClientCache.inst.end(profile);
74-
const serverPath = ConfigUtils.getServerPath(profile.profile);
75-
await ConfigUtils.showSessionInTree(profile.name!, false, zoweExplorerApi);
71+
await SshClientCache.inst.connect(profile, { restart: true, retryRequests: false });
7672

77-
// Create error callback for uninstall operation
78-
const errorCallback = SshErrorHandler.getInstance().createErrorCallback(ZoweExplorerApiType.All, "Server uninstall");
79-
await ZSshUtils.uninstallServer(ZSshUtils.buildSession(profile.profile), serverPath, {
80-
onError: errorCallback,
81-
});
73+
imperative.Logger.getAppLogger().info(`Restarted Zowe Remote SSH server on ${(profile.profile?.host as string) ?? profile.name}`);
74+
const statusMsg = Gui.setStatusBarMessage("Restarted Zowe Remote SSH server");
75+
setTimeout(() => {
76+
statusMsg.dispose();
77+
// eslint-disable-next-line no-magic-numbers
78+
}, 5000);
79+
}
8280

83-
const infoMsg = `Uninstalled Zowe Remote SSH server from ${(profile.profile.host as string) ?? profile.name}`;
84-
imperative.Logger.getAppLogger().info(infoMsg);
85-
await Gui.showMessage(infoMsg);
86-
}),
87-
];
81+
private static async uninstallCallback(zoweExplorerApi: IApiExplorerExtender, profName?: string): Promise<void> {
82+
imperative.Logger.getAppLogger().trace("Running uninstall command for profile %s", profName);
83+
const profCache = zoweExplorerApi.getProfilesCache();
84+
const vscePromptApi = new VscePromptApi(await profCache.getProfileInfo());
85+
const profile = await vscePromptApi.promptForProfile(profName, { prioritizeProjectLevelConfig: false, disableCreateNewProfile: true });
86+
if (!profile?.profile) {
87+
return;
88+
}
89+
90+
SshClientCache.inst.end(profile);
91+
const serverPath = ConfigUtils.getServerPath(profile.profile);
92+
await ConfigUtils.showSessionInTree(profile.name!, false, zoweExplorerApi);
93+
94+
// Create error callback for uninstall operation
95+
const errorCallback = SshErrorHandler.getInstance().createErrorCallback(ZoweExplorerApiType.All, "Server uninstall");
96+
await ZSshUtils.uninstallServer(ZSshUtils.buildSession(profile.profile), serverPath, {
97+
onError: errorCallback,
98+
});
99+
100+
const infoMsg = `Uninstalled Zowe Remote SSH server from ${(profile.profile.host as string) ?? profile.name}`;
101+
imperative.Logger.getAppLogger().info(infoMsg);
102+
await Gui.showMessage(infoMsg);
103+
}
88104
}

packages/zowex-for-zowe-explorer/src/api/SshUssApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export class SshUssApi extends SshCommonApi implements MainframeInteraction.IUss
190190
throw new Error("File no longer exists");
191191
}
192192
const isDir = ussItem.apiResponse.items[0].mode.startsWith("d");
193-
let success = false;
193+
let success = true;
194194
if (attributes.tag) {
195195
const response = await (
196196
await this.client

packages/zowex-for-zowe-explorer/src/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/**
2+
* This program and the accompanying materials are made available under the terms of the
3+
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
4+
* https://www.eclipse.org/legal/epl-v20.html
5+
*
6+
* SPDX-License-Identifier: EPL-2.0
7+
*
8+
* Copyright Contributors to the Zowe Project.
9+
*
10+
*/
11+
112
export * from "./api";
213
export * from "./ConfigUtils";
314
export * from "./NativeSshHelper";

0 commit comments

Comments
 (0)