From a791abb162604056c7398fc57ae06b2c2aea8772 Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Mon, 29 Jul 2024 17:03:34 -0400 Subject: [PATCH] done: Properly type the rest of the interfaces :yum: Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- .../src/extend/MainframeInteraction.ts | 10 +-- .../src/fs/types/abstract.ts | 2 +- .../src/tree/IZoweTreeNode.ts | 77 ++++++++++++++++--- .../__tests__/__mocks__/DatasetTree.ts | 16 ++-- .../__tests__/__mocks__/USSTree.ts | 12 +-- .../commands/ZoweCommandProvider.unit.test.ts | 2 +- .../trees/dataset/DatasetTree.unit.test.ts | 4 +- .../src/commands/ZoweCommandProvider.ts | 5 +- .../src/configuration/Profiles.ts | 6 +- .../src/trees/ZoweTreeProvider.ts | 18 +---- .../src/trees/dataset/DatasetTree.ts | 15 ++-- .../zowe-explorer/src/trees/job/JobTree.ts | 16 ++-- .../zowe-explorer/src/trees/uss/USSTree.ts | 13 ++-- .../src/trees/uss/ZoweUSSNode.ts | 7 +- samples/uss-profile-sample/src/SshUssApi.ts | 2 +- 15 files changed, 117 insertions(+), 88 deletions(-) diff --git a/packages/zowe-explorer-api/src/extend/MainframeInteraction.ts b/packages/zowe-explorer-api/src/extend/MainframeInteraction.ts index 1ad359e820..29677723f2 100644 --- a/packages/zowe-explorer-api/src/extend/MainframeInteraction.ts +++ b/packages/zowe-explorer-api/src/extend/MainframeInteraction.ts @@ -40,13 +40,13 @@ export namespace MainframeInteraction { getSession(profile?: imperative.IProfileLoaded): imperative.Session; /** - * Create a session for the specific profile type. + * Retrieve the status of a specific profile. * - * @param {imperative.IProfileLoaded} profile - * will use the profile the API was retrieved with by default - * @returns {IZosmfInfoResponse} z/OSMF Check Status response + * @param {imperative.IProfileLoaded} profile the profile for which we will retrieve the status + * @param {string} profileType the type of profile being requested + * @returns {Promise} The status of the profile (e.g. active, inactive, unverified) */ - getStatus?(profile: imperative.IProfileLoaded, profileType?): Promise; + getStatus?(profile: imperative.IProfileLoaded, profileType?: string): Promise; /** * Create a session for a set command arguments. The session will be created independent diff --git a/packages/zowe-explorer-api/src/fs/types/abstract.ts b/packages/zowe-explorer-api/src/fs/types/abstract.ts index e85cec8dcb..f29305bc6b 100644 --- a/packages/zowe-explorer-api/src/fs/types/abstract.ts +++ b/packages/zowe-explorer-api/src/fs/types/abstract.ts @@ -40,7 +40,7 @@ export class BufferBuilder extends Duplex { this.chunks = []; } - public _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error) => void): void { + public _write(chunk: any, _encoding: BufferEncoding, callback: (error?: Error) => void): void { this.chunks.push(chunk); callback(); } diff --git a/packages/zowe-explorer-api/src/tree/IZoweTreeNode.ts b/packages/zowe-explorer-api/src/tree/IZoweTreeNode.ts index 6a0eca7d6c..6d0817cc0c 100644 --- a/packages/zowe-explorer-api/src/tree/IZoweTreeNode.ts +++ b/packages/zowe-explorer-api/src/tree/IZoweTreeNode.ts @@ -11,10 +11,11 @@ import * as vscode from "vscode"; import * as imperative from "@zowe/imperative"; -import * as zosjobs from "@zowe/zos-jobs-for-zowe-sdk"; import { Sorting } from "./sorting"; import { ZoweTreeNodeActions } from "./ZoweNodeActions"; import type { Types } from "../Types"; +import { IJob } from "@zowe/zos-jobs-for-zowe-sdk"; +import { IZosFilesResponse } from "@zowe/zos-files-for-zowe-sdk"; interface TextEncoding { kind: "text"; @@ -30,6 +31,7 @@ interface OtherEncoding { } export type ZosEncoding = TextEncoding | BinaryEncoding | OtherEncoding; + export type EncodingMap = Record; /** @@ -43,60 +45,74 @@ export interface IZoweTreeNode extends vscode.TreeItem { * Indicator that the child data may have become stale and requires refreshing. */ dirty: boolean; + /** * Describes the full path of a file */ fullPath?: string; + /** * Children nodes of this node */ children?: IZoweTreeNode[]; + /** * Any ongoing actions that must be awaited before continuing */ ongoingActions?: Record>; + /** * whether the node was double-clicked */ wasDoubleClicked?: boolean; + /** * Sorting method for this node's children */ sort?: Sorting.NodeSort; + /** * Retrieves the node label */ getLabel(): string | vscode.TreeItemLabel; + /** * Retrieves the nodes parent node */ getParent(): IZoweTreeNode; + /** * Retrieves the nodes children nodes */ getChildren(): Promise; + /** * Retrieves the profile name in use with this node */ getProfileName(): string; + /** * Retrieves the session node in use with this node */ getSessionNode(): IZoweTreeNode; + /** * Retrieves the session object in use with this node */ getSession(): imperative.Session; + /** * Retrieves the profile object in use with this node */ getProfile(): imperative.IProfileLoaded; + /** * Set the profile to use for this node to be the one chosen in the parameters * * @param profileObj The profile you will set the node to use */ setProfileToChoice(profileObj: imperative.IProfileLoaded): void; + /** * Set the session to use for this node to be the one chosen in the parameters * @@ -116,32 +132,38 @@ export interface IZoweDatasetTreeNode extends IZoweTreeNode { * Search criteria for a Dataset search */ pattern?: string; + /** * Search criteria for a Dataset member search */ memberPattern?: string; + /** * @deprecated Please use `setStats` and `getStats` instead. * * Additional statistics about this data set */ stats?: Partial; + /** * Filter method for this data set's children */ filter?: Sorting.DatasetFilter; + /** * @deprecated Please use `getEncodingInMap` and `updateEncodingInMap` instead. * * List of child nodes and user-selected encodings */ encodingMap?: Record; + /** * @deprecated Please use `setEncoding` and `getEncoding` instead. * * Binary indicator. Default false (text) */ binary?: boolean; + /** * @deprecated Please use `setEncoding` and `getEncoding` instead. * @@ -151,24 +173,28 @@ export interface IZoweDatasetTreeNode extends IZoweTreeNode { * * `undefined` = user did not specify */ encoding?: string; + /** * Retrieves child nodes of this IZoweDatasetTreeNode * * @returns {Promise} */ getChildren(): Promise; + /** * Retrieves the etag value for the file * * @returns {string} */ getEtag(): string | PromiseLike; + /** * Sets the etag value for the file * * @param {string} */ setEtag(etag: string): void | PromiseLike; + /** * Downloads and displays a file in a text editor view * @@ -177,12 +203,14 @@ export interface IZoweDatasetTreeNode extends IZoweTreeNode { * @param datasetFileProvider the tree provider */ openDs?(download: boolean, previewFile: boolean, datasetFileProvider: Types.IZoweDatasetTreeType): Promise; + /** * Gets the codepage value for the file * * @param {string} */ getEncoding(): ZosEncoding | PromiseLike; + /** * Sets the codepage value for the file * @@ -224,25 +252,33 @@ export interface IZoweUSSTreeNode extends IZoweTreeNode { * Retrieves an abridged for of the label */ shortLabel?: string; + + /** + * Encoding indicator. + */ encoding?: string; + /** * @deprecated Please use `getEncodingInMap` and `updateEncodingInMap` instead. * * List of child nodes and user-selected encodings */ encodingMap?: Record; + /** * @deprecated Please use `getEncoding` and `setEncoding` instead. * * Binary indicator. Default false (text) */ binary?: boolean; + /** * @deprecated Please use `setAttributes` and `getAttributes` instead. * * File attributes */ attributes?: Types.FileAttributes; + /** * Event that fires whenever an existing node is updated. */ @@ -281,6 +317,7 @@ export interface IZoweUSSTreeNode extends IZoweTreeNode { * @returns {string} */ getEtag(): string | PromiseLike; + /** * Sets the etag value for the file * @@ -303,24 +340,28 @@ export interface IZoweUSSTreeNode extends IZoweTreeNode { * * @param {string} newNamePath */ - rename?(newNamePath: string); + rename?(newNamePath: string): Promise; + /** * Gets the codepage value for the file * * @param {string} */ getEncoding(): ZosEncoding | PromiseLike; + /** * Sets the codepage value for the file * * @param {string} */ setEncoding(encoding: ZosEncoding): void | PromiseLike; + // /** // * Opens the text document // * @return vscode.TextDocument // */ // getOpenedDocumentInstance?(): vscode.TextDocument; + /** * Downloads and displays a file in a text editor view * @@ -328,46 +369,53 @@ export interface IZoweUSSTreeNode extends IZoweTreeNode { * @param preview the file, true or false * @param ussFileProvider the tree provider */ - openUSS?(download: boolean, previewFile: boolean, ussFileProvider: Types.IZoweUSSTreeType): Promise; + openUSS?(download: boolean, previewFile: boolean, ussFileProvider: Types.IZoweUSSTreeType): void | Promise; + /** * Returns the local file path for the ZoweUSSNode * @deprecated Zowe Explorer no longer uses local file paths for uploading and downloading USS files. */ getUSSDocumentFilePath?(): string; + /** * Refreshes the node with current mainframe data * */ - refreshUSS?(); + refreshUSS?(): void | Promise; + /** * * @param ussFileProvider Deletes the USS tree node * @param filePath * @param cancelled optional */ - deleteUSSNode?(ussFileProvider: Types.IZoweUSSTreeType, filePath: string, cancelled?: boolean); + deleteUSSNode?(ussFileProvider: Types.IZoweUSSTreeType, filePath: string, cancelled?: boolean): void | Promise; + /** * Process for renaming a USS Node. This could be a Favorite Node * * @param {USSTree} ussFileProvider * @param {string} filePath */ - renameUSSNode?(ussFileProvider: Types.IZoweUSSTreeType, filePath: string); + renameUSSNode?(ussFileProvider: Types.IZoweUSSTreeType, filePath: string): void | Promise; + /** * Reopens a file if it was closed (e.g. while it was being renamed). * @param hasClosedInstance */ - reopen?(hasClosedInstance?: boolean); + reopen?(hasClosedInstance?: boolean): void | Promise; + /** * Adds a search node to the USS favorites list * * @param {USSTree} ussFileProvider */ - saveSearch?(ussFileProvider: Types.IZoweUSSTreeType); + saveSearch?(ussFileProvider: Types.IZoweUSSTreeType): void | Promise; + /** * Uploads a tree of USS file(s)/folder(s) to mainframe */ - pasteUssTree?(); + pasteUssTree?(): void | Promise; } /** @@ -381,43 +429,52 @@ export interface IZoweJobTreeNode extends IZoweTreeNode { * Use Job-specific tree node for children. */ children?: IZoweJobTreeNode[]; + /** * Standard job response document * Represents the attributes and status of a z/OS batch job * @interface IJob */ - job?: zosjobs.IJob; + job?: IJob; + /** * Search criteria for a Job search */ searchId?: string; + /** * Job Prefix i.e "MYJOB" * Attribute of Job query */ prefix?: string; + /** * Job Owner i.e "MYID" * Attribute of Job query */ owner?: string; + /** * Job Status i.e "ACTIVE" * Attribute of Job query */ status?: string; + /** * Returns whether the job node is a filtered search */ filtered?: boolean; + /** * Filter method for this job search */ filter?: string; + /** * Array of original filter search results job's children */ actualJobs?: IZoweTreeNode[]; + /** * Retrieves child nodes of this IZoweJobTreeNode * diff --git a/packages/zowe-explorer/__tests__/__mocks__/DatasetTree.ts b/packages/zowe-explorer/__tests__/__mocks__/DatasetTree.ts index c9d58b4132..65b1879d5d 100644 --- a/packages/zowe-explorer/__tests__/__mocks__/DatasetTree.ts +++ b/packages/zowe-explorer/__tests__/__mocks__/DatasetTree.ts @@ -48,9 +48,7 @@ export class DatasetTree implements vscode.TreeDataProvider { */ @MockMethod() public getChildren(_element?: ZoweDatasetNode): Promise { - return new Promise((resolve) => { - return resolve([]); - }); + return Promise.resolve([]); } /** @@ -76,19 +74,15 @@ export class DatasetTree implements vscode.TreeDataProvider { } @MockMethod() - public async addSession(_sessionName?: string): Promise { - return new Promise((resolve) => { - return resolve(); - }); + public addSession(_sessionName?: string): void | Promise { + return Promise.resolve(); } @MockMethod() public deleteSession(_node?: ZoweDatasetNode): void {} @MockMethod() - public async removeFavorite(_node: ZoweDatasetNode) { - return new Promise((resolve) => { - return resolve(); - }); + public removeFavorite(_node: ZoweDatasetNode): void | Promise { + return Promise.resolve(); } } diff --git a/packages/zowe-explorer/__tests__/__mocks__/USSTree.ts b/packages/zowe-explorer/__tests__/__mocks__/USSTree.ts index 7dd2b7eb85..885baa612c 100644 --- a/packages/zowe-explorer/__tests__/__mocks__/USSTree.ts +++ b/packages/zowe-explorer/__tests__/__mocks__/USSTree.ts @@ -99,7 +99,7 @@ export class USSTree implements vscode.TreeDataProvider { */ @MockMethod() public checkCurrentProfile(_node: IZoweUSSTreeNode): Validation.IValidationProfile | Promise { - return { status: "inactive", name: "mock" }; + return { status: "unverified", name: "mock" }; } /** @@ -146,9 +146,7 @@ export class USSTree implements vscode.TreeDataProvider { */ @MockMethod() public getChildren(_element?: ZoweUSSNode): Promise { - return new Promise((resolve) => { - return resolve([]); - }); + return Promise.resolve([]); } /** @@ -174,10 +172,8 @@ export class USSTree implements vscode.TreeDataProvider { } @MockMethod() - public async addSession(_sessionName?: string): Promise { - return new Promise((resolve) => { - return resolve(); - }); + public addSession(_sessionName?: string): void | Promise { + return Promise.resolve(); } @MockMethod() diff --git a/packages/zowe-explorer/__tests__/__unit__/commands/ZoweCommandProvider.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/commands/ZoweCommandProvider.unit.test.ts index 0b4f7ee156..b294ac18ac 100644 --- a/packages/zowe-explorer/__tests__/__unit__/commands/ZoweCommandProvider.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/commands/ZoweCommandProvider.unit.test.ts @@ -40,7 +40,7 @@ describe("ZoweCommandProvider Unit Tests", () => { }); describe("ZoweCommandProvide Unit Tests - function checkCurrentProfile", () => { - const testNode = new ZoweDatasetNode({ + const testNode: any = new ZoweDatasetNode({ label: "test", collapsibleState: vscode.TreeItemCollapsibleState.None, session: globalMocks.testSession, diff --git a/packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetTree.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetTree.unit.test.ts index ea807578a1..fb124c64b2 100644 --- a/packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetTree.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetTree.unit.test.ts @@ -1705,7 +1705,7 @@ describe("Dataset Tree Unit Tests - Function editSession", () => { imperativeProfile: createIProfile(), mockDefaultProfile: jest.fn(), treeView: createTreeView(), - datasetSessionNode: null, + datasetSessionNode: null as any as ZoweDatasetNode, profile: null, mockGetProfileSetting: jest.fn(), mockEditSession: jest.fn(), @@ -1751,7 +1751,7 @@ describe("Dataset Tree Unit Tests - Function editSession", () => { parentNode: testTree.mSessionNodes[1], }); - await testTree.editSession(node, testTree); + await testTree.editSession(node); expect(node.getProfile().profile).toBe("testProfile"); }); diff --git a/packages/zowe-explorer/src/commands/ZoweCommandProvider.ts b/packages/zowe-explorer/src/commands/ZoweCommandProvider.ts index b082042079..d2ac576dc8 100644 --- a/packages/zowe-explorer/src/commands/ZoweCommandProvider.ts +++ b/packages/zowe-explorer/src/commands/ZoweCommandProvider.ts @@ -10,7 +10,7 @@ */ import * as vscode from "vscode"; -import { IZoweTreeNode, PersistenceSchemaEnum } from "@zowe/zowe-explorer-api"; +import { IZoweTreeNode, PersistenceSchemaEnum, Validation } from "@zowe/zowe-explorer-api"; import { ZowePersistentFilters } from "../tools/ZowePersistentFilters"; import { ZoweLogger } from "../tools/ZoweLogger"; import { SharedContext } from "../trees/shared/SharedContext"; @@ -52,7 +52,7 @@ export class ZoweCommandProvider { this.mOnDidChangeTreeData.fire(); } - public async checkCurrentProfile(node: IZoweTreeNode): Promise { + public async checkCurrentProfile(node: IZoweTreeNode): Promise { ZoweLogger.trace("ZoweCommandProvider.checkCurrentProfile called."); const profile = node.getProfile(); const profileStatus = await Profiles.getInstance().checkCurrentProfile(profile); @@ -99,5 +99,6 @@ export class ZoweCommandProvider { } } this.refresh(); + return profileStatus; } } diff --git a/packages/zowe-explorer/src/configuration/Profiles.ts b/packages/zowe-explorer/src/configuration/Profiles.ts index 015dad6a42..7d4d1cc0f2 100644 --- a/packages/zowe-explorer/src/configuration/Profiles.ts +++ b/packages/zowe-explorer/src/configuration/Profiles.ts @@ -398,7 +398,7 @@ export class Profiles extends ProfilesCache { } } - public async editSession(profileLoaded: imperative.IProfileLoaded): Promise { + public async editSession(profileLoaded: imperative.IProfileLoaded): Promise { const currentProfile = await this.getProfileFromConfig(profileLoaded.name); const filePath = currentProfile.profLoc.osLoc[0]; await this.openConfigFile(filePath); @@ -422,7 +422,7 @@ export class Profiles extends ProfilesCache { return profileType; } - public async createZoweSchema(_zoweFileProvider: IZoweTree): Promise { + public async createZoweSchema(_zoweFileProvider: IZoweTree): Promise { ZoweLogger.trace("Profiles.createZoweSchema called."); try { let user = false; @@ -487,7 +487,6 @@ export class Profiles extends ProfilesCache { configName = config.configName; } await this.openConfigFile(path.join(rootPath, configName)); - return path.join(rootPath, configName); } catch (err) { ZoweLogger.error(err); ZoweExplorerExtender.showZoweConfigError(err.message); @@ -862,7 +861,6 @@ export class Profiles extends ProfilesCache { }); ZoweLogger.error(message); Gui.errorMessage(message); - return; } } diff --git a/packages/zowe-explorer/src/trees/ZoweTreeProvider.ts b/packages/zowe-explorer/src/trees/ZoweTreeProvider.ts index 2f7ab14e98..ecf8139bab 100644 --- a/packages/zowe-explorer/src/trees/ZoweTreeProvider.ts +++ b/packages/zowe-explorer/src/trees/ZoweTreeProvider.ts @@ -19,7 +19,6 @@ import { Constants } from "../configuration/Constants"; import { IconGenerator } from "../icons/IconGenerator"; import { SettingsConfig } from "../configuration/SettingsConfig"; import { SharedTreeProviders } from "./shared/SharedTreeProviders"; -import { ProfilesUtils } from "../utils/ProfilesUtils"; import { SharedActions } from "./shared/SharedActions"; import { IconUtils } from "../icons/IconUtils"; import { AuthUtils } from "../utils/AuthUtils"; @@ -213,22 +212,7 @@ export class ZoweTreeProvider { public async editSession(node: IZoweTreeNode): Promise { ZoweLogger.trace("ZoweTreeProvider.editSession called."); const profile = node.getProfile(); - const EditSession = await Profiles.getInstance().editSession(profile); - if (EditSession) { - node.getProfile().profile = EditSession as imperative.IProfile; - ProfilesUtils.setProfile(node, EditSession as imperative.IProfile); - if (node.getSession()) { - ProfilesUtils.setSession(node, EditSession as imperative.ISession); - } else { - this.deleteSession(node.getSessionNode()); - this.mHistory.addSession(node.label as string); - await this.addSession({ sessionName: node.getProfileName() }); - } - this.refresh(); - // Remove the edited profile from profilesForValidation - // Revalidate updated profile and update the validation icon - await this.checkCurrentProfile(node); - } + await Profiles.getInstance().editSession(profile); } public async checkCurrentProfile(node: IZoweTreeNode): Promise { diff --git a/packages/zowe-explorer/src/trees/dataset/DatasetTree.ts b/packages/zowe-explorer/src/trees/dataset/DatasetTree.ts index c9e219524c..8355ac45ef 100644 --- a/packages/zowe-explorer/src/trees/dataset/DatasetTree.ts +++ b/packages/zowe-explorer/src/trees/dataset/DatasetTree.ts @@ -654,7 +654,7 @@ export class DatasetTree extends ZoweTreeProvider implemen ); // Remove profile node from Favorites if it contains no more favorites. if (profileNodeInFavorites.children.length < 1) { - return this.removeFavProfile(profileName, false); + await this.removeFavProfile(profileName, false); } this.updateFavorites(); this.refreshElement(this.mFavoriteSession); @@ -692,14 +692,13 @@ export class DatasetTree extends ZoweTreeProvider implemen comment: ["Profile name"], }); const continueRemove = vscode.l10n.t("Continue"); - await Gui.warningMessage(checkConfirmation, { + const selection = await Gui.warningMessage(checkConfirmation, { items: [continueRemove], vsCodeOpts: { modal: true }, - }).then((selection) => { - if (!selection || selection === "Cancel") { - cancelled = true; - } }); + if (!selection || selection === "Cancel") { + cancelled = true; + } } if (cancelled) { @@ -708,7 +707,7 @@ export class DatasetTree extends ZoweTreeProvider implemen // Remove favorited profile from UI this.mFavorites.forEach((favProfileNode) => { - const favProfileLabel = favProfileNode.label as string; + const favProfileLabel = favProfileNode.label?.toString(); if (favProfileLabel === profileName) { this.mFavorites = this.mFavorites.filter((tempNode) => tempNode.label.toString() !== favProfileLabel); favProfileNode.dirty = true; @@ -720,7 +719,7 @@ export class DatasetTree extends ZoweTreeProvider implemen this.updateFavorites(); } - public async onDidChangeConfiguration(e): Promise { + public async onDidChangeConfiguration(e: vscode.ConfigurationChangeEvent): Promise { ZoweLogger.trace("DatasetTree.onDidChangeConfiguration called."); // Empties the persistent favorites & history arrays, if the user has set persistence to False if (e.affectsConfiguration(DatasetTree.persistenceSchema)) { diff --git a/packages/zowe-explorer/src/trees/job/JobTree.ts b/packages/zowe-explorer/src/trees/job/JobTree.ts index abd4051dfc..176447cb89 100644 --- a/packages/zowe-explorer/src/trees/job/JobTree.ts +++ b/packages/zowe-explorer/src/trees/job/JobTree.ts @@ -138,10 +138,9 @@ export class JobTree extends ZoweTreeProvider implements Types * * @param {IZoweJobTreeNode} node */ - public async saveSearch(node: IZoweJobTreeNode): Promise { + public saveSearch(node: IZoweJobTreeNode): void { ZoweLogger.trace("ZosJobsProvider.saveSearch called."); node.contextValue = SharedContext.asFavorite(node); - return Promise.resolve(); } public saveFile(_document: vscode.TextDocument): void { throw new Error("Method not implemented."); @@ -556,7 +555,7 @@ export class JobTree extends ZoweTreeProvider implements Types ); // Remove profile node from Favorites if it contains no more favorites. if (profileNodeInFavorites.children.length < 1) { - return this.removeFavProfile(profileName, false); + await this.removeFavProfile(profileName, false); } if (startLength !== profileNodeInFavorites.children.length) { this.updateFavorites(); @@ -600,14 +599,13 @@ export class JobTree extends ZoweTreeProvider implements Types comment: ["Profile name"], }); const continueRemove = vscode.l10n.t("Continue"); - await Gui.warningMessage(checkConfirmation, { + const selection = await Gui.warningMessage(checkConfirmation, { items: [continueRemove], vsCodeOpts: { modal: true }, - }).then((selection) => { - if (!selection || selection === "Cancel") { - cancelled = true; - } }); + if (!selection || selection === "Cancel") { + cancelled = true; + } } if (cancelled) { return; @@ -615,7 +613,7 @@ export class JobTree extends ZoweTreeProvider implements Types // Remove favorited profile from UI this.mFavorites.forEach((favProfileNode) => { - const favProfileLabel = favProfileNode.label as string; + const favProfileLabel = favProfileNode.label?.toString(); if (favProfileLabel === profileName) { this.mFavorites = this.mFavorites.filter((tempNode) => tempNode.label.toString() !== favProfileLabel); favProfileNode.dirty = true; diff --git a/packages/zowe-explorer/src/trees/uss/USSTree.ts b/packages/zowe-explorer/src/trees/uss/USSTree.ts index 16c44186e2..d668ba31b0 100644 --- a/packages/zowe-explorer/src/trees/uss/USSTree.ts +++ b/packages/zowe-explorer/src/trees/uss/USSTree.ts @@ -613,7 +613,7 @@ export class USSTree extends ZoweTreeProvider implements Types ); // Remove profile node from Favorites if it contains no more favorites. if (profileNodeInFavorites.children?.length < 1) { - return this.removeFavProfile(profileName, false); + await this.removeFavProfile(profileName, false); } } this.updateFavorites(); @@ -648,14 +648,13 @@ export class USSTree extends ZoweTreeProvider implements Types comment: ["Profile name"], }); const continueRemove = vscode.l10n.t("Continue"); - await Gui.warningMessage(checkConfirmation, { + const selection = await Gui.warningMessage(checkConfirmation, { items: [continueRemove], vsCodeOpts: { modal: true }, - }).then((selection) => { - if (!selection || selection === "Cancel") { - cancelled = true; - } }); + if (!selection || selection === "Cancel") { + cancelled = true; + } } if (cancelled) { return; @@ -663,7 +662,7 @@ export class USSTree extends ZoweTreeProvider implements Types // Remove favorited profile from UI this.mFavorites.forEach((favProfileNode) => { - const favProfileLabel = favProfileNode.label as string; + const favProfileLabel = favProfileNode.label?.toString(); if (favProfileLabel === profileName) { this.mFavorites = this.mFavorites.filter((tempNode) => tempNode?.label.toString() !== favProfileLabel); favProfileNode.dirty = true; diff --git a/packages/zowe-explorer/src/trees/uss/ZoweUSSNode.ts b/packages/zowe-explorer/src/trees/uss/ZoweUSSNode.ts index 3cad845e36..85b0411a02 100644 --- a/packages/zowe-explorer/src/trees/uss/ZoweUSSNode.ts +++ b/packages/zowe-explorer/src/trees/uss/ZoweUSSNode.ts @@ -376,7 +376,7 @@ export class ZoweUSSNode extends ZoweTreeNode implements IZoweUSSTreeNode { * Helper method to change the UI node names in one go * @param newFullPath string */ - public async rename(newFullPath: string): Promise { + public async rename(newFullPath: string): Promise { ZoweLogger.trace("ZoweUSSNode.rename called."); const oldUri = vscode.Uri.from({ @@ -407,7 +407,10 @@ export class ZoweUSSNode extends ZoweTreeNode implements IZoweUSSTreeNode { } const providers = SharedTreeProviders.providers; providers.uss.refresh(); - return true; + return { + success: true, + commandResponse: null, + }; } /** diff --git a/samples/uss-profile-sample/src/SshUssApi.ts b/samples/uss-profile-sample/src/SshUssApi.ts index 1a885afd79..87ffea0e82 100644 --- a/samples/uss-profile-sample/src/SshUssApi.ts +++ b/samples/uss-profile-sample/src/SshUssApi.ts @@ -17,7 +17,7 @@ export class SshUssApi implements MainframeInteraction.IUss { return new imperative.Session(sessCfg); } - public async getStatus(profile: imperative.IProfileLoaded, profileType?: any): Promise { + public async getStatus(profile: imperative.IProfileLoaded, profileType?: string): Promise { if (profileType === ZosUssProfile.type) { try { return await this.withClient(this.getSession(profile), () => Promise.resolve("active"));