Skip to content

Commit

Permalink
move enable, disable, and delete to quickpick
Browse files Browse the repository at this point in the history
Signed-off-by: Billie Simmons <[email protected]>
  • Loading branch information
JillieBeanSim committed Oct 2, 2023
1 parent fdace6e commit 71cd777
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 63 deletions.
2 changes: 2 additions & 0 deletions packages/zowe-explorer/__tests__/__theia__/theia/Locators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const UssLocators = {
addToFavoriteOptionXpath: "//li[@data-command='zowe.uss.addFavorite']",
removeFavoriteProfileFromUssOptionXpath: "//li[@data-command='zowe.uss.removeFavProfile']",
hideProfileFromUssOptionXpath: "//li[@data-command='zowe.uss.removeSession']",
manageProfileFromUnixXpath: "(//li[@data-command='zowe.profileManagement'])",
};

export const JobsLocators = {
Expand All @@ -60,6 +61,7 @@ export const JobsLocators = {
removeFavoriteProfileFromJobsOptionXpath: "//li[@data-command='zowe.jobs.removeFavProfile']",
hideProfileFromJobsOptionXpath: "//li[@data-command='zowe.jobs.removeJobsSession']",
secondJobsProfileBeforeHidingXpath: "(//div[contains(@id,'TestSeleniumProfile')])[2]",
manageProfileFromJobsXpath: "(//li[@data-command='zowe.profileManagement'])",
};

export const TheiaNotificationMessages = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,21 @@ export async function addProfileToFavoritesInJobs() {
export async function hideProfileInUss() {
const hideProfileFromUss = await driverChrome.wait(until.elementLocated(By.xpath(UssLocators.secondUssProfileXpath)), WAITTIME);
await driverChrome.actions().click(hideProfileFromUss, Button.RIGHT).perform();
await driverChrome.wait(until.elementLocated(By.xpath(UssLocators.hideProfileFromUssOptionXpath)), WAITTIME).click();
driverChrome.wait(until.elementLocated(By.xpath(UssLocators.manageProfileFromUnixXpath)), WAITTIME).click();
await driverChrome.sleep(SHORTSLEEPTIME);
const manageProfile = driverChrome.wait(until.elementLocated(By.xpath(UssLocators.emptyInputBoxXpath)), WAITTIME);
manageProfile.sendKeys("Hide Profile");
manageProfile.sendKeys(Key.ENTER);
}

export async function hideProfileInJobs() {
const hideProfileFromJobs = await driverChrome.wait(until.elementLocated(By.xpath(JobsLocators.secondJobsProfileBeforeHidingXpath)), WAITTIME);
await driverChrome.actions().click(hideProfileFromJobs, Button.RIGHT).perform();
await driverChrome.wait(until.elementLocated(By.xpath(JobsLocators.hideProfileFromJobsOptionXpath)), WAITTIME).click();
driverChrome.wait(until.elementLocated(By.xpath(JobsLocators.manageProfileFromJobsXpath)), WAITTIME).click();
await driverChrome.sleep(SHORTSLEEPTIME);
const manageProfile = driverChrome.wait(until.elementLocated(By.xpath(JobsLocators.emptyInputBoxXpath)), WAITTIME);
manageProfile.sendKeys("Hide Profile");
manageProfile.sendKeys(Key.ENTER);
}

export async function verifyProfileIsHideInUss() {
Expand Down
2 changes: 1 addition & 1 deletion packages/zowe-explorer/i18n/sample/src/Profiles.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
"validateProfiles.error": "Profile validation failed for {0}.",
"ssoAuth.usingBasicAuth": "This profile is using basic authentication and does not support token authentication.",
"ssoLogin.tokenType.error": "Error getting supported tokenType value for profile {0}",
"ssoLogin.successful": "Login to authentication service was successful.",
"ssoLogin.error": "Unable to log in with {0}. {1}",
"ssoLogout.successful": "Logout from authentication service was successful for {0}.",
"ssoLogout.error": "Unable to log out with {0}. {1}",
"ssoLogin.successful": "Login to authentication service was successful.",
"getConfigLocationPrompt.placeholder.create": "Select the location where the config file will be initialized",
"getConfigLocationPrompt.placeholder.edit": "Select the location of the config file to edit",
"getConfigLocationPrompt.showQuickPick.global": "Global: in the Zowe home directory",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
"updateBasicAuthQpItem.updateCredentials.qpLabel": "$(refresh) Update Credentials",
"updateBasicAuthQpItem.updateCredentials.qpDetail": "Update stored username and password",
"deleteProfileQpItem.delete.qpLabel": "$(trash) Delete Profile",
"disableProfileValildationQpItem.disableValidation.qpLabel": "$(workspace-untrusted) Disable Profile Validation",
"disableProfileValildationQpItem.disableValidation.qpDetail": "Disable validation of server check for profile.",
"enableProfileValildationQpItem.enableValidation.qpLabel": "$(workspace-trusted) Enable Profile Validation",
"enableProfileValildationQpItem.enableValidation.qpDetail": "Enable validation of server check for profile.",
"editProfileQpItem.editProfile.qpLabel": "$(pencil) Edit Profile",
"editProfileQpItem.editProfile.qpDetail": "Update profile connection information",
"hideProfileQpItems.hideProfile.qpLabel": "$(eye-closed) Hide Profile",
"hideProfileQpItems.hideProfile.qpDetail": "Hide profile name from tree view.",
"loginQpItem.login.qpLabel": "$(arrow-right) Log in to authentication service",
"loginQpItem.login.qpDetail": "Log in to obtain a new token value",
"logoutQpItem.logout.qpLabel": "$(arrow-left) Log out of authentication service",
Expand Down
45 changes: 0 additions & 45 deletions packages/zowe-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -958,26 +958,11 @@
"command": "zowe.uss.deleteNode",
"group": "099_zowe_ussModification:@4"
},
{
"when": "view == zowe.uss.explorer && viewItem =~ /_validate/ && !listMultiSelection",
"command": "zowe.uss.disableValidation",
"group": "099_zowe_ussProfileAuthentication@96"
},
{
"when": "view == zowe.uss.explorer && viewItem =~ /_noValidate/ && !listMultiSelection",
"command": "zowe.uss.enableValidation",
"group": "099_zowe_ussProfileAuthentication@97"
},
{
"when": "view == zowe.uss.explorer && viewItem =~ /^(?!.*_fav.*)ussSession.*/ && !listMultiSelection",
"command": "zowe.profileManagement",
"group": "099_zowe_ussProfileAuthentication@99"
},
{
"when": "viewItem =~ /^(?!.*_fav.*)ussSession.*/",
"command": "zowe.uss.removeSession",
"group": "099_zowe_ussProfileAuthentication@98"
},
{
"when": "view == zowe.ds.explorer && viewItem =~ /^(?!.*_fav.*)session.*/ && !listMultiSelection",
"command": "zowe.ds.pattern",
Expand Down Expand Up @@ -1153,26 +1138,11 @@
"command": "zowe.ds.deleteDataset",
"group": "099_zowe_dsModification@5"
},
{
"when": "view == zowe.ds.explorer && viewItem =~ /_validate/ && !listMultiSelection",
"command": "zowe.ds.disableValidation",
"group": "099_zowe_dsProfileAuthentication@96"
},
{
"when": "view == zowe.ds.explorer && viewItem =~ /_noValidate/ && !listMultiSelection",
"command": "zowe.ds.enableValidation",
"group": "099_zowe_dsProfileAuthentication@97"
},
{
"when": "view == zowe.ds.explorer && viewItem =~ /^(?!.*_fav.*)session.*/ && !listMultiSelection",
"command": "zowe.profileManagement",
"group": "099_zowe_dsProfileAuthentication@99"
},
{
"when": "view == zowe.ds.explorer && viewItem =~ /^(?!.*_fav.*)session.*/",
"command": "zowe.ds.removeSession",
"group": "099_zowe_dsProfileAuthentication@98"
},
{
"when": "view == zowe.jobs.explorer && viewItem =~ /^(?!.*_fav.*)server.*/ && !listMultiSelection",
"command": "zowe.jobs.search",
Expand Down Expand Up @@ -1298,26 +1268,11 @@
"command": "zowe.jobs.cancelJob",
"group": "099_zowe_jobsModification"
},
{
"when": "view == zowe.jobs.explorer && viewItem =~ /_validate/ && !listMultiSelection",
"command": "zowe.jobs.disableValidation",
"group": "099_zowe_jobsProfileAuthentication@96"
},
{
"when": "view == zowe.jobs.explorer && viewItem =~ /_noValidate/ && !listMultiSelection",
"command": "zowe.jobs.enableValidation",
"group": "099_zowe_jobsProfileAuthentication@97"
},
{
"when": "view == zowe.jobs.explorer && viewItem =~ /^(?!.*_fav.*)server.*/ && !listMultiSelection",
"command": "zowe.profileManagement",
"group": "099_zowe_jobsProfileAuthentication@99"
},
{
"when": "view == zowe.jobs.explorer && viewItem =~ /^(?!.*_fav.*)server.*/",
"command": "zowe.jobs.removeJobsSession",
"group": "099_zowe_jobsProfileAuthentication@98"
},
{
"when": "view == zowe.jobs.explorer && viewItem =~ /^(?!.*_fav.*)server.*/ && !listMultiSelection",
"command": "zowe.jobs.sortbyid",
Expand Down
104 changes: 89 additions & 15 deletions packages/zowe-explorer/src/utils/ProfileManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
*/

import * as vscode from "vscode";
import * as globals from "../globals";
import { Gui, IZoweTreeNode, imperative } from "@zowe/zowe-explorer-api";
import { ZoweLogger } from "./LoggerUtils";
import { ProfilesUtils } from "./ProfilesUtils";
import * as nls from "vscode-nls";
import { Profiles } from "../Profiles";
import { ZoweExplorerApiRegister } from "../ZoweExplorerApiRegister";
import { isZoweDatasetTreeNode, isZoweUSSTreeNode } from "../shared/utils";

// Set up localization
nls.config({
Expand All @@ -31,27 +33,30 @@ export class ProfileManagement {
switch (true) {
case ProfilesUtils.isProfileUsingBasicAuth(profile): {
ZoweLogger.debug(`Profile ${profile.name} is using basic authentication.`);
selected = await this.setupProfileManagementQp(imperative.SessConstants.AUTH_TYPE_BASIC, profile);
selected = await this.setupProfileManagementQp(imperative.SessConstants.AUTH_TYPE_BASIC, node);
break;
}
case await ProfilesUtils.isUsingTokenAuth(profile.name): {
ZoweLogger.debug(`Profile ${profile.name} is using token authentication.`);
selected = await this.setupProfileManagementQp("token", profile);
selected = await this.setupProfileManagementQp("token", node);
break;
}
// will need a case for isUsingCertAuth
default: {
ZoweLogger.debug(`Profile ${profile.name} authentication method is unkown.`);
selected = await this.setupProfileManagementQp(null, profile);
selected = await this.setupProfileManagementQp(null, node);
break;
}
}
await this.handleAuthSelection(selected, node, profile);
}
public static AuthQpLabels = {
add: "add-credentials",
delete: "delete",
delete: "delete-profile",
disable: "disable-validation",
edit: "edit-profile",
enable: "enable-validation",
hide: "hide-profile",
login: "obtain-token",
logout: "invalidate-token",
update: "update-credentials",
Expand All @@ -73,12 +78,30 @@ export class ProfileManagement {
label: localize("deleteProfileQpItem.delete.qpLabel", "$(trash) Delete Profile"),
},
};
public static disableProfileValildationQpItem: Record<string, vscode.QuickPickItem> = {
[this.AuthQpLabels.disable]: {
label: localize("disableProfileValildationQpItem.disableValidation.qpLabel", "$(workspace-untrusted) Disable Profile Validation"),
description: localize("disableProfileValildationQpItem.disableValidation.qpDetail", "Disable validation of server check for profile."),
},
};
public static enableProfileValildationQpItem: Record<string, vscode.QuickPickItem> = {
[this.AuthQpLabels.enable]: {
label: localize("enableProfileValildationQpItem.enableValidation.qpLabel", "$(workspace-trusted) Enable Profile Validation"),
description: localize("enableProfileValildationQpItem.enableValidation.qpDetail", "Enable validation of server check for profile."),
},
};
public static editProfileQpItems: Record<string, vscode.QuickPickItem> = {
[this.AuthQpLabels.edit]: {
label: localize("editProfileQpItem.editProfile.qpLabel", "$(pencil) Edit Profile"),
description: localize("editProfileQpItem.editProfile.qpDetail", "Update profile connection information"),
},
};
public static hideProfileQpItems: Record<string, vscode.QuickPickItem> = {
[this.AuthQpLabels.hide]: {
label: localize("hideProfileQpItems.hideProfile.qpLabel", "$(eye-closed) Hide Profile"),
description: localize("hideProfileQpItems.hideProfile.qpDetail", "Hide profile name from tree view."),
},
};
public static tokenAuthLoginQpItem: Record<string, vscode.QuickPickItem> = {
[this.AuthQpLabels.login]: {
label: localize("loginQpItem.login.qpLabel", "$(arrow-right) Log in to authentication service"),
Expand All @@ -91,23 +114,24 @@ export class ProfileManagement {
description: localize("logoutQpItem.logout.qpDetail", "Log out to invalidate and remove stored token value"),
},
};
private static async setupProfileManagementQp(managementType: string, profile: imperative.IProfileLoaded): Promise<vscode.QuickPickItem> {
private static async setupProfileManagementQp(managementType: string, node: IZoweTreeNode): Promise<vscode.QuickPickItem> {
const profile = node.getProfile();
const qp = Gui.createQuickPick();
let quickPickOptions: vscode.QuickPickItem[];
const placeholders = this.getQpPlaceholders(profile);
switch (managementType) {
case imperative.SessConstants.AUTH_TYPE_BASIC: {
quickPickOptions = this.basicAuthQp();
quickPickOptions = this.basicAuthQp(node);
qp.placeholder = placeholders.basicAuth;
break;
}
case "token": {
quickPickOptions = this.tokenAuthQp(profile);
quickPickOptions = this.tokenAuthQp(node);
qp.placeholder = placeholders.tokenAuth;
break;
}
default: {
quickPickOptions = this.chooseAuthQp(profile);
quickPickOptions = this.chooseAuthQp(node);
qp.placeholder = placeholders.chooseAuth;
break;
}
Expand Down Expand Up @@ -142,10 +166,22 @@ export class ProfileManagement {
await ProfilesUtils.promptCredentials(node);
break;
}
case this.hideProfileQpItems[this.AuthQpLabels.hide]: {
await this.handleHideProfiles(node);
break;

Check warning on line 171 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L169-L171

Added lines #L169 - L171 were not covered by tests
}
case this.deleteProfileQpItem[this.AuthQpLabels.delete]: {
await this.handleDeleteProfiles(node);
break;
}
case this.enableProfileValildationQpItem[this.AuthQpLabels.enable]: {
await this.handleEnableProfileValidation(node);
break;

Check warning on line 179 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L177-L179

Added lines #L177 - L179 were not covered by tests
}
case this.disableProfileValildationQpItem[this.AuthQpLabels.disable]: {
await this.handleDisableProfileValidation(node);
break;

Check warning on line 183 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L181-L183

Added lines #L181 - L183 were not covered by tests
}
default: {
Gui.infoMessage(localize("profiles.operation.cancelled", "Operation Cancelled"));
break;
Expand All @@ -165,29 +201,37 @@ export class ProfileManagement {
};
}

private static basicAuthQp(): vscode.QuickPickItem[] {
private static basicAuthQp(node: IZoweTreeNode): vscode.QuickPickItem[] {
const quickPickOptions: vscode.QuickPickItem[] = Object.values(this.basicAuthUpdateQpItems);
return this.addFinalQpOptions(quickPickOptions);
return this.addFinalQpOptions(node, quickPickOptions);
}
private static tokenAuthQp(profile: imperative.IProfileLoaded): vscode.QuickPickItem[] {
private static tokenAuthQp(node: IZoweTreeNode): vscode.QuickPickItem[] {
const profile = node.getProfile();
const quickPickOptions: vscode.QuickPickItem[] = Object.values(this.tokenAuthLoginQpItem);
if (profile.profile.tokenType) {
quickPickOptions.push(this.tokenAuthLogoutQpItem[this.AuthQpLabels.logout]);
}
return this.addFinalQpOptions(quickPickOptions);
return this.addFinalQpOptions(node, quickPickOptions);
}
private static chooseAuthQp(profile: imperative.IProfileLoaded): vscode.QuickPickItem[] {
private static chooseAuthQp(node: IZoweTreeNode): vscode.QuickPickItem[] {
const profile = node.getProfile();
const quickPickOptions: vscode.QuickPickItem[] = Object.values(this.basicAuthAddQpItems);
try {
ZoweExplorerApiRegister.getInstance().getCommonApi(profile).getTokenTypeName();
quickPickOptions.push(this.tokenAuthLoginQpItem[this.AuthQpLabels.login]);
} catch {
ZoweLogger.debug(`Profile ${profile.name} doesn't support token authentication, will not provide option.`);

Check warning on line 223 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L223

Added line #L223 was not covered by tests
}
return this.addFinalQpOptions(quickPickOptions);
return this.addFinalQpOptions(node, quickPickOptions);
}
private static addFinalQpOptions(quickPickOptions: vscode.QuickPickItem[]): vscode.QuickPickItem[] {
private static addFinalQpOptions(node: IZoweTreeNode, quickPickOptions: vscode.QuickPickItem[]): vscode.QuickPickItem[] {
if (node.contextValue.includes(globals.NO_VALIDATE_SUFFIX)) {
quickPickOptions.push(this.enableProfileValildationQpItem[this.AuthQpLabels.enable]);

Check warning on line 229 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L229

Added line #L229 was not covered by tests
} else {
quickPickOptions.push(this.disableProfileValildationQpItem[this.AuthQpLabels.disable]);
}
quickPickOptions.push(this.editProfileQpItems[this.AuthQpLabels.edit]);
quickPickOptions.push(this.hideProfileQpItems[this.AuthQpLabels.hide]);
quickPickOptions.push(this.deleteProfileQpItem[this.AuthQpLabels.delete]);
return quickPickOptions;
}
Expand All @@ -200,4 +244,34 @@ export class ProfileManagement {
}
await vscode.commands.executeCommand("zowe.ds.deleteProfile", node);
}

private static async handleHideProfiles(node: IZoweTreeNode): Promise<void> {

Check warning on line 248 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L248

Added line #L248 was not covered by tests
if (isZoweDatasetTreeNode(node)) {
return vscode.commands.executeCommand("zowe.ds.removeSession", node);

Check warning on line 250 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L250

Added line #L250 was not covered by tests
}
if (isZoweUSSTreeNode(node)) {
return vscode.commands.executeCommand("zowe.uss.removeSession", node);

Check warning on line 253 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L253

Added line #L253 was not covered by tests
}
return vscode.commands.executeCommand("zowe.jobs.removeJobsSession", node);

Check warning on line 255 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L255

Added line #L255 was not covered by tests
}

private static async handleEnableProfileValidation(node: IZoweTreeNode): Promise<void> {

Check warning on line 258 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L258

Added line #L258 was not covered by tests
if (isZoweDatasetTreeNode(node)) {
return vscode.commands.executeCommand("zowe.ds.enableValidation", node);

Check warning on line 260 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L260

Added line #L260 was not covered by tests
}
if (isZoweUSSTreeNode(node)) {
return vscode.commands.executeCommand("zowe.uss.enableValidation", node);

Check warning on line 263 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L263

Added line #L263 was not covered by tests
}
return vscode.commands.executeCommand("zowe.jobs.enableValidation", node);

Check warning on line 265 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L265

Added line #L265 was not covered by tests
}

private static async handleDisableProfileValidation(node: IZoweTreeNode): Promise<void> {

Check warning on line 268 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L268

Added line #L268 was not covered by tests
if (isZoweDatasetTreeNode(node)) {
return vscode.commands.executeCommand("zowe.ds.disableValidation", node);

Check warning on line 270 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L270

Added line #L270 was not covered by tests
}
if (isZoweUSSTreeNode(node)) {
return vscode.commands.executeCommand("zowe.uss.disableValidation", node);

Check warning on line 273 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L273

Added line #L273 was not covered by tests
}
return vscode.commands.executeCommand("zowe.jobs.disableValidation", node);

Check warning on line 275 in packages/zowe-explorer/src/utils/ProfileManagement.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/utils/ProfileManagement.ts#L275

Added line #L275 was not covered by tests
}
}

0 comments on commit 71cd777

Please sign in to comment.