diff --git a/packages/zowe-explorer/CHANGELOG.md b/packages/zowe-explorer/CHANGELOG.md index 358b9d55cc..8759fe044c 100644 --- a/packages/zowe-explorer/CHANGELOG.md +++ b/packages/zowe-explorer/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen ### Bug fixes +- Fixed issue with favorited Job filter search. [#2440](https://github.com/zowe/vscode-extension-for-zowe/issues/2440) - Remove the 'Show Attributes' context menu action for migrated datasets. [#2033](https://github.com/zowe/vscode-extension-for-zowe/issues/2033) - Fixed issue with endless credential prompt loop when logging out. [#2262](https://github.com/zowe/vscode-extension-for-zowe/issues/2262) - Bump `@zowe/secrets-for-zowe-sdk` to 7.18.4 to handle install errors gracefully and to allow running without MSVC redistributables. 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 c91bcb9607..0c6847479e 100644 --- a/packages/zowe-explorer/__tests__/__unit__/job/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/job/actions.unit.test.ts @@ -1038,8 +1038,6 @@ describe("Jobs Actions Unit Tests - Function refreshJobsServer", () => { it("Checking common execution of function", async () => { createGlobalMocks(); const blockMocks = createBlockMocks(); - - mocked(Profiles.getInstance).mockReturnValue(blockMocks.profileInstance); const job = new Job( "jobtest", vscode.TreeItemCollapsibleState.Expanded, @@ -1052,75 +1050,11 @@ describe("Jobs Actions Unit Tests - Function refreshJobsServer", () => { mocked(zowe.ZosmfSession.createSessCfgFromArgs).mockReturnValueOnce(blockMocks.session.ISession); await jobActions.refreshJobsServer(job, blockMocks.testJobTree); - - expect(blockMocks.testJobTree.checkCurrentProfile).toHaveBeenCalledWith(job); expect(blockMocks.testJobTree.refreshElement).toHaveBeenCalledWith(job); }); it("Checking common execution of function with Unverified", async () => { createGlobalMocks(); const blockMocks = createBlockMocks(); - - mocked(Profiles.getInstance).mockReturnValue(blockMocks.profileInstance); - Object.defineProperty(Profiles, "getInstance", { - value: jest.fn(() => { - return { - checkCurrentProfile: blockMocks.mockCheckCurrentProfile.mockReturnValueOnce({ - name: blockMocks.imperativeProfile.name, - status: "unverified", - }), - validProfile: ValidProfileEnum.UNVERIFIED, - }; - }), - }); - const job = new Job( - "jobtest", - vscode.TreeItemCollapsibleState.Expanded, - null, - blockMocks.session, - blockMocks.iJob, - blockMocks.imperativeProfile - ); - job.contextValue = globals.JOBS_SESSION_CONTEXT; - mocked(zowe.ZosmfSession.createSessCfgFromArgs).mockReturnValueOnce(blockMocks.session.ISession); - - await jobActions.refreshJobsServer(job, blockMocks.testJobTree); - - expect(blockMocks.testJobTree.checkCurrentProfile).toHaveBeenCalledWith(job); - expect(blockMocks.testJobTree.refreshElement).toHaveBeenCalledWith(job); - }); - it("Checking failed attempt to execute the function", async () => { - createGlobalMocks(); - const blockMocks = createBlockMocks(); - - mocked(Profiles.getInstance).mockReturnValue(blockMocks.profileInstance); - const job = new Job( - "jobtest", - vscode.TreeItemCollapsibleState.Expanded, - null, - blockMocks.session, - blockMocks.iJob, - blockMocks.imperativeProfile - ); - job.contextValue = globals.JOBS_SESSION_CONTEXT; - mocked(zowe.ZosmfSession.createSessCfgFromArgs).mockReturnValueOnce(blockMocks.session.ISession); - blockMocks.testJobTree.checkCurrentProfile.mockImplementationOnce(() => { - throw Error("test"); - }); - - try { - await jobActions.refreshJobsServer(job, blockMocks.testJobTree); - } catch (err) { - expect(err).toEqual(Error("test")); - } - - expect(blockMocks.testJobTree.refreshElement).not.toHaveBeenCalled(); - }); - it("Checking execution of function with credential prompt", async () => { - createGlobalMocks(); - const blockMocks = createBlockMocks(); - - blockMocks.profileInstance.promptCredentials.mockReturnValue(["fake", "fake", "fake"]); - mocked(Profiles.getInstance).mockReturnValue(blockMocks.profileInstance); const job = new Job( "jobtest", vscode.TreeItemCollapsibleState.Expanded, @@ -1133,30 +1067,6 @@ describe("Jobs Actions Unit Tests - Function refreshJobsServer", () => { mocked(zowe.ZosmfSession.createSessCfgFromArgs).mockReturnValueOnce(blockMocks.session.ISession); await jobActions.refreshJobsServer(job, blockMocks.testJobTree); - - expect(blockMocks.testJobTree.checkCurrentProfile).toHaveBeenCalledWith(job); - expect(blockMocks.testJobTree.refreshElement).toHaveBeenCalledWith(job); - }); - it("Checking execution of function with credential prompt for favorite", async () => { - createGlobalMocks(); - const blockMocks = createBlockMocks(); - - blockMocks.profileInstance.promptCredentials.mockReturnValue(["fake", "fake", "fake"]); - mocked(Profiles.getInstance).mockReturnValue(blockMocks.profileInstance); - const job = new Job( - "jobtest", - vscode.TreeItemCollapsibleState.Expanded, - null, - blockMocks.session, - blockMocks.iJob, - blockMocks.imperativeProfile - ); - job.contextValue = globals.JOBS_SESSION_CONTEXT + globals.FAV_SUFFIX; - mocked(zowe.ZosmfSession.createSessCfgFromArgs).mockReturnValueOnce(blockMocks.session.ISession); - - await jobActions.refreshJobsServer(job, blockMocks.testJobTree); - - expect(blockMocks.testJobTree.checkCurrentProfile).toHaveBeenCalledWith(job); expect(blockMocks.testJobTree.refreshElement).toHaveBeenCalledWith(job); }); }); diff --git a/packages/zowe-explorer/__tests__/__unit__/utils.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/utils.unit.test.ts index 631d04fcf7..ca4a59e7f4 100644 --- a/packages/zowe-explorer/__tests__/__unit__/utils.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/utils.unit.test.ts @@ -86,7 +86,7 @@ describe("Utils Unit Tests - Function errorHandling", () => { await utils.errorHandling(errorDetails, label); expect(vscode.window.showErrorMessage).toHaveBeenCalledWith( - `Invalid Credentials. Please ensure the username and password for ${label} are valid or this may lead to a lock-out.`, + `Invalid Credentials for profile '${label}'. Please ensure the username and password are valid or this may lead to a lock-out.`, { modal: true }, "Update Credentials" ); @@ -105,7 +105,7 @@ describe("Utils Unit Tests - Function errorHandling", () => { await utils.errorHandling(errorDetails, label); expect(vscode.window.showErrorMessage).toHaveBeenCalledWith( - `Invalid Credentials. Please ensure the username and password for ${label} are valid or this may lead to a lock-out.`, + `Invalid Credentials for profile '${label}'. Please ensure the username and password are valid or this may lead to a lock-out.`, { modal: true }, "Update Credentials" ); @@ -126,7 +126,7 @@ describe("Utils Unit Tests - Function errorHandling", () => { // TODO: check why this return two messages? expect(vscode.window.showErrorMessage).toHaveBeenCalledWith( - `Invalid Credentials. Please ensure the username and password for ${label} are valid or this may lead to a lock-out.`, + `Invalid Credentials for profile '${label}'. Please ensure the username and password are valid or this may lead to a lock-out.`, { modal: true }, "Update Credentials" ); diff --git a/packages/zowe-explorer/i18n/sample/src/utils/ProfilesUtils.i18n.json b/packages/zowe-explorer/i18n/sample/src/utils/ProfilesUtils.i18n.json index 04c6197e3f..c7888a2b2c 100644 --- a/packages/zowe-explorer/i18n/sample/src/utils/ProfilesUtils.i18n.json +++ b/packages/zowe-explorer/i18n/sample/src/utils/ProfilesUtils.i18n.json @@ -1,6 +1,6 @@ { "errorHandling.invalid.host": "Required parameter 'host' must not be blank.", - "errorHandling.invalid.credentials": "Invalid Credentials. Please ensure the username and password for {0} are valid or this may lead to a lock-out.", + "errorHandling.invalid.credentials": "Invalid Credentials for profile '{0}'. Please ensure the username and password are valid or this may lead to a lock-out.", "errorHandling.invalid.token": "Your connection is no longer active. Please log in to an authentication service to restore the connection.", "errorHandling.authentication.login": "Log in to Authentication Service", "errorHandling.checkCredentials.button": "Update Credentials", diff --git a/packages/zowe-explorer/src/job/ZosJobsProvider.ts b/packages/zowe-explorer/src/job/ZosJobsProvider.ts index cb60519073..15001ee6bf 100644 --- a/packages/zowe-explorer/src/job/ZosJobsProvider.ts +++ b/packages/zowe-explorer/src/job/ZosJobsProvider.ts @@ -807,7 +807,7 @@ export class ZosJobsProvider extends ZoweTreeProvider implements IZoweTree { const thisSessionNode = this.getSessionNode(); ZoweLogger.trace(`ZoweJobNode.getChildren called for ${String(thisSessionNode.label)}.`); - if (contextually.isSession(this) && !this.filtered) { + if (contextually.isSession(this) && !this.filtered && !contextually.isFavorite(this)) { return [ new Job( localize("getChildren.search", "Use the search button to display jobs"), @@ -178,7 +178,7 @@ export class Job extends ZoweTreeNode implements IZoweJobTreeNode { // Fetch jobs under session node const jobs = await this.getJobs(this._owner, this._prefix, this._searchId, this._jobStatus); - if (!jobs || jobs.length === 0) { + if (jobs.length === 0) { const noJobsNode = new Job( localize("getChildren.noJobs", "No jobs found"), vscode.TreeItemCollapsibleState.None, @@ -368,14 +368,14 @@ export class Job extends ZoweTreeNode implements IZoweJobTreeNode { } }, []); } - return jobsInternal; } catch (error) { ZoweLogger.trace("Error getting jobs from Rest API."); - await errorHandling(error, this.label, localize("getChildren.error.response", "Retrieving response from ") + `zowe.GetJobs`); + await errorHandling(error, cachedProfile.name, localize("getChildren.error.response", "Retrieving response from ") + `zowe.GetJobs`); syncSessionNode(Profiles.getInstance())((profileValue) => ZoweExplorerApiRegister.getJesApi(profileValue).getSession())( this.getSessionNode() ); } + return jobsInternal; } } diff --git a/packages/zowe-explorer/src/job/actions.ts b/packages/zowe-explorer/src/job/actions.ts index 56693c89d9..06fecac4c5 100644 --- a/packages/zowe-explorer/src/job/actions.ts +++ b/packages/zowe-explorer/src/job/actions.ts @@ -117,28 +117,24 @@ export async function getSpoolContent(session: string, spool: zowe.IJobFile, ref } const statusMsg = Gui.setStatusBarMessage(localize("jobActions.openSpoolFile", "$(sync~spin) Opening spool file...", this.label as string)); - await profiles.checkCurrentProfile(zosmfProfile); - if (profiles.validProfile !== ValidProfileEnum.INVALID) { - const uri = encodeJobFile(session, spool); - try { - const spoolFile = SpoolProvider.files[uri.path]; - if (spoolFile) { - // Fetch any changes to the spool file if it exists in the SpoolProvider - await spoolFile.fetchContent(); - } - await Gui.showTextDocument(uri, { preview: false }); - } catch (error) { - const isTextDocActive = - vscode.window.activeTextEditor && - vscode.window.activeTextEditor.document.uri?.path === `${spool.jobname}.${spool.jobid}.${spool.ddname}`; + const uri = encodeJobFile(session, spool); + try { + const spoolFile = SpoolProvider.files[uri.path]; + if (spoolFile) { + // Fetch any changes to the spool file if it exists in the SpoolProvider + await spoolFile.fetchContent(); + } + await Gui.showTextDocument(uri, { preview: false }); + } catch (error) { + const isTextDocActive = + vscode.window.activeTextEditor && vscode.window.activeTextEditor.document.uri?.path === `${spool.jobname}.${spool.jobid}.${spool.ddname}`; - statusMsg.dispose(); - if (isTextDocActive && String(error.message).includes("Failed to show text document")) { - return; - } - await errorHandling(error, session); + statusMsg.dispose(); + if (isTextDocActive && String(error.message).includes("Failed to show text document")) { return; } + await errorHandling(error, session); + return; } statusMsg.dispose(); } @@ -191,10 +187,7 @@ export async function getSpoolContentFromMainframe(node: IZoweJobTreeNode): Prom */ export async function refreshJobsServer(node: IZoweJobTreeNode, jobsProvider: IZoweTree): Promise { ZoweLogger.trace("job.actions.refreshJobsServer called."); - jobsProvider.checkCurrentProfile(node); - if (Profiles.getInstance().validProfile === ValidProfileEnum.VALID || Profiles.getInstance().validProfile === ValidProfileEnum.UNVERIFIED) { - await jobsProvider.refreshElement(node); - } + await jobsProvider.refreshElement(node); } /** diff --git a/packages/zowe-explorer/src/uss/USSTree.ts b/packages/zowe-explorer/src/uss/USSTree.ts index 0fc787e86b..be393857b9 100644 --- a/packages/zowe-explorer/src/uss/USSTree.ts +++ b/packages/zowe-explorer/src/uss/USSTree.ts @@ -647,6 +647,7 @@ export class USSTree extends ZoweTreeProvider implements IZoweTree { ZoweLogger.trace("ProfilesUtils.syncSessionNode called."); - const profileType = sessionNode.getProfile().type; + const profileType = sessionNode.getProfile()?.type; const profileName = sessionNode.getProfileName(); let profile: imperative.IProfileLoaded;