From df6656b9a0aa867542d22929fe43f533fd8c4344 Mon Sep 17 00:00:00 2001 From: Dave Nice <32769325+davenice@users.noreply.github.com> Date: Tue, 4 Feb 2025 15:15:10 +0000 Subject: [PATCH] remove multi-select, simplify profile selection code Signed-off-by: Dave Nice <32769325+davenice@users.noreply.github.com> --- packages/vsce/CHANGELOG.md | 1 + packages/vsce/package.json | 2 +- packages/vsce/src/trees/CICSTree.ts | 64 +++++------------------------ 3 files changed, 13 insertions(+), 54 deletions(-) diff --git a/packages/vsce/CHANGELOG.md b/packages/vsce/CHANGELOG.md index c77b312d..b5db2104 100644 --- a/packages/vsce/CHANGELOG.md +++ b/packages/vsce/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to the "cics-extension-for-zowe" extension will be documente ## Recent Changes +- BugFix: Editing profile results in exception - removed ability to multi-select profiles. [#222](https://github.com/zowe/cics-for-zowe-client/issues/222) - BugFix: Update documentation to reflect changes to fully support V3 profiles. [#209](https://github.com/zowe/cics-for-zowe-client/issues/209) ## `3.3.1` diff --git a/packages/vsce/package.json b/packages/vsce/package.json index 8ccf35d3..1a115531 100644 --- a/packages/vsce/package.json +++ b/packages/vsce/package.json @@ -719,7 +719,7 @@ "group": "" }, { - "when": "view == cics-view && viewItem =~ /^cicssession.*/", + "when": "view == cics-view && viewItem =~ /^cicssession.*/ && !listMultiSelection", "command": "cics-extension-for-zowe.manageSession", "title": "Manage Session" }, diff --git a/packages/vsce/src/trees/CICSTree.ts b/packages/vsce/src/trees/CICSTree.ts index 5bec29e2..b7062256 100644 --- a/packages/vsce/src/trees/CICSTree.ts +++ b/packages/vsce/src/trees/CICSTree.ts @@ -85,32 +85,27 @@ export class CICSTree implements TreeDataProvider { * @param treeview CICSTree View * *@param node current selected node */ - async manageProfile(treeview: TreeView, node: any) { - const allSelectedNodes = findSelectedNodes(treeview, CICSSessionTree, node); - if (!allSelectedNodes || !allSelectedNodes.length) { - window.showErrorMessage("No profile selected to manage"); - return; - } + async manageProfile(treeview: TreeView, node: CICSSessionTree) { try { const configInstance = await ProfileManagement.getConfigInstance(); if (configInstance.getTeamConfig().exists) { - const currentProfile = await ProfileManagement.getProfilesCache().getProfileFromConfig(allSelectedNodes[allSelectedNodes.length - 1].label); + const currentProfile = await ProfileManagement.getProfilesCache().getProfileFromConfig(String(node.label)); const deleteProfile: QuickPickItem = { - label: `$(trash) ${l10n.t(`Delete Profile${allSelectedNodes.length > 1 ? "s" : ""}`)}`, - description: l10n.t(`Delete the selected Profile${allSelectedNodes.length > 1 ? "s" : ""}`), + label: `$(trash) ${l10n.t(`Delete Profile`)}`, + description: l10n.t(`Delete the selected Profile`), }; const hideProfile: QuickPickItem = { - label: `$(eye-closed) ${l10n.t(`Hide Profile${allSelectedNodes.length > 1 ? "s" : ""}`)}`, - description: l10n.t(`Hide the selected Profile${allSelectedNodes.length > 1 ? "s" : ""}`), + label: `$(eye-closed) ${l10n.t(`Hide Profile`)}`, + description: l10n.t(`Hide the selected Profile`), }; const editProfile: QuickPickItem = { - label: `$(pencil) ${l10n.t(`Edit Profile${allSelectedNodes.length > 1 ? "s" : ""}`)}`, - description: l10n.t(`Update the selected Profile${allSelectedNodes.length > 1 ? "s" : ""}`), + label: `$(pencil) ${l10n.t(`Edit Profile`)}`, + description: l10n.t(`Update the selected Profile`), }; const quickpick = Gui.createQuickPick(); - const addProfilePlaceholder = "Choose user action for selected profiles"; + const addProfilePlaceholder = "Choose user action for selected profile"; quickpick.items = [editProfile, hideProfile, deleteProfile]; quickpick.placeholder = addProfilePlaceholder; quickpick.ignoreFocusOut = true; @@ -122,13 +117,10 @@ export class CICSTree implements TreeDataProvider { Gui.showMessage(debugMsg); return; } else if (choice === hideProfile) { - this.hideZoweConfigFile(allSelectedNodes); + await this.removeSession(node); return; - } else if (choice === editProfile) { - for (const sessionTree of allSelectedNodes) { - await this.updateSession(sessionTree, configInstance); - } } else { + // editProfile or deleteProfile const filePath = currentProfile.profLoc.osLoc[0]; await openConfigFile(filePath); return; @@ -451,26 +443,6 @@ export class CICSTree implements TreeDataProvider { this._onDidChangeTreeData.fire(undefined); } - /** - * Method for profile configuration that provides UI for user to hide a selected profile. - * @param allSelectedNodes array of selected nodes - */ - async hideZoweConfigFile(allSelectedNodes: any[]) { - for (const index in allSelectedNodes) { - try { - const currentNode = allSelectedNodes[parseInt(index)]; - await this.removeSession(currentNode); - } catch (error) { - window.showErrorMessage( - `Something went wrong when hiding the profile - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( - /(\\n\t|\\n|\\t)/gm, - " ", - )}`, - ); - } - } - } - async removeSession(session: CICSSessionTree, profile?: imperative.IProfileLoaded, position?: number) { const persistentStorage = new PersistentStorage("zowe.cics.persistent"); await persistentStorage.removeLoadedCICSProfile(session.label.toString()); @@ -481,20 +453,6 @@ export class CICSTree implements TreeDataProvider { this._onDidChangeTreeData.fire(undefined); } - /** - * Update profile functionality for profile configuration - * @param session CICSSessions Tree - */ - async updateSession(session: CICSSessionTree, configInstance: imperative.ProfileInfo) { - await ProfileManagement.profilesCacheRefresh(); - const profileCache = await ProfileManagement.getProfilesCache(); - const profileToUpdate = profileCache.loadNamedProfile(session.label?.toString()!, "cics"); - const currentProfile = await profileCache.getProfileFromConfig(profileToUpdate.name); - const teamConfigFilePath = configInstance.getTeamConfig().opts.homeDir + "/zowe.config.json"; - const filePath = currentProfile?.profLoc.osLoc?.[0] ?? teamConfigFilePath; - await openConfigFile(filePath); - } - /** * Method for profile configuration that returns the context of a configuration file. * @param action string create or edit