Skip to content

Commit df6656b

Browse files
daveniceAndrewTwydell
authored andcommitted
remove multi-select, simplify profile selection code
Signed-off-by: Dave Nice <[email protected]>
1 parent 1087db6 commit df6656b

File tree

3 files changed

+13
-54
lines changed

3 files changed

+13
-54
lines changed

packages/vsce/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ All notable changes to the "cics-extension-for-zowe" extension will be documente
44

55
## Recent Changes
66

7+
- BugFix: Editing profile results in exception - removed ability to multi-select profiles. [#222](https://github.com/zowe/cics-for-zowe-client/issues/222)
78
- BugFix: Update documentation to reflect changes to fully support V3 profiles. [#209](https://github.com/zowe/cics-for-zowe-client/issues/209)
89

910
## `3.3.1`

packages/vsce/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@
719719
"group": ""
720720
},
721721
{
722-
"when": "view == cics-view && viewItem =~ /^cicssession.*/",
722+
"when": "view == cics-view && viewItem =~ /^cicssession.*/ && !listMultiSelection",
723723
"command": "cics-extension-for-zowe.manageSession",
724724
"title": "Manage Session"
725725
},

packages/vsce/src/trees/CICSTree.ts

+11-53
Original file line numberDiff line numberDiff line change
@@ -85,32 +85,27 @@ export class CICSTree implements TreeDataProvider<CICSSessionTree> {
8585
* @param treeview CICSTree View
8686
* *@param node current selected node
8787
*/
88-
async manageProfile(treeview: TreeView<any>, node: any) {
89-
const allSelectedNodes = findSelectedNodes(treeview, CICSSessionTree, node);
90-
if (!allSelectedNodes || !allSelectedNodes.length) {
91-
window.showErrorMessage("No profile selected to manage");
92-
return;
93-
}
88+
async manageProfile(treeview: TreeView<any>, node: CICSSessionTree) {
9489
try {
9590
const configInstance = await ProfileManagement.getConfigInstance();
9691
if (configInstance.getTeamConfig().exists) {
97-
const currentProfile = await ProfileManagement.getProfilesCache().getProfileFromConfig(allSelectedNodes[allSelectedNodes.length - 1].label);
92+
const currentProfile = await ProfileManagement.getProfilesCache().getProfileFromConfig(String(node.label));
9893

9994
const deleteProfile: QuickPickItem = {
100-
label: `$(trash) ${l10n.t(`Delete Profile${allSelectedNodes.length > 1 ? "s" : ""}`)}`,
101-
description: l10n.t(`Delete the selected Profile${allSelectedNodes.length > 1 ? "s" : ""}`),
95+
label: `$(trash) ${l10n.t(`Delete Profile`)}`,
96+
description: l10n.t(`Delete the selected Profile`),
10297
};
10398
const hideProfile: QuickPickItem = {
104-
label: `$(eye-closed) ${l10n.t(`Hide Profile${allSelectedNodes.length > 1 ? "s" : ""}`)}`,
105-
description: l10n.t(`Hide the selected Profile${allSelectedNodes.length > 1 ? "s" : ""}`),
99+
label: `$(eye-closed) ${l10n.t(`Hide Profile`)}`,
100+
description: l10n.t(`Hide the selected Profile`),
106101
};
107102
const editProfile: QuickPickItem = {
108-
label: `$(pencil) ${l10n.t(`Edit Profile${allSelectedNodes.length > 1 ? "s" : ""}`)}`,
109-
description: l10n.t(`Update the selected Profile${allSelectedNodes.length > 1 ? "s" : ""}`),
103+
label: `$(pencil) ${l10n.t(`Edit Profile`)}`,
104+
description: l10n.t(`Update the selected Profile`),
110105
};
111106

112107
const quickpick = Gui.createQuickPick();
113-
const addProfilePlaceholder = "Choose user action for selected profiles";
108+
const addProfilePlaceholder = "Choose user action for selected profile";
114109
quickpick.items = [editProfile, hideProfile, deleteProfile];
115110
quickpick.placeholder = addProfilePlaceholder;
116111
quickpick.ignoreFocusOut = true;
@@ -122,13 +117,10 @@ export class CICSTree implements TreeDataProvider<CICSSessionTree> {
122117
Gui.showMessage(debugMsg);
123118
return;
124119
} else if (choice === hideProfile) {
125-
this.hideZoweConfigFile(allSelectedNodes);
120+
await this.removeSession(node);
126121
return;
127-
} else if (choice === editProfile) {
128-
for (const sessionTree of allSelectedNodes) {
129-
await this.updateSession(sessionTree, configInstance);
130-
}
131122
} else {
123+
// editProfile or deleteProfile
132124
const filePath = currentProfile.profLoc.osLoc[0];
133125
await openConfigFile(filePath);
134126
return;
@@ -451,26 +443,6 @@ export class CICSTree implements TreeDataProvider<CICSSessionTree> {
451443
this._onDidChangeTreeData.fire(undefined);
452444
}
453445

454-
/**
455-
* Method for profile configuration that provides UI for user to hide a selected profile.
456-
* @param allSelectedNodes array of selected nodes
457-
*/
458-
async hideZoweConfigFile(allSelectedNodes: any[]) {
459-
for (const index in allSelectedNodes) {
460-
try {
461-
const currentNode = allSelectedNodes[parseInt(index)];
462-
await this.removeSession(currentNode);
463-
} catch (error) {
464-
window.showErrorMessage(
465-
`Something went wrong when hiding the profile - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace(
466-
/(\\n\t|\\n|\\t)/gm,
467-
" ",
468-
)}`,
469-
);
470-
}
471-
}
472-
}
473-
474446
async removeSession(session: CICSSessionTree, profile?: imperative.IProfileLoaded, position?: number) {
475447
const persistentStorage = new PersistentStorage("zowe.cics.persistent");
476448
await persistentStorage.removeLoadedCICSProfile(session.label.toString());
@@ -481,20 +453,6 @@ export class CICSTree implements TreeDataProvider<CICSSessionTree> {
481453
this._onDidChangeTreeData.fire(undefined);
482454
}
483455

484-
/**
485-
* Update profile functionality for profile configuration
486-
* @param session CICSSessions Tree
487-
*/
488-
async updateSession(session: CICSSessionTree, configInstance: imperative.ProfileInfo) {
489-
await ProfileManagement.profilesCacheRefresh();
490-
const profileCache = await ProfileManagement.getProfilesCache();
491-
const profileToUpdate = profileCache.loadNamedProfile(session.label?.toString()!, "cics");
492-
const currentProfile = await profileCache.getProfileFromConfig(profileToUpdate.name);
493-
const teamConfigFilePath = configInstance.getTeamConfig().opts.homeDir + "/zowe.config.json";
494-
const filePath = currentProfile?.profLoc.osLoc?.[0] ?? teamConfigFilePath;
495-
await openConfigFile(filePath);
496-
}
497-
498456
/**
499457
* Method for profile configuration that returns the context of a configuration file.
500458
* @param action string create or edit

0 commit comments

Comments
 (0)