Skip to content

Commit

Permalink
updates to logging and add tree node type check
Browse files Browse the repository at this point in the history
Signed-off-by: Billie Simmons <[email protected]>
  • Loading branch information
JillieBeanSim committed Sep 19, 2023
1 parent 7836b5a commit 0ab92b8
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 42 deletions.
2 changes: 1 addition & 1 deletion packages/zowe-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@
"group": "099_zowe_jobsProfileModification@99"
},
{
"when": "viewItem =~ /^(textFile|spool.*|member.*|ds.*)/ && !listMultiSelection && !zowe.compareFileStarted",
"when": "viewItem =~ /^(textFile|spool.*|member.*|ds.*)/ && !listMultiSelection",
"command": "zowe.selectForCompare",
"group": "010_zowe_fileOperations@1"
},
Expand Down
28 changes: 6 additions & 22 deletions packages/zowe-explorer/src/abstract/ZoweTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ export class ZoweTreeProvider {
* @returns {vscode.TreeItem}
*/
public getTreeItem(element: IZoweTreeNode): vscode.TreeItem | Thenable<vscode.TreeItem> {
ZoweLogger.trace("ZoweTreeProvider.getTreeItem called.");
return element;
}

public getParent(element: IZoweTreeNode): IZoweTreeNode {
ZoweLogger.trace("ZoweTreeProvider.getParent called.");
return element.getParent();
}

Expand All @@ -65,7 +63,6 @@ export class ZoweTreeProvider {
* @param {IZoweTreeNode}
*/
public setItem(treeView: vscode.TreeView<IZoweTreeNode>, item: IZoweTreeNode): void {
ZoweLogger.trace("ZoweTreeProvider.setItem called.");
treeView.reveal(item, { select: true, focus: true });
}

Expand All @@ -74,7 +71,7 @@ export class ZoweTreeProvider {
* @param node Node to refresh
*/
public async refreshHomeProfileContext(node): Promise<void> {
ZoweLogger.trace("ZoweTreeProvider.refreshHomeProfileContext called.");
ZoweLogger.trace(`ZoweTreeProvider.refreshHomeProfileContext called with ${String(node.label)}.`);
const mProfileInfo = await Profiles.getInstance().getProfileInfo();
if (!contextually.isHomeProfile(node)) {
const prof = mProfileInfo.getAllProfiles().find((p) => p.profName === node.getProfileName());
Expand All @@ -90,7 +87,6 @@ export class ZoweTreeProvider {
*
*/
public refreshElement(element: IZoweDatasetTreeNode): void {
ZoweLogger.trace("ZoweTreeProvider.refreshElement called.");
element.dirty = true;
this.mOnDidChangeTreeData.fire(element);
}
Expand All @@ -100,7 +96,6 @@ export class ZoweTreeProvider {
*
*/
public refresh(): void {
ZoweLogger.trace("ZoweTreeProvider.refresh called.");
this.mOnDidChangeTreeData.fire();
}

Expand All @@ -111,7 +106,6 @@ export class ZoweTreeProvider {
* @param isOpen the intended state of the the tree view provider, true or false
*/
public flipState(element: IZoweTreeNode, isOpen: boolean = false): void {
ZoweLogger.trace("ZoweTreeProvider.flipState called.");
element.collapsibleState = isOpen ? vscode.TreeItemCollapsibleState.Expanded : vscode.TreeItemCollapsibleState.Collapsed;
const icon = getIconByNode(element);
if (icon) {
Expand All @@ -124,7 +118,6 @@ export class ZoweTreeProvider {
}

public async onDidChangeConfiguration(e: vscode.ConfigurationChangeEvent): Promise<void> {
ZoweLogger.trace("ZoweTreeProvider.onDidChangeConfiguration called.");
if (e.affectsConfiguration(this.persistenceSchema)) {
const setting: any = {
...SettingsConfig.getDirectValue(this.persistenceSchema),
Expand All @@ -138,42 +131,35 @@ export class ZoweTreeProvider {
}

public getSearchHistory(): string[] {
ZoweLogger.trace("ZoweTreeProvider.getSearchHistory called.");
return this.mHistory.getSearchHistory();
}

public getTreeType(): PersistenceSchemaEnum {
ZoweLogger.trace("ZoweTreeProvider.getTreeType called.");
return this.persistenceSchema;
}

public addSearchHistory(criteria: string): void {
ZoweLogger.trace("ZoweTreeProvider.addSearchHistory called.");
if (criteria) {
this.mHistory.addSearchHistory(criteria);
}
}

public findNonFavoritedNode(_element: IZoweTreeNode): any {
ZoweLogger.trace("ZoweTreeProvider.findNonFavoritedNode called.");
return undefined;
}

public findFavoritedNode(_element: IZoweTreeNode): any {
ZoweLogger.trace("ZoweTreeProvider.findFavoritedNode called.");
return undefined;
}
public renameFavorite(_node: IZoweTreeNode, _newLabel: string): any {
ZoweLogger.trace("ZoweTreeProvider.renameFavorite called.");
return undefined;
}
public renameNode(_profile: string, _beforeDataSetName: string, _afterDataSetName: string): any {
ZoweLogger.trace("ZoweTreeProvider.renameNode called.");
return undefined;
}

public async editSession(node: IZoweTreeNode, zoweFileProvider: IZoweTree<IZoweNodeType>): Promise<void> {
ZoweLogger.trace("ZoweTreeProvider.editSession called.");
ZoweLogger.trace(`ZoweTreeProvider.editSession called for ${String(node.label)}.`);
const profile = node.getProfile();
const profileName = node.getProfileName();
const EditSession = await Profiles.getInstance().editSession(profile, profileName);
Expand All @@ -195,7 +181,7 @@ export class ZoweTreeProvider {
}

public async checkCurrentProfile(node: IZoweTreeNode): Promise<void> {
ZoweLogger.trace("ZoweTreeProvider.checkCurrentProfile called.");
ZoweLogger.trace(`ZoweTreeProvider.checkCurrentProfile called for ${String(node.label)}.`);
const profile = node.getProfile();
const profileStatus = await Profiles.getInstance().checkCurrentProfile(profile);
if (profileStatus.status === "inactive") {
Expand Down Expand Up @@ -244,7 +230,7 @@ export class ZoweTreeProvider {
}

public async ssoLogin(node: IZoweTreeNode): Promise<void> {
ZoweLogger.trace("ZoweTreeProvider.ssoLogin called.");
ZoweLogger.trace(`ZoweTreeProvider.ssoLogin called for ${String(node.label)}.`);
await Profiles.getInstance().ssoLogin(node);
if (contextually.isDsSession(node)) {
await vscode.commands.executeCommand("zowe.ds.refreshAll");
Expand All @@ -256,7 +242,7 @@ export class ZoweTreeProvider {
}

public async ssoLogout(node: IZoweTreeNode): Promise<void> {
ZoweLogger.trace("ZoweTreeProvider.ssoLogout called.");
ZoweLogger.trace(`ZoweTreeProvider.ssoLogout called for ${String(node.label)}.`);
await Profiles.getInstance().ssoLogout(node);
if (contextually.isDsSession(node)) {
await vscode.commands.executeCommand("zowe.ds.refreshAll");
Expand All @@ -268,17 +254,15 @@ export class ZoweTreeProvider {
}

public async createZoweSchema(zoweFileProvider: IZoweTree<IZoweNodeType>): Promise<void> {
ZoweLogger.trace("ZoweTreeProvider.createZoweSchema called.");
await Profiles.getInstance().createZoweSchema(zoweFileProvider);
}

public async createZoweSession(zoweFileProvider: IZoweTree<IZoweNodeType>): Promise<void> {
ZoweLogger.trace("ZoweTreeProvider.createZoweSession called.");
await Profiles.getInstance().createZoweSession(zoweFileProvider);
}

protected deleteSessionByLabel(revisedLabel: string): void {
ZoweLogger.trace("ZoweTreeProvider.deleteSessionByLabel called.");
ZoweLogger.trace(`ZoweTreeProvider.deleteSessionByLabel called for ${revisedLabel}.`);
this.mHistory.removeSession(revisedLabel);
this.refresh();
}
Expand Down
15 changes: 8 additions & 7 deletions packages/zowe-explorer/src/shared/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,26 +204,27 @@ export function registerCommonCommands(context: vscode.ExtensionContext, provide
);
context.subscriptions.push(
vscode.commands.registerCommand("zowe.selectForCompare", (node: IZoweTreeNode) => {
globals.setCompareSelectionTrue();
globals.clearFilesToCompareArray();
filesToCompare.push(node);
vscode.window.showInformationMessage("Select for Compare chosen.");
vscode.commands.executeCommand("selectForCompare");
globals.setCompareSelectionTrue();
ZoweLogger.trace(`${String(filesToCompare[0].label)} selected for compare.`);
})
);
context.subscriptions.push(
vscode.commands.registerCommand("zowe.compareWithSelected", async (node: IZoweTreeNode) => {
vscode.window.showInformationMessage(`Compare with Selected chosen.`);
vscode.commands.registerCommand("zowe.compareWithSelected", (node: IZoweTreeNode) => {
filesToCompare.push(node);
ZoweLogger.trace(`${String(filesToCompare[0].label)} will be compared with selected.`);
ZoweLogger.info(`Comparing files ${String(filesToCompare[0].label)} and ${String(filesToCompare[1].label)}.`);
compareChosenFileContent();
await vscode.commands.executeCommand("compareSelected");
// flip settings and configurations after compare is complete
ZoweLogger.trace(`Compare complete, clearing files to compare.`);
globals.clearFilesToCompareArray();
globals.setCompareSelectionFalse();
console.log(filesToCompare);
})
);
context.subscriptions.push(
vscode.commands.registerCommand("zowe.compareFileStarted", () => {
ZoweLogger.trace(`Checking if any files have been chosen for compare: ${String(globals.FILE_SELECTED_TO_COMPARE)}`);
return globals.FILE_SELECTED_TO_COMPARE;
})
);
Expand Down
35 changes: 23 additions & 12 deletions packages/zowe-explorer/src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,16 +397,27 @@ export async function compareSavedFileContent(
*/
export function compareChosenFileContent(): void {
// function for compare of 2 files, ds/members, unix, jes spool files
console.log(globals.filesToCompare[0]);
console.log(globals.filesToCompare[1]);
const profile1 = globals.filesToCompare[0].getProfile().name;
console.log(profile1);
const profile2 = globals.filesToCompare[1].getProfile().name;
console.log(profile2);
const profilesMatch = profile1 === profile2;
if (profilesMatch) {
vscode.window.showInformationMessage(`Compare to be done with profile ${profile2}`);
} else {
vscode.window.showInformationMessage(`Profiles ${profile1} and ${profile2} don't match, cannot compare selected.`);
}
// Should be able to compare with any profile on any selection
// each selection will download content and return URI
// should be able to compare using VSC commands and the URIs
globals.filesToCompare.forEach((node) => {
// find tree node type to determine file download method
switch (true) {
case isZoweDatasetTreeNode(node): {
// do something with ds tree node
console.log(`${String(node.label)} is a ds tree node.`);

Check failure on line 408 in packages/zowe-explorer/src/shared/utils.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
break;
}
case isZoweUSSTreeNode(node): {
// do something with uss tree node
console.log(`${String(node.label)} is a uss tree node.`);

Check failure on line 413 in packages/zowe-explorer/src/shared/utils.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
break;
}
default: {
// do something with job spool tree node
console.log(`${String(node.label)} is a job spool tree node.`);

Check failure on line 418 in packages/zowe-explorer/src/shared/utils.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
break;
}
}
});
}

0 comments on commit 0ab92b8

Please sign in to comment.