Skip to content

Commit

Permalink
Merge pull request #777 from zowe/fix-deleting-profile
Browse files Browse the repository at this point in the history
Fix deleting profiles (issue #743)
  • Loading branch information
zFernand0 authored May 7, 2020
2 parents a702e9c + fc9882b commit 2d09a64
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 40 deletions.
2 changes: 1 addition & 1 deletion i18n/sample/src/Profiles.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"deleteProfile.noProfilesLoaded": "No profiles available",
"deleteProfile.quickPickOption": "Are you sure you want to permanently delete ",
"deleteProfile.undefined.profilename": "Operation Cancelled",
"deleteProfile.noSelected": "Operation Cancelled",
"deleteProfile.log.debug": "Deleting profile ",
"deleteProfile.showQuickPick.yes": "Yes",
"deleteProfile.showQuickPick.no": "No",
"deleteProfile.showQuickPick.log.debug": "User picked no. Cancelling delete of profile",
"deleteProfile.delete.log.error": "Error encountered when deleting profile! ",
"deleteProfile.noSelected": "Operation Cancelled",
"createNewConnection.option.prompt.url.placeholder": "https://url:port",
"createNewConnection.option.prompt.url": "Enter a z/OSMF URL in the format 'https://url:port'.",
"createNewConnection.zosmfURL": "No valid value for z/OSMF URL. Operation Cancelled",
Expand Down
77 changes: 38 additions & 39 deletions src/Profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,45 +388,6 @@ export class Profiles {
return allProfiles.find((temprofile) => temprofile.name === sesName);
}

public async deletePrompt(deletedProfile: IProfileLoaded) {
const profileName = deletedProfile.name;
this.log.debug(localize("deleteProfile.log.debug", "Deleting profile ") + profileName);
const quickPickOptions: vscode.QuickPickOptions = {
placeHolder: localize("deleteProfile.quickPickOption", "Are you sure you want to permanently delete ") + profileName,
ignoreFocusOut: true,
canPickMany: false
};
// confirm that the user really wants to delete
if (await vscode.window.showQuickPick([localize("deleteProfile.showQuickPick.yes", "Yes"),
localize("deleteProfile.showQuickPick.no", "No")], quickPickOptions) !== localize("deleteProfile.showQuickPick.yes", "Yes")) {
this.log.debug(localize("deleteProfile.showQuickPick.log.debug", "User picked no. Cancelling delete of profile"));
return;
}

const profileType = ZoweExplorerApiRegister.getMvsApi(deletedProfile).getProfileTypeName();
try {
this.deleteProf(deletedProfile, profileName, profileType);
} catch (error) {
this.log.error(localize("deleteProfile.delete.log.error", "Error encountered when deleting profile! ") + JSON.stringify(error));
await errorHandling(error, profileName, error.message);
throw error;
}

vscode.window.showInformationMessage("Profile " + profileName + " was deleted.");
return profileName;
}

public async deleteProf(ProfileInfo, ProfileName, ProfileType) {
let zosmfProfile: IProfile;
try {
zosmfProfile = await (await this.getCliProfileManager(ProfileType))
.delete({ profile: ProfileInfo, name: ProfileName, type: ProfileType });
} catch (error) {
vscode.window.showErrorMessage(error.message);
}
return zosmfProfile.profile;
}

public async deleteProfile(datasetTree: IZoweTree<IZoweDatasetTreeNode>, ussTree: IZoweTree<IZoweUSSTreeNode>,
jobsProvider: IZoweTree<IZoweJobTreeNode>, node?: IZoweNodeType) {

Expand Down Expand Up @@ -595,6 +556,44 @@ export class Profiles {
return directProfile;
}

private async deletePrompt(deletedProfile: IProfileLoaded) {
const profileName = deletedProfile.name;
this.log.debug(localize("deleteProfile.log.debug", "Deleting profile ") + profileName);
const quickPickOptions: vscode.QuickPickOptions = {
placeHolder: localize("deleteProfile.quickPickOption", "Are you sure you want to permanently delete ") + profileName,
ignoreFocusOut: true,
canPickMany: false
};
// confirm that the user really wants to delete
if (await vscode.window.showQuickPick([localize("deleteProfile.showQuickPick.yes", "Yes"),
localize("deleteProfile.showQuickPick.no", "No")], quickPickOptions) !== localize("deleteProfile.showQuickPick.yes", "Yes")) {
this.log.debug(localize("deleteProfile.showQuickPick.log.debug", "User picked no. Cancelling delete of profile"));
return;
}

try {
this.deleteProfileOnDisk(deletedProfile, profileName, deletedProfile.type);
} catch (error) {
this.log.error(localize("deleteProfile.delete.log.error", "Error encountered when deleting profile! ") + JSON.stringify(error));
await errorHandling(error, profileName, error.message);
throw error;
}

vscode.window.showInformationMessage("Profile " + profileName + " was deleted.");
return profileName;
}

private async deleteProfileOnDisk(ProfileInfo, ProfileName, ProfileType) {
let zosmfProfile: IProfile;
try {
zosmfProfile = await (await this.getCliProfileManager(ProfileType))
.delete({ profile: ProfileInfo, name: ProfileName, type: ProfileType });
} catch (error) {
vscode.window.showErrorMessage(error.message);
}
return zosmfProfile.profile;
}

// ** Functions for handling Profile Information */

private async urlInfo(input?) {
Expand Down

0 comments on commit 2d09a64

Please sign in to comment.