Skip to content

Commit

Permalink
Merge branch 'master' into Fix-for-Issue#375
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin-Stone authored Dec 11, 2019
2 parents f18650e + 369e057 commit 6f9a8a8
Show file tree
Hide file tree
Showing 15 changed files with 225 additions and 289 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
// Make sure people do not accidentally forget to sign
"git.alwaysSignOff": true
"git.alwaysSignOff": true,
"typescript.tsdk": "node_modules/typescript/lib"
}
4 changes: 2 additions & 2 deletions __tests__/__integration__/extension.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe("Extension Integration Tests", () => {
const stubresolve = sandbox.stub(utils, "resolveQuickPickHelper");
stubresolve.returns(new utils.FilterItem(profileNamesList[0]));

await extension.addSession(testTree);
await extension.addZoweSession(testTree);
expect(testTree.mSessionNodes[testTree.mSessionNodes.length - 1].label).to.equal(profileNamesList[0]);
}).timeout(TIMEOUT);
});
Expand Down Expand Up @@ -944,7 +944,7 @@ describe("Extension Integration Tests - USS", () => {
const stubresolve = sandbox.stub(utils, "resolveQuickPickHelper");
stubresolve.returns(new utils.FilterItem(profileNamesList[0]));

await extension.addUSSSession(ussTestTree);
await extension.addZoweSession(ussTestTree);
expect(ussTestTree.mSessionNodes[ussTestTree.mSessionNodes.length - 1].label).to.equal(profileNamesList[0]);
}).timeout(TIMEOUT);
});
Expand Down
142 changes: 70 additions & 72 deletions __tests__/__unit__/extension.unit.test.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions __tests__/__unit__/uss/ussNodeActions.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Utilities = jest.fn();
const uss = jest.fn();
const ussFile = jest.fn();
const renameUSSFile = jest.fn();
const mockAddUSSSession = jest.fn();
const mockaddZoweSession = jest.fn();
const mockUSSRefresh = jest.fn();
const mockUSSRefreshElement = jest.fn();
const mockGetUSSChildren = jest.fn();
Expand Down Expand Up @@ -72,7 +72,7 @@ function getUSSTree() {
return {
mSessionNodes: [],
mFavorites: [ussNodeFav],
addSession: mockAddUSSSession,
addSession: mockaddZoweSession,
refresh: mockUSSRefresh,
refreshAll: mockUSSRefresh,
refreshElement: mockUSSRefreshElement,
Expand Down
4 changes: 2 additions & 2 deletions i18n/sample/src/extension.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"addSession.log.debug.createNewProfile": "User created a new profile",
"addSession.log.debug.selectedProfile": "User selected profile ",
"addSession.log.debug.cancelledSelection": "Operation Cancelled",
"addUSSSession.log.debug.selectProfile": "User selected profile ",
"addUSSSession.log.debug.cancelledSelection": "User cancelled profile selection",
"addZoweSession.log.debug.selectProfile": "User selected profile ",
"addZoweSession.log.debug.cancelledSelection": "User cancelled profile selection",
"createFile.quickPickOption.dataSetType": "Type of Data Set to be Created",
"createFile.dataSetBinary": "Data Set Binary",
"createFile.dataSetC": "Data Set C",
Expand Down
3 changes: 2 additions & 1 deletion src/DatasetTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as extension from "../src/extension";
import { PersistentFilters } from "./PersistentFilters";
import { Profiles } from "./Profiles";
import { sortTreeItems, applyIcons, FilterDescriptor, FilterItem, resolveQuickPickHelper } from "./utils";
import { IZoweTree } from "./ZoweTree";
import { ZoweNode } from "./ZoweNode";
const localize = nls.config({ messageFormat: nls.MessageFormat.file })();

Expand All @@ -40,7 +41,7 @@ export async function createDatasetTree(log: Logger) {
* @class DatasetTree
* @implements {vscode.TreeDataProvider}
*/
export class DatasetTree implements vscode.TreeDataProvider<ZoweNode> {
export class DatasetTree implements IZoweTree<ZoweNode> {

private static readonly persistenceSchema: string = "Zowe-DS-Persistent";
private static readonly defaultDialogText: string = "\uFF0B " + localize("ussFilterPrompt.option.prompt.search", "Create a new filter");
Expand Down
8 changes: 4 additions & 4 deletions src/Profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class Profiles { // Processing stops if there are no profiles detected
return validationResult;
}

public async createNewConnection(profileName) {
public async createNewConnection(profileName: string): Promise<string | undefined> {
let userName: string;
let passWord: string;
let zosmfURL: string;
Expand All @@ -157,7 +157,7 @@ export class Profiles { // Processing stops if there are no profiles detected
if (!zosmfURL) {
vscode.window.showInformationMessage(localize("createNewConnection.zosmfURL",
"No valid value for z/OSMF URL. Operation Cancelled"));
return;
return undefined;
}

const zosmfUrlParsed = this.validateAndParseUrl(zosmfURL);
Expand Down Expand Up @@ -209,14 +209,14 @@ export class Profiles { // Processing stops if there are no profiles detected
} else {
vscode.window.showInformationMessage(localize("createNewConnection.rejectUnauthorize",
"Operation Cancelled"));
return;
return undefined;
}

for (const profile of this.allProfiles) {
if (profile.name === profileName) {
vscode.window.showErrorMessage(localize("createNewConnection.duplicateProfileName",
"Profile name already exists. Please create a profile using a different name"));
return;
return undefined;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/USSTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as zowe from "@brightside/core";
import { IProfileLoaded, Logger } from "@brightside/imperative";
import { applyIcons, FilterItem, FilterDescriptor, resolveQuickPickHelper, sortTreeItems } from "./utils";
import * as vscode from "vscode";
import { IZoweTree } from "./ZoweTree";
import { ZoweUSSNode } from "./ZoweUSSNode";
import { Profiles } from "./Profiles";
import { PersistentFilters } from "./PersistentFilters";
Expand All @@ -40,7 +41,7 @@ export async function createUSSTree(log: Logger) {
* @class USSTree
* @implements {vscode.TreeDataProvider}
*/
export class USSTree implements vscode.TreeDataProvider<ZoweUSSNode> {
export class USSTree implements IZoweTree<ZoweUSSNode> {
public static readonly defaultDialogText: string = "\uFF0B " + localize("ussFilterPrompt.option.prompt.search", "Create a new filter");
private static readonly persistenceSchema: string = "Zowe-USS-Persistent";

Expand Down
3 changes: 2 additions & 1 deletion src/ZosJobsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { IProfileLoaded, Logger } from "@brightside/imperative";
import { Profiles } from "./Profiles";
import { PersistentFilters } from "./PersistentFilters";
import { Job } from "./ZoweJobNode";
import { IZoweTree } from "./ZoweTree";
import { OwnerFilterDescriptor, JobIdFilterDescriptor, applyIcons, FilterItem, FilterDescriptor, resolveQuickPickHelper, sortTreeItems } from "./utils";
import * as extension from "../src/extension";
import * as nls from "vscode-nls";
Expand All @@ -36,7 +37,7 @@ export async function createJobsTree(log: Logger) {
}

// tslint:disable-next-line: max-classes-per-file
export class ZosJobsProvider implements vscode.TreeDataProvider<Job> {
export class ZosJobsProvider implements IZoweTree<Job> {
public static readonly JobId = "JobId:";
public static readonly Owner = "Owner:";
public static readonly Prefix = "Prefix:";
Expand Down
14 changes: 12 additions & 2 deletions src/ZoweJobNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import { Session, IProfileLoaded, Logger } from "@brightside/imperative";
// tslint:disable-next-line: no-duplicate-imports
import { IJob, IJobFile } from "@brightside/core";
import * as extension from "./extension";
import { ZosJobsProvider } from "./ZosJobsProvider";
import { IZoweTreeNode } from "./ZoweTree";
import * as utils from "./utils";

// tslint:disable-next-line: max-classes-per-file
export class Job extends vscode.TreeItem {
export class Job extends vscode.TreeItem implements IZoweTreeNode {
public static readonly JobId = "JobId:";
public static readonly Owner = "Owner:";
public static readonly Prefix = "Prefix:";
Expand All @@ -44,6 +44,16 @@ export class Job extends vscode.TreeItem {
utils.applyIcons(this);
}

/**
* Implements access to profile name
* for {IZoweTreeNode}.
*
* @returns {string}
*/
public getProfileName(): string {
return this.label.trim();
}

public getSessionName(): string {
return this.getSessionNode().label.trim();
}
Expand Down
13 changes: 12 additions & 1 deletion src/ZoweNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Session } from "@brightside/imperative";
import * as nls from "vscode-nls";
import * as utils from "./utils";
import * as extension from "../src/extension";
import { IZoweTreeNode } from "./ZoweTree";
const localize = nls.config({ messageFormat: nls.MessageFormat.file })();

/**
Expand All @@ -24,7 +25,7 @@ const localize = nls.config({ messageFormat: nls.MessageFormat.file })();
* @class ZoweNode
* @extends {vscode.TreeItem}
*/
export class ZoweNode extends vscode.TreeItem {
export class ZoweNode extends vscode.TreeItem implements IZoweTreeNode {
public command: vscode.Command;
public pattern = "";
public dirty = extension.ISTHEIA; // Make sure this is true for theia instances
Expand Down Expand Up @@ -59,6 +60,16 @@ export class ZoweNode extends vscode.TreeItem {
utils.applyIcons(this);
}

/**
* Implements access to profile name
* for {IZoweTreeNode}.
*
* @returns {string}
*/
public getProfileName(): string {
return this.label.trim();
}

/**
* Retrieves child nodes of this ZoweNode
*
Expand Down
42 changes: 42 additions & 0 deletions src/ZoweTree.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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. *
* *
*/

// TODO: Evolve these interfaces for additional refactoring of the commonalities of
// the three tree views. Consider adding also abstract base classes as well.

import * as vscode from "vscode";

/**
* The base interface for Zowe tree brosers that implement the
* vscode.TreeDataProvider.
*
* @export
* @interface IZoweTree
* @extends {vscode.TreeDataProvider<T>}
* @template T provide a subtype of vscode.TreeItem
*/
export interface IZoweTree<T> extends vscode.TreeDataProvider<T> {
mSessionNodes: T[];
mFavoriteSession: T;
mFavorites: T[];

addSession(sessionName?: string): Promise<void>;
refresh(): void;
}
/**
* The base interface for Zowe tree nodes.
*
* @export
* @interface IZoweTreeNode
*/
export interface IZoweTreeNode {
getProfileName(): string;
}
13 changes: 12 additions & 1 deletion src/ZoweUSSNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import * as zowe from "@brightside/core";
import { Session } from "@brightside/imperative";
import * as vscode from "vscode";
import * as nls from "vscode-nls";
import { IZoweTreeNode } from "./ZoweTree";
const localize = nls.config({ messageFormat: nls.MessageFormat.file })();
import * as extension from "../src/extension";
import * as utils from "./utils";
Expand All @@ -24,7 +25,7 @@ import * as utils from "./utils";
* @class ZoweUSSNode
* @extends {vscode.TreeItem}
*/
export class ZoweUSSNode extends vscode.TreeItem {
export class ZoweUSSNode extends vscode.TreeItem implements IZoweTreeNode {
public command: vscode.Command;
public fullPath = "";
public dirty = extension.ISTHEIA; // Make sure this is true for theia instances
Expand Down Expand Up @@ -79,6 +80,16 @@ export class ZoweUSSNode extends vscode.TreeItem {
utils.applyIcons(this);
}

/**
* Implements access to profile name
* for {IZoweTreeNode}.
*
* @returns {string}
*/
public getProfileName(): string {
return this.mProfileName;
}

/**
* Retrieves child nodes of this ZoweUSSNode
*
Expand Down
Loading

0 comments on commit 6f9a8a8

Please sign in to comment.