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

Add type to session nodes #3309

Merged
merged 14 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
1 change: 1 addition & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
- Power users and developers can now build links to efficiently open mainframe resources in Zowe Explorer. Use the **Copy External Link** option in the context menu to get the URL for a data set or USS resource, or create a link in the format `vscode://Zowe.vscode-extension-for-zowe?<ZoweResourceUri>`. For more information on building resource URIs, see the [FileSystemProvider wiki article](https://github.com/zowe/zowe-explorer-vscode/wiki/FileSystemProvider#file-paths-vs-uris). [#3271](https://github.com/zowe/zowe-explorer-vscode/pull/3271)
- Implemented more user-friendly error messages for API or network errors within Zowe Explorer. [#3243](https://github.com/zowe/zowe-explorer-vscode/pull/3243)
- Use the "Troubleshoot" option for certain errors to obtain additional context, tips, and resources for how to resolve the errors. [#3243](https://github.com/zowe/zowe-explorer-vscode/pull/3243)
- Allow extenders to add context menu actions to a top level node, i.e. data sets, USS, Jobs, by encoding the profile type in the context value. [#3309](https://github.com/zowe/zowe-explorer-vscode/pull/3309)
- You can now add multiple partitioned data sets or USS directories to your workspace at once using the "Add to Workspace" feature. [#3324](https://github.com/zowe/zowe-explorer-vscode/issues/3324)

### Bug fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,22 @@ describe("USSTree Unit Tests - Function addSingleSession", () => {
expect(blockMocks.testTree.mSessionNodes.length).toEqual(2);
});

it("Tests that addSingleSession adds type info to the session", async () => {
const dsTree = new DatasetTree();
const profile1 = await createIProfile();

profile1.name = "test1Profile";

await dsTree.addSingleSession(profile1);

const sessionNode = dsTree.mSessionNodes.find((tNode) => tNode.label?.toString() === profile1.name)

expect(sessionNode).toBeDefined();

const context = sessionNode?.contextValue;
expect(context).toContain("_type=zosmf");
});

it("Tests that addSingleSession successfully adds a session", async () => {
await createGlobalMocks();
const blockMocks = await createBlockMocks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,25 @@ describe("ZosJobsProvider unit tests - Function getChildren", () => {
return newMocks;
}

it("Tests that addSingleSession adds type info to the session", async () => {
const globalMocks = await createGlobalMocks();
const blockMocks = createBlockMocks(globalMocks);
mocked(vscode.window.createTreeView).mockReturnValueOnce(blockMocks.treeView);
const jobTree = new JobTree();
const profile1 = await createIProfile();

profile1.name = "test1Profile";

await jobTree.addSingleSession(profile1);

const sessionNode = jobTree.mSessionNodes.find((tNode) => tNode.label?.toString() === profile1.name)

expect(sessionNode).toBeDefined();

const context = sessionNode?.contextValue;
expect(context).toContain("_type=zosmf");
});

it("Tests that getChildren returns the Favorites and sessions when called at the root node", async () => {
const globalMocks = await createGlobalMocks();
const blockMocks = createBlockMocks(globalMocks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,22 @@ describe("USSTree Unit Tests - Function addSingleSession", () => {
expect(globalMocks.testTree.mSessionNodes.length).toEqual(2);
});

it("Tests that addSingleSession adds type info to the session", async () => {
const ussTree = new USSTree();
const profile1 = await createIProfile();

profile1.name = "test1Profile";

await ussTree.addSingleSession(profile1);

const sessionNode = ussTree.mSessionNodes.find((tNode) => tNode.label?.toString() === profile1.name)

expect(sessionNode).toBeDefined();

const context = sessionNode?.contextValue;
expect(context).toContain("_type=zosmf");
});

it("Tests that addSingleSession successfully adds a session", async () => {
const globalMocks = createGlobalMocks();

Expand Down
1 change: 1 addition & 0 deletions packages/zowe-explorer/src/configuration/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class Constants {
public static readonly HOME_SUFFIX = Constants.CONTEXT_PREFIX + "home";
public static readonly FAV_PROFILE_CONTEXT = "profile_fav";
public static readonly RC_SUFFIX = Constants.CONTEXT_PREFIX + "rc=";
public static readonly TYPE_SUFFIX = Constants.CONTEXT_PREFIX + "type=";
public static readonly VALIDATE_SUFFIX = Constants.CONTEXT_PREFIX + "validate";
public static readonly NO_VALIDATE_SUFFIX = Constants.CONTEXT_PREFIX + "noValidate";
public static readonly INFORMATION_CONTEXT = "information";
Expand Down
2 changes: 1 addition & 1 deletion packages/zowe-explorer/src/trees/dataset/DatasetTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ export class DatasetTree extends ZoweTreeProvider<IZoweDatasetTreeNode> implemen
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
session,
profile,
contextOverride: Constants.DS_SESSION_CONTEXT,
contextOverride: Constants.DS_SESSION_CONTEXT + Constants.TYPE_SUFFIX + profile.type,
});
if (profile.type !== "zosmf") {
// TODO: Why do we inject profiles in context value only for DS tree?
Expand Down
2 changes: 1 addition & 1 deletion packages/zowe-explorer/src/trees/job/JobTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export class JobTree extends ZoweTreeProvider<IZoweJobTreeNode> implements Types
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
session,
profile,
contextOverride: Constants.JOBS_SESSION_CONTEXT,
contextOverride: Constants.JOBS_SESSION_CONTEXT + Constants.TYPE_SUFFIX + profile.type,
});
await this.refreshHomeProfileContext(node);
const icon = IconGenerator.getIconByNode(node);
Expand Down
2 changes: 1 addition & 1 deletion packages/zowe-explorer/src/trees/uss/USSTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ export class USSTree extends ZoweTreeProvider<IZoweUSSTreeNode> implements Types
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
session,
profile,
contextOverride: Constants.USS_SESSION_CONTEXT,
contextOverride: Constants.USS_SESSION_CONTEXT + Constants.TYPE_SUFFIX + profile.type,
});
await this.refreshHomeProfileContext(node);
const icon = IconGenerator.getIconByNode(node);
Expand Down