From 98b0d0545fcba356aa5bcbbe45a37987c4ac8e91 Mon Sep 17 00:00:00 2001 From: Rushabh Sojitra Date: Mon, 23 Dec 2024 16:19:25 +0530 Subject: [PATCH] Removed v1 changes from vsce package Signed-off-by: Rushabh Sojitra --- .../vsce/src/commands/deleteSessionCommand.ts | 2 - packages/vsce/src/trees/CICSTree.ts | 179 +----------------- packages/vsce/src/utils/loggerUtils.ts | 27 --- packages/vsce/src/utils/profileDefinition.ts | 8 +- packages/vsce/src/utils/profileManagement.ts | 19 +- 5 files changed, 9 insertions(+), 226 deletions(-) delete mode 100644 packages/vsce/src/utils/loggerUtils.ts diff --git a/packages/vsce/src/commands/deleteSessionCommand.ts b/packages/vsce/src/commands/deleteSessionCommand.ts index 30234912..dc9eaeea 100644 --- a/packages/vsce/src/commands/deleteSessionCommand.ts +++ b/packages/vsce/src/commands/deleteSessionCommand.ts @@ -31,8 +31,6 @@ export function getDeleteSessionCommand(tree: CICSTree, treeview: TreeView) const filePath = currentProfile.profLoc.osLoc ? currentProfile.profLoc.osLoc[0] : ""; await openConfigFile(filePath); } - } else { - await tree.deleteSession(allSelectedNodes); } } catch (error) { window.showErrorMessage( diff --git a/packages/vsce/src/trees/CICSTree.ts b/packages/vsce/src/trees/CICSTree.ts index 28c85721..9d681d75 100644 --- a/packages/vsce/src/trees/CICSTree.ts +++ b/packages/vsce/src/trees/CICSTree.ts @@ -311,15 +311,6 @@ export class CICSTree implements TreeDataProvider { await configInstance.updateProperty({ ...upd, property: "rejectUnauthorized", value: false }); updatedProfile = await ProfileManagement.getProfilesCache().getLoadedProfConfig(profile.name); } else { - // flip rejectUnauthorized to false - const message = { - name: profile.name, - profile: { - ...profile.profile, - rejectUnauthorized: false, - }, - }; - const newProfile = await ProfileManagement.updateProfile(message); await ProfileManagement.profilesCacheRefresh(); updatedProfile = await ProfileManagement.getProfilesCache().loadNamedProfile(profile.name, "cics"); } @@ -376,115 +367,13 @@ export class CICSTree implements TreeDataProvider { * and creates a profile. */ async createNewProfile() { - if (isTheia()) { - const connnectionName = await Gui.showInputBox({ - prompt: "Name of connection", - placeHolder: "e.g. my-cics-profile", - ignoreFocusOut: true, - }); - if (!connnectionName) { - return; - } - const hostDetails = await Gui.showInputBox({ - prompt: "Input protocol, host and port for connection", - placeHolder: "e.g. https://mycicshostname.com:12345", - ignoreFocusOut: true, - }); - - if (!hostDetails) { - return; - } - - const splitHostDetails = hostDetails.split(":"); - - const protocol = splitHostDetails[0].toLowerCase(); - if (!["http", "https"].includes(protocol)) { - return; - } - - let host = splitHostDetails[1]; - if (host.slice(0, 2) !== "//") { - return; - } - host = host.slice(2); - - const port = parseInt(splitHostDetails[2]); - if (!port || isNaN(port)) { - return; - } - - const username = await Gui.showInputBox({ - prompt: "Input Username", - placeHolder: "e.g. user123", - ignoreFocusOut: true, - }); - if (!username) { - return; - } - - const userPassword = await Gui.showInputBox({ - prompt: "Input Password", - placeHolder: "e.g. 12345678", - password: true, - ignoreFocusOut: true, - }); - if (!userPassword) { - return; - } - - const plexName = await Gui.showInputBox({ - prompt: "Input Plex Name", - placeHolder: "e.g. PLEX123", - ignoreFocusOut: true, - }); - - const regionName = await Gui.showInputBox({ - prompt: "Input Region Name", - placeHolder: "e.g. REGION123", - ignoreFocusOut: true, - }); - - const rejectUnauthorized = await Gui.showQuickPick(["True", "False"], { - placeHolder: "Reject Unauthorized", - ignoreFocusOut: true, - }); - if (!rejectUnauthorized) { - return; - } - const message = { - profile: { - name: connnectionName, - host: host, - port: port, - user: username, - password: userPassword, - rejectUnauthorized: rejectUnauthorized === "True" ? true : false, - protocol: protocol, - cicsPlex: plexName.length === 0 ? undefined : plexName, - regionName: regionName.length === 0 ? undefined : regionName, - }, - name: connnectionName, - type: "CICS", - overwrite: true, - }; - - try { - await ProfileManagement.createNewProfile(message); - await ProfileManagement.profilesCacheRefresh(); - await this.loadProfile(ProfileManagement.getProfilesCache().loadNamedProfile(message.name, "cics")); - } catch (error) { - // @ts-ignore - window.showErrorMessage(error); - } - } else { - // Initialize new team configuration file - const response = await window.showQuickPick([{ label: "\uFF0B Create a New Team Configuration File" }], { - ignoreFocusOut: true, - placeHolder: "Create a New Team Configuration File", - }); - if (response) { - commands.executeCommand("zowe.all.config.init"); - } + // Initialize new team configuration file + const response = await window.showQuickPick([{ label: "\uFF0B Create a New Team Configuration File" }], { + ignoreFocusOut: true, + placeHolder: "Create a New Team Configuration File", + }); + if (response) { + commands.executeCommand("zowe.all.config.init"); } } @@ -498,60 +387,6 @@ export class CICSTree implements TreeDataProvider { this._onDidChangeTreeData.fire(undefined); } - /** - * Delete profile functionality for V1 profile configuration - * @param sessions - */ - async deleteSession(sessions: CICSSessionTree[]) { - let answer; - if (sessions.length === 1) { - answer = await window.showInformationMessage( - `Are you sure you want to delete the profile "${sessions[0].label?.toString()!}"`, - ...["Yes", "No"] - ); - } else if (sessions.length > 1) { - answer = await window.showInformationMessage( - `Are you sure you want to delete the profiles "${sessions.map((sessionTree) => { - return sessionTree.label?.toString()!; - })}"`, - ...["Yes", "No"] - ); - } - if (answer === "Yes") { - window.withProgress( - { - title: "Delete Profile", - location: ProgressLocation.Notification, - cancellable: true, - }, - async (progress, token) => { - token.onCancellationRequested(() => { - console.log("Cancelling the delete command"); - }); - for (const index in sessions) { - progress.report({ - message: `Deleting profile ${parseInt(index) + 1} of ${sessions.length}`, - increment: (parseInt(index) / sessions.length) * 100, - }); - try { - await ProfileManagement.deleteProfile({ - name: sessions[parseInt(index)].label?.toString()!, - rejectIfDependency: true, - }); - const persistentStorage = new PersistentStorage("zowe.cics.persistent"); - await persistentStorage.removeLoadedCICSProfile(sessions[parseInt(index)].label.toString()); - - this.loadedProfiles = this.loadedProfiles.filter((profile) => profile !== sessions[parseInt(index)]); - this._onDidChangeTreeData.fire(undefined); - } catch (error) { - // @ts-ignore - window.showErrorMessage(error); - } - } - } - ); - } - } async updateSession(session: CICSSessionTree) { await ProfileManagement.profilesCacheRefresh(); diff --git a/packages/vsce/src/utils/loggerUtils.ts b/packages/vsce/src/utils/loggerUtils.ts deleted file mode 100644 index c4b86251..00000000 --- a/packages/vsce/src/utils/loggerUtils.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { IZoweLogger } from "@zowe/zowe-explorer-api"; -import { getZoweDir } from "@zowe/core-for-zowe-sdk"; -import { join as joinPaths } from "path"; - -export class LoggerUtils { - // Explicit null typing used to satisfy linter rule "eqeqeq" - static loggerObj: IZoweLogger | null = null; - - public static get instance(): IZoweLogger { - if (LoggerUtils.loggerObj === null) { - LoggerUtils.loggerObj = new IZoweLogger("vscode-extension-for-cics", joinPaths(getZoweDir(), "vscode-extension-for-cics")); - } - - return LoggerUtils.loggerObj; - } -} diff --git a/packages/vsce/src/utils/profileDefinition.ts b/packages/vsce/src/utils/profileDefinition.ts index 2cec42d3..4df516de 100644 --- a/packages/vsce/src/utils/profileDefinition.ts +++ b/packages/vsce/src/utils/profileDefinition.ts @@ -104,13 +104,7 @@ const cicsProfileMeta: imperative.ICommandProfileTypeConfiguration[] = [ }, }, required: [], - }, - createProfileExamples: [ - { - options: "cics123 --host zos123 --port 1490 --user ibmuser --password myp4ss", - description: "Create a cics profile named 'cics123' to connect to CICS at host zos123 and port 1490", - }, - ], + } }, ]; diff --git a/packages/vsce/src/utils/profileManagement.ts b/packages/vsce/src/utils/profileManagement.ts index 43f1a969..658e2d7c 100644 --- a/packages/vsce/src/utils/profileManagement.ts +++ b/packages/vsce/src/utils/profileManagement.ts @@ -9,14 +9,13 @@ * */ -import { ProfilesCache, Types, ZoweVsCodeExtension, imperative } from "@zowe/zowe-explorer-api"; +import { Types, ZoweVsCodeExtension, imperative } from "@zowe/zowe-explorer-api"; import axios, { AxiosRequestConfig } from "axios"; import { window } from "vscode"; import { xml2json } from "xml-js"; import cicsProfileMeta from "./profileDefinition"; import * as https from "https"; import { CICSPlexTree } from "../trees/CICSPlexTree"; -import { LoggerUtils } from "./loggerUtils"; export class ProfileManagement { private static zoweExplorerAPI = ZoweVsCodeExtension.getZoweExplorerApi(); @@ -48,22 +47,6 @@ export class ProfileManagement { await ProfileManagement.getProfilesCache().refresh(apiRegiser); } - public static async createNewProfile(formResponse: imperative.ISaveProfile) { - await ProfileManagement.ProfilesCache.getCliProfileManager("cics")?.save(formResponse); - await ProfileManagement.getExplorerApis().getExplorerExtenderApi().reloadProfiles(); - } - - public static async updateProfile(formResponse: imperative.IUpdateProfile) { - const profile: imperative.IProfileUpdated = await ProfileManagement.ProfilesCache.getCliProfileManager("cics")?.update(formResponse); - await ProfileManagement.getExplorerApis().getExplorerExtenderApi().reloadProfiles(); - return profile; - } - - public static async deleteProfile(formResponse: imperative.IDeleteProfile) { - await ProfileManagement.ProfilesCache.getCliProfileManager("cics")?.delete(formResponse); - await ProfileManagement.getExplorerApis().getExplorerExtenderApi().reloadProfiles(); - } - public static async getConfigInstance(): Promise { const mProfileInfo = await ProfileManagement.getProfilesCache().getProfileInfo(); return mProfileInfo;