Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port fixes from main for 3.0.3 #3301

Merged
merged 17 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
9 changes: 9 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@
"console": "integratedTerminal",
"sourceMaps": true
},
{
"type": "node",
"name": "Current Unit Tests (Jest)",
"request": "launch",
"runtimeArgs": ["--inspect-brk", "${workspaceFolder}/node_modules/jest/bin/jest", "-i", "${fileBasenameNoExtension}"],
"cwd": "${workspaceFolder}/packages/zowe-explorer",
"console": "integratedTerminal",
"sourceMaps": true
},
{
"type": "node",
"name": "API Unit Tests (Jest)",
Expand Down
3 changes: 3 additions & 0 deletions packages/zowe-explorer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t

### Bug fixes

- Fixed an issue where the `responseTimeout` profile property was ignored for z/OSMF MVS and USS API calls. [#3225](https://github.com/zowe/zowe-explorer-vscode/issues/3225)
- Fixed an issue where the assignment of the `profile` property in `ZoweTreeNode.setProfileToChoice` caused references to that object to break elsewhere. [#3289](https://github.com/zowe/zowe-explorer-vscode/issues/3289)

## `3.0.2`

### New features and enhancements
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ import * as vscode from "vscode";
import { ZoweTreeNode } from "../../../src/tree/ZoweTreeNode";
import { IZoweTreeNode } from "../../../src/tree/IZoweTreeNode";
import * as imperative from "@zowe/imperative";
import { BaseProvider } from "../../../src";

describe("ZoweTreeNode", () => {
const innerProfile = { user: "apple", password: "banana" };
const fakeProfile: imperative.IProfileLoaded = {
name: "amazingProfile",
profile: innerProfile,
message: "",
type: "zosmf",
failNotFound: true,
};

const makeNode = (
name: string,
collapseState: vscode.TreeItemCollapsibleState,
Expand Down Expand Up @@ -48,8 +56,8 @@ describe("ZoweTreeNode", () => {

it("getProfile should return profile of current node", () => {
const node = makeNode("test", vscode.TreeItemCollapsibleState.None, undefined);
node.setProfileToChoice("myProfile" as unknown as imperative.IProfileLoaded);
expect(node.getProfile()).toBe("myProfile");
node.setProfileToChoice(fakeProfile);
expect(node.getProfile().name).toBe("amazingProfile");
});

it("getProfile should return profile of parent node", () => {
Expand Down Expand Up @@ -83,49 +91,43 @@ describe("ZoweTreeNode", () => {

it("setProfileToChoice should update properties on existing profile object", () => {
const node = makeNode("test", vscode.TreeItemCollapsibleState.None, undefined, undefined, {
name: "oldProfile",
profile: { host: "example.com" },
...fakeProfile,
});
node.setProfileToChoice({ name: "newProfile", profile: { host: "example.com", port: 443 } } as unknown as imperative.IProfileLoaded);
// Profile name should not change but properties should
expect(node.getProfileName()).toBe("oldProfile");
node.setProfileToChoice({ ...fakeProfile, profile: { host: "example.com", port: 443 } });
expect(node.getProfile().profile?.port).toBeDefined();
});

it("setProfileToChoice should update profile for associated FSProvider entry", () => {
const node = makeNode("test", vscode.TreeItemCollapsibleState.None, undefined);
node.resourceUri = vscode.Uri.file(__dirname);
const prof = { ...fakeProfile, profile: { ...innerProfile } };
const fsEntry = {
metadata: {
profile: { name: "oldProfile" },
profile: prof,
},
};
node.setProfileToChoice(
{ name: "newProfile" } as unknown as imperative.IProfileLoaded,
{
lookup: jest.fn().mockReturnValue(fsEntry),
} as unknown as BaseProvider
);
expect(node.getProfileName()).toBe("newProfile");
expect(fsEntry.metadata.profile.name).toBe("newProfile");
prof.profile.user = "banana";
prof.profile.password = "apple";
node.setProfileToChoice(prof);
expect(node.getProfile().profile?.user).toBe("banana");
expect(node.getProfile().profile?.password).toBe("apple");
expect(fsEntry.metadata.profile.profile?.user).toBe("banana");
expect(fsEntry.metadata.profile.profile?.password).toBe("apple");
});

it("setProfileToChoice should update child nodes with the new profile", () => {
const node = makeNode("test", vscode.TreeItemCollapsibleState.Expanded, undefined);
node.setProfileToChoice({ ...fakeProfile, profile: { ...fakeProfile.profile, user: "banana" } });
const nodeChild = makeNode("child", vscode.TreeItemCollapsibleState.None, undefined);
nodeChild.setProfileToChoice(node.getProfile());
node.children = [nodeChild as any];
const setProfileToChoiceChildMock = jest.spyOn(nodeChild, "setProfileToChoice").mockImplementation();
const fsEntry = {
metadata: {
profile: { name: "oldProfile" },
profile: node.getProfile(),
},
};
const mockNewProfile = { name: "newProfile" } as unknown as imperative.IProfileLoaded;
const mockProvider = {
lookup: jest.fn().mockReturnValue(fsEntry),
} as unknown as BaseProvider;
node.setProfileToChoice(mockNewProfile, mockProvider);
expect(node.getProfileName()).toBe("newProfile");
expect(setProfileToChoiceChildMock).toHaveBeenCalledWith(mockNewProfile, mockProvider);
expect(node.getProfile().profile?.user).toBe("banana");
expect(nodeChild.getProfile().profile?.user).toBe("banana");
expect(fsEntry.metadata.profile.profile?.user).toBe("banana");
});
});
107 changes: 82 additions & 25 deletions packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,22 @@ export namespace ZoweExplorerZosmf {
*/
export class UssApi extends CommonApi implements MainframeInteraction.IUss {
public fileList(ussFilePath: string): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.List.fileList(this.getSession(), ussFilePath);
return zosfiles.List.fileList(this.getSession(), ussFilePath, { responseTimeout: this.profile?.profile?.responseTimeout });
}

public isFileTagBinOrAscii(ussFilePath: string): Promise<boolean> {
return zosfiles.Utilities.isFileTagBinOrAscii(this.getSession(), ussFilePath);
}

public getContents(inputFilePath: string, options: zosfiles.IDownloadSingleOptions): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.Download.ussFile(this.getSession(), inputFilePath, options);
return zosfiles.Download.ussFile(this.getSession(), inputFilePath, {
responseTimeout: this.profile?.profile?.responseTimeout,
...options,
});
}

public copy(outputPath: string, options?: Omit<object, "request">): Promise<Buffer> {
return zosfiles.Utilities.putUSSPayload(this.getSession(), outputPath, { ...(options ?? {}), request: "copy" });
return zosfiles.Utilities.putUSSPayload(this.getSession(), outputPath, { ...options, request: "copy" });
}

public async move(oldPath: string, newPath: string): Promise<void> {
Expand All @@ -142,11 +145,17 @@ export namespace ZoweExplorerZosmf {
}

public uploadFromBuffer(buffer: Buffer, filePath: string, options?: zosfiles.IUploadOptions): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.Upload.bufferToUssFile(this.getSession(), filePath, buffer, options);
return zosfiles.Upload.bufferToUssFile(this.getSession(), filePath, buffer, {
responseTimeout: this.profile?.profile?.responseTimeout,
...options,
});
}

public putContent(inputFilePath: string, ussFilePath: string, options: zosfiles.IUploadOptions): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.Upload.fileToUssFile(this.getSession(), inputFilePath, ussFilePath, options);
return zosfiles.Upload.fileToUssFile(this.getSession(), inputFilePath, ussFilePath, {
responseTimeout: this.profile?.profile?.responseTimeout,
...options,
});
}

public async updateAttributes(ussPath: string, attributes: Partial<Types.FileAttributes>): Promise<zosfiles.IZosFilesResponse> {
Expand Down Expand Up @@ -199,17 +208,20 @@ export namespace ZoweExplorerZosmf {
ussDirectoryPath: string,
options?: zosfiles.IUploadOptions
): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.Upload.dirToUSSDirRecursive(this.getSession(), inputDirectoryPath, ussDirectoryPath, options);
return zosfiles.Upload.dirToUSSDirRecursive(this.getSession(), inputDirectoryPath, ussDirectoryPath, {
responseTimeout: this.profile?.profile?.responseTimeout,
...options,
});
}

public create(ussPath: string, type: string, mode?: string): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.Create.uss(this.getSession(), ussPath, type, mode);
return zosfiles.Create.uss(this.getSession(), ussPath, type, mode, { responseTimeout: this.profile?.profile?.responseTimeout });
}

public delete(ussPath: string, recursive?: boolean): Promise<zosfiles.IZosFilesResponse> {
// handle zosmf api issue with file paths
const fixedName = ussPath.startsWith("/") ? ussPath.substring(1) : ussPath;
return zosfiles.Delete.ussFile(this.getSession(), fixedName, recursive);
return zosfiles.Delete.ussFile(this.getSession(), fixedName, recursive, { responseTimeout: this.profile?.profile?.responseTimeout });
}

public async rename(currentUssPath: string, newUssPath: string): Promise<zosfiles.IZosFilesResponse> {
Expand All @@ -235,39 +247,59 @@ export namespace ZoweExplorerZosmf {
*/
export class MvsApi extends CommonApi implements MainframeInteraction.IMvs {
public dataSet(filter: string, options?: zosfiles.IListOptions): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.List.dataSet(this.getSession(), filter, options);
return zosfiles.List.dataSet(this.getSession(), filter, { responseTimeout: this.profile?.profile?.responseTimeout, ...options });
}

public allMembers(dataSetName: string, options?: zosfiles.IListOptions): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.List.allMembers(this.getSession(), dataSetName, options);
return zosfiles.List.allMembers(this.getSession(), dataSetName, {
responseTimeout: this.profile?.profile?.responseTimeout,
...options,
});
}

public getContents(dataSetName: string, options?: zosfiles.IDownloadSingleOptions): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.Download.dataSet(this.getSession(), dataSetName, options);
return zosfiles.Download.dataSet(this.getSession(), dataSetName, {
responseTimeout: this.profile?.profile?.responseTimeout,
...options,
});
}

public uploadFromBuffer(buffer: Buffer, dataSetName: string, options?: zosfiles.IUploadOptions): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.Upload.bufferToDataSet(this.getSession(), buffer, dataSetName, options);
return zosfiles.Upload.bufferToDataSet(this.getSession(), buffer, dataSetName, {
responseTimeout: this.profile?.profile?.responseTimeout,
...options,
});
}

public putContents(inputFilePath: string, dataSetName: string, options?: zosfiles.IUploadOptions): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.Upload.pathToDataSet(this.getSession(), inputFilePath, dataSetName, options);
return zosfiles.Upload.pathToDataSet(this.getSession(), inputFilePath, dataSetName, {
responseTimeout: this.profile?.profile?.responseTimeout,
...options,
});
}

public createDataSet(
dataSetType: zosfiles.CreateDataSetTypeEnum,
dataSetName: string,
options?: Partial<zosfiles.ICreateDataSetOptions>
): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.Create.dataSet(this.getSession(), dataSetType, dataSetName, options);
return zosfiles.Create.dataSet(this.getSession(), dataSetType, dataSetName, {
responseTimeout: this.profile?.profile?.responseTimeout,
...options,
});
}

public createDataSetMember(dataSetName: string, options?: zosfiles.IUploadOptions): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.Upload.bufferToDataSet(this.getSession(), Buffer.from(""), dataSetName, options);
return zosfiles.Upload.bufferToDataSet(this.getSession(), Buffer.from(""), dataSetName, {
responseTimeout: this.profile?.profile?.responseTimeout,
...options,
});
}

public allocateLikeDataSet(dataSetName: string, likeDataSetName: string): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.Create.dataSetLike(this.getSession(), dataSetName, likeDataSetName);
return zosfiles.Create.dataSetLike(this.getSession(), dataSetName, likeDataSetName, {
responseTimeout: this.profile?.profile?.responseTimeout,
});
}

public copyDataSetMember(
Expand All @@ -282,42 +314,67 @@ export namespace ZoweExplorerZosmf {
} else {
newOptions = {
...options,
...{ "from-dataset": { dsn: fromDataSetName, member: fromMemberName } },
"from-dataset": { dsn: fromDataSetName, member: fromMemberName },
};
}
} else {
// If we decide to match 1:1 the Zowe.Copy.dataSet implementation,
// we will need to break the interface definition in the ZoweExplorerApi
newOptions = { "from-dataset": { dsn: fromDataSetName, member: fromMemberName } };
}
return zosfiles.Copy.dataSet(this.getSession(), { dsn: toDataSetName, member: toMemberName }, newOptions);
return zosfiles.Copy.dataSet(
this.getSession(),
{ dsn: toDataSetName, member: toMemberName },
{
responseTimeout: this.profile?.profile?.responseTimeout,
...newOptions,
}
);
}

public renameDataSet(currentDataSetName: string, newDataSetName: string): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.Rename.dataSet(this.getSession(), currentDataSetName, newDataSetName);
return zosfiles.Rename.dataSet(this.getSession(), currentDataSetName, newDataSetName, {
responseTimeout: this.profile?.profile?.responseTimeout,
});
}

public renameDataSetMember(dataSetName: string, oldMemberName: string, newMemberName: string): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.Rename.dataSetMember(this.getSession(), dataSetName, oldMemberName, newMemberName);
return zosfiles.Rename.dataSetMember(this.getSession(), dataSetName, oldMemberName, newMemberName, {
responseTimeout: this.profile?.profile?.responseTimeout,
});
}

public hMigrateDataSet(dataSetName: string): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.HMigrate.dataSet(this.getSession(), dataSetName);
return zosfiles.HMigrate.dataSet(this.getSession(), dataSetName, {
responseTimeout: this.profile?.profile?.responseTimeout,
});
}

public hRecallDataSet(dataSetName: string): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.HRecall.dataSet(this.getSession(), dataSetName);
return zosfiles.HRecall.dataSet(this.getSession(), dataSetName, {
responseTimeout: this.profile?.profile?.responseTimeout,
});
}

public deleteDataSet(dataSetName: string, options?: zosfiles.IDeleteDatasetOptions): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.Delete.dataSet(this.getSession(), dataSetName, options);
return zosfiles.Delete.dataSet(this.getSession(), dataSetName, {
responseTimeout: this.profile?.profile?.responseTimeout,
...options,
});
}

public dataSetsMatchingPattern(filter: string[], options?: zosfiles.IDsmListOptions): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.List.dataSetsMatchingPattern(this.getSession(), filter, options);
return zosfiles.List.dataSetsMatchingPattern(this.getSession(), filter, {
responseTimeout: this.profile?.profile?.responseTimeout,
...options,
});
}
public copyDataSet(fromDataSetName: string, toDataSetName: string, enq?: string, replace?: boolean): Promise<zosfiles.IZosFilesResponse> {
return zosfiles.Copy.dataSet(this.getSession(), { dsn: toDataSetName }, { "from-dataset": { dsn: fromDataSetName }, enq, replace });
return zosfiles.Copy.dataSet(
this.getSession(),
{ dsn: toDataSetName },
{ "from-dataset": { dsn: fromDataSetName }, enq, replace, responseTimeout: this.profile?.profile?.responseTimeout }
);
}
}

Expand Down
17 changes: 2 additions & 15 deletions packages/zowe-explorer-api/src/tree/ZoweTreeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,8 @@ export class ZoweTreeNode extends vscode.TreeItem {
* @param {imperative.IProfileLoaded} The profile you will set the node to use
*/
public setProfileToChoice(aProfile: imperative.IProfileLoaded, fsProvider?: BaseProvider): void {
if (this.profile == null) {
this.profile = aProfile;
} else {
// Don't reassign profile, we want to keep object reference shared across nodes
this.profile.profile = aProfile.profile;
}
if (this.resourceUri != null) {
const fsEntry = fsProvider?.lookup(this.resourceUri, true);
if (fsEntry != null) {
fsEntry.metadata.profile = aProfile;
}
}
for (const child of this.children) {
(child as unknown as ZoweTreeNode).setProfileToChoice(aProfile, fsProvider);
}
// Don't reassign profile if its already defined, as we want to keep the reference valid for other nodes and filesystems
this.profile = Object.assign(this.profile ?? {}, aProfile);
}
/**
* Sets the session for this node to the one chosen in parameters.
Expand Down
2 changes: 2 additions & 0 deletions packages/zowe-explorer-ftp-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to the "zowe-explorer-ftp-extension" extension will be docum

### Bug fixes

- Fixed issue where the MVS API `putContents` function did not support PDS members when the member was not specified in the data set name. [#3305](https://github.com/zowe/zowe-explorer-vscode/issues/3305)

## `3.0.2`

### New features and enhancements
Expand Down
Loading
Loading