Skip to content

Commit

Permalink
Merge pull request #2992 from zowe/fix/submit-jcl-uss
Browse files Browse the repository at this point in the history
Fix issue where USS files can't be submitted as JCL
  • Loading branch information
t1m0thyj authored Jul 10, 2024
2 parents d7badfa + eb29171 commit e3c63fd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.17.0-SNAPSHOT",
"version": "2.16.3",
"command": {
"version": {
"forcePublish": true,
Expand Down
2 changes: 2 additions & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen

### Bug fixes

- Fixed issue where USS files could not be submitted as JCL. [#2991](https://github.com/zowe/zowe-explorer-vscode/issues/2991)

## `2.16.2`

### Bug fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { ProfileManagement } from "../../../src/utils/ProfileManagement";
import { TreeProviders } from "../../../src/shared/TreeProviders";
import { mocked } from "../../../__mocks__/mockUtils";
import { TreeViewUtils } from "../../../src/utils/TreeViewUtils";
import * as path from "path";

const activeTextEditorDocument = jest.fn();

Expand Down Expand Up @@ -423,8 +424,6 @@ describe("Jobs Actions Unit Tests - Function submitJcl", () => {
const imperativeProfile = createIProfile();
const datasetSessionNode = createDatasetSessionNode(session, imperativeProfile);
const textDocument = createTextDocument("HLQ.TEST.AFILE(mem)", datasetSessionNode);
(textDocument.languageId as any) = "jcl";
(textDocument.uri.fsPath as any) = "/user/temp/textdocument.txt";
const profileInstance = createInstanceOfProfile(imperativeProfile);
const jesApi = createJesApi(imperativeProfile);
const mockCheckCurrentProfile = jest.fn();
Expand Down Expand Up @@ -651,22 +650,25 @@ describe("Jobs Actions Unit Tests - Function submitJcl", () => {
expect(showMessagespy).toBeCalledWith("No profiles available");
});
it("Getting session name from the path itself", async () => {
globals.defineGlobals("/user/");
globals.defineGlobals(__dirname);
createGlobalMocks();
const blockMocks: any = createBlockMocks();
mocked(zowe.ZosmfSession.createSessCfgFromArgs).mockReturnValue(blockMocks.session);
mocked(Profiles.getInstance).mockReturnValue(blockMocks.profileInstance);
const loadNamedProfileSpy = jest.spyOn(blockMocks.profileInstance, "loadNamedProfile");
blockMocks.testDatasetTree.getChildren.mockResolvedValueOnce([
new ZoweDatasetNode({ label: "node", collapsibleState: vscode.TreeItemCollapsibleState.None, parentNode: blockMocks.datasetSessionNode }),
blockMocks.datasetSessionNode,
]);
blockMocks.datasetSessionNode.label = "temp";
blockMocks.textDocument.fileName = path.join(globals.USS_DIR, "lpar1_zosmf", "file.txt");
blockMocks.textDocument.uri = vscode.Uri.file(blockMocks.textDocument.fileName);
activeTextEditorDocument.mockReturnValue(blockMocks.textDocument);
const submitJclSpy = jest.spyOn(blockMocks.jesApi, "submitJcl");
submitJclSpy.mockClear();
submitJclSpy.mockResolvedValueOnce(blockMocks.iJob);
await dsActions.submitJcl(blockMocks.testDatasetTree, undefined);

expect(loadNamedProfileSpy).toBeCalledWith("lpar1_zosmf");
expect(submitJclSpy).toBeCalled();
expect(mocked(Gui.showMessage)).toBeCalled();
expect(mocked(Gui.showMessage).mock.calls.length).toBe(1);
Expand Down
45 changes: 18 additions & 27 deletions packages/zowe-explorer/src/dataset/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -933,39 +933,30 @@ export async function submitJcl(datasetProvider: api.IZoweTree<api.IZoweDatasetT
}

// get session name
const sessionregex = /\[(.*)(\])(?!.*\])/;
const regExp = sessionregex.exec(doc.fileName);
const profiles = Profiles.getInstance();
let sessProfileName;
if (regExp === null) {
if (!doc.uri.fsPath.includes(globals.ZOWETEMPFOLDER)) {
const profileNamesList = ProfileManagement.getRegisteredProfileNameList(globals.Trees.JES);
if (profileNamesList.length > 1) {
const quickPickOptions: vscode.QuickPickOptions = {
placeHolder: localize("submitJcl.qp.placeholder", "Select the Profile to use to submit the job"),
ignoreFocusOut: true,
canPickMany: false,
};
sessProfileName = await api.Gui.showQuickPick(profileNamesList, quickPickOptions);
if (!sessProfileName) {
api.Gui.infoMessage(localizedStrings.opCancelled);
return;
}
} else if (profileNamesList.length > 0) {
sessProfileName = profileNamesList[0];
} else {
api.Gui.showMessage(localize("submitJcl.noProfile", "No profiles available"));
if (!doc.uri.fsPath.includes(globals.ZOWETEMPFOLDER)) {
const profileNamesList = ProfileManagement.getRegisteredProfileNameList(globals.Trees.JES);
if (profileNamesList.length > 1) {
const quickPickOptions: vscode.QuickPickOptions = {
placeHolder: localize("submitJcl.qp.placeholder", "Select the Profile to use to submit the job"),
ignoreFocusOut: true,
canPickMany: false,
};
sessProfileName = await api.Gui.showQuickPick(profileNamesList, quickPickOptions);
if (!sessProfileName) {
api.Gui.infoMessage(localizedStrings.opCancelled);
return;
}
} else if (profileNamesList.length > 0) {
sessProfileName = profileNamesList[0];
} else {
const filePathArray = doc.uri.fsPath.split(path.sep);
sessProfileName = filePathArray[filePathArray.length - 2];
api.Gui.showMessage(localize("submitJcl.noProfile", "No profiles available"));
}
} else {
sessProfileName = regExp[1];
if (sessProfileName.includes("[")) {
// if submitting from favorites, sesName might be the favorite node, so extract further
sessProfileName = sessionregex.exec(sessProfileName)[1];
}
const start = path.join(globals.ZOWETEMPFOLDER + path.sep).length;
const pathSegments = doc.fileName.substring(start).split(path.sep);
sessProfileName = pathSegments[1];
}

// get profile from session name
Expand Down

0 comments on commit e3c63fd

Please sign in to comment.