Skip to content

Commit

Permalink
Fix issue where USS files can't be submitted as JCL
Browse files Browse the repository at this point in the history
Co-authored-by: Trae Yelovich <[email protected]>
Signed-off-by: Timothy Johnson <[email protected]>
  • Loading branch information
t1m0thyj and traeok committed Jul 9, 2024
1 parent d7badfa commit aacb094
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 28 deletions.
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 @@ -656,17 +657,19 @@ describe("Jobs Actions Unit Tests - Function submitJcl", () => {
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");
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 aacb094

Please sign in to comment.