diff --git a/lerna.json b/lerna.json index 2c85738f2b..b1461b29c0 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.17.0-SNAPSHOT", + "version": "2.16.3", "command": { "version": { "forcePublish": true, diff --git a/packages/zowe-explorer/CHANGELOG.md b/packages/zowe-explorer/CHANGELOG.md index 3d28d9358a..3307e7e6b3 100644 --- a/packages/zowe-explorer/CHANGELOG.md +++ b/packages/zowe-explorer/CHANGELOG.md @@ -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 diff --git a/packages/zowe-explorer/__tests__/__unit__/job/actions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/job/actions.unit.test.ts index 7caf175676..70640f3bbf 100644 --- a/packages/zowe-explorer/__tests__/__unit__/job/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/job/actions.unit.test.ts @@ -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(); @@ -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(); @@ -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); diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index e97ce2d4b6..b65cfd954f 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -933,39 +933,30 @@ export async function submitJcl(datasetProvider: api.IZoweTree 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