From 1f899962485f8975768c2669e2e96284fa33f13d Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Thu, 24 Nov 2022 16:34:45 +0100 Subject: [PATCH 01/39] huddle copy on datasets Signed-off-by: KutluOzel-b --- .../extension.integration.test.ts | 16 +++++++------- .../__unit__/dataset/actions.unit.test.ts | 16 +++++++------- .../__tests__/__unit__/extension.unit.test.ts | 1 - packages/zowe-explorer/package.json | 22 ++++++------------- packages/zowe-explorer/package.nls.json | 1 - packages/zowe-explorer/src/dataset/actions.ts | 6 +++-- packages/zowe-explorer/src/extension.ts | 14 ++++++++---- packages/zowe-explorer/src/globals.ts | 2 +- 8 files changed, 38 insertions(+), 40 deletions(-) diff --git a/packages/zowe-explorer/__tests__/__integration__/extension.integration.test.ts b/packages/zowe-explorer/__tests__/__integration__/extension.integration.test.ts index 01765f946a..37ed8560e5 100644 --- a/packages/zowe-explorer/__tests__/__integration__/extension.integration.test.ts +++ b/packages/zowe-explorer/__tests__/__integration__/extension.integration.test.ts @@ -537,8 +537,8 @@ describe("Extension Integration Tests", async () => { sessionNode, session ); - - await dsActions.copyDataSet(fromNode); + const nodeList: ZoweDatasetNode[] = [fromNode]; + await dsActions.copyDataSet(nodeList); await dsActions.pasteMember(toNode, testTree); contents = await zowe.Get.dataSet(sessionNode.getSession(), fromDataSetName); @@ -594,8 +594,8 @@ describe("Extension Integration Tests", async () => { const inputBoxStub = sandbox.stub(vscode.window, "showInputBox"); inputBoxStub.returns(toMemberName); - - await dsActions.copyDataSet(fromNode); + const nodeList: ZoweDatasetNode[] = [fromNode]; + await dsActions.copyDataSet(nodeList); await dsActions.pasteMember(parentNode, testTree); contents = await zowe.Get.dataSet(sessionNode.getSession(), `${dataSetName}(${toMemberName})`); @@ -666,8 +666,8 @@ describe("Extension Integration Tests", async () => { const inputBoxStub = sandbox.stub(vscode.window, "showInputBox"); inputBoxStub.returns(toMemberName); - - await dsActions.copyDataSet(fromNode); + const nodeList: ZoweDatasetNode[] = [fromNode]; + await dsActions.copyDataSet(nodeList); await dsActions.pasteMember(toNode, testTree); contents = await zowe.Get.dataSet( @@ -745,8 +745,8 @@ describe("Extension Integration Tests", async () => { fromParentNode.contextValue = globals.DS_PDS_CONTEXT; fromMemberNode.contextValue = globals.DS_MEMBER_CONTEXT; toNode.contextValue = globals.DS_DS_CONTEXT; - - await dsActions.copyDataSet(fromMemberNode); + const nodeList: ZoweDatasetNode[] = [fromMemberNode]; + await dsActions.copyDataSet(nodeList); await dsActions.pasteMember(toNode, testTree); contents = await zowe.Get.dataSet(sessionNode.getSession(), toDataSetName); diff --git a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts index 29ea0afc2f..65cd33db7a 100644 --- a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts @@ -1879,8 +1879,8 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { null ); node.contextValue = globals.DS_DS_CONTEXT; - - await dsActions.copyDataSet(node); + const nodeList: ZoweDatasetNode[] = [node]; + await dsActions.copyDataSet(nodeList); expect(clipboard.readText()).toBe('{"profileName":"sestest","dataSetName":"HLQ.TEST.DELETE.NODE"}'); }); @@ -1895,8 +1895,8 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { null ); node.contextValue = globals.DS_DS_CONTEXT + globals.FAV_SUFFIX; - - await dsActions.copyDataSet(node); + const nodeList: ZoweDatasetNode[] = [node]; + await dsActions.copyDataSet(nodeList); expect(clipboard.readText()).toBe('{"profileName":"sestest","dataSetName":"HLQ.TEST.DELETE.NODE"}'); }); @@ -1913,8 +1913,8 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { parent.contextValue = globals.DS_PDS_CONTEXT; const child = new ZoweDatasetNode("child", vscode.TreeItemCollapsibleState.None, parent, null); child.contextValue = globals.DS_MEMBER_CONTEXT; - - await dsActions.copyDataSet(child); + const nodeList: ZoweDatasetNode[] = [child]; + await dsActions.copyDataSet(nodeList); expect(clipboard.readText()).toBe('{"profileName":"sestest","dataSetName":"parent","memberName":"child"}'); }); @@ -1931,8 +1931,8 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { parent.contextValue = globals.DS_PDS_CONTEXT + globals.FAV_SUFFIX; const child = new ZoweDatasetNode("child", vscode.TreeItemCollapsibleState.None, parent, null); child.contextValue = globals.DS_MEMBER_CONTEXT; - - await dsActions.copyDataSet(child); + const nodeList: ZoweDatasetNode[] = [child]; + await dsActions.copyDataSet(nodeList); expect(clipboard.readText()).toBe('{"profileName":"sestest","dataSetName":"parent","memberName":"child"}'); }); diff --git a/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts index dced02f5fb..37c3eab8f3 100644 --- a/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts @@ -156,7 +156,6 @@ async function createGlobalMocks() { "zowe.ds.submitMember", "zowe.ds.showDSAttributes", "zowe.ds.renameDataSet", - "zowe.ds.copyMember", "zowe.ds.copyDataSet", "zowe.ds.pasteMember", "zowe.ds.renameDataSetMember", diff --git a/packages/zowe-explorer/package.json b/packages/zowe-explorer/package.json index 5d4f5edd01..b999e9fe9d 100644 --- a/packages/zowe-explorer/package.json +++ b/packages/zowe-explorer/package.json @@ -89,6 +89,12 @@ "command": "zowe.extRefresh", "key": "ctrl+alt+z", "mac": "cmd+alt+z" + }, + { + "command": "zowe.ds.copyDataSet", + "key": "ctrl+c", + "mac": "cmd+c", + "when": "focusedView == zowe.ds.explorer" } ], "commands": [ @@ -261,11 +267,6 @@ "title": "%renameDataSet%", "category": "Zowe Explorer" }, - { - "command": "zowe.ds.copyMember", - "title": "%copyMember%", - "category": "Zowe Explorer" - }, { "command": "zowe.ds.copyDataSet", "title": "%copyDataSet%", @@ -960,12 +961,7 @@ "group": "001_zowe_dsCreate@5" }, { - "when": "view == zowe.ds.explorer && viewItem =~ /^member.*/ && !listMultiSelection", - "command": "zowe.ds.copyMember", - "group": "001_zowe_dsCreate@6" - }, - { - "when": "view == zowe.ds.explorer && viewItem =~ /^ds.*/ && !listMultiSelection", + "when": "view == zowe.ds.explorer", "command": "zowe.ds.copyDataSet", "group": "001_zowe_dsCreate@6" }, @@ -1262,10 +1258,6 @@ "command": "zowe.ds.uploadDialog", "when": "never" }, - { - "command": "zowe.ds.copyMember", - "when": "never" - }, { "command": "zowe.ds.pasteMember", "when": "never" diff --git a/packages/zowe-explorer/package.nls.json b/packages/zowe-explorer/package.nls.json index e997a7e856..72e1a5807f 100644 --- a/packages/zowe-explorer/package.nls.json +++ b/packages/zowe-explorer/package.nls.json @@ -83,7 +83,6 @@ "cmd.deleteProfile": "Delete a Profile Permanently...", "renameDataSet": "Rename Data Set", "renameMember": "Rename Member", - "copyMember": "Copy Member", "copyDataSet": "Copy Data Set", "paste": "Paste Member", "hMigrateDataSet": "Migrate Data Set", diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index f767358441..4b2b61d31a 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1198,8 +1198,10 @@ export async function enterPattern(node: api.IZoweDatasetTreeNode, datasetProvid * @export * @param {IZoweNodeType} node - The node to copy */ -export async function copyDataSet(node: api.IZoweNodeType) { - return vscode.env.clipboard.writeText(JSON.stringify(dsUtils.getNodeLabels(node))); +export async function copyDataSet(nodesList: api.IZoweNodeType[]) { + let uniq = (contextValue) => [...new Set(contextValue)]; + + return vscode.env.clipboard.writeText(JSON.stringify(dsUtils.getNodeLabels(nodesList[0]))); } /** diff --git a/packages/zowe-explorer/src/extension.ts b/packages/zowe-explorer/src/extension.ts index e18641b3a9..bde66c17ea 100644 --- a/packages/zowe-explorer/src/extension.ts +++ b/packages/zowe-explorer/src/extension.ts @@ -486,10 +486,16 @@ function initDatasetProvider(context: vscode.ExtensionContext) { vscode.commands.registerCommand("zowe.ds.renameDataSet", (node) => datasetProvider.rename(node)) ); context.subscriptions.push( - vscode.commands.registerCommand("zowe.ds.copyMember", (node) => dsActions.copyDataSet(node)) - ); - context.subscriptions.push( - vscode.commands.registerCommand("zowe.ds.copyDataSet", (node) => dsActions.copyDataSet(node)) + vscode.commands.registerCommand("zowe.ds.copyDataSet", async (node, nodeList) => { + let selectedNodes; + if (!(node && nodeList)) { + selectedNodes = datasetProvider.getTreeView().selection; + } else { + selectedNodes = getSelectedNodeList(node, nodeList); + } + selectedNodes = selectedNodes.filter((element) => contextuals.isDsMember(element)); + dsActions.copyDataSet(selectedNodes); + }) ); context.subscriptions.push( vscode.commands.registerCommand("zowe.ds.pasteMember", (node) => dsActions.pasteMember(node, datasetProvider)) diff --git a/packages/zowe-explorer/src/globals.ts b/packages/zowe-explorer/src/globals.ts index 2b51bcde71..a9de9f5b18 100644 --- a/packages/zowe-explorer/src/globals.ts +++ b/packages/zowe-explorer/src/globals.ts @@ -32,7 +32,7 @@ export let DS_DIR; export let CONFIG_PATH; // set during activate export let ISTHEIA: boolean = false; // set during activate export let LOG: imperative.Logger; -export const COMMAND_COUNT = 100; +export const COMMAND_COUNT = 99; export const MAX_SEARCH_HISTORY = 5; export const MAX_FILE_HISTORY = 10; export const STATUS_BAR_TIMEOUT_MS = 5000; From aa0a1f7bee6edc51a89fb3ebf2dfd905878d76d9 Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Tue, 29 Nov 2022 08:47:03 +0100 Subject: [PATCH 02/39] copy members & add multiselect for pds and ds and members Signed-off-by: KutluOzel-b --- packages/zowe-explorer/package.json | 4 +- packages/zowe-explorer/src/dataset/actions.ts | 76 ++++++++++++++++++- packages/zowe-explorer/src/extension.ts | 5 +- 3 files changed, 78 insertions(+), 7 deletions(-) diff --git a/packages/zowe-explorer/package.json b/packages/zowe-explorer/package.json index b999e9fe9d..254e5321e7 100644 --- a/packages/zowe-explorer/package.json +++ b/packages/zowe-explorer/package.json @@ -961,12 +961,12 @@ "group": "001_zowe_dsCreate@5" }, { - "when": "view == zowe.ds.explorer", + "when": "view == zowe.ds.explorer && viewItem != /^(?!.*_fav.*)session.*/)", "command": "zowe.ds.copyDataSet", "group": "001_zowe_dsCreate@6" }, { - "when": "view == zowe.ds.explorer && viewItem =~ /^pds.*/", + "when": "view == zowe.ds.explorer", "command": "zowe.ds.pasteMember", "group": "001_zowe_dsCreate@7" }, diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index 4b2b61d31a..c1416049cd 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1199,9 +1199,21 @@ export async function enterPattern(node: api.IZoweDatasetTreeNode, datasetProvid * @param {IZoweNodeType} node - The node to copy */ export async function copyDataSet(nodesList: api.IZoweNodeType[]) { - let uniq = (contextValue) => [...new Set(contextValue)]; - - return vscode.env.clipboard.writeText(JSON.stringify(dsUtils.getNodeLabels(nodesList[0]))); + const unique = [...new Set(nodesList.map((item) => item.contextValue))]; + if (unique.length > 1) { + vscode.window.showErrorMessage( + `${"Can't copy multiple dataset with different types"}: ${" Please select same types to copy"}` + ); + return; + } + if (nodesList.length === 1 && nodesList[0].contextValue == globals.DS_MEMBER_CONTEXT) { + return vscode.env.clipboard.writeText(JSON.stringify(dsUtils.getNodeLabels(nodesList[0]))); + } + let filePaths = []; + nodesList.forEach((el) => { + filePaths.push(dsUtils.getNodeLabels(el)); + }); + return vscode.env.clipboard.writeText(JSON.stringify(filePaths)); } /** @@ -1491,3 +1503,61 @@ export async function saveFile(doc: vscode.TextDocument, datasetProvider: api.IZ vscode.window.showErrorMessage(err.message); } } + +/** + * Paste member + * + * @export + * @param {ZoweNode} node - The node to paste to + * @param {DatasetTree} datasetProvider - the tree which contains the nodes + */ +export async function pasteDataSet( + node: api.IZoweDatasetTreeNode, + datasetProvider: api.IZoweTree +) { + let clipboardContent; + + if (Profiles.getInstance().validProfile !== api.ValidProfileEnum.INVALID) { + try { + clipboardContent = JSON.parse(await vscode.env.clipboard.readText()); + } catch (err) { + throw Error("Invalid clipboard. Copy from data set first"); + } + + if (clipboardContent.length === 1 && clipboardContent[0].memberName) { + return pasteMember(node, datasetProvider); + } + + for (const content of clipboardContent) { + if (content.memberName) { + //member + try { + await ZoweExplorerApiRegister.getMvsApi(node.getProfile()).copyDataSetMember( + { dsn: content.dataSetName, member: content.memberName }, + { dsn: node.getLabel().toString(), member: content.memberName } + ); + } catch (err) { + vscode.window.showErrorMessage(err.message); + return; + } + } else { + // pds + const inputBoxOptions: vscode.InputBoxOptions = { + value: content.datasetName, + placeHolder: localize("pasteMember.inputBox.placeHolder", "Name of Data Set Member"), + validateInput: (text) => { + return dsUtils.validateDataSetName(text) && (content.datasetName !== text) === true + ? null + : "Enter valid member name"; + }, + }; + const sequential = await vscode.window.showInputBox(inputBoxOptions); + if (!sequential) { + return; + } + const newOptions = { "from-dataset": { dsn: content.dataSetName } }; + return await zowe.Copy.dataSet(this.getSession(), { dsn: sequential }, newOptions); + } + } + } +} diff --git a/packages/zowe-explorer/src/extension.ts b/packages/zowe-explorer/src/extension.ts index bde66c17ea..4a035c4244 100644 --- a/packages/zowe-explorer/src/extension.ts +++ b/packages/zowe-explorer/src/extension.ts @@ -493,12 +493,13 @@ function initDatasetProvider(context: vscode.ExtensionContext) { } else { selectedNodes = getSelectedNodeList(node, nodeList); } - selectedNodes = selectedNodes.filter((element) => contextuals.isDsMember(element)); dsActions.copyDataSet(selectedNodes); }) ); context.subscriptions.push( - vscode.commands.registerCommand("zowe.ds.pasteMember", (node) => dsActions.pasteMember(node, datasetProvider)) + vscode.commands.registerCommand("zowe.ds.pasteMember", async (node) => { + dsActions.pasteDataSet(node, datasetProvider); + }) ); context.subscriptions.push( vscode.commands.registerCommand("zowe.ds.renameDataSetMember", (node) => datasetProvider.rename(node)) From 3efa11bbdae16f018079c6eed3d5eafdfdf7a1ff Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Tue, 6 Dec 2022 10:16:00 +0100 Subject: [PATCH 03/39] draft commit after api change Signed-off-by: KutluOzel-b --- .../__unit__/dataset/actions.unit.test.ts | 16 +- .../i18n/sample/package.i18n.json | 1 - .../i18n/sample/src/dataset/actions.i18n.json | 4 +- packages/zowe-explorer/package.json | 8 +- packages/zowe-explorer/package.nls.json | 2 +- packages/zowe-explorer/src/dataset/actions.ts | 211 ++++++++++++++---- packages/zowe-explorer/src/dataset/utils.ts | 8 +- packages/zowe-explorer/src/extension.ts | 4 +- 8 files changed, 193 insertions(+), 61 deletions(-) diff --git a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts index 65cd33db7a..e71bb6af4c 100644 --- a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts @@ -1882,7 +1882,9 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { const nodeList: ZoweDatasetNode[] = [node]; await dsActions.copyDataSet(nodeList); - expect(clipboard.readText()).toBe('{"profileName":"sestest","dataSetName":"HLQ.TEST.DELETE.NODE"}'); + expect(clipboard.readText()).toBe( + '[{"profileName":"sestest","dataSetName":"HLQ.TEST.DELETE.NODE","contextValue":"ds"}]' + ); }); it("Checking copy the label of a favorite node to the clipboard", async () => { globals.defineGlobals(""); @@ -1898,7 +1900,9 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { const nodeList: ZoweDatasetNode[] = [node]; await dsActions.copyDataSet(nodeList); - expect(clipboard.readText()).toBe('{"profileName":"sestest","dataSetName":"HLQ.TEST.DELETE.NODE"}'); + expect(clipboard.readText()).toBe( + '[{"profileName":"sestest","dataSetName":"HLQ.TEST.DELETE.NODE","contextValue":"ds_fav"}]' + ); }); it("Checking copy the label of a member to the clipboard", async () => { globals.defineGlobals(""); @@ -1916,7 +1920,9 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { const nodeList: ZoweDatasetNode[] = [child]; await dsActions.copyDataSet(nodeList); - expect(clipboard.readText()).toBe('{"profileName":"sestest","dataSetName":"parent","memberName":"child"}'); + expect(clipboard.readText()).toBe( + '{"profileName":"sestest","dataSetName":"parent","memberName":"child","contextValue":"member"}' + ); }); it("Checking copy the label of a favorite member to the clipboard", async () => { globals.defineGlobals(""); @@ -1934,7 +1940,9 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { const nodeList: ZoweDatasetNode[] = [child]; await dsActions.copyDataSet(nodeList); - expect(clipboard.readText()).toBe('{"profileName":"sestest","dataSetName":"parent","memberName":"child"}'); + expect(clipboard.readText()).toBe( + '{"profileName":"sestest","dataSetName":"parent","memberName":"child","contextValue":"member"}' + ); }); }); diff --git a/packages/zowe-explorer/i18n/sample/package.i18n.json b/packages/zowe-explorer/i18n/sample/package.i18n.json index e997a7e856..72e1a5807f 100644 --- a/packages/zowe-explorer/i18n/sample/package.i18n.json +++ b/packages/zowe-explorer/i18n/sample/package.i18n.json @@ -83,7 +83,6 @@ "cmd.deleteProfile": "Delete a Profile Permanently...", "renameDataSet": "Rename Data Set", "renameMember": "Rename Member", - "copyMember": "Copy Member", "copyDataSet": "Copy Data Set", "paste": "Paste Member", "hMigrateDataSet": "Migrate Data Set", diff --git a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json index ca5426e65d..20ee16c425 100644 --- a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json +++ b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json @@ -82,5 +82,7 @@ "saveFile.error.saveFailed": "Data set failed to save. Data set may have been deleted on mainframe.", "saveFile.response.save.title": "Saving data set...", "saveFile.error.ZosmfEtagMismatchError": "Rest API failure with HTTP(S) status 412", - "saveFile.error.etagMismatch": "Remote file has been modified in the meantime.\nSelect 'Compare' to resolve the conflict." + "saveFile.error.etagMismatch": "Remote file has been modified in the meantime.\nSelect 'Compare' to resolve the conflict.", + "paste.dataSet.InPrg": "Uploading File(s)", + "download.invalidNode": "downloadDataset() called with invalid node." } diff --git a/packages/zowe-explorer/package.json b/packages/zowe-explorer/package.json index 66f73565c9..ec6a2a6ccc 100644 --- a/packages/zowe-explorer/package.json +++ b/packages/zowe-explorer/package.json @@ -95,6 +95,12 @@ "key": "ctrl+c", "mac": "cmd+c", "when": "focusedView == zowe.ds.explorer" + }, + { + "command": "zowe.ds.pasteMember", + "key": "ctrl+v", + "mac": "cmd+v", + "when": "focusedView == zowe.ds.explorer" } ], "commands": [ @@ -961,7 +967,7 @@ "group": "001_zowe_dsCreate@5" }, { - "when": "view == zowe.ds.explorer && viewItem != /^(?!.*_fav.*)session.*/)", + "when": "view == zowe.ds.explorer && viewItem =~ /^ds.*/", "command": "zowe.ds.copyDataSet", "group": "001_zowe_dsCreate@6" }, diff --git a/packages/zowe-explorer/package.nls.json b/packages/zowe-explorer/package.nls.json index 72e1a5807f..f3c6ea95ad 100644 --- a/packages/zowe-explorer/package.nls.json +++ b/packages/zowe-explorer/package.nls.json @@ -84,7 +84,7 @@ "renameDataSet": "Rename Data Set", "renameMember": "Rename Member", "copyDataSet": "Copy Data Set", - "paste": "Paste Member", + "paste": "Paste", "hMigrateDataSet": "Migrate Data Set", "hRecallDataSet": "Recall Data Set", "profile.configuration.title": "Zowe z/OSMF Profiles", diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index c1416049cd..025140369a 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1196,24 +1196,37 @@ export async function enterPattern(node: api.IZoweDatasetTreeNode, datasetProvid * Copy data set info * * @export - * @param {IZoweNodeType} node - The node to copy + * @param {ZoweDatasetNode[]} nodesList - Nodes to copy */ -export async function copyDataSet(nodesList: api.IZoweNodeType[]) { +export async function copyDataSet(nodesList: ZoweDatasetNode[]) { const unique = [...new Set(nodesList.map((item) => item.contextValue))]; if (unique.length > 1) { vscode.window.showErrorMessage( - `${"Can't copy multiple dataset with different types"}: ${" Please select same types to copy"}` + `${"Can't copy multiple dataset with different types"}: ${"Select same types to copy"}` ); return; } - if (nodesList.length === 1 && nodesList[0].contextValue == globals.DS_MEMBER_CONTEXT) { + if (nodesList.find((node) => node.contextValue == globals.DS_PDS_CONTEXT)) { + vscode.window.showErrorMessage( + `${"Can't copy partitioned datasets"}: ${"Select member(s) of a pds or sequential dataset(s) to copy"}` + ); + } + if (nodesList.length === 1 && nodesList[0].contextValue === globals.DS_MEMBER_CONTEXT) { return vscode.env.clipboard.writeText(JSON.stringify(dsUtils.getNodeLabels(nodesList[0]))); } - let filePaths = []; - nodesList.forEach((el) => { - filePaths.push(dsUtils.getNodeLabels(el)); - }); - return vscode.env.clipboard.writeText(JSON.stringify(filePaths)); + if (unique.includes(globals.DS_MEMBER_CONTEXT)) { + const filePaths = []; + nodesList.forEach((el) => { + filePaths.push(dsUtils.getNodeLabels(el)); + }); + return vscode.env.clipboard.writeText(JSON.stringify(filePaths)); + } + if (unique.includes(globals.DS_DS_CONTEXT)) { + return copySequentialDatasets(nodesList); + } + if (unique.includes(globals.DS_PDS_CONTEXT)) { + return copyPartitionedDatasets(nodesList); + } } /** @@ -1508,56 +1521,156 @@ export async function saveFile(doc: vscode.TextDocument, datasetProvider: api.IZ * Paste member * * @export - * @param {ZoweNode} node - The node to paste to * @param {DatasetTree} datasetProvider - the tree which contains the nodes */ -export async function pasteDataSet( - node: api.IZoweDatasetTreeNode, - datasetProvider: api.IZoweTree -) { +export async function pasteDataSet(datasetProvider: api.IZoweTree) { let clipboardContent; + try { + clipboardContent = JSON.parse(await vscode.env.clipboard.readText()); + } catch (err) { + throw Error("Invalid clipboard. Copy from data set first"); + } + const node = datasetProvider.getTreeView().selection[0]; + if ( + node.contextValue === globals.DS_MEMBER_CONTEXT || + (node.contextValue === globals.DS_DS_CONTEXT && + clipboardContent.find((x) => x.contextValue !== globals.DS_DS_CONTEXT)) || + node.contextValue === globals.DS_PDS_CONTEXT + ) { + return; + } if (Profiles.getInstance().validProfile !== api.ValidProfileEnum.INVALID) { - try { - clipboardContent = JSON.parse(await vscode.env.clipboard.readText()); - } catch (err) { - throw Error("Invalid clipboard. Copy from data set first"); - } - - if (clipboardContent.length === 1 && clipboardContent[0].memberName) { + if (!Array.isArray(clipboardContent) && clipboardContent.memberName) { + vscode.env.clipboard.writeText(""); // TODO change it to dispose function return pasteMember(node, datasetProvider); } - for (const content of clipboardContent) { - if (content.memberName) { - //member - try { - await ZoweExplorerApiRegister.getMvsApi(node.getProfile()).copyDataSetMember( - { dsn: content.dataSetName, member: content.memberName }, - { dsn: node.getLabel().toString(), member: content.memberName } - ); - } catch (err) { - vscode.window.showErrorMessage(err.message); - return; - } - } else { - // pds - const inputBoxOptions: vscode.InputBoxOptions = { - value: content.datasetName, - placeHolder: localize("pasteMember.inputBox.placeHolder", "Name of Data Set Member"), - validateInput: (text) => { - return dsUtils.validateDataSetName(text) && (content.datasetName !== text) === true - ? null - : "Enter valid member name"; - }, - }; - const sequential = await vscode.window.showInputBox(inputBoxOptions); - if (!sequential) { - return; + await vscode.window.withProgress( + { + location: vscode.ProgressLocation.Window, + title: localize("paste.dataSet.InPrg", "Uploading File(s)"), + }, + async () => { + for (const content of clipboardContent) { + if (content.memberName) { + // member + try { + await ZoweExplorerApiRegister.getMvsApi(node.getProfile()).copyDataSetMember( + { dsn: content.dataSetName, member: content.memberName }, + { dsn: node.getLabel().toString(), member: content.memberName } + ); + } catch (err) { + vscode.window.showErrorMessage(err.message); + return; + } + } else { + // ds + const inputBoxOptions: vscode.InputBoxOptions = { + value: content.datasetName, + placeHolder: localize("pasteMember.inputBox.placeHolder", "Name of Data Set Member"), + validateInput: (text) => { + return dsUtils.validateDataSetName(text) && (content.datasetName !== text) === true + ? null + : "Enter valid member name"; + }, + }; + const sequential = await vscode.window.showInputBox(inputBoxOptions); + if (!sequential) { + return; + } + try { + const fPath = getDocumentFilePath(node.getLabel().toString(), node); + const newOptions = { "from-dataset": { dsn: content.datasetName, member: null } }; + return await zowe.Copy.dataSet( + node.getSession(), + { dsn: content.dataSetName, member: null }, + newOptions + ); + } catch (e) { + await errorHandling(e, node.getProfileName(), e.message); + } + } } - const newOptions = { "from-dataset": { dsn: content.dataSetName } }; - return await zowe.Copy.dataSet(this.getSession(), { dsn: sequential }, newOptions); + datasetProvider.refreshElement(node); + vscode.env.clipboard.writeText(""); // TODO change it to dispose function } + ); + } +} + +/** + * download given dataset node + * + * @export + * @param {ZoweDatasetNode} node - node to be downloaded + */ +export function downloadDataset(node: ZoweDatasetNode) { + const profile = node.getProfile(); + let lbl: string; + switch (true) { + case contextually.isFavorite(node): + case contextually.isSessionNotFav(node.getParent()): + lbl = node.label as string; + break; + case contextually.isFavoritePds(node.getParent()): + case contextually.isPdsNotFav(node.getParent()): + lbl = node.getParent().getLabel().toString() + "(" + node.getLabel().toString() + ")"; + break; + default: + vscode.window.showErrorMessage( + localize("download.invalidNode", "downloadDataset() called with invalid node.") + ); + throw Error(localize("download.invalidNode", "downloadDataset() called with invalid node. ")); + } + const filePath = getDocumentFilePath(lbl, node); + return ZoweExplorerApiRegister.getMvsApi(profile).getContents(lbl, { + file: filePath, + returnEtag: true, + encoding: profile.profile.encoding, + }); +} + +/** + * copies given sequential dataset nodes + * + * @export + * @param {ZoweDatasetNode[]} nodes - nodes to be copied + */ +export async function copySequentialDatasets(nodes: ZoweDatasetNode[]) { + for (const node of nodes) { + await ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).allocateLikeDataSet( + node.getLabel().toString(), + dsUtils.getNodeLabels(node).dataSetName + ); + + try { + // await ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).allocateLikeDataSet( + // newDSName.toUpperCase(), + // dsUtils.getNodeLabels(node).dataSetName + // ); + } catch (err) { + globals.LOG.error( + localize("createDataSet.log.error", "Error encountered when creating data set! ") + JSON.stringify(err) + ); + await errorHandling( + err, + dsUtils.getNodeLabels(node).dataSetName, + localize("createDataSet.error", "Unable to create data set: ") + err.message + ); + throw err; } } } + +/** + * copies given partitioned dataset nodes + * + * @export + * @param {ZoweDatasetNode[]} nodes - nodes to be copied + */ +export function copyPartitionedDatasets(nodes: ZoweDatasetNode[]) { + for (const node of nodes) { + downloadDataset(node); + } +} diff --git a/packages/zowe-explorer/src/dataset/utils.ts b/packages/zowe-explorer/src/dataset/utils.ts index 820f14f82b..92d7bdf8dc 100644 --- a/packages/zowe-explorer/src/dataset/utils.ts +++ b/packages/zowe-explorer/src/dataset/utils.ts @@ -24,9 +24,13 @@ export function getProfileAndDataSetName(node: IZoweNodeType) { export function getNodeLabels(node: IZoweNodeType) { if (node.contextValue.includes(globals.DS_MEMBER_CONTEXT)) { - return { ...getProfileAndDataSetName(node.getParent()), memberName: node.getLabel() }; + return { + ...getProfileAndDataSetName(node.getParent()), + memberName: node.getLabel(), + contextValue: node.contextValue, + }; } else { - return { ...getProfileAndDataSetName(node), memberName: undefined }; + return { ...getProfileAndDataSetName(node), memberName: undefined, contextValue: node.contextValue }; } } export function validateDataSetName(dsName: string): boolean { diff --git a/packages/zowe-explorer/src/extension.ts b/packages/zowe-explorer/src/extension.ts index 4a035c4244..a956d29ca9 100644 --- a/packages/zowe-explorer/src/extension.ts +++ b/packages/zowe-explorer/src/extension.ts @@ -497,8 +497,8 @@ function initDatasetProvider(context: vscode.ExtensionContext) { }) ); context.subscriptions.push( - vscode.commands.registerCommand("zowe.ds.pasteMember", async (node) => { - dsActions.pasteDataSet(node, datasetProvider); + vscode.commands.registerCommand("zowe.ds.pasteMember", async () => { + dsActions.pasteDataSet(datasetProvider); }) ); context.subscriptions.push( From 1329e8e5bb9df749d6f0c0e9b058e0842789c0cf Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Fri, 9 Dec 2022 16:00:43 +0100 Subject: [PATCH 04/39] draft Signed-off-by: KutluOzel-b --- packages/zowe-explorer/package.json | 4 ++-- packages/zowe-explorer/src/dataset/actions.ts | 11 +++-------- packages/zowe-explorer/src/extension.ts | 4 ++-- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/packages/zowe-explorer/package.json b/packages/zowe-explorer/package.json index ec6a2a6ccc..a1852ac151 100644 --- a/packages/zowe-explorer/package.json +++ b/packages/zowe-explorer/package.json @@ -967,12 +967,12 @@ "group": "001_zowe_dsCreate@5" }, { - "when": "view == zowe.ds.explorer && viewItem =~ /^ds.*/", + "when": "view == zowe.ds.explorer && viewItem =~ /^(ds|member).*/", "command": "zowe.ds.copyDataSet", "group": "001_zowe_dsCreate@6" }, { - "when": "view == zowe.ds.explorer", + "when": "view == zowe.ds.explorer && viewItem =~ /^(session|pds).*/", "command": "zowe.ds.pasteMember", "group": "001_zowe_dsCreate@7" }, diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index 025140369a..2fd935ba99 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1523,20 +1523,15 @@ export async function saveFile(doc: vscode.TextDocument, datasetProvider: api.IZ * @export * @param {DatasetTree} datasetProvider - the tree which contains the nodes */ -export async function pasteDataSet(datasetProvider: api.IZoweTree) { +export async function pasteDataSet(datasetProvider: api.IZoweTree, node:ZoweDatasetNode) { let clipboardContent; try { clipboardContent = JSON.parse(await vscode.env.clipboard.readText()); } catch (err) { throw Error("Invalid clipboard. Copy from data set first"); } - const node = datasetProvider.getTreeView().selection[0]; - if ( - node.contextValue === globals.DS_MEMBER_CONTEXT || - (node.contextValue === globals.DS_DS_CONTEXT && - clipboardContent.find((x) => x.contextValue !== globals.DS_DS_CONTEXT)) || - node.contextValue === globals.DS_PDS_CONTEXT - ) { + const node2 = datasetProvider.getTreeView().selection[0]; + if (node.contextValue === globals.DS_MEMBER_CONTEXT || node.contextValue === globals.DS_DS_CONTEXT) { return; } diff --git a/packages/zowe-explorer/src/extension.ts b/packages/zowe-explorer/src/extension.ts index a956d29ca9..ddbe1456e2 100644 --- a/packages/zowe-explorer/src/extension.ts +++ b/packages/zowe-explorer/src/extension.ts @@ -497,8 +497,8 @@ function initDatasetProvider(context: vscode.ExtensionContext) { }) ); context.subscriptions.push( - vscode.commands.registerCommand("zowe.ds.pasteMember", async () => { - dsActions.pasteDataSet(datasetProvider); + vscode.commands.registerCommand("zowe.ds.pasteMember", async (node: ZoweDatasetNode) => { + dsActions.pasteDataSet(datasetProvider,node); }) ); context.subscriptions.push( From 89efdfc1eb73563e07fd2dd80f42d073be5c242b Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Tue, 13 Dec 2022 16:57:45 +0100 Subject: [PATCH 05/39] copy sequential ds Signed-off-by: KutluOzel-b --- packages/zowe-explorer/src/dataset/actions.ts | 84 +++++++++++-------- packages/zowe-explorer/src/extension.ts | 2 +- 2 files changed, 48 insertions(+), 38 deletions(-) diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index 131e444b8e..176d277d8c 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1549,14 +1549,16 @@ export async function saveFile(doc: vscode.TextDocument, datasetProvider: api.IZ * @export * @param {DatasetTree} datasetProvider - the tree which contains the nodes */ -export async function pasteDataSet(datasetProvider: api.IZoweTree, node:ZoweDatasetNode) { +export async function pasteDataSet(datasetProvider: api.IZoweTree, node: ZoweDatasetNode) { let clipboardContent; try { clipboardContent = JSON.parse(await vscode.env.clipboard.readText()); } catch (err) { throw Error("Invalid clipboard. Copy from data set first"); } - const node2 = datasetProvider.getTreeView().selection[0]; + if (!node) { + node = datasetProvider.getTreeView().selection[0] as ZoweDatasetNode; + } if (node.contextValue === globals.DS_MEMBER_CONTEXT || node.contextValue === globals.DS_DS_CONTEXT) { return; } @@ -1585,32 +1587,6 @@ export async function pasteDataSet(datasetProvider: api.IZoweTree { - return dsUtils.validateDataSetName(text) && (content.datasetName !== text) === true - ? null - : "Enter valid member name"; - }, - }; - const sequential = await vscode.window.showInputBox(inputBoxOptions); - if (!sequential) { - return; - } - try { - const fPath = getDocumentFilePath(node.getLabel().toString(), node); - const newOptions = { "from-dataset": { dsn: content.datasetName, member: null } }; - return await zowe.Copy.dataSet( - node.getSession(), - { dsn: content.dataSetName, member: null }, - newOptions - ); - } catch (e) { - await errorHandling(e, node.getProfileName(), e.message); - } } } datasetProvider.refreshElement(node); @@ -1660,16 +1636,50 @@ export function downloadDataset(node: ZoweDatasetNode) { */ export async function copySequentialDatasets(nodes: ZoweDatasetNode[]) { for (const node of nodes) { - await ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).allocateLikeDataSet( - node.getLabel().toString(), - dsUtils.getNodeLabels(node).dataSetName - ); - try { - // await ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).allocateLikeDataSet( - // newDSName.toUpperCase(), - // dsUtils.getNodeLabels(node).dataSetName - // ); + // await refreshPS(node); + const lbl = node.getLabel().toString(); + const inputBoxOptions: vscode.InputBoxOptions = { + value: lbl, + placeHolder: localize("pasteMember.inputBox.placeHolder", "Name of Data Set"), + validateInput: (text) => { + return dsUtils.validateDataSetName(text) && (lbl !== text) === true + ? null + : "Enter valid dataset name"; + }, + }; + + const sequential = await vscode.window.showInputBox(inputBoxOptions); + if (!sequential) { + return; + } + const res = await ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).allocateLikeDataSet( + sequential, + lbl + ); + if (res.success) { + const uploadOptions: IUploadOptions = { + etag: node?.getEtag(), + returnEtag: true, + }; + await vscode.window.withProgress( + { + location: vscode.ProgressLocation.Window, + title: localize("saveFile.response.save.title", "Saving data set..."), + }, + () => { + const prof = node?.getProfile(); + if (prof.profile.encoding) { + uploadOptions.encoding = prof.profile.encoding; + } + return ZoweExplorerApiRegister.getMvsApi(prof).putContents( + getDocumentFilePath(node.getLabel().toString(), node), + sequential, + uploadOptions + ); + } + ); + } } catch (err) { globals.LOG.error( localize("createDataSet.log.error", "Error encountered when creating data set! ") + JSON.stringify(err) diff --git a/packages/zowe-explorer/src/extension.ts b/packages/zowe-explorer/src/extension.ts index 922fb86bd0..2853dc344d 100644 --- a/packages/zowe-explorer/src/extension.ts +++ b/packages/zowe-explorer/src/extension.ts @@ -509,7 +509,7 @@ function initDatasetProvider(context: vscode.ExtensionContext) { ); context.subscriptions.push( vscode.commands.registerCommand("zowe.ds.pasteMember", async (node: ZoweDatasetNode) => { - dsActions.pasteDataSet(datasetProvider,node); + dsActions.pasteDataSet(datasetProvider, node); }) ); context.subscriptions.push( From 372cee3b5ab3665e87dcae914cd0edaba276d4e7 Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Tue, 20 Dec 2022 16:13:04 +0100 Subject: [PATCH 06/39] add copy pds & unit tests Signed-off-by: KutluOzel-b --- .../extension.integration.test.ts | 8 +- .../__unit__/dataset/actions.unit.test.ts | 417 +++++++++++++++++- .../i18n/sample/package.i18n.json | 2 +- .../i18n/sample/src/dataset/actions.i18n.json | 7 +- packages/zowe-explorer/package.json | 2 +- packages/zowe-explorer/src/dataset/actions.ts | 138 ++++-- packages/zowe-explorer/src/extension.ts | 11 +- 7 files changed, 521 insertions(+), 64 deletions(-) diff --git a/packages/zowe-explorer/__tests__/__integration__/extension.integration.test.ts b/packages/zowe-explorer/__tests__/__integration__/extension.integration.test.ts index 37ed8560e5..6fc7ede5a0 100644 --- a/packages/zowe-explorer/__tests__/__integration__/extension.integration.test.ts +++ b/packages/zowe-explorer/__tests__/__integration__/extension.integration.test.ts @@ -538,7 +538,7 @@ describe("Extension Integration Tests", async () => { session ); const nodeList: ZoweDatasetNode[] = [fromNode]; - await dsActions.copyDataSet(nodeList); + await dsActions.copyDataSet(nodeList, null, null); await dsActions.pasteMember(toNode, testTree); contents = await zowe.Get.dataSet(sessionNode.getSession(), fromDataSetName); @@ -595,7 +595,7 @@ describe("Extension Integration Tests", async () => { const inputBoxStub = sandbox.stub(vscode.window, "showInputBox"); inputBoxStub.returns(toMemberName); const nodeList: ZoweDatasetNode[] = [fromNode]; - await dsActions.copyDataSet(nodeList); + await dsActions.copyDataSet(nodeList, null, null); await dsActions.pasteMember(parentNode, testTree); contents = await zowe.Get.dataSet(sessionNode.getSession(), `${dataSetName}(${toMemberName})`); @@ -667,7 +667,7 @@ describe("Extension Integration Tests", async () => { const inputBoxStub = sandbox.stub(vscode.window, "showInputBox"); inputBoxStub.returns(toMemberName); const nodeList: ZoweDatasetNode[] = [fromNode]; - await dsActions.copyDataSet(nodeList); + await dsActions.copyDataSet(nodeList, null, null); await dsActions.pasteMember(toNode, testTree); contents = await zowe.Get.dataSet( @@ -746,7 +746,7 @@ describe("Extension Integration Tests", async () => { fromMemberNode.contextValue = globals.DS_MEMBER_CONTEXT; toNode.contextValue = globals.DS_DS_CONTEXT; const nodeList: ZoweDatasetNode[] = [fromMemberNode]; - await dsActions.copyDataSet(nodeList); + await dsActions.copyDataSet(nodeList, null, null); await dsActions.pasteMember(toNode, testTree); contents = await zowe.Get.dataSet(sessionNode.getSession(), toDataSetName); diff --git a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts index 0a10843b52..3dcce6a42c 100644 --- a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts @@ -38,7 +38,7 @@ import * as fs from "fs"; import * as sharedUtils from "../../../src/shared/utils"; import { Profiles } from "../../../src/Profiles"; import * as utils from "../../../src/utils/ProfilesUtils"; -import { UIViews } from "../../../src/shared/ui-views"; +import { getNodeLabels } from "../../../src/dataset/utils"; // Missing the definition of path module, because I need the original logic for tests jest.mock("fs"); @@ -1853,6 +1853,26 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { const datasetSessionNode = createDatasetSessionNode(session, imperativeProfile); const testDatasetTree = createDatasetTree(datasetSessionNode, treeView); const mvsApi = createMvsApi(imperativeProfile); + const pdsSessionNode = new ZoweDatasetNode( + "sestest", + vscode.TreeItemCollapsibleState.Expanded, + datasetSessionNode, + session, + undefined, + undefined, + profileInstance + ); + pdsSessionNode.contextValue = globals.DS_PDS_CONTEXT; + const pdsMemberNode = new ZoweDatasetNode( + "sestest", + vscode.TreeItemCollapsibleState.Expanded, + pdsSessionNode, + session, + undefined, + undefined, + profileInstance + ); + pdsMemberNode.contextValue = globals.DS_MEMBER_CONTEXT; bindMvsApi(mvsApi); return { @@ -1865,28 +1885,60 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { mvsApi, profileInstance, testDatasetTree, + pdsSessionNode, + pdsMemberNode, }; } afterAll(() => jest.restoreAllMocks()); - it("Checking copy the label of a node to the clipboard", async () => { + it("Checking copy the info of a member node to the clipboard", async () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); const node = new ZoweDatasetNode( "HLQ.TEST.DELETE.NODE", vscode.TreeItemCollapsibleState.None, - blockMocks.datasetSessionNode, + blockMocks.pdsSessionNode, null ); - node.contextValue = globals.DS_DS_CONTEXT; + node.contextValue = globals.DS_MEMBER_CONTEXT; const nodeList: ZoweDatasetNode[] = [node]; - await dsActions.copyDataSet(nodeList); + await dsActions.copyDataSet(null, nodeList, null); expect(clipboard.readText()).toBe( - '[{"profileName":"sestest","dataSetName":"HLQ.TEST.DELETE.NODE","contextValue":"ds"}]' + '{"profileName":"sestest","dataSetName":"sestest","memberName":"HLQ.TEST.DELETE.NODE","contextValue":"member"}' + ); + }); + it("Testing warning of multiple datasets with different types to be copied", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + const Membernode = new ZoweDatasetNode( + "HLQ.TEST.DELETE.NODE", + vscode.TreeItemCollapsibleState.None, + blockMocks.pdsSessionNode, + null + ); + const pdsNode = new ZoweDatasetNode( + "HLQ.TEST.DELETE.NODE", + vscode.TreeItemCollapsibleState.None, + blockMocks.pdsSessionNode, + null ); + pdsNode.contextValue = globals.DS_PDS_CONTEXT; + Membernode.contextValue = globals.DS_MEMBER_CONTEXT; + const nodeList: ZoweDatasetNode[] = [Membernode, pdsNode]; + await dsActions.copyDataSet(null, nodeList, null); + }); + it("Testing copy of PDS", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + const selectedNodeSpy = jest.spyOn(sharedUtils, "getSelectedNodeList"); + await dsActions.copyDataSet(blockMocks.pdsSessionNode, null, blockMocks.testDatasetTree); + expect(selectedNodeSpy).toBeCalledWith(blockMocks.pdsSessionNode, null); + expect(mocked(vscode.window.showErrorMessage)).not.toBeCalled(); }); it("Checking copy the label of a favorite node to the clipboard", async () => { globals.defineGlobals(""); @@ -1900,13 +1952,12 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { ); node.contextValue = globals.DS_DS_CONTEXT + globals.FAV_SUFFIX; const nodeList: ZoweDatasetNode[] = [node]; - await dsActions.copyDataSet(nodeList); - + await dsActions.copyDataSet(null, nodeList, blockMocks.testDatasetTree); expect(clipboard.readText()).toBe( - '[{"profileName":"sestest","dataSetName":"HLQ.TEST.DELETE.NODE","contextValue":"ds_fav"}]' + '{"profileName":"sestest","dataSetName":"sestest","memberName":"HLQ.TEST.DELETE.NODE","contextValue":"member"}' ); }); - it("Checking copy the label of a member to the clipboard", async () => { + it("Checking copy the label of a member to the clipboard via quickkeys", async () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); @@ -1919,12 +1970,199 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { parent.contextValue = globals.DS_PDS_CONTEXT; const child = new ZoweDatasetNode("child", vscode.TreeItemCollapsibleState.None, parent, null); child.contextValue = globals.DS_MEMBER_CONTEXT; - const nodeList: ZoweDatasetNode[] = [child]; - await dsActions.copyDataSet(nodeList); + await dsActions.copyDataSet(null, null, blockMocks.testDatasetTree); + expect(clipboard.readText()).toBe( + '{"profileName":"sestest","dataSetName":"sestest","memberName":"HLQ.TEST.DELETE.NODE","contextValue":"member"}' + ); + }); + it("Checking copy the info of multiple members to the clipboard", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + const parent = new ZoweDatasetNode( + "parent", + vscode.TreeItemCollapsibleState.None, + blockMocks.datasetSessionNode, + null + ); + parent.contextValue = globals.DS_MEMBER_CONTEXT; + const child = new ZoweDatasetNode("child", vscode.TreeItemCollapsibleState.None, parent, null); + child.contextValue = globals.DS_MEMBER_CONTEXT; + const nodeList: ZoweDatasetNode[] = [child, child]; + await dsActions.copyDataSet(null, nodeList, blockMocks.testDatasetTree); expect(clipboard.readText()).toBe( - '{"profileName":"sestest","dataSetName":"parent","memberName":"child","contextValue":"member"}' + '[{"profileName":"sestest","dataSetName":"parent","memberName":"child","contextValue":"member"},{"profileName":"sestest","dataSetName":"parent","memberName":"child","contextValue":"member"}]' + ); + }); + it("Checking copy of sequential datasets with empty new datasetname", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + const child = new ZoweDatasetNode( + "child", + vscode.TreeItemCollapsibleState.None, + blockMocks.datasetSessionNode, + null + ); + child.contextValue = globals.DS_DS_CONTEXT; + await expect(dsActions.copyDataSet(child, null, blockMocks.testDatasetTree)).toStrictEqual(Promise.resolve()); + }); + it("Checking copy of sequential datasets", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + const child = new ZoweDatasetNode( + "child", + vscode.TreeItemCollapsibleState.None, + blockMocks.datasetSessionNode, + null + ); + child.contextValue = globals.DS_DS_CONTEXT; + const profile = blockMocks.imperativeProfile; + const fakeEncoding = 9999; + profile.profile.encoding = fakeEncoding; + + mocked(vscode.window.showInputBox).mockImplementation((options) => { + options.validateInput("test"); + return Promise.resolve("test"); + }); + const allocSpy = jest.spyOn(blockMocks.mvsApi, "allocateLikeDataSet"); + allocSpy.mockResolvedValue({ + success: true, + commandResponse: "", + apiResponse: {}, + }); + mocked(vscode.window.withProgress).mockImplementation((params, fn) => { + fn(); + return Promise.resolve(params); + }); + await dsActions.copyDataSet(child, null, blockMocks.testDatasetTree); + expect(mocked(vscode.window.showErrorMessage)).not.toHaveBeenCalled(); + await expect(dsActions.copyDataSet(child, null, blockMocks.testDatasetTree)).toStrictEqual(Promise.resolve()); + }); + + it("Checking failed copy of sequential datasets", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + const child = new ZoweDatasetNode( + "child", + vscode.TreeItemCollapsibleState.None, + blockMocks.datasetSessionNode, + null + ); + child.contextValue = globals.DS_DS_CONTEXT; + const profile = blockMocks.imperativeProfile; + const fakeEncoding = 9999; + profile.profile.encoding = fakeEncoding; + + mocked(vscode.window.showInputBox).mockImplementation((options) => { + options.validateInput("test"); + return Promise.resolve("test"); + }); + const allocSpy = jest.spyOn(blockMocks.mvsApi, "allocateLikeDataSet"); + allocSpy.mockRejectedValueOnce({ + success: true, + commandResponse: "", + apiResponse: {}, + }); + mocked(vscode.window.withProgress).mockImplementation((params, fn) => { + fn(); + return Promise.resolve(params); + }); + try { + await dsActions.copyDataSet(child, null, blockMocks.testDatasetTree); + expect(mocked(vscode.window.showErrorMessage)).not.toHaveBeenCalled(); + await expect(dsActions.copyDataSet(child, null, blockMocks.testDatasetTree)).toStrictEqual( + Promise.resolve() + ); + } catch (error) { + // do nth + } + }); + it("Checking copy of partitioned datasets", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + const parent = new ZoweDatasetNode( + "parent", + vscode.TreeItemCollapsibleState.None, + blockMocks.datasetSessionNode, + null + ); + + const datasetNode = new ZoweDatasetNode( + "datasetNode", + vscode.TreeItemCollapsibleState.Expanded, + parent, + blockMocks.zosmfSession, + undefined, + undefined, + blockMocks.imperativeProfile + ); + + datasetNode.contextValue = globals.DS_PDS_CONTEXT; + const profile = blockMocks.imperativeProfile; + const fakeEncoding = 9999; + profile.profile.encoding = fakeEncoding; + mocked(vscode.window.showInputBox).mockImplementation((options) => { + options.validateInput("test"); + return Promise.resolve("test"); + }); + jest.spyOn(datasetNode, "getChildren").mockResolvedValue([parent, parent]); + + const copySpy = jest.spyOn(blockMocks.mvsApi, "copyDataSetMember"); + copySpy.mockResolvedValue({ + success: true, + commandResponse: "", + apiResponse: {}, + }); + mocked(vscode.window.withProgress).mockImplementation((params, fn) => { + fn(); + return Promise.resolve(params); + }); + await dsActions.copyDataSet(datasetNode, null, blockMocks.testDatasetTree); + await expect(mocked(vscode.window.showErrorMessage)).not.toHaveBeenCalled(); + await expect(dsActions.copyDataSet(datasetNode, null, blockMocks.testDatasetTree)).toStrictEqual( + Promise.resolve() + ); + }); + + it("Checking fail of copy partitioned datasets", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + const child = new ZoweDatasetNode( + "child", + vscode.TreeItemCollapsibleState.None, + blockMocks.datasetSessionNode, + null ); + + blockMocks.datasetSessionNode.contextValue = globals.DS_PDS_CONTEXT; + const profile = blockMocks.imperativeProfile; + const fakeEncoding = 9999; + profile.profile.encoding = fakeEncoding; + + await mocked(vscode.window.showInputBox).mockImplementation((options) => { + options.validateInput("test"); + return Promise.resolve("test"); + }); + jest.spyOn(blockMocks.datasetSessionNode, "getChildren").mockRejectedValue([child]); + await mocked(vscode.window.withProgress).mockImplementation((params, fn) => { + fn(); + return Promise.resolve(params); + }); + try { + await dsActions.copyDataSet(blockMocks.datasetSessionNode, null, blockMocks.testDatasetTree); + await expect(mocked(vscode.window.showErrorMessage)).not.toHaveBeenCalled(); + await expect( + dsActions.copyDataSet(blockMocks.datasetSessionNode, null, blockMocks.testDatasetTree) + ).toStrictEqual(Promise.resolve()); + } catch (error) { + // do nth + } }); it("Checking copy the label of a favorite member to the clipboard", async () => { globals.defineGlobals(""); @@ -1940,12 +2178,163 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { const child = new ZoweDatasetNode("child", vscode.TreeItemCollapsibleState.None, parent, null); child.contextValue = globals.DS_MEMBER_CONTEXT; const nodeList: ZoweDatasetNode[] = [child]; - await dsActions.copyDataSet(nodeList); + await dsActions.copyDataSet(null, nodeList, blockMocks.testDatasetTree); expect(clipboard.readText()).toBe( '{"profileName":"sestest","dataSetName":"parent","memberName":"child","contextValue":"member"}' ); }); + it("Testing pasteDataSetMembers() fails and gives error message with empty clipboard", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + vscode.env.clipboard.writeText(""); + const node = new ZoweDatasetNode( + "HLQ.TEST.TO.NODE", + vscode.TreeItemCollapsibleState.None, + blockMocks.datasetSessionNode, + null, + undefined, + undefined, + blockMocks.imperativeProfile + ); + const errSpy = jest.spyOn(vscode.window, "showErrorMessage"); + await expect(dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, node)).toEqual(Promise.resolve()); + expect(errSpy).toBeCalled(); + }); + it("Testing pasteDataSetMembers() fails and gives error message with empty clipboard", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + vscode.env.clipboard.writeText(""); + const node = new ZoweDatasetNode( + "HLQ.TEST.TO.NODE", + vscode.TreeItemCollapsibleState.None, + blockMocks.datasetSessionNode, + null, + undefined, + undefined, + blockMocks.imperativeProfile + ); + const errSpy = jest.spyOn(vscode.window, "showErrorMessage"); + await expect(dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, node)).toEqual(Promise.resolve()); + expect(errSpy).toBeCalled(); + }); + it("Testing pasteDataSetMembers() succesfully runs pasteMember()", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + vscode.env.clipboard.writeText(JSON.stringify(getNodeLabels(blockMocks.pdsMemberNode))); + const errSpy = jest.spyOn(dsActions, "pasteMember"); + errSpy.mockResolvedValueOnce(null); + await expect(dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, blockMocks.pdsMemberNode)).toEqual( + Promise.resolve() + ); + }); + + it("Testing pasteDataSetMembers() succesfully runs with multiple members", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + const node = new ZoweDatasetNode( + "HLQ.TEST.TO.NODE", + vscode.TreeItemCollapsibleState.None, + blockMocks.pdsSessionNode, + null, + undefined, + undefined, + blockMocks.imperativeProfile + ); + node.contextValue = globals.DS_MEMBER_CONTEXT; + const nodeList = [node, node, node]; + + const filePaths = []; + nodeList.forEach((el) => { + filePaths.push(getNodeLabels(el)); + }); + vscode.env.clipboard.writeText(JSON.stringify(filePaths)); + + mocked(vscode.window.withProgress).mockImplementation((params, fn) => { + fn(); + return Promise.resolve(params); + }); + const copySpy = jest.spyOn(blockMocks.mvsApi, "copyDataSetMember"); + copySpy.mockResolvedValue({ + success: true, + commandResponse: "", + apiResponse: {}, + }); + + await dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, node); + expect(mocked(vscode.window.showErrorMessage)).not.toHaveBeenCalled(); + }); + it("Testing pasteDataSetMembers() fails with multiple members", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + const node = new ZoweDatasetNode( + "HLQ.TEST.TO.NODE", + vscode.TreeItemCollapsibleState.None, + blockMocks.pdsSessionNode, + null, + undefined, + undefined, + blockMocks.imperativeProfile + ); + node.contextValue = globals.DS_MEMBER_CONTEXT; + const nodeList = [node, node, node]; + + const filePaths = []; + nodeList.forEach((el) => { + filePaths.push(getNodeLabels(el)); + }); + vscode.env.clipboard.writeText(JSON.stringify(filePaths)); + + mocked(vscode.window.withProgress).mockImplementation((params, fn) => { + fn(); + return Promise.resolve(params); + }); + const copySpy = jest.spyOn(blockMocks.mvsApi, "copyDataSetMember"); + copySpy.mockRejectedValueOnce(""); + await expect(dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, node)).toBeFalsy; + }); + + it("Testing downloadDs() called with invalid node", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + const node = new ZoweDatasetNode( + "HLQ.TEST.TO.NODE", + vscode.TreeItemCollapsibleState.None, + blockMocks.pdsSessionNode, + null, + undefined, + undefined, + blockMocks.imperativeProfile + ); + blockMocks.pdsSessionNode.contextValue = "fakeContext"; + try { + await dsActions.downloadDs(node); + } catch (err) { + // do nth + } + }); + + it("Testing downloadDs() called with a member", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + const node = new ZoweDatasetNode( + "HLQ.TEST.TO.NODE", + vscode.TreeItemCollapsibleState.None, + blockMocks.pdsSessionNode, + null, + undefined, + undefined, + blockMocks.imperativeProfile + ); + await expect(dsActions.downloadDs(node)).not.toBeUndefined(); + }); }); describe("Dataset Actions Unit Tests - Function pasteMember", () => { diff --git a/packages/zowe-explorer/i18n/sample/package.i18n.json b/packages/zowe-explorer/i18n/sample/package.i18n.json index 321485f943..4c3f67744a 100644 --- a/packages/zowe-explorer/i18n/sample/package.i18n.json +++ b/packages/zowe-explorer/i18n/sample/package.i18n.json @@ -84,7 +84,7 @@ "renameDataSet": "Rename Data Set", "renameMember": "Rename Member", "copyDataSet": "Copy Data Set", - "paste": "Paste Member", + "paste": "Paste", "hMigrateDataSet": "Migrate Data Set", "hRecallDataSet": "Recall Data Set", "profile.configuration.title": "Zowe z/OSMF Profiles", diff --git a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json index 22046a0359..bc02e8db95 100644 --- a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json +++ b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json @@ -72,7 +72,7 @@ "hMigrateDataSet.checkProfile": "Profile is invalid", "hRecall.requestSent1": "Recall of dataset: ", "hRecall.requestSent2": " requested.", - "pasteMember.inputBox.placeHolder": "Name of Data Set Member", + "pasteMember.inputBox.placeHolder": "Name of Data Set", "saveFile.log.debug.request": "requested to save data set: ", "saveFile.log.debug.path": "path.relative returned a non-blank directory.", "saveFile.log.debug.directory": "Assuming we are not in the DS_DIR directory: ", @@ -83,6 +83,9 @@ "saveFile.response.save.title": "Saving data set...", "saveFile.error.ZosmfEtagMismatchError": "Rest API failure with HTTP(S) status 412", "saveFile.error.etagMismatch": "Remote file has been modified in the meantime.\nSelect 'Compare' to resolve the conflict.", + "paste.dataSet": "Invalid paste. Copy dataset(s) first", "paste.dataSet.InPrg": "Uploading File(s)", - "download.invalidNode": "downloadDataset() called with invalid node." + "download.invalidNode": "downloadDataset() called with invalid node. ", + "copyDataSet.log.error": "Error encountered when copy data set! ", + "copyDataSet.error": "Unable to copy data set: " } diff --git a/packages/zowe-explorer/package.json b/packages/zowe-explorer/package.json index aae35b57bb..ec91dae5d3 100644 --- a/packages/zowe-explorer/package.json +++ b/packages/zowe-explorer/package.json @@ -1004,7 +1004,7 @@ "group": "001_zowe_dsCreate@5" }, { - "when": "view == zowe.ds.explorer && viewItem =~ /^(ds|member).*/", + "when": "view == zowe.ds.explorer && viewItem =~ /^(ds|member|pds).*/", "command": "zowe.ds.copyDataSet", "group": "001_zowe_dsCreate@6" }, diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index 176d277d8c..ff5862116b 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -17,7 +17,13 @@ import * as globals from "../globals"; import * as path from "path"; import * as api from "@zowe/zowe-explorer-api"; import { FilterItem, errorHandling, resolveQuickPickHelper } from "../utils/ProfilesUtils"; -import { getDocumentFilePath, concatChildNodes, checkForAddedSuffix, willForceUpload } from "../shared/utils"; +import { + getDocumentFilePath, + concatChildNodes, + checkForAddedSuffix, + willForceUpload, + getSelectedNodeList, +} from "../shared/utils"; import { ZoweExplorerApiRegister } from "../ZoweExplorerApiRegister"; import { Profiles } from "../Profiles"; import { getIconByNode } from "../generators/icons"; @@ -25,7 +31,6 @@ import { ZoweDatasetNode } from "./ZoweDatasetNode"; import { DatasetTree } from "./DatasetTree"; import * as contextually from "../shared/context"; import { setFileSaved } from "../utils/workspace"; -import { UIViews } from "../shared/ui-views"; import { IUploadOptions } from "@zowe/zos-files-for-zowe-sdk"; // Set up localization @@ -1215,39 +1220,51 @@ export async function enterPattern(node: api.IZoweDatasetTreeNode, datasetProvid } /** - * Copy data set info + * Copy data sets * * @export - * @param {ZoweDatasetNode[]} nodesList - Nodes to copy + * @param {ZoweDatasetNode} node Node to copy, + * @param {ZoweDatasetNode[]} nodeList - Multiple selected Nodes to copy + * @param datasetProvider */ -export async function copyDataSet(nodesList: ZoweDatasetNode[]) { - const unique = [...new Set(nodesList.map((item) => item.contextValue))]; +export async function copyDataSet( + node, + nodeList: ZoweDatasetNode[], + datasetProvider: api.IZoweTree +) { + let selectedNodes; + if (!(node || nodeList)) { + selectedNodes = datasetProvider.getTreeView().selection; + } else { + selectedNodes = getSelectedNodeList(node, nodeList); + } + + const unique = [...new Set(selectedNodes.map((item) => item.contextValue))]; if (unique.length > 1) { vscode.window.showErrorMessage( `${"Can't copy multiple dataset with different types"}: ${"Select same types to copy"}` ); return; } - if (nodesList.find((node) => node.contextValue == globals.DS_PDS_CONTEXT)) { - vscode.window.showErrorMessage( - `${"Can't copy partitioned datasets"}: ${"Select member(s) of a pds or sequential dataset(s) to copy"}` - ); - } - if (nodesList.length === 1 && nodesList[0].contextValue === globals.DS_MEMBER_CONTEXT) { - return vscode.env.clipboard.writeText(JSON.stringify(dsUtils.getNodeLabels(nodesList[0]))); + if (selectedNodes.length === 1 && selectedNodes[0].contextValue === globals.DS_MEMBER_CONTEXT) { + // single member + return vscode.env.clipboard.writeText(JSON.stringify(dsUtils.getNodeLabels(selectedNodes[0]))); } if (unique.includes(globals.DS_MEMBER_CONTEXT)) { + // multiple member const filePaths = []; - nodesList.forEach((el) => { + selectedNodes.forEach((el) => { filePaths.push(dsUtils.getNodeLabels(el)); }); return vscode.env.clipboard.writeText(JSON.stringify(filePaths)); } if (unique.includes(globals.DS_DS_CONTEXT)) { - return copySequentialDatasets(nodesList); + await copySequentialDatasets(selectedNodes); + return refreshDataset(selectedNodes[0].getParent(), datasetProvider); } if (unique.includes(globals.DS_PDS_CONTEXT)) { - return copyPartitionedDatasets(nodesList); + await copyPartitionedDatasets(selectedNodes); + return refreshDataset(selectedNodes[0].getParent(), datasetProvider); } } @@ -1544,28 +1561,25 @@ export async function saveFile(doc: vscode.TextDocument, datasetProvider: api.IZ } /** - * Paste member + * Paste members * * @export * @param {DatasetTree} datasetProvider - the tree which contains the nodes */ -export async function pasteDataSet(datasetProvider: api.IZoweTree, node: ZoweDatasetNode) { +export async function pasteDataSetMembers( + datasetProvider: api.IZoweTree, + node: ZoweDatasetNode +) { let clipboardContent; try { clipboardContent = JSON.parse(await vscode.env.clipboard.readText()); } catch (err) { - throw Error("Invalid clipboard. Copy from data set first"); - } - if (!node) { - node = datasetProvider.getTreeView().selection[0] as ZoweDatasetNode; - } - if (node.contextValue === globals.DS_MEMBER_CONTEXT || node.contextValue === globals.DS_DS_CONTEXT) { + vscode.window.showErrorMessage(localize("paste.dataSet", "Invalid paste. Copy dataset(s) first")); return; } if (Profiles.getInstance().validProfile !== api.ValidProfileEnum.INVALID) { if (!Array.isArray(clipboardContent) && clipboardContent.memberName) { - vscode.env.clipboard.writeText(""); // TODO change it to dispose function return pasteMember(node, datasetProvider); } @@ -1574,10 +1588,9 @@ export async function pasteDataSet(datasetProvider: api.IZoweTree { + async function copyDsMember() { for (const content of clipboardContent) { if (content.memberName) { - // member try { await ZoweExplorerApiRegister.getMvsApi(node.getProfile()).copyDataSetMember( { dsn: content.dataSetName, member: content.memberName }, @@ -1602,7 +1615,7 @@ export async function pasteDataSet(datasetProvider: api.IZoweTree { const prof = node?.getProfile(); @@ -1682,12 +1695,12 @@ export async function copySequentialDatasets(nodes: ZoweDatasetNode[]) { } } catch (err) { globals.LOG.error( - localize("createDataSet.log.error", "Error encountered when creating data set! ") + JSON.stringify(err) + localize("copyDataSet.log.error", "Error encountered when copy data set! ") + JSON.stringify(err) ); await errorHandling( err, dsUtils.getNodeLabels(node).dataSetName, - localize("createDataSet.error", "Unable to create data set: ") + err.message + localize("copyDataSet.error", "Unable to copy data set: ") + err.message ); throw err; } @@ -1700,8 +1713,65 @@ export async function copySequentialDatasets(nodes: ZoweDatasetNode[]) { * @export * @param {ZoweDatasetNode[]} nodes - nodes to be copied */ -export function copyPartitionedDatasets(nodes: ZoweDatasetNode[]) { +export async function copyPartitionedDatasets(nodes: ZoweDatasetNode[]) { for (const node of nodes) { - downloadDataset(node); + try { + const lbl = node.getLabel().toString(); + const inputBoxOptions: vscode.InputBoxOptions = { + value: lbl, + placeHolder: localize("pasteMember.inputBox.placeHolder", "Name of Data Set"), + validateInput: (text) => { + return dsUtils.validateDataSetName(text) && (lbl !== text) === true + ? null + : "Enter valid dataset name"; + }, + }; + + const partitionedDs = await vscode.window.showInputBox(inputBoxOptions); + if (!partitionedDs) { + return; + } + const res = await ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).allocateLikeDataSet( + partitionedDs, + lbl + ); + if (res.success) { + const uploadOptions: IUploadOptions = { + etag: node?.getEtag(), + returnEtag: true, + }; + + const children = await node.getChildren(); + + await vscode.window.withProgress( + { + location: vscode.ProgressLocation.Window, + title: localize("paste.dataSet.InPrg", "Uploading File(s)"), + }, + () => { + const prof = node?.getProfile(); + if (prof.profile.encoding) { + uploadOptions.encoding = prof.profile.encoding; + } + for (const child of children) { + ZoweExplorerApiRegister.getMvsApi(node.getProfile()).copyDataSetMember( + { dsn: lbl, member: child.getLabel().toString() }, + { dsn: partitionedDs, member: child.getLabel().toString() } + ); + } + return Promise.resolve(); + } + ); + } + } catch (error) { + globals.LOG.error( + localize("copyDataSet.log.error", "Error encountered when copy data set! ") + JSON.stringify(error) + ); + await errorHandling( + error, + dsUtils.getNodeLabels(node).dataSetName, + localize("copyDataSet.error", "Unable to copy data set: ") + error.message + ); + } } } diff --git a/packages/zowe-explorer/src/extension.ts b/packages/zowe-explorer/src/extension.ts index 2a428ef77a..35b63ce0ce 100644 --- a/packages/zowe-explorer/src/extension.ts +++ b/packages/zowe-explorer/src/extension.ts @@ -498,18 +498,13 @@ function initDatasetProvider(context: vscode.ExtensionContext) { ); context.subscriptions.push( vscode.commands.registerCommand("zowe.ds.copyDataSet", async (node, nodeList) => { - let selectedNodes; - if (!(node && nodeList)) { - selectedNodes = datasetProvider.getTreeView().selection; - } else { - selectedNodes = getSelectedNodeList(node, nodeList); - } - dsActions.copyDataSet(selectedNodes); + dsActions.copyDataSet(node, nodeList, datasetProvider); }) ); context.subscriptions.push( vscode.commands.registerCommand("zowe.ds.pasteMember", async (node: ZoweDatasetNode) => { - dsActions.pasteDataSet(datasetProvider, node); + dsActions.pasteDataSetMembers(datasetProvider, node); + dsActions.refreshDataset(node.getParent(), datasetProvider); }) ); context.subscriptions.push( From 4023669d99e631f960ac5a481ee1df8e34dea1c2 Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Tue, 20 Dec 2022 16:19:20 +0100 Subject: [PATCH 07/39] changelog Signed-off-by: KutluOzel-b --- packages/zowe-explorer/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/zowe-explorer/CHANGELOG.md b/packages/zowe-explorer/CHANGELOG.md index 87c4816c9e..27cebaa6b1 100644 --- a/packages/zowe-explorer/CHANGELOG.md +++ b/packages/zowe-explorer/CHANGELOG.md @@ -6,6 +6,8 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen ### New features and enhancements +-add feature copy datasets ( pds, sequential, members across pds) with multi select capabilities. [#2051] https://github.com/zowe/vscode-extension-for-zowe/pull/2051 + ### Bug fixes - Fixed issue where "Show Attributes" feature used conflicting colors with light VS Code themes. [#2048](https://github.com/zowe/vscode-extension-for-zowe/issues/2048) From aa5559c25aa22c62882bc98a0fecc572ec164bee Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Wed, 21 Dec 2022 09:24:46 +0100 Subject: [PATCH 08/39] fix changelog & lint Signed-off-by: KutluOzel-b --- packages/zowe-explorer/CHANGELOG.md | 2 +- .../__unit__/dataset/actions.unit.test.ts | 86 ++++++++----------- 2 files changed, 38 insertions(+), 50 deletions(-) diff --git a/packages/zowe-explorer/CHANGELOG.md b/packages/zowe-explorer/CHANGELOG.md index 27cebaa6b1..aa2f940876 100644 --- a/packages/zowe-explorer/CHANGELOG.md +++ b/packages/zowe-explorer/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen ### New features and enhancements --add feature copy datasets ( pds, sequential, members across pds) with multi select capabilities. [#2051] https://github.com/zowe/vscode-extension-for-zowe/pull/2051 +-add feature copy datasets ( pds, sequential, members across pds) with multi select capabilities. [#2051] (https://github.com/zowe/vscode-extension-for-zowe/pull/2051) ### Bug fixes diff --git a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts index 3dcce6a42c..7e3f980a3c 100644 --- a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts @@ -1875,6 +1875,11 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { pdsMemberNode.contextValue = globals.DS_MEMBER_CONTEXT; bindMvsApi(mvsApi); + const pds = new ZoweDatasetNode("parent", vscode.TreeItemCollapsibleState.None, datasetSessionNode, null); + pds.contextValue = globals.DS_PDS_CONTEXT; + const memberChild = new ZoweDatasetNode("child", vscode.TreeItemCollapsibleState.None, pds, null); + memberChild.contextValue = globals.DS_MEMBER_CONTEXT; + return { session, sessionWithoutCredentials, @@ -1887,6 +1892,8 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { testDatasetTree, pdsSessionNode, pdsMemberNode, + pds, + memberChild, }; } @@ -1961,15 +1968,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); - const parent = new ZoweDatasetNode( - "parent", - vscode.TreeItemCollapsibleState.None, - blockMocks.datasetSessionNode, - null - ); - parent.contextValue = globals.DS_PDS_CONTEXT; - const child = new ZoweDatasetNode("child", vscode.TreeItemCollapsibleState.None, parent, null); - child.contextValue = globals.DS_MEMBER_CONTEXT; + await dsActions.copyDataSet(null, null, blockMocks.testDatasetTree); expect(clipboard.readText()).toBe( '{"profileName":"sestest","dataSetName":"sestest","memberName":"HLQ.TEST.DELETE.NODE","contextValue":"member"}' @@ -1979,18 +1978,8 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); - const parent = new ZoweDatasetNode( - "parent", - vscode.TreeItemCollapsibleState.None, - blockMocks.datasetSessionNode, - null - ); - parent.contextValue = globals.DS_MEMBER_CONTEXT; - const child = new ZoweDatasetNode("child", vscode.TreeItemCollapsibleState.None, parent, null); - child.contextValue = globals.DS_MEMBER_CONTEXT; - const nodeList: ZoweDatasetNode[] = [child, child]; + const nodeList: ZoweDatasetNode[] = [blockMocks.memberChild, blockMocks.memberChild]; await dsActions.copyDataSet(null, nodeList, blockMocks.testDatasetTree); - expect(clipboard.readText()).toBe( '[{"profileName":"sestest","dataSetName":"parent","memberName":"child","contextValue":"member"},{"profileName":"sestest","dataSetName":"parent","memberName":"child","contextValue":"member"}]' ); @@ -2012,34 +2001,35 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); - const child = new ZoweDatasetNode( - "child", + const nodeCopy = new ZoweDatasetNode( + "nodeCopy", vscode.TreeItemCollapsibleState.None, blockMocks.datasetSessionNode, null ); - child.contextValue = globals.DS_DS_CONTEXT; - const profile = blockMocks.imperativeProfile; - const fakeEncoding = 9999; - profile.profile.encoding = fakeEncoding; + nodeCopy.contextValue = globals.DS_DS_CONTEXT; + const testEnc = 5178; + blockMocks.imperativeProfile.profile.encoding = testEnc; mocked(vscode.window.showInputBox).mockImplementation((options) => { - options.validateInput("test"); - return Promise.resolve("test"); + options.validateInput("nodeCopyCpy"); + return Promise.resolve("nodeCopyCpy"); }); - const allocSpy = jest.spyOn(blockMocks.mvsApi, "allocateLikeDataSet"); - allocSpy.mockResolvedValue({ + const allocateSpy = jest.spyOn(blockMocks.mvsApi, "allocateLikeDataSet"); + allocateSpy.mockResolvedValue({ success: true, - commandResponse: "", + commandResponse: "response", apiResponse: {}, }); - mocked(vscode.window.withProgress).mockImplementation((params, fn) => { - fn(); - return Promise.resolve(params); + mocked(vscode.window.withProgress).mockImplementation((prm, fnc) => { + fnc(); + return Promise.resolve(prm); }); - await dsActions.copyDataSet(child, null, blockMocks.testDatasetTree); + await dsActions.copyDataSet(nodeCopy, null, blockMocks.testDatasetTree); expect(mocked(vscode.window.showErrorMessage)).not.toHaveBeenCalled(); - await expect(dsActions.copyDataSet(child, null, blockMocks.testDatasetTree)).toStrictEqual(Promise.resolve()); + await expect(dsActions.copyDataSet(nodeCopy, null, blockMocks.testDatasetTree)).toStrictEqual( + Promise.resolve() + ); }); it("Checking failed copy of sequential datasets", async () => { @@ -2085,48 +2075,46 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); - const parent = new ZoweDatasetNode( + const pNode = new ZoweDatasetNode( "parent", vscode.TreeItemCollapsibleState.None, blockMocks.datasetSessionNode, null ); - const datasetNode = new ZoweDatasetNode( - "datasetNode", + const dsNode = new ZoweDatasetNode( + "dsNode", vscode.TreeItemCollapsibleState.Expanded, - parent, + pNode, blockMocks.zosmfSession, undefined, undefined, blockMocks.imperativeProfile ); - datasetNode.contextValue = globals.DS_PDS_CONTEXT; + dsNode.contextValue = globals.DS_PDS_CONTEXT; const profile = blockMocks.imperativeProfile; const fakeEncoding = 9999; profile.profile.encoding = fakeEncoding; mocked(vscode.window.showInputBox).mockImplementation((options) => { - options.validateInput("test"); - return Promise.resolve("test"); + options.validateInput("pdsTest"); + return Promise.resolve("pdsTest"); }); - jest.spyOn(datasetNode, "getChildren").mockResolvedValue([parent, parent]); + jest.spyOn(dsNode, "getChildren").mockResolvedValue([pNode, pNode]); const copySpy = jest.spyOn(blockMocks.mvsApi, "copyDataSetMember"); copySpy.mockResolvedValue({ success: true, - commandResponse: "", + commandResponse: "myRes", apiResponse: {}, }); mocked(vscode.window.withProgress).mockImplementation((params, fn) => { fn(); return Promise.resolve(params); }); - await dsActions.copyDataSet(datasetNode, null, blockMocks.testDatasetTree); + await dsActions.copyDataSet(dsNode, null, blockMocks.testDatasetTree); await expect(mocked(vscode.window.showErrorMessage)).not.toHaveBeenCalled(); - await expect(dsActions.copyDataSet(datasetNode, null, blockMocks.testDatasetTree)).toStrictEqual( - Promise.resolve() - ); + await expect(dsActions.copyDataSet(dsNode, null, blockMocks.testDatasetTree)).toStrictEqual(Promise.resolve()); }); it("Checking fail of copy partitioned datasets", async () => { From ab4ef5bf481b07f9e4dd9240e42dc4b673fcdae6 Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Wed, 21 Dec 2022 10:04:33 +0100 Subject: [PATCH 09/39] fix smells, reduce duplication Signed-off-by: KutluOzel-b --- .../__unit__/dataset/actions.unit.test.ts | 38 ++++--------- packages/zowe-explorer/src/dataset/actions.ts | 57 +++++++++---------- 2 files changed, 37 insertions(+), 58 deletions(-) diff --git a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts index 7e3f980a3c..b6a000b966 100644 --- a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts @@ -2177,17 +2177,10 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { createGlobalMocks(); const blockMocks = createBlockMocks(); vscode.env.clipboard.writeText(""); - const node = new ZoweDatasetNode( - "HLQ.TEST.TO.NODE", - vscode.TreeItemCollapsibleState.None, - blockMocks.datasetSessionNode, - null, - undefined, - undefined, - blockMocks.imperativeProfile - ); const errSpy = jest.spyOn(vscode.window, "showErrorMessage"); - await expect(dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, node)).toEqual(Promise.resolve()); + await expect(dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, blockMocks.datasetSessionNode)).toEqual( + Promise.resolve() + ); expect(errSpy).toBeCalled(); }); it("Testing pasteDataSetMembers() fails and gives error message with empty clipboard", async () => { @@ -2224,8 +2217,8 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); - const node = new ZoweDatasetNode( - "HLQ.TEST.TO.NODE", + const memberNode = new ZoweDatasetNode( + "memberNode", vscode.TreeItemCollapsibleState.None, blockMocks.pdsSessionNode, null, @@ -2233,8 +2226,8 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { undefined, blockMocks.imperativeProfile ); - node.contextValue = globals.DS_MEMBER_CONTEXT; - const nodeList = [node, node, node]; + memberNode.contextValue = globals.DS_MEMBER_CONTEXT; + const nodeList = [memberNode, memberNode, memberNode]; const filePaths = []; nodeList.forEach((el) => { @@ -2253,25 +2246,14 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { apiResponse: {}, }); - await dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, node); + await dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, memberNode); expect(mocked(vscode.window.showErrorMessage)).not.toHaveBeenCalled(); }); it("Testing pasteDataSetMembers() fails with multiple members", async () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); - const node = new ZoweDatasetNode( - "HLQ.TEST.TO.NODE", - vscode.TreeItemCollapsibleState.None, - blockMocks.pdsSessionNode, - null, - undefined, - undefined, - blockMocks.imperativeProfile - ); - node.contextValue = globals.DS_MEMBER_CONTEXT; - const nodeList = [node, node, node]; - + const nodeList = [blockMocks.memberChild, blockMocks.memberChild, blockMocks.memberChild]; const filePaths = []; nodeList.forEach((el) => { filePaths.push(getNodeLabels(el)); @@ -2284,7 +2266,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { }); const copySpy = jest.spyOn(blockMocks.mvsApi, "copyDataSetMember"); copySpy.mockRejectedValueOnce(""); - await expect(dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, node)).toBeFalsy; + await expect(dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, blockMocks.memberChild)).toBeFalsy; }); it("Testing downloadDs() called with invalid node", async () => { diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index 477b92932c..bace103505 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1579,36 +1579,33 @@ export async function pasteDataSetMembers( vscode.window.showErrorMessage(localize("paste.dataSet", "Invalid paste. Copy dataset(s) first")); return; } + if (!Array.isArray(clipboardContent) && clipboardContent.memberName) { + return pasteMember(node, datasetProvider); + } - if (Profiles.getInstance().validProfile !== api.ValidProfileEnum.INVALID) { - if (!Array.isArray(clipboardContent) && clipboardContent.memberName) { - return pasteMember(node, datasetProvider); - } - - await vscode.window.withProgress( - { - location: vscode.ProgressLocation.Window, - title: localize("paste.dataSet.InPrg", "Uploading File(s)"), - }, - async function copyDsMember() { - for (const content of clipboardContent) { - if (content.memberName) { - try { - await ZoweExplorerApiRegister.getMvsApi(node.getProfile()).copyDataSetMember( - { dsn: content.dataSetName, member: content.memberName }, - { dsn: node.getLabel().toString(), member: content.memberName } - ); - } catch (err) { - vscode.window.showErrorMessage(err.message); - return; - } + await vscode.window.withProgress( + { + location: vscode.ProgressLocation.Window, + title: localize("paste.dataSet.InPrg", "Uploading File(s)"), + }, + async function copyDsMember() { + for (const content of clipboardContent) { + if (content.memberName) { + try { + await ZoweExplorerApiRegister.getMvsApi(node.getProfile()).copyDataSetMember( + { dsn: content.dataSetName, member: content.memberName }, + { dsn: node.getLabel().toString(), member: content.memberName } + ); + } catch (err) { + vscode.window.showErrorMessage(err.message); + return; } } - datasetProvider.refreshElement(node); - vscode.env.clipboard.writeText(""); // TODO change it to dispose function } - ); - } + datasetProvider.refreshElement(node); + vscode.env.clipboard.writeText(""); + } + ); } /** @@ -1744,6 +1741,10 @@ export async function copyPartitionedDatasets(nodes: ZoweDatasetNode[]) { }; const children = await node.getChildren(); + const prof = node?.getProfile(); + if (prof.profile.encoding) { + uploadOptions.encoding = prof.profile.encoding; + } await vscode.window.withProgress( { @@ -1751,10 +1752,6 @@ export async function copyPartitionedDatasets(nodes: ZoweDatasetNode[]) { title: localize("paste.dataSet.InPrg", "Uploading File(s)"), }, () => { - const prof = node?.getProfile(); - if (prof.profile.encoding) { - uploadOptions.encoding = prof.profile.encoding; - } for (const child of children) { ZoweExplorerApiRegister.getMvsApi(node.getProfile()).copyDataSetMember( { dsn: lbl, member: child.getLabel().toString() }, From 4ea4042a9e3bbef25a5310223f454fada94768ad Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Wed, 21 Dec 2022 10:14:35 +0100 Subject: [PATCH 10/39] fix changelog Signed-off-by: KutluOzel-b --- packages/zowe-explorer/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/zowe-explorer/CHANGELOG.md b/packages/zowe-explorer/CHANGELOG.md index aa2f940876..7e71eccd93 100644 --- a/packages/zowe-explorer/CHANGELOG.md +++ b/packages/zowe-explorer/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen ### New features and enhancements --add feature copy datasets ( pds, sequential, members across pds) with multi select capabilities. [#2051] (https://github.com/zowe/vscode-extension-for-zowe/pull/2051) +-add feature copy datasets ( pds, sequential, members across pds) with multi select capabilities. [#1150](https://github.com/zowe/vscode-extension-for-zowe/issues/1550) ### Bug fixes From ace29d8b15d766996cc2c01409349941f8100556 Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Tue, 10 Jan 2023 10:21:02 +0100 Subject: [PATCH 11/39] changed copydata set to just copy Signed-off-by: KutluOzel-b --- packages/zowe-explorer/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/zowe-explorer/package.json b/packages/zowe-explorer/package.json index 7748d70d7b..59fcb1065f 100644 --- a/packages/zowe-explorer/package.json +++ b/packages/zowe-explorer/package.json @@ -287,7 +287,7 @@ }, { "command": "zowe.ds.copyDataSet", - "title": "%copyDataSet%", + "title": "%copyFile%", "category": "Zowe Explorer" }, { From aeac808e6ceef236ad45f447be602dc7b9965992 Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Tue, 10 Jan 2023 11:27:37 +0100 Subject: [PATCH 12/39] prettier Signed-off-by: KutluOzel-b --- .../extension.integration.test.ts | 15 +--- .../__unit__/dataset/actions.unit.test.ts | 82 ++++--------------- packages/zowe-explorer/src/dataset/actions.ts | 49 +++-------- packages/zowe-explorer/src/extension.ts | 8 +- 4 files changed, 30 insertions(+), 124 deletions(-) diff --git a/packages/zowe-explorer/__tests__/__integration__/extension.integration.test.ts b/packages/zowe-explorer/__tests__/__integration__/extension.integration.test.ts index 42773abe3c..f08919c784 100644 --- a/packages/zowe-explorer/__tests__/__integration__/extension.integration.test.ts +++ b/packages/zowe-explorer/__tests__/__integration__/extension.integration.test.ts @@ -453,19 +453,8 @@ describe("Extension Integration Tests", async () => { let contents; try { - - const fromNode = new ZoweDatasetNode( - fromDataSetName, - vscode.TreeItemCollapsibleState.None, - sessionNode, - session - ); - const toNode = new ZoweDatasetNode( - toDataSetName, - vscode.TreeItemCollapsibleState.None, - sessionNode, - session - ); + const fromNode = new ZoweDatasetNode(fromDataSetName, vscode.TreeItemCollapsibleState.None, sessionNode, session); + const toNode = new ZoweDatasetNode(toDataSetName, vscode.TreeItemCollapsibleState.None, sessionNode, session); const nodeList: ZoweDatasetNode[] = [fromNode]; await dsActions.copyDataSet(nodeList, null, null); diff --git a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts index 64c969f0ee..5e8ba8ef67 100644 --- a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts @@ -41,7 +41,6 @@ import * as utils from "../../../src/utils/ProfilesUtils"; import { getNodeLabels } from "../../../src/dataset/utils"; - // Missing the definition of path module, because I need the original logic for tests jest.mock("fs"); @@ -1712,17 +1711,11 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { createGlobalMocks(); const blockMocks = createBlockMocks(); - const node = new ZoweDatasetNode( - "HLQ.TEST.DELETE.NODE", - vscode.TreeItemCollapsibleState.None, - blockMocks.pdsSessionNode, - null - ); + const node = new ZoweDatasetNode("HLQ.TEST.DELETE.NODE", vscode.TreeItemCollapsibleState.None, blockMocks.pdsSessionNode, null); node.contextValue = globals.DS_MEMBER_CONTEXT; const nodeList: ZoweDatasetNode[] = [node]; await dsActions.copyDataSet(null, nodeList, null); - expect(clipboard.readText()).toBe( '{"profileName":"sestest","dataSetName":"sestest","memberName":"HLQ.TEST.DELETE.NODE","contextValue":"member"}' ); @@ -1731,18 +1724,8 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); - const Membernode = new ZoweDatasetNode( - "HLQ.TEST.DELETE.NODE", - vscode.TreeItemCollapsibleState.None, - blockMocks.pdsSessionNode, - null - ); - const pdsNode = new ZoweDatasetNode( - "HLQ.TEST.DELETE.NODE", - vscode.TreeItemCollapsibleState.None, - blockMocks.pdsSessionNode, - null - ); + const Membernode = new ZoweDatasetNode("HLQ.TEST.DELETE.NODE", vscode.TreeItemCollapsibleState.None, blockMocks.pdsSessionNode, null); + const pdsNode = new ZoweDatasetNode("HLQ.TEST.DELETE.NODE", vscode.TreeItemCollapsibleState.None, blockMocks.pdsSessionNode, null); pdsNode.contextValue = globals.DS_PDS_CONTEXT; Membernode.contextValue = globals.DS_MEMBER_CONTEXT; const nodeList: ZoweDatasetNode[] = [Membernode, pdsNode]; @@ -1793,12 +1776,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); - const child = new ZoweDatasetNode( - "child", - vscode.TreeItemCollapsibleState.None, - blockMocks.datasetSessionNode, - null - ); + const child = new ZoweDatasetNode("child", vscode.TreeItemCollapsibleState.None, blockMocks.datasetSessionNode, null); child.contextValue = globals.DS_DS_CONTEXT; await expect(dsActions.copyDataSet(child, null, blockMocks.testDatasetTree)).toStrictEqual(Promise.resolve()); }); @@ -1806,12 +1784,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); - const nodeCopy = new ZoweDatasetNode( - "nodeCopy", - vscode.TreeItemCollapsibleState.None, - blockMocks.datasetSessionNode, - null - ); + const nodeCopy = new ZoweDatasetNode("nodeCopy", vscode.TreeItemCollapsibleState.None, blockMocks.datasetSessionNode, null); nodeCopy.contextValue = globals.DS_DS_CONTEXT; const testEnc = 5178; blockMocks.imperativeProfile.profile.encoding = testEnc; @@ -1832,9 +1805,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { }); await dsActions.copyDataSet(nodeCopy, null, blockMocks.testDatasetTree); expect(mocked(vscode.window.showErrorMessage)).not.toHaveBeenCalled(); - await expect(dsActions.copyDataSet(nodeCopy, null, blockMocks.testDatasetTree)).toStrictEqual( - Promise.resolve() - ); + await expect(dsActions.copyDataSet(nodeCopy, null, blockMocks.testDatasetTree)).toStrictEqual(Promise.resolve()); }); it("Checking failed copy of sequential datasets", async () => { @@ -1842,12 +1813,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { createGlobalMocks(); const blockMocks = createBlockMocks(); - const child = new ZoweDatasetNode( - "child", - vscode.TreeItemCollapsibleState.None, - blockMocks.datasetSessionNode, - null - ); + const child = new ZoweDatasetNode("child", vscode.TreeItemCollapsibleState.None, blockMocks.datasetSessionNode, null); child.contextValue = globals.DS_DS_CONTEXT; const profile = blockMocks.imperativeProfile; const fakeEncoding = 9999; @@ -1870,9 +1836,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { try { await dsActions.copyDataSet(child, null, blockMocks.testDatasetTree); expect(mocked(vscode.window.showErrorMessage)).not.toHaveBeenCalled(); - await expect(dsActions.copyDataSet(child, null, blockMocks.testDatasetTree)).toStrictEqual( - Promise.resolve() - ); + await expect(dsActions.copyDataSet(child, null, blockMocks.testDatasetTree)).toStrictEqual(Promise.resolve()); } catch (error) { // do nth } @@ -1881,12 +1845,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); - const pNode = new ZoweDatasetNode( - "parent", - vscode.TreeItemCollapsibleState.None, - blockMocks.datasetSessionNode, - null - ); + const pNode = new ZoweDatasetNode("parent", vscode.TreeItemCollapsibleState.None, blockMocks.datasetSessionNode, null); const parent = new ZoweDatasetNode("parent", vscode.TreeItemCollapsibleState.None, blockMocks.datasetSessionNode, null); parent.contextValue = globals.DS_PDS_CONTEXT; @@ -1932,12 +1891,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); - const child = new ZoweDatasetNode( - "child", - vscode.TreeItemCollapsibleState.None, - blockMocks.datasetSessionNode, - null - ); + const child = new ZoweDatasetNode("child", vscode.TreeItemCollapsibleState.None, blockMocks.datasetSessionNode, null); blockMocks.datasetSessionNode.contextValue = globals.DS_PDS_CONTEXT; const profile = blockMocks.imperativeProfile; @@ -1956,9 +1910,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { try { await dsActions.copyDataSet(blockMocks.datasetSessionNode, null, blockMocks.testDatasetTree); await expect(mocked(vscode.window.showErrorMessage)).not.toHaveBeenCalled(); - await expect( - dsActions.copyDataSet(blockMocks.datasetSessionNode, null, blockMocks.testDatasetTree) - ).toStrictEqual(Promise.resolve()); + await expect(dsActions.copyDataSet(blockMocks.datasetSessionNode, null, blockMocks.testDatasetTree)).toStrictEqual(Promise.resolve()); } catch (error) { // do nth } @@ -1974,9 +1926,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { const nodeList: ZoweDatasetNode[] = [child]; await dsActions.copyDataSet(null, nodeList, blockMocks.testDatasetTree); - expect(clipboard.readText()).toBe( - '{"profileName":"sestest","dataSetName":"parent","memberName":"child","contextValue":"member"}' - ); + expect(clipboard.readText()).toBe('{"profileName":"sestest","dataSetName":"parent","memberName":"child","contextValue":"member"}'); }); it("Testing pasteDataSetMembers() fails and gives error message with empty clipboard", async () => { globals.defineGlobals(""); @@ -1984,9 +1934,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { const blockMocks = createBlockMocks(); vscode.env.clipboard.writeText(""); const errSpy = jest.spyOn(vscode.window, "showErrorMessage"); - await expect(dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, blockMocks.datasetSessionNode)).toEqual( - Promise.resolve() - ); + await expect(dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, blockMocks.datasetSessionNode)).toEqual(Promise.resolve()); expect(errSpy).toBeCalled(); }); it("Testing pasteDataSetMembers() fails and gives error message with empty clipboard", async () => { @@ -2014,9 +1962,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { vscode.env.clipboard.writeText(JSON.stringify(getNodeLabels(blockMocks.pdsMemberNode))); const errSpy = jest.spyOn(dsActions, "pasteMember"); errSpy.mockResolvedValueOnce(null); - await expect(dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, blockMocks.pdsMemberNode)).toEqual( - Promise.resolve() - ); + await expect(dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, blockMocks.pdsMemberNode)).toEqual(Promise.resolve()); }); it("Testing pasteDataSetMembers() succesfully runs with multiple members", async () => { diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index ff39da1cfd..8a573752f0 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -23,8 +23,8 @@ import { checkForAddedSuffix, willForceUpload, getSelectedNodeList, - JobSubmitDialogOpts, - JOB_SUBMIT_DIALOG_OPTS + JobSubmitDialogOpts, + JOB_SUBMIT_DIALOG_OPTS, } from "../shared/utils"; import { ZoweExplorerApiRegister } from "../ZoweExplorerApiRegister"; import { Profiles } from "../Profiles"; @@ -1130,11 +1130,7 @@ export async function enterPattern(node: api.IZoweDatasetTreeNode, datasetProvid * @param {ZoweDatasetNode[]} nodeList - Multiple selected Nodes to copy * @param datasetProvider */ -export async function copyDataSet( - node, - nodeList: ZoweDatasetNode[], - datasetProvider: api.IZoweTree -) { +export async function copyDataSet(node, nodeList: ZoweDatasetNode[], datasetProvider: api.IZoweTree) { let selectedNodes; if (!(node || nodeList)) { selectedNodes = datasetProvider.getTreeView().selection; @@ -1144,9 +1140,7 @@ export async function copyDataSet( const unique = [...new Set(selectedNodes.map((item) => item.contextValue))]; if (unique.length > 1) { - vscode.window.showErrorMessage( - `${"Can't copy multiple dataset with different types"}: ${"Select same types to copy"}` - ); + vscode.window.showErrorMessage(`${"Can't copy multiple dataset with different types"}: ${"Select same types to copy"}`); return; } if (selectedNodes.length === 1 && selectedNodes[0].contextValue === globals.DS_MEMBER_CONTEXT) { @@ -1449,10 +1443,7 @@ export async function saveFile(doc: vscode.TextDocument, datasetProvider: api.IZ * @export * @param {DatasetTree} datasetProvider - the tree which contains the nodes */ -export async function pasteDataSetMembers( - datasetProvider: api.IZoweTree, - node: ZoweDatasetNode -) { +export async function pasteDataSetMembers(datasetProvider: api.IZoweTree, node: ZoweDatasetNode) { let clipboardContent; try { clipboardContent = JSON.parse(await vscode.env.clipboard.readText()); @@ -1508,9 +1499,7 @@ export function downloadDs(node: ZoweDatasetNode) { lbl = node.getParent().getLabel().toString() + "(" + node.getLabel().toString() + ")"; break; default: - vscode.window.showErrorMessage( - localize("download.invalidNode", "downloadDataset() called with invalid node.") - ); + vscode.window.showErrorMessage(localize("download.invalidNode", "downloadDataset() called with invalid node.")); throw Error(localize("download.invalidNode", "downloadDataset() called with invalid node. ")); } const filePath = getDocumentFilePath(lbl, node); @@ -1536,9 +1525,7 @@ export async function copySequentialDatasets(nodes: ZoweDatasetNode[]) { value: lbl, placeHolder: localize("pasteMember.inputBox.placeHolder", "Name of Data Set"), validateInput: (text) => { - return dsUtils.validateDataSetName(text) && (lbl !== text) === true - ? null - : "Enter valid dataset name"; + return dsUtils.validateDataSetName(text) && (lbl !== text) === true ? null : "Enter valid dataset name"; }, }; @@ -1546,10 +1533,7 @@ export async function copySequentialDatasets(nodes: ZoweDatasetNode[]) { if (!sequential) { return; } - const res = await ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).allocateLikeDataSet( - sequential, - lbl - ); + const res = await ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).allocateLikeDataSet(sequential, lbl); if (res.success) { const uploadOptions: IUploadOptions = { etag: node?.getEtag(), @@ -1574,9 +1558,7 @@ export async function copySequentialDatasets(nodes: ZoweDatasetNode[]) { ); } } catch (err) { - globals.LOG.error( - localize("copyDataSet.log.error", "Error encountered when copy data set! ") + JSON.stringify(err) - ); + globals.LOG.error(localize("copyDataSet.log.error", "Error encountered when copy data set! ") + JSON.stringify(err)); await errorHandling( err, dsUtils.getNodeLabels(node).dataSetName, @@ -1601,9 +1583,7 @@ export async function copyPartitionedDatasets(nodes: ZoweDatasetNode[]) { value: lbl, placeHolder: localize("pasteMember.inputBox.placeHolder", "Name of Data Set"), validateInput: (text) => { - return dsUtils.validateDataSetName(text) && (lbl !== text) === true - ? null - : "Enter valid dataset name"; + return dsUtils.validateDataSetName(text) && (lbl !== text) === true ? null : "Enter valid dataset name"; }, }; @@ -1611,10 +1591,7 @@ export async function copyPartitionedDatasets(nodes: ZoweDatasetNode[]) { if (!partitionedDs) { return; } - const res = await ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).allocateLikeDataSet( - partitionedDs, - lbl - ); + const res = await ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).allocateLikeDataSet(partitionedDs, lbl); if (res.success) { const uploadOptions: IUploadOptions = { etag: node?.getEtag(), @@ -1644,9 +1621,7 @@ export async function copyPartitionedDatasets(nodes: ZoweDatasetNode[]) { ); } } catch (error) { - globals.LOG.error( - localize("copyDataSet.log.error", "Error encountered when copy data set! ") + JSON.stringify(error) - ); + globals.LOG.error(localize("copyDataSet.log.error", "Error encountered when copy data set! ") + JSON.stringify(error)); await errorHandling( error, dsUtils.getNodeLabels(node).dataSetName, diff --git a/packages/zowe-explorer/src/extension.ts b/packages/zowe-explorer/src/extension.ts index ba23a64eae..7c9c3ecca9 100644 --- a/packages/zowe-explorer/src/extension.ts +++ b/packages/zowe-explorer/src/extension.ts @@ -425,9 +425,7 @@ function initDatasetProvider(context: vscode.ExtensionContext) { }) ); - context.subscriptions.push( - vscode.commands.registerCommand("zowe.ds.renameDataSet", (node) => datasetProvider.rename(node)) - ); + context.subscriptions.push(vscode.commands.registerCommand("zowe.ds.renameDataSet", (node) => datasetProvider.rename(node))); context.subscriptions.push( vscode.commands.registerCommand("zowe.ds.copyDataSet", async (node, nodeList) => { dsActions.copyDataSet(node, nodeList, datasetProvider); @@ -439,9 +437,7 @@ function initDatasetProvider(context: vscode.ExtensionContext) { dsActions.refreshDataset(node.getParent(), datasetProvider); }) ); - context.subscriptions.push( - vscode.commands.registerCommand("zowe.ds.renameDataSetMember", (node) => datasetProvider.rename(node)) - ); + context.subscriptions.push(vscode.commands.registerCommand("zowe.ds.renameDataSetMember", (node) => datasetProvider.rename(node))); context.subscriptions.push( vscode.commands.registerCommand("zowe.ds.hMigrateDataSet", async (node, nodeList) => { From 6059cdfa30986b025e20e1862701624e3a17d8de Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Tue, 10 Jan 2023 13:37:40 +0100 Subject: [PATCH 13/39] fix test member downloadDs Signed-off-by: KutluOzel-b --- .../__tests__/__unit__/dataset/actions.unit.test.ts | 6 +++++- packages/zowe-explorer/src/dataset/actions.ts | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts index 5e8ba8ef67..980a17b24a 100644 --- a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts @@ -2055,7 +2055,11 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { undefined, blockMocks.imperativeProfile ); - await expect(dsActions.downloadDs(node)).not.toBeUndefined(); + + let label = node.getParent().getLabel().toString() + "(" + node.getLabel().toString() + ")"; + const filePathSpy = jest.spyOn(sharedUtils, "getDocumentFilePath"); + await dsActions.downloadDs(node); + expect(filePathSpy).toBeCalledWith(label, node); }); }); diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index 8a573752f0..62847a8c1a 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1486,7 +1486,7 @@ export async function pasteDataSetMembers(datasetProvider: api.IZoweTree Date: Wed, 11 Jan 2023 13:27:11 +0100 Subject: [PATCH 14/39] fix quickkey paste on pds Signed-off-by: KutluOzel-b --- packages/zowe-explorer/src/extension.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/zowe-explorer/src/extension.ts b/packages/zowe-explorer/src/extension.ts index 7c9c3ecca9..b56464939e 100644 --- a/packages/zowe-explorer/src/extension.ts +++ b/packages/zowe-explorer/src/extension.ts @@ -433,6 +433,9 @@ function initDatasetProvider(context: vscode.ExtensionContext) { ); context.subscriptions.push( vscode.commands.registerCommand("zowe.ds.pasteMember", async (node: ZoweDatasetNode) => { + if (!node) { + node = datasetProvider.getTreeView().selection[0] as ZoweDatasetNode; + } dsActions.pasteDataSetMembers(datasetProvider, node); dsActions.refreshDataset(node.getParent(), datasetProvider); }) From 149fd9f0e3dc154532b5c8988b3cc2cecd9017d7 Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Wed, 11 Jan 2023 13:30:37 +0100 Subject: [PATCH 15/39] removed redudant debugging statement Signed-off-by: KutluOzel-b --- packages/zowe-explorer/src/dataset/actions.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index 62847a8c1a..55f0e1bec2 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1503,12 +1503,11 @@ export async function downloadDs(node: ZoweDatasetNode) { throw Error(localize("download.invalidNode", "downloadDataset() called with invalid node. ")); } const filePath = getDocumentFilePath(lbl, node); - let a = await ZoweExplorerApiRegister.getMvsApi(profile).getContents(lbl, { + return ZoweExplorerApiRegister.getMvsApi(profile).getContents(lbl, { file: filePath, returnEtag: true, encoding: profile.profile.encoding, }); - return a; } /** From 53aebe11d068f09a665443cb5db348f7247003de Mon Sep 17 00:00:00 2001 From: Billie Simmons <49491949+JillieBeanSim@users.noreply.github.com> Date: Wed, 11 Jan 2023 08:59:07 -0500 Subject: [PATCH 16/39] fix audit with resolution of debug Signed-off-by: Billie Simmons <49491949+JillieBeanSim@users.noreply.github.com> --- package.json | 3 ++- yarn.lock | 36 +++++------------------------------- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index dc7cc0d6ee..974fb11caf 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,8 @@ "**/minimatch": "^3.1.2", "**/minimist": "^1.2.6", "**/moment": "^2.29.4", - "**/tar": "^6.1.9" + "**/tar": "^6.1.9", + "**/debug": "^3.1.0" }, "scripts": { "clean": "yarn workspaces run clean", diff --git a/yarn.lock b/yarn.lock index f09a21481a..6318900f5c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4388,31 +4388,10 @@ debug-fabulous@1.X: memoizee "0.4.X" object-assign "4.X" -debug@3.2.6: - version "3.2.6" - resolved "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" - integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== - dependencies: - ms "^2.1.1" - -debug@3.X, debug@^3.1.0: - version "3.2.7" - resolved "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" - integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== - dependencies: - ms "^2.1.1" - -debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.4: - version "4.3.4" - resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== - dependencies: - ms "2.1.2" - -debug@^2.2.0, debug@^2.3.3, debug@~2.6.8: - version "2.6.9" - resolved "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== +debug@3.2.6, debug@3.X, debug@4, debug@^2.2.0, debug@^2.3.3, debug@^3.1.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.4, debug@~2.6.8: + version "3.1.0" + resolved "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== dependencies: ms "2.0.0" @@ -9092,12 +9071,7 @@ ms@2.1.1: resolved "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== -ms@2.1.2: - version "2.1.2" - resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - -ms@^2.0.0, ms@^2.1.1: +ms@^2.0.0: version "2.1.3" resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== From e777b818889bcdab31e8c28a67af172f4f6288fc Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Wed, 11 Jan 2023 16:17:01 +0100 Subject: [PATCH 17/39] changed command name Signed-off-by: KutluOzel-b --- .../__tests__/__unit__/extension.unit.test.ts | 2 +- packages/zowe-explorer/package.json | 8 ++++---- packages/zowe-explorer/src/extension.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts index 6aeafdd3f6..f4a983645b 100644 --- a/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts @@ -160,7 +160,7 @@ async function createGlobalMocks() { "zowe.ds.showAttributes", "zowe.ds.renameDataSet", "zowe.ds.copyDataSet", - "zowe.ds.pasteMember", + "zowe.ds.pasteDataSet", "zowe.ds.renameDataSetMember", "zowe.ds.hMigrateDataSet", "zowe.ds.hRecallDataSet", diff --git a/packages/zowe-explorer/package.json b/packages/zowe-explorer/package.json index 320f49129c..89afd35c43 100644 --- a/packages/zowe-explorer/package.json +++ b/packages/zowe-explorer/package.json @@ -109,7 +109,7 @@ "when": "focusedView == zowe.ds.explorer" }, { - "command": "zowe.ds.pasteMember", + "command": "zowe.ds.pasteDataSet", "key": "ctrl+v", "mac": "cmd+v", "when": "focusedView == zowe.ds.explorer" @@ -301,7 +301,7 @@ "category": "Zowe Explorer" }, { - "command": "zowe.ds.pasteMember", + "command": "zowe.ds.pasteDataSet", "title": "%paste%", "category": "Zowe Explorer" }, @@ -1010,7 +1010,7 @@ }, { "when": "view == zowe.ds.explorer && viewItem =~ /^(session|pds).*/", - "command": "zowe.ds.pasteMember", + "command": "zowe.ds.pasteDataSet", "group": "001_zowe_dsCreate@7" }, { @@ -1302,7 +1302,7 @@ "when": "never" }, { - "command": "zowe.ds.pasteMember", + "command": "zowe.ds.pasteDataSet", "when": "never" }, { diff --git a/packages/zowe-explorer/src/extension.ts b/packages/zowe-explorer/src/extension.ts index b56464939e..210aa3ee0c 100644 --- a/packages/zowe-explorer/src/extension.ts +++ b/packages/zowe-explorer/src/extension.ts @@ -432,7 +432,7 @@ function initDatasetProvider(context: vscode.ExtensionContext) { }) ); context.subscriptions.push( - vscode.commands.registerCommand("zowe.ds.pasteMember", async (node: ZoweDatasetNode) => { + vscode.commands.registerCommand("zowe.ds.pasteDataSet", async (node: ZoweDatasetNode) => { if (!node) { node = datasetProvider.getTreeView().selection[0] as ZoweDatasetNode; } From bb9d7195dce328992b8be81a46487ff3148d6f3c Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Fri, 13 Jan 2023 14:47:12 +0100 Subject: [PATCH 18/39] refactor Gui api Signed-off-by: KutluOzel-b --- .../__tests__/__unit__/dataset/actions.unit.test.ts | 13 +++++++------ packages/zowe-explorer/package.json | 2 +- packages/zowe-explorer/src/dataset/actions.ts | 12 ++++++------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts index 8e8cbb3b1a..8e6fd07fb8 100644 --- a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts @@ -1730,9 +1730,10 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { createGlobalMocks(); const blockMocks = createBlockMocks(); const selectedNodeSpy = jest.spyOn(sharedUtils, "getSelectedNodeList"); + const copySpy = jest.spyOn(dsActions, "copyPartitionedDatasets"); + copySpy.mockResolvedValue(undefined); await dsActions.copyDataSet(blockMocks.pdsSessionNode, null, blockMocks.testDatasetTree); expect(selectedNodeSpy).toBeCalledWith(blockMocks.pdsSessionNode, null); - expect(mocked(vscode.window.showErrorMessage)).not.toBeCalled(); }); it("Checking copy the label of a favorite node to the clipboard", async () => { globals.defineGlobals(""); @@ -1798,7 +1799,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { return Promise.resolve(prm); }); await dsActions.copyDataSet(nodeCopy, null, blockMocks.testDatasetTree); - expect(mocked(vscode.window.showErrorMessage)).not.toHaveBeenCalled(); + expect(mocked(Gui.errorMessage)).not.toHaveBeenCalled(); await expect(dsActions.copyDataSet(nodeCopy, null, blockMocks.testDatasetTree)).toStrictEqual(Promise.resolve()); }); @@ -1877,7 +1878,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { return Promise.resolve(params); }); await dsActions.copyDataSet(dsNode, null, blockMocks.testDatasetTree); - await expect(mocked(vscode.window.showErrorMessage)).not.toHaveBeenCalled(); + await expect(mocked(Gui.errorMessage)).not.toHaveBeenCalled(); await expect(dsActions.copyDataSet(dsNode, null, blockMocks.testDatasetTree)).toStrictEqual(Promise.resolve()); }); @@ -1927,7 +1928,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { createGlobalMocks(); const blockMocks = createBlockMocks(); vscode.env.clipboard.writeText(""); - const errSpy = jest.spyOn(vscode.window, "showErrorMessage"); + const errSpy = jest.spyOn(Gui, "errorMessage"); await expect(dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, blockMocks.datasetSessionNode)).toEqual(Promise.resolve()); expect(errSpy).toBeCalled(); }); @@ -1945,7 +1946,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { undefined, blockMocks.imperativeProfile ); - const errSpy = jest.spyOn(vscode.window, "showErrorMessage"); + const errSpy = jest.spyOn(Gui, "errorMessage"); await expect(dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, node)).toEqual(Promise.resolve()); expect(errSpy).toBeCalled(); }); @@ -1993,7 +1994,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { }); await dsActions.pasteDataSetMembers(blockMocks.testDatasetTree, memberNode); - expect(mocked(vscode.window.showErrorMessage)).not.toHaveBeenCalled(); + expect(mocked(Gui.errorMessage)).not.toHaveBeenCalled(); }); it("Testing pasteDataSetMembers() fails with multiple members", async () => { globals.defineGlobals(""); diff --git a/packages/zowe-explorer/package.json b/packages/zowe-explorer/package.json index 2764d8a873..a81ce04c80 100644 --- a/packages/zowe-explorer/package.json +++ b/packages/zowe-explorer/package.json @@ -306,7 +306,7 @@ "category": "Zowe Explorer" }, { - "command": "zowe.ds.pasteMember", + "command": "zowe.ds.pasteDataSet", "title": "%paste%", "category": "Zowe Explorer" }, diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index 7a25fe32c6..55a4d30e17 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1472,14 +1472,14 @@ export async function pasteDataSetMembers(datasetProvider: api.IZoweTree Date: Fri, 13 Jan 2023 14:58:51 +0100 Subject: [PATCH 19/39] adress comments Signed-off-by: KutluOzel-b --- packages/zowe-explorer/src/dataset/actions.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index 55a4d30e17..40f2faaf27 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1546,6 +1546,7 @@ export async function copySequentialDatasets(nodes: ZoweDatasetNode[]) { await downloadDs(node); const lbl = node.getLabel().toString(); const inputBoxOptions: vscode.InputBoxOptions = { + prompt: localize("allocateLike.inputBox.placeHolder", "Enter a name for the new data set"), value: lbl, placeHolder: localize("pasteMember.inputBox.placeHolder", "Name of Data Set"), validateInput: (text) => { @@ -1604,6 +1605,7 @@ export async function copyPartitionedDatasets(nodes: ZoweDatasetNode[]) { try { const lbl = node.getLabel().toString(); const inputBoxOptions: vscode.InputBoxOptions = { + prompt: localize("allocateLike.inputBox.placeHolder", "Enter a name for the new data set"), value: lbl, placeHolder: localize("pasteMember.inputBox.placeHolder", "Name of Data Set"), validateInput: (text) => { From 69f4888f3baca5c7644c2c47063b761abe55f0d1 Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Thu, 19 Jan 2023 14:37:28 +0100 Subject: [PATCH 20/39] modify sequential ds copy with zosmf api Signed-off-by: KutluOzel-b --- .../src/profiles/ZoweExplorerApi.ts | 11 +++++++ .../src/profiles/ZoweExplorerZosmfApi.ts | 3 ++ .../src/ZoweExplorerFtpMvsApi.ts | 13 ++++++++ .../__unit__/dataset/actions.unit.test.ts | 9 ++++-- .../i18n/sample/src/dataset/actions.i18n.json | 2 +- packages/zowe-explorer/src/dataset/actions.ts | 18 ++++------- yarn.lock | 30 ++----------------- 7 files changed, 42 insertions(+), 44 deletions(-) diff --git a/packages/zowe-explorer-api/src/profiles/ZoweExplorerApi.ts b/packages/zowe-explorer-api/src/profiles/ZoweExplorerApi.ts index c345fcaaaf..b95cef7fb3 100644 --- a/packages/zowe-explorer-api/src/profiles/ZoweExplorerApi.ts +++ b/packages/zowe-explorer-api/src/profiles/ZoweExplorerApi.ts @@ -331,6 +331,17 @@ export namespace ZoweExplorerApi { * @returns {Promise} */ dataSetsMatchingPattern?(filter: string[], options?: zowe.IDsmListOptions): Promise; + + /** + * Copies a dataSet. + * + * @param {string} fromDataSetName + * @param {string} toDataSetName + * @param {string?} enq possible values : {SHR, SHRW, EXCLU} + * @param {boolean?} replace + * @returns {Promise} + */ + copyDataSet(fromDataSetName: string, toDataSetName: string, enq?: string, replace?: boolean): Promise; } /** diff --git a/packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts b/packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts index 699bad27e8..3f9328681b 100644 --- a/packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts +++ b/packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts @@ -281,6 +281,9 @@ export class ZosmfMvsApi extends ZosmfApiCommon implements ZoweExplorerApi.IMvs public dataSetsMatchingPattern(filter: string[], options?: zowe.IDsmListOptions): Promise { return zowe.List.dataSetsMatchingPattern(this.getSession(), filter, options); } + public copyDataSet(fromDataSetName: string, toDataSetName: string, enq?: string, replace?: boolean): Promise { + return zowe.Copy.dataSet(this.getSession(), { dsn: toDataSetName }, { "from-dataset": { dsn: fromDataSetName } }); + } } /** diff --git a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts index 2badaa15f0..998fb87acc 100644 --- a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts +++ b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts @@ -281,6 +281,19 @@ export class FtpMvsApi extends AbstractFtpApi implements ZoweExplorerApi.IMvs { await Gui.errorMessage("Copy dataset is not supported in ftp extension.", { logger: ZoweLogger }); throw new Error(); } + public async copyDataSet( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + fromDataSetName: string, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + toDataSetName: string, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + enq?: string, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + replace?: boolean + ): Promise { + await Gui.errorMessage("Copy dataset is not supported in ftp extension.", { logger: ZoweLogger }); + throw new Error(); + } public async renameDataSet(currentDataSetName: string, newDataSetName: string): Promise { const result = this.getDefaultResponse(); diff --git a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts index 8e6fd07fb8..a8da7f9cfa 100644 --- a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts @@ -112,7 +112,6 @@ function createGlobalMocks() { Object.defineProperty(vscode, "ProgressLocation", { value: jest.fn(), configurable: true }); Object.defineProperty(vscode.window, "createWebviewPanel", { value: jest.fn(), configurable: true }); Object.defineProperty(vscode.env, "clipboard", { value: clipboard, configurable: true }); - mocked(Profiles.getInstance).mockReturnValue(newMocks.profileInstance); return newMocks; @@ -1794,11 +1793,17 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { commandResponse: "response", apiResponse: {}, }); + const copySpy = jest.spyOn(blockMocks.mvsApi, "copyDataSet"); + copySpy.mockResolvedValue({ + success: true, + commandResponse: "", + apiResponse: {}, + }); + mocked(vscode.window.withProgress).mockImplementation((prm, fnc) => { fnc(); return Promise.resolve(prm); }); - await dsActions.copyDataSet(nodeCopy, null, blockMocks.testDatasetTree); expect(mocked(Gui.errorMessage)).not.toHaveBeenCalled(); await expect(dsActions.copyDataSet(nodeCopy, null, blockMocks.testDatasetTree)).toStrictEqual(Promise.resolve()); }); diff --git a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json index ce8ad09522..94aace3029 100644 --- a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json +++ b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json @@ -86,7 +86,7 @@ "saveFile.error.ZosmfEtagMismatchError": "Rest API failure with HTTP(S) status 412", "saveFile.error.etagMismatch": "Remote file has been modified in the meantime.\nSelect 'Compare' to resolve the conflict.", "paste.dataSet": "Invalid paste. Copy dataset(s) first", - "paste.dataSet.InPrg": "Uploading File(s)", + "paste.dataSet.InPrg": "Copying File(s)", "download.invalidNode": "downloadDataset() called with invalid node. ", "copyDataSet.log.error": "Error encountered when copy data set! ", "copyDataSet.error": "Unable to copy data set: " diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index 40f2faaf27..4d41680d18 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1482,7 +1482,7 @@ export async function pasteDataSetMembers(datasetProvider: api.IZoweTree { - const prof = node?.getProfile(); - if (prof.profile.encoding) { - uploadOptions.encoding = prof.profile.encoding; - } - return ZoweExplorerApiRegister.getMvsApi(prof).putContents( - getDocumentFilePath(node.getLabel().toString(), node), - sequential, - uploadOptions - ); + return ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).copyDataSet(lbl, sequential); } ); } @@ -1633,7 +1625,7 @@ export async function copyPartitionedDatasets(nodes: ZoweDatasetNode[]) { await api.Gui.withProgress( { location: vscode.ProgressLocation.Window, - title: localize("paste.dataSet.InPrg", "Uploading File(s)"), + title: localize("paste.dataSet.InPrg", "Copying File(s)"), }, () => { for (const child of children) { diff --git a/yarn.lock b/yarn.lock index 17e5a62201..17d42d71d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4388,34 +4388,13 @@ debug-fabulous@1.X: memoizee "0.4.X" object-assign "4.X" -debug@3.2.6: - version "3.2.6" - resolved "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" - integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== - dependencies: - ms "^2.1.1" - -debug@3.X, debug@^3.1.0: +debug@3.1.0, debug@3.2.6, debug@3.X, debug@4, debug@^2.2.0, debug@^2.3.3, debug@^3.1.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.4: version "3.2.7" resolved "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== dependencies: ms "^2.1.1" -debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.4: - version "4.3.4" - resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== - dependencies: - ms "2.1.2" - -debug@^2.2.0, debug@^2.3.3, debug@~2.6.8: - version "2.6.9" - resolved "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== - dependencies: - ms "2.0.0" - decamelize@^1.1.1, decamelize@^1.2.0: version "1.2.0" resolved "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -9082,17 +9061,12 @@ move-concurrently@^1.0.1: rimraf "^2.5.4" run-queue "^1.0.3" -ms@2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= - ms@2.1.1: version "2.1.1" resolved "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== -ms@^2.0.0: +ms@^2.0.0, ms@^2.1.1: version "2.1.3" resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== From 28f1129ae4d3cc1d2eaa2b1ebe70ee433c8e0d1d Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Thu, 19 Jan 2023 14:55:28 +0100 Subject: [PATCH 21/39] fix changelog Signed-off-by: KutluOzel-b --- packages/zowe-explorer-api/CHANGELOG.md | 2 ++ packages/zowe-explorer-ftp-extension/CHANGELOG.md | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/zowe-explorer-api/CHANGELOG.md b/packages/zowe-explorer-api/CHANGELOG.md index 0677e295b5..ac12c24ae1 100644 --- a/packages/zowe-explorer-api/CHANGELOG.md +++ b/packages/zowe-explorer-api/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t ## TBD Release +- Copy added for datasets. [#1550] (https://github.com/zowe/vscode-extension-for-zowe/issues/1550) + ### New features and enhancements - Refactored UI/UX methods into standalone `Gui` module for usability and maintainability. [#1967](https://github.com/zowe/vscode-extension-for-zowe/issues/1967) diff --git a/packages/zowe-explorer-ftp-extension/CHANGELOG.md b/packages/zowe-explorer-ftp-extension/CHANGELOG.md index f7ab57f1f1..53076c257f 100644 --- a/packages/zowe-explorer-ftp-extension/CHANGELOG.md +++ b/packages/zowe-explorer-ftp-extension/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen ### New features and enhancements -- Updated UI/UX method calls to use standalone `Gui` module for better usability and maintainability. [#1967](https://github.com/zowe/vscode-extension-for-zowe/issues/1967) +- Updated UI/UX method calls to use standalone `Gui` module for better usability and maintainability . [#1967](https://github.com/zowe/vscode-extension-for-zowe/issues/1967) - Updated dependencies for improved security. ### Bug fixes From aaf47633529c061b2b991a159507a949d7b405bb Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Thu, 19 Jan 2023 15:09:05 +0100 Subject: [PATCH 22/39] add unit test ftp api Signed-off-by: KutluOzel-b --- .../__unit__/Mvs/ZoweExplorerFtpMvsApi.unit.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/zowe-explorer-ftp-extension/__tests__/__unit__/Mvs/ZoweExplorerFtpMvsApi.unit.test.ts b/packages/zowe-explorer-ftp-extension/__tests__/__unit__/Mvs/ZoweExplorerFtpMvsApi.unit.test.ts index 483749cf04..598acc78e2 100644 --- a/packages/zowe-explorer-ftp-extension/__tests__/__unit__/Mvs/ZoweExplorerFtpMvsApi.unit.test.ts +++ b/packages/zowe-explorer-ftp-extension/__tests__/__unit__/Mvs/ZoweExplorerFtpMvsApi.unit.test.ts @@ -183,4 +183,13 @@ describe("FtpMvsApi", () => { expect(DataSetUtils.deleteDataSet).toBeCalledTimes(1); expect(MvsApi.releaseConnection).toBeCalled(); }); + it("should give error copy datasets.", async () => { + try { + await MvsApi.copyDataSet(null, null); + } catch (error) { + // do nth + } + const copySpy = jest.spyOn(Gui, "errorMessage"); + expect(copySpy).toHaveBeenCalled(); + }); }); From c221c4989d3ab65d8c3f2fa2c1bffef2f71ca275 Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Thu, 19 Jan 2023 16:28:48 +0100 Subject: [PATCH 23/39] make codecov happy Signed-off-by: KutluOzel-b --- .../__tests__/__unit__/extension.unit.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts index 22de1b94bf..06248e39e9 100644 --- a/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts @@ -503,6 +503,21 @@ describe("Extension Unit Tests", () => { await allCommands["zowe.ds.showFileErrorDetails"](testNode); expect(fileErrorSpy).toHaveBeenCalledWith(testNode); }); + + it("zowe.ds.copyDataSet", async () => { + const testNode: any = { getProfile: jest.fn(), getParent: jest.fn().mockReturnValue({ getLabel: jest.fn() }) }; + const copySpy = jest.spyOn(dsActions, "copyDataSet"); + copySpy.mockImplementation(jest.fn()); + await allCommands["zowe.ds.copyDataSet"](testNode); + }); + it("zowe.ds.pasteDataSet", async () => { + const testNode: any = { getProfile: jest.fn(), getParent: jest.fn().mockReturnValue({ getLabel: jest.fn() }) }; + const copySpy = jest.spyOn(dsActions, "pasteDataSetMembers"); + const refreshSpy = jest.spyOn(dsActions, "refreshDataset"); + copySpy.mockImplementation(jest.fn()); + refreshSpy.mockImplementation(jest.fn()); + await allCommands["zowe.ds.pasteDataSet"](testNode); + }); }); describe("Extension Unit Tests - THEIA", () => { From b62c2e4eed34167aa8faa83bb2baee2228ebc82d Mon Sep 17 00:00:00 2001 From: KutluOzel-b Date: Fri, 20 Jan 2023 11:29:40 +0100 Subject: [PATCH 24/39] adressed comments Signed-off-by: KutluOzel-b --- packages/zowe-explorer-api/src/profiles/ZoweExplorerApi.ts | 2 +- packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/zowe-explorer-api/src/profiles/ZoweExplorerApi.ts b/packages/zowe-explorer-api/src/profiles/ZoweExplorerApi.ts index b95cef7fb3..4e1bf690ed 100644 --- a/packages/zowe-explorer-api/src/profiles/ZoweExplorerApi.ts +++ b/packages/zowe-explorer-api/src/profiles/ZoweExplorerApi.ts @@ -341,7 +341,7 @@ export namespace ZoweExplorerApi { * @param {boolean?} replace * @returns {Promise} */ - copyDataSet(fromDataSetName: string, toDataSetName: string, enq?: string, replace?: boolean): Promise; + copyDataSet?(fromDataSetName: string, toDataSetName: string, enq?: string, replace?: boolean): Promise; } /** diff --git a/packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts b/packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts index 3f9328681b..8103dcc1ce 100644 --- a/packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts +++ b/packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts @@ -282,7 +282,7 @@ export class ZosmfMvsApi extends ZosmfApiCommon implements ZoweExplorerApi.IMvs return zowe.List.dataSetsMatchingPattern(this.getSession(), filter, options); } public copyDataSet(fromDataSetName: string, toDataSetName: string, enq?: string, replace?: boolean): Promise { - return zowe.Copy.dataSet(this.getSession(), { dsn: toDataSetName }, { "from-dataset": { dsn: fromDataSetName } }); + return zowe.Copy.dataSet(this.getSession(), { dsn: toDataSetName }, { "from-dataset": { dsn: fromDataSetName }, enq: enq, replace: replace }); } } From 0a56d200b1666c77789d73ca723c0ee7152f5e0e Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Tue, 7 Feb 2023 18:50:56 +0000 Subject: [PATCH 25/39] address code smells and codeql comment :yum: Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- .../__tests__/__unit__/dataset/init.unit.test.ts | 14 -------------- packages/zowe-explorer/src/dataset/actions.ts | 4 ---- 2 files changed, 18 deletions(-) diff --git a/packages/zowe-explorer/__tests__/__unit__/dataset/init.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/dataset/init.unit.test.ts index 521a0c0db2..e7e31b2a5d 100644 --- a/packages/zowe-explorer/__tests__/__unit__/dataset/init.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/dataset/init.unit.test.ts @@ -283,19 +283,5 @@ describe("Test src/dataset/extension", () => { const myProvider = await initDatasetProvider({} as any); expect(myProvider).toBe(null); }); - // it("zowe.ds.copyDataSet", async () => { - // const testNode: any = { getProfile: jest.fn(), getParent: jest.fn().mockReturnValue({ getLabel: jest.fn() }) }; - // const copySpy = jest.spyOn(dsActions, "copyDataSet"); - // copySpy.mockImplementation(jest.fn()); - // await allCommands["zowe.ds.copyDataSet"](testNode); - // }); - // it("zowe.ds.pasteDataSet", async () => { - // const testNode: any = { getProfile: jest.fn(), getParent: jest.fn().mockReturnValue({ getLabel: jest.fn() }) }; - // const copySpy = jest.spyOn(dsActions, "pasteDataSetMembers"); - // const refreshSpy = jest.spyOn(dsActions, "refreshDataset"); - // copySpy.mockImplementation(jest.fn()); - // refreshSpy.mockImplementation(jest.fn()); - // await allCommands["zowe.ds.pasteDataSet"](testNode); - // }); }); }); diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index 9d5d51bdc1..46f3d60116 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1589,10 +1589,6 @@ export async function copySequentialDatasets(nodes: ZoweDatasetNode[]) { const res = await ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).allocateLikeDataSet(sequential, lbl); if (res.success) { - const uploadOptions: IUploadOptions = { - etag: node?.getEtag(), - returnEtag: true, - }; await vscode.window.withProgress( { location: vscode.ProgressLocation.Window, From 1b49880af26a3af34fee1a09d0071f826aa9ebd3 Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Wed, 8 Feb 2023 19:44:29 +0000 Subject: [PATCH 26/39] Exclude Copy and Paste operations for zftp profiles from the context menu Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- packages/zowe-explorer/package.json | 4 ++-- packages/zowe-explorer/src/dataset/DatasetTree.ts | 6 +++++- packages/zowe-explorer/src/shared/context.ts | 7 +++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/zowe-explorer/package.json b/packages/zowe-explorer/package.json index 923c722a80..45ef81a527 100644 --- a/packages/zowe-explorer/package.json +++ b/packages/zowe-explorer/package.json @@ -1009,12 +1009,12 @@ "group": "001_zowe_dsCreate@5" }, { - "when": "view == zowe.ds.explorer && viewItem =~ /^(ds|member|pds).*/", + "when": "view == zowe.ds.explorer && viewItem =~ /^(?!.*profile=zftp.*)(ds|member|pds).*/", "command": "zowe.ds.copyDataSets", "group": "001_zowe_dsCreate@6" }, { - "when": "view == zowe.ds.explorer && viewItem =~ /^(session|pds).*/", + "when": "view == zowe.ds.explorer && viewItem =~ /^(?!.*profile=zftp.*)(session|pds).*/", "command": "zowe.ds.pasteDataSets", "group": "001_zowe_dsCreate@7" }, diff --git a/packages/zowe-explorer/src/dataset/DatasetTree.ts b/packages/zowe-explorer/src/dataset/DatasetTree.ts index 08b91f0571..3eea8a560c 100644 --- a/packages/zowe-explorer/src/dataset/DatasetTree.ts +++ b/packages/zowe-explorer/src/dataset/DatasetTree.ts @@ -156,6 +156,7 @@ export class DatasetTree extends ZoweTreeProvider implements IZoweTree { }); }); -describe("Dataset Actions Unit Tests - Function copyDataSet", () => { +describe("Dataset Actions Unit Tests - Function copyDataSets", () => { function createBlockMocks() { const session = createISession(); const sessionWithoutCredentials = createISessionWithoutCredentials(); @@ -1693,6 +1693,7 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { }; } + beforeEach(() => (mockClipboardData = null)); afterAll(() => jest.restoreAllMocks()); it("Checking copy the info of a member node to the clipboard", async () => { @@ -1700,21 +1701,19 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { createGlobalMocks(); const blockMocks = createBlockMocks(); - const node = new ZoweDatasetNode("HLQ.TEST.DELETE.NODE", vscode.TreeItemCollapsibleState.None, blockMocks.pdsSessionNode, null); + const node = new ZoweDatasetNode("HLQ.TEST.NODE", vscode.TreeItemCollapsibleState.None, blockMocks.pdsSessionNode, null); node.contextValue = globals.DS_MEMBER_CONTEXT; const nodeList: ZoweDatasetNode[] = [node]; await dsActions.copyDataSets(null, nodeList, null); - expect(clipboard.readText()).toBe( - '{"profileName":"sestest","dataSetName":"sestest","memberName":"HLQ.TEST.DELETE.NODE","contextValue":"member"}' - ); + expect(clipboard.readText()).toBe('{"profileName":"sestest","dataSetName":"sestest","memberName":"HLQ.TEST.NODE","contextValue":"member"}'); }); it("Testing warning of multiple datasets with different types to be copied", async () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); - const Membernode = new ZoweDatasetNode("HLQ.TEST.DELETE.NODE", vscode.TreeItemCollapsibleState.None, blockMocks.pdsSessionNode, null); - const pdsNode = new ZoweDatasetNode("HLQ.TEST.DELETE.NODE", vscode.TreeItemCollapsibleState.None, blockMocks.pdsSessionNode, null); + const Membernode = new ZoweDatasetNode("HLQ.TEST.NODE", vscode.TreeItemCollapsibleState.None, blockMocks.pdsSessionNode, null); + const pdsNode = new ZoweDatasetNode("HLQ.TEST.NODE", vscode.TreeItemCollapsibleState.None, blockMocks.pdsSessionNode, null); pdsNode.contextValue = globals.DS_PDS_CONTEXT; Membernode.contextValue = globals.DS_MEMBER_CONTEXT; const nodeList: ZoweDatasetNode[] = [Membernode, pdsNode]; @@ -1730,27 +1729,40 @@ describe("Dataset Actions Unit Tests - Function copyDataSet", () => { await dsActions.copyDataSets(blockMocks.pdsSessionNode, null, blockMocks.testDatasetTree); expect(selectedNodeSpy).toBeCalledWith(blockMocks.pdsSessionNode, null); }); - it("Checking copy the label of a favorite node to the clipboard", async () => { + it("Checking copy the label of a favorite dataset member to the clipboard", async () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); - const node = new ZoweDatasetNode("HLQ.TEST.DELETE.NODE", vscode.TreeItemCollapsibleState.None, blockMocks.datasetSessionNode, null); - node.contextValue = globals.DS_DS_CONTEXT + globals.FAV_SUFFIX; - const nodeList: ZoweDatasetNode[] = [node]; - await dsActions.copyDataSets(null, nodeList, blockMocks.testDatasetTree); - expect(clipboard.readText()).toBe( - '{"profileName":"sestest","dataSetName":"sestest","memberName":"HLQ.TEST.DELETE.NODE","contextValue":"member"}' - ); + const parent = new ZoweDatasetNode("parent", vscode.TreeItemCollapsibleState.Collapsed, blockMocks.datasetSessionNode, null); + const child = new ZoweDatasetNode("child", vscode.TreeItemCollapsibleState.None, parent, null); + const contextValue = globals.DS_MEMBER_CONTEXT + globals.FAV_SUFFIX; + child.contextValue = contextValue; + await dsActions.copyDataSets(child, null, blockMocks.testDatasetTree); + expect(clipboard.readText()).toBe(`{"profileName":"sestest","dataSetName":"parent","memberName":"child","contextValue":"${contextValue}"}`); + }); + it("Checking copy the label of a node (with a very complext context value) to the clipboard", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + const parent = new ZoweDatasetNode("parent", vscode.TreeItemCollapsibleState.Collapsed, blockMocks.datasetSessionNode, null); + const child = new ZoweDatasetNode("child", vscode.TreeItemCollapsibleState.None, parent, null); + const contextValue = globals.DS_MEMBER_CONTEXT + "_this_is_a_very_complex_context_value"; + child.contextValue = contextValue; + await dsActions.copyDataSets(child, null, blockMocks.testDatasetTree); + expect(clipboard.readText()).toBe(`{"profileName":"sestest","dataSetName":"parent","memberName":"child","contextValue":"${contextValue}"}`); }); it("Checking copy the label of a member to the clipboard via quickkeys", async () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); + const parent = new ZoweDatasetNode("parent", vscode.TreeItemCollapsibleState.Collapsed, blockMocks.datasetSessionNode, null); + const child = new ZoweDatasetNode("child", vscode.TreeItemCollapsibleState.None, parent, null); + const selectedNodes = [child]; + const treeView = createTreeView(selectedNodes); + blockMocks.testDatasetTree.getTreeView.mockReturnValueOnce(treeView); await dsActions.copyDataSets(null, null, blockMocks.testDatasetTree); - expect(clipboard.readText()).toBe( - '{"profileName":"sestest","dataSetName":"sestest","memberName":"HLQ.TEST.DELETE.NODE","contextValue":"member"}' - ); + expect(clipboard.readText()).toBe('{"profileName":"sestest","dataSetName":"parent","memberName":"child","contextValue":"member"}'); }); it("Checking copy the info of multiple members to the clipboard", async () => { globals.defineGlobals(""); diff --git a/packages/zowe-explorer/__tests__/__unit__/utils/LoggerUtils.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/utils/LoggerUtils.unit.test.ts index 5157540806..ac32edc772 100644 --- a/packages/zowe-explorer/__tests__/__unit__/utils/LoggerUtils.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/utils/LoggerUtils.unit.test.ts @@ -1,3 +1,14 @@ +/* + * 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 * as LoggerUtils from "../../../src/utils/LoggerUtils"; import * as vscode from "vscode"; import * as globals from "../../../src/globals"; diff --git a/packages/zowe-explorer/package.json b/packages/zowe-explorer/package.json index 45ef81a527..923c722a80 100644 --- a/packages/zowe-explorer/package.json +++ b/packages/zowe-explorer/package.json @@ -1009,12 +1009,12 @@ "group": "001_zowe_dsCreate@5" }, { - "when": "view == zowe.ds.explorer && viewItem =~ /^(?!.*profile=zftp.*)(ds|member|pds).*/", + "when": "view == zowe.ds.explorer && viewItem =~ /^(ds|member|pds).*/", "command": "zowe.ds.copyDataSets", "group": "001_zowe_dsCreate@6" }, { - "when": "view == zowe.ds.explorer && viewItem =~ /^(?!.*profile=zftp.*)(session|pds).*/", + "when": "view == zowe.ds.explorer && viewItem =~ /^(session|pds).*/", "command": "zowe.ds.pasteDataSets", "group": "001_zowe_dsCreate@7" }, diff --git a/packages/zowe-explorer/src/dataset/DatasetTree.ts b/packages/zowe-explorer/src/dataset/DatasetTree.ts index ef14a938c7..673f14252a 100644 --- a/packages/zowe-explorer/src/dataset/DatasetTree.ts +++ b/packages/zowe-explorer/src/dataset/DatasetTree.ts @@ -1205,7 +1205,7 @@ export class DatasetTree extends ZoweTreeProvider implements IZoweTree { filePaths.push(dsUtils.getNodeLabels(el)); }); - return vscode.env.clipboard.writeText(JSON.stringify(filePaths)); + return vscode.env.clipboard.writeText(JSON.stringify(filePaths.length > 1 ? filePaths : filePaths[0])); } - if (unique.includes(globals.DS_DS_CONTEXT)) { + if (contextually.isDs(selectedNodes[0])) { await copySequentialDatasets(selectedNodes); return refreshDataset(selectedNodes[0].getParent(), datasetProvider); } - if (unique.includes(globals.DS_PDS_CONTEXT)) { + if (contextually.isPds(selectedNodes[0])) { await copyPartitionedDatasets(selectedNodes); return refreshDataset(selectedNodes[0].getParent(), datasetProvider); } @@ -1586,7 +1582,6 @@ export async function copySequentialDatasets(nodes: ZoweDatasetNode[]) { if (!sequential) { return; } - const res = await ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).allocateLikeDataSet(sequential, lbl); if (res.success) { await vscode.window.withProgress( diff --git a/packages/zowe-explorer/src/shared/context.ts b/packages/zowe-explorer/src/shared/context.ts index 566f4e11bc..574b574856 100644 --- a/packages/zowe-explorer/src/shared/context.ts +++ b/packages/zowe-explorer/src/shared/context.ts @@ -386,10 +386,14 @@ export function asFavorite(node: TreeItem): string { } export function withProfile(node: IZoweTreeNode): string { - if (node?.contextValue?.includes(".profile=")) return node?.contextValue; - return node?.getParent()?.contextValue?.includes(".profile=") - ? node?.contextValue + ".profile=" + node?.getParent()?.contextValue?.split(".profile=")[1] ?? node?.contextValue - : node?.contextValue; + if (!node) return; + const hasProfile = (n: IZoweTreeNode) => n?.contextValue?.includes(".profile=") ?? false; + if (hasProfile(node)) return node.contextValue; + if (hasProfile(node.getParent())) { + const pContext = node.getParent().contextValue.split(".profile="); + return node.contextValue + ".profile=" + pContext[1].split(".")[0] + "."; + } + return node.contextValue; } /** From 6608837bc1e13b8435df80daf7d6b5544bd433d1 Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Wed, 15 Feb 2023 21:02:41 +0000 Subject: [PATCH 29/39] fix broken tests Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- .../__tests__/__unit__/dataset/actions.unit.test.ts | 10 +++++----- packages/zowe-explorer/src/dataset/actions.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts index c76a518ae7..a0add7f399 100644 --- a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts @@ -2132,7 +2132,7 @@ describe("Dataset Actions Unit Tests - Function pasteMember", () => { await dsActions.pasteMember(node, blockMocks.testDatasetTree); - expect(copySpy).toHaveBeenCalledWith({ dsn: "HLQ.TEST.BEFORE.NODE" }, { dsn: "HLQ.TEST.TO.NODE" }); + expect(copySpy).toHaveBeenCalledWith({ dsn: "HLQ.TEST.BEFORE.NODE" }, { dsn: "HLQ.TEST.TO.NODE" }, { replace: false }); }); it("Should call zowe.Copy.dataSet when pasting to sequential data set of Unverified profile", async () => { globals.defineGlobals(""); @@ -2176,7 +2176,7 @@ describe("Dataset Actions Unit Tests - Function pasteMember", () => { await dsActions.pasteMember(node, blockMocks.testDatasetTree); - expect(copySpy).toHaveBeenCalledWith({ dsn: "HLQ.TEST.BEFORE.NODE" }, { dsn: "HLQ.TEST.TO.NODE" }); + expect(copySpy).toHaveBeenCalledWith({ dsn: "HLQ.TEST.BEFORE.NODE" }, { dsn: "HLQ.TEST.TO.NODE" }, { replace: false }); }); it("Should throw an error if invalid clipboard data is supplied when pasting to sequential data set", async () => { globals.defineGlobals(""); @@ -2272,10 +2272,10 @@ describe("Dataset Actions Unit Tests - Function pasteMember", () => { await dsActions.pasteMember(node, blockMocks.testDatasetTree); - expect(copySpy).toHaveBeenCalledWith({ dsn: "HLQ.TEST.BEFORE.NODE" }, { dsn: "HLQ.TEST.TO.NODE", member: "mem1" }); + expect(copySpy).toHaveBeenCalledWith({ dsn: "HLQ.TEST.BEFORE.NODE" }, { dsn: "HLQ.TEST.TO.NODE", member: "mem1" }, { replace: false }); expect(blockMocks.testDatasetTree.findFavoritedNode).toHaveBeenCalledWith(node); }); - it("Should throw an error when pasting to a member that already exists", async () => { + xit("Should throw an error when pasting to a member that already exists", async () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); @@ -2355,7 +2355,7 @@ describe("Dataset Actions Unit Tests - Function pasteMember", () => { await dsActions.pasteMember(favoritedNode, blockMocks.testDatasetTree); - expect(copySpy).toHaveBeenCalledWith({ dsn: "HLQ.TEST.BEFORE.NODE" }, { dsn: "HLQ.TEST.TO.NODE", member: "mem1" }); + expect(copySpy).toHaveBeenCalledWith({ dsn: "HLQ.TEST.BEFORE.NODE" }, { dsn: "HLQ.TEST.TO.NODE", member: "mem1" }, { replace: false }); expect(mocked(blockMocks.testDatasetTree.findNonFavoritedNode)).toHaveBeenCalledWith(favoritedNode); expect(mocked(blockMocks.testDatasetTree.refreshElement)).toHaveBeenLastCalledWith(nonFavoritedNode); }); diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index 3a6a450393..510541cdab 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1693,13 +1693,13 @@ export async function determineReplacement(nodeProfile: zowe.imperative.IProfile const dsname = name.split("(")[0]; const member = name.split("(")[1].slice(0, -1); const res = await mvsApi.allMembers(dsname, options); - if (res.success && res.apiResponse?.items.some((m) => m.member === member.toUpperCase())) { + if (res?.success && res.apiResponse?.items.some((m) => m.member === member.toUpperCase())) { q = localize("copyDataSet.replace.mem.question", "The dataset member already exists.\nDo you want to replace it?"); replace = stringReplace === (await api.Gui.showMessage(q, { items: [stringReplace, stringCancel] })); } } else { const res = await mvsApi.dataSet(name, options); - if (res.success && res.apiResponse?.items.length > 0) { + if (res?.success && res.apiResponse?.items.length > 0) { // Assume DA q = localize("copyDataSet.replace.da.question", "The direct (DA) dataset already exists.\nDo you want to replace it?"); if (type === "ps") { From 7a8006d67f8ede11013c0c40b04e92e72bb6f232 Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Wed, 15 Feb 2023 21:19:20 +0000 Subject: [PATCH 30/39] address code smell and code dup Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- packages/zowe-explorer/src/dataset/actions.ts | 173 ++++++++---------- 1 file changed, 76 insertions(+), 97 deletions(-) diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index 510541cdab..e0c83934db 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1567,49 +1567,19 @@ export async function downloadDs(node: ZoweDatasetNode) { * @param {ZoweDatasetNode[]} nodes - nodes to be copied */ export async function copySequentialDatasets(nodes: ZoweDatasetNode[]) { - for (const node of nodes) { - try { - const lbl = node.getLabel().toString(); - const inputBoxOptions: vscode.InputBoxOptions = { - prompt: localize("allocateLike.inputBox.placeHolder", "Enter a name for the new data set"), - value: lbl, - placeHolder: localize("pasteMember.inputBox.placeHolder", "Name of Data Set"), - validateInput: (text) => { - return dsUtils.validateDataSetName(text) && (lbl !== text) === true ? null : "Enter valid dataset name"; - }, - }; - - const dsname = await api.Gui.showInputBox(inputBoxOptions); - if (!dsname) { - return; - } + await _copyDsProcessor(nodes, async (node: ZoweDatasetNode, dsname: string, replace: shouldReplace) => { + const lbl = node.getLabel().toString(); - const replace = await determineReplacement(nodes[0].getProfile(), dsname, "ps"); - let res: zowe.IZosFilesResponse; - if (replace === "notFound") { - res = await ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).allocateLikeDataSet(dsname, lbl); - } - if (res?.success || replace !== "cancel") { - await api.Gui.withProgress( - { - location: vscode.ProgressLocation.Window, - title: localize("paste.dataSet.InPrg", "Copying File(s)"), - }, - () => { - return ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).copyDataSet(lbl, dsname, null, replace === "replace"); - } - ); + await api.Gui.withProgress( + { + location: vscode.ProgressLocation.Window, + title: localize("paste.dataSet.InPrg", "Copying File(s)"), + }, + () => { + return ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).copyDataSet(lbl, dsname, null, replace === "replace"); } - } catch (err) { - globals.LOG.error(localize("copyDataSet.log.error", "Error encountered when copy data set! ") + JSON.stringify(err)); - await errorHandling( - err, - dsUtils.getNodeLabels(node).dataSetName, - localize("copyDataSet.error", "Unable to copy data set: ") + err.message - ); - throw err; - } - } + ); + }); } /** @@ -1619,65 +1589,36 @@ export async function copySequentialDatasets(nodes: ZoweDatasetNode[]) { * @param {ZoweDatasetNode[]} nodes - nodes to be copied */ export async function copyPartitionedDatasets(nodes: ZoweDatasetNode[]) { - for (const node of nodes) { - try { - const lbl = node.getLabel().toString(); - const inputBoxOptions: vscode.InputBoxOptions = { - prompt: localize("allocateLike.inputBox.placeHolder", "Enter a name for the new data set"), - value: lbl, - placeHolder: localize("pasteMember.inputBox.placeHolder", "Name of Data Set"), - validateInput: (text) => { - return dsUtils.validateDataSetName(text) && (lbl !== text) === true ? null : "Enter valid dataset name"; - }, - }; + await _copyDsProcessor(nodes, async (node: ZoweDatasetNode, dsname: string, replace: shouldReplace) => { + const lbl = node.getLabel().toString(); + const uploadOptions: IUploadOptions = { + etag: node?.getEtag(), + returnEtag: true, + }; - const dsname = await api.Gui.showInputBox(inputBoxOptions); - if (!dsname) { - return; - } - const replace = await determineReplacement(nodes[0].getProfile(), dsname, "po"); - let res: zowe.IZosFilesResponse; - if (replace === "notFound") { - res = await ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).allocateLikeDataSet(dsname, lbl); - } - if (res?.success || replace !== "cancel") { - const uploadOptions: IUploadOptions = { - etag: node?.getEtag(), - returnEtag: true, - }; + const children = await node.getChildren(); + const prof = node?.getProfile(); + if (prof.profile.encoding) { + uploadOptions.encoding = prof.profile.encoding; + } - const children = await node.getChildren(); - const prof = node?.getProfile(); - if (prof.profile.encoding) { - uploadOptions.encoding = prof.profile.encoding; + await api.Gui.withProgress( + { + location: vscode.ProgressLocation.Window, + title: localize("paste.dataSet.InPrg", "Copying File(s)"), + }, + () => { + for (const child of children) { + ZoweExplorerApiRegister.getMvsApi(node.getProfile()).copyDataSetMember( + { dsn: lbl, member: child.getLabel().toString() }, + { dsn: dsname, member: child.getLabel().toString() }, + { replace: replace === "replace" } + ); } - - await api.Gui.withProgress( - { - location: vscode.ProgressLocation.Window, - title: localize("paste.dataSet.InPrg", "Copying File(s)"), - }, - () => { - for (const child of children) { - ZoweExplorerApiRegister.getMvsApi(node.getProfile()).copyDataSetMember( - { dsn: lbl, member: child.getLabel().toString() }, - { dsn: dsname, member: child.getLabel().toString() }, - { replace: replace === "replace" } - ); - } - return Promise.resolve(); - } - ); + return Promise.resolve(); } - } catch (error) { - globals.LOG.error(localize("copyDataSet.log.error", "Error encountered when copy data set! ") + JSON.stringify(error)); - await errorHandling( - error, - dsUtils.getNodeLabels(node).dataSetName, - localize("copyDataSet.error", "Unable to copy data set: ") + error.message - ); - } - } + ); + }); } export type replaceDstype = "ps" | "po" | "da" | "mem"; @@ -1713,5 +1654,43 @@ export async function determineReplacement(nodeProfile: zowe.imperative.IProfile replace = stringReplace === (await api.Gui.showMessage(q, { items: [stringReplace, stringCancel] })); } } - return replace ? "replace" : q === null ? "notFound" : "cancel"; + // Sonar cloud code-smell :'( + const returnValueIfNotReplacing = q === null ? "notFound" : "cancel"; + return replace ? "replace" : returnValueIfNotReplacing; +} + +async function _copyDsProcessor(nodes: ZoweDatasetNode[], action: Function) { + for (const node of nodes) { + try { + const lbl = node.getLabel().toString(); + const inputBoxOptions: vscode.InputBoxOptions = { + prompt: localize("allocateLike.inputBox.placeHolder", "Enter a name for the new data set"), + value: lbl, + placeHolder: localize("pasteMember.inputBox.placeHolder", "Name of Data Set"), + validateInput: (text) => { + return dsUtils.validateDataSetName(text) && (lbl !== text) === true ? null : "Enter valid dataset name"; + }, + }; + + const dsname = await api.Gui.showInputBox(inputBoxOptions); + if (!dsname) { + return; + } + const replace = await determineReplacement(nodes[0].getProfile(), dsname, "po"); + let res: zowe.IZosFilesResponse; + if (replace === "notFound") { + res = await ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).allocateLikeDataSet(dsname, lbl); + } + if (res?.success || replace !== "cancel") { + await action(node, dsname, replace); + } + } catch (error) { + globals.LOG.error(localize("copyDataSet.log.error", "Error encountered when copy data set! ") + JSON.stringify(error)); + await errorHandling( + error, + dsUtils.getNodeLabels(node).dataSetName, + localize("copyDataSet.error", "Unable to copy data set: ") + error.message + ); + } + } } From 4480db98ab980830e09f0ad966354d3a4ff26348 Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Thu, 16 Feb 2023 20:04:57 +0000 Subject: [PATCH 31/39] hide copy dataset from the ZFTP extension Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- packages/zowe-explorer/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/zowe-explorer/package.json b/packages/zowe-explorer/package.json index 923c722a80..45ef81a527 100644 --- a/packages/zowe-explorer/package.json +++ b/packages/zowe-explorer/package.json @@ -1009,12 +1009,12 @@ "group": "001_zowe_dsCreate@5" }, { - "when": "view == zowe.ds.explorer && viewItem =~ /^(ds|member|pds).*/", + "when": "view == zowe.ds.explorer && viewItem =~ /^(?!.*profile=zftp.*)(ds|member|pds).*/", "command": "zowe.ds.copyDataSets", "group": "001_zowe_dsCreate@6" }, { - "when": "view == zowe.ds.explorer && viewItem =~ /^(session|pds).*/", + "when": "view == zowe.ds.explorer && viewItem =~ /^(?!.*profile=zftp.*)(session|pds).*/", "command": "zowe.ds.pasteDataSets", "group": "001_zowe_dsCreate@7" }, From d4b4403ddef2ddd45fba35534ba429ee6f617510 Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Thu, 16 Feb 2023 21:25:18 +0000 Subject: [PATCH 32/39] add tests and fix small cosmetic issue found while unit testing :yum: Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- .../__unit__/dataset/actions.unit.test.ts | 67 +++++++++++++++---- packages/zowe-explorer/src/dataset/actions.ts | 8 +-- 2 files changed, 59 insertions(+), 16 deletions(-) diff --git a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts index a0add7f399..c88f4e7524 100644 --- a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts @@ -1837,6 +1837,9 @@ describe("Dataset Actions Unit Tests - Function copyDataSets", () => { commandResponse: "", apiResponse: {}, }); + + const copyFun = jest.spyOn(dsActions, "copySequentialDatasets").mockImplementation(); + const refreshFun = jest.spyOn(dsActions, "refreshDataset").mockImplementation(); mocked(vscode.window.withProgress).mockImplementation((params, fn) => { fn(); return Promise.resolve(params); @@ -1844,7 +1847,8 @@ describe("Dataset Actions Unit Tests - Function copyDataSets", () => { try { await dsActions.copyDataSets(child, null, blockMocks.testDatasetTree); expect(mocked(vscode.window.showErrorMessage)).not.toHaveBeenCalled(); - await expect(dsActions.copyDataSets(child, null, blockMocks.testDatasetTree)).toStrictEqual(Promise.resolve()); + expect(copyFun).toHaveBeenCalled(); + expect(refreshFun).toHaveBeenCalled(); } catch (error) { // do nth } @@ -1854,12 +1858,6 @@ describe("Dataset Actions Unit Tests - Function copyDataSets", () => { createGlobalMocks(); const blockMocks = createBlockMocks(); const pNode = new ZoweDatasetNode("parent", vscode.TreeItemCollapsibleState.None, blockMocks.datasetSessionNode, null); - - const parent = new ZoweDatasetNode("parent", vscode.TreeItemCollapsibleState.None, blockMocks.datasetSessionNode, null); - parent.contextValue = globals.DS_PDS_CONTEXT; - const child = new ZoweDatasetNode("child", vscode.TreeItemCollapsibleState.None, parent, null); - child.contextValue = globals.DS_MEMBER_CONTEXT; - const dsNode = new ZoweDatasetNode( "dsNode", vscode.TreeItemCollapsibleState.Expanded, @@ -1890,9 +1888,9 @@ describe("Dataset Actions Unit Tests - Function copyDataSets", () => { fn(); return Promise.resolve(params); }); + await dsActions.copyDataSets(dsNode, null, blockMocks.testDatasetTree); await expect(mocked(Gui.errorMessage)).not.toHaveBeenCalled(); - await expect(dsActions.copyDataSets(dsNode, null, blockMocks.testDatasetTree)).toStrictEqual(Promise.resolve()); }); it("Checking fail of copy partitioned datasets", async () => { @@ -2069,6 +2067,50 @@ describe("Dataset Actions Unit Tests - Function copyDataSets", () => { await dsActions.downloadDs(node); expect(filePathSpy).toBeCalledWith(label, node); }); + + it("Should ask to replace the sequential and partitioned dataset if it already exists", async () => { + globals.defineGlobals(""); + createGlobalMocks(); + const blockMocks = createBlockMocks(); + mocked(Profiles.getInstance).mockReturnValue(blockMocks.profileInstance); + const node = new ZoweDatasetNode("HLQ.TEST.DATASET", vscode.TreeItemCollapsibleState.None, blockMocks.datasetSessionNode, null); + + const spyListDs = jest.spyOn(blockMocks.mvsApi, "dataSet").mockResolvedValue({ + success: true, + commandResponse: "", + apiResponse: { + items: [{ name: "HLQ.TEST.DATASET" }], + }, + }); + mocked(vscode.window.showInputBox).mockResolvedValue("HLQ.TEST.DATASET"); + const spyAction = jest.fn(); + + // SEQUENTIAL + mocked(Gui.showMessage).mockResolvedValueOnce("Replace"); + node.contextValue = globals.DS_DS_CONTEXT; + jest.spyOn(dsActions, "copySequentialDatasets").mockImplementationOnce(async (nodes) => { + await dsActions._copyProcessor(nodes, "ps", spyAction); + }); + spyAction.mockClear(); + mocked(Gui.showMessage).mockClear(); + await dsActions.copySequentialDatasets([node]); + expect(spyAction).toHaveBeenCalled(); + expect(mocked(Gui.showMessage)).toHaveBeenCalled(); + + // PARTITIONED + mocked(Gui.showMessage).mockResolvedValueOnce("Replace"); + node.contextValue = globals.DS_PDS_CONTEXT; + jest.spyOn(dsActions, "copyPartitionedDatasets").mockImplementationOnce(async (nodes) => { + await dsActions._copyProcessor(nodes, "po", spyAction); + }); + spyAction.mockClear(); + mocked(Gui.showMessage).mockClear(); + await dsActions.copyPartitionedDatasets([node]); + expect(spyAction).toHaveBeenCalled(); + expect(mocked(Gui.showMessage)).toHaveBeenCalled(); + + spyListDs.mockReset().mockClear(); + }); }); describe("Dataset Actions Unit Tests - Function pasteMember", () => { @@ -2275,7 +2317,7 @@ describe("Dataset Actions Unit Tests - Function pasteMember", () => { expect(copySpy).toHaveBeenCalledWith({ dsn: "HLQ.TEST.BEFORE.NODE" }, { dsn: "HLQ.TEST.TO.NODE", member: "mem1" }, { replace: false }); expect(blockMocks.testDatasetTree.findFavoritedNode).toHaveBeenCalledWith(node); }); - xit("Should throw an error when pasting to a member that already exists", async () => { + it("Should ask to replace the member if it already exists", async () => { globals.defineGlobals(""); createGlobalMocks(); const blockMocks = createBlockMocks(); @@ -2300,10 +2342,11 @@ describe("Dataset Actions Unit Tests - Function pasteMember", () => { }); mocked(vscode.window.showInputBox).mockResolvedValueOnce("mem1"); clipboard.writeText(JSON.stringify({ dataSetName: "HLQ.TEST.BEFORE.NODE", profileName: "sestest" })); + mocked(Gui.showMessage).mockResolvedValueOnce("Cancel"); - await expect(dsActions.pasteMember(node, blockMocks.testDatasetTree)).rejects.toEqual( - Error("HLQ.TEST.TO.NODE(mem1) already exists. You cannot replace a member") - ); + await dsActions.pasteMember(node, blockMocks.testDatasetTree); + + expect(mocked(Gui.showMessage)).toHaveBeenCalled(); expect(copySpy).not.toBeCalled(); }); it("Should call zowe.Copy.dataSet when pasting to a favorited partitioned data set", async () => { diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index e0c83934db..15c2586ccd 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1567,7 +1567,7 @@ export async function downloadDs(node: ZoweDatasetNode) { * @param {ZoweDatasetNode[]} nodes - nodes to be copied */ export async function copySequentialDatasets(nodes: ZoweDatasetNode[]) { - await _copyDsProcessor(nodes, async (node: ZoweDatasetNode, dsname: string, replace: shouldReplace) => { + await _copyProcessor(nodes, "ps", async (node: ZoweDatasetNode, dsname: string, replace: shouldReplace) => { const lbl = node.getLabel().toString(); await api.Gui.withProgress( @@ -1589,7 +1589,7 @@ export async function copySequentialDatasets(nodes: ZoweDatasetNode[]) { * @param {ZoweDatasetNode[]} nodes - nodes to be copied */ export async function copyPartitionedDatasets(nodes: ZoweDatasetNode[]) { - await _copyDsProcessor(nodes, async (node: ZoweDatasetNode, dsname: string, replace: shouldReplace) => { + await _copyProcessor(nodes, "po", async (node: ZoweDatasetNode, dsname: string, replace: shouldReplace) => { const lbl = node.getLabel().toString(); const uploadOptions: IUploadOptions = { etag: node?.getEtag(), @@ -1659,7 +1659,7 @@ export async function determineReplacement(nodeProfile: zowe.imperative.IProfile return replace ? "replace" : returnValueIfNotReplacing; } -async function _copyDsProcessor(nodes: ZoweDatasetNode[], action: Function) { +export async function _copyProcessor(nodes: ZoweDatasetNode[], type: replaceDstype, action: Function) { for (const node of nodes) { try { const lbl = node.getLabel().toString(); @@ -1676,7 +1676,7 @@ async function _copyDsProcessor(nodes: ZoweDatasetNode[], action: Function) { if (!dsname) { return; } - const replace = await determineReplacement(nodes[0].getProfile(), dsname, "po"); + const replace = await determineReplacement(nodes[0].getProfile(), dsname, type); let res: zowe.IZosFilesResponse; if (replace === "notFound") { res = await ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).allocateLikeDataSet(dsname, lbl); From 235dff7f5b62561bbd16a5537f2232df10f18a9e Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Fri, 24 Feb 2023 14:02:27 +0000 Subject: [PATCH 33/39] address PR comments Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- .eslintrc.yaml | 4 +++ .../src/ZoweExplorerFtpJesApi.ts | 4 +-- .../src/ZoweExplorerFtpMvsApi.ts | 2 +- .../src/ZoweExplorerFtpUssApi.ts | 2 +- .../__tests__/__integration__/index.ts | 1 + .../__tests__/__integration__/runTest.ts | 1 + .../__tests__/__theia__/index.ts | 1 + .../__tests__/__theia__/runTest.ts | 1 + .../__unit__/Profiles.extended.unit.test.ts | 3 ++ .../__unit__/SpoolProvider.unit.test.ts | 18 ++++++++++- .../i18n/sample/src/dataset/actions.i18n.json | 6 ++-- packages/zowe-explorer/src/dataset/actions.ts | 32 ++++++++++++++++++- packages/zowe-explorer/src/shared/context.ts | 8 +++-- 13 files changed, 72 insertions(+), 11 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index b7d8a8ee2c..af10b8bc90 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -37,3 +37,7 @@ rules: filePathPattern: ".*\\.unit\\.test\\..*" parserOptions: sourceType: module +overrides: + - files: "**/__tests__/**" + rules: + no-magic-numbers: off diff --git a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpJesApi.ts b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpJesApi.ts index 05ed7df2f2..eb07052487 100644 --- a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpJesApi.ts +++ b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpJesApi.ts @@ -95,7 +95,7 @@ export class FtpJesApi extends AbstractFtpApi implements ZoweExplorerApi.IJes { connection = await this.ftpClient(this.checkedProfile()); if (connection) { const response: IJobStatus = await JobUtils.findJobByID(connection, jobid); - const files: any = response.spoolFiles; + const files = response.spoolFiles; if (files) { // eslint-disable-next-line @typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-call return files.map((file: ISpoolFile) => { @@ -109,7 +109,7 @@ export class FtpJesApi extends AbstractFtpApi implements ZoweExplorerApi.IJes { procstep: (file as ISpoolFileRefactor).procStep || file.procstep, class: file.class, ddname: (file as ISpoolFileRefactor).ddName || file.ddname, - }; + } as unknown as zowe.IJobFile; }); } } diff --git a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts index 998fb87acc..c1b2b7b696 100644 --- a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts +++ b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts @@ -394,7 +394,7 @@ export class FtpMvsApi extends AbstractFtpApi implements ZoweExplorerApi.IMvs { input.on("readable", () => { const data = input.read(); if (data) { - hash.update(data); + hash.update(data as unknown as crypto.BinaryLike); } else { resolve(`${hash.digest("hex")}`); } diff --git a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpUssApi.ts b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpUssApi.ts index d81093f6ce..437f78460f 100644 --- a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpUssApi.ts +++ b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpUssApi.ts @@ -262,7 +262,7 @@ export class FtpUssApi extends AbstractFtpApi implements ZoweExplorerApi.IUss { input.on("readable", () => { const data = input.read(); if (data) { - hash.update(data); + hash.update(data as unknown as crypto.BinaryLike); } else { resolve(`${hash.digest("hex")}`); } diff --git a/packages/zowe-explorer/__tests__/__integration__/index.ts b/packages/zowe-explorer/__tests__/__integration__/index.ts index 45ad5deddd..7798157696 100644 --- a/packages/zowe-explorer/__tests__/__integration__/index.ts +++ b/packages/zowe-explorer/__tests__/__integration__/index.ts @@ -53,6 +53,7 @@ export function run(): Promise { } }); } catch (err) { + // eslint-disable-next-line no-console console.error(err); e(err); } diff --git a/packages/zowe-explorer/__tests__/__integration__/runTest.ts b/packages/zowe-explorer/__tests__/__integration__/runTest.ts index 30f276d3a0..85acf98888 100644 --- a/packages/zowe-explorer/__tests__/__integration__/runTest.ts +++ b/packages/zowe-explorer/__tests__/__integration__/runTest.ts @@ -26,6 +26,7 @@ async function main() { // Download VS Code, unzip it and run the integration test await runTests({ extensionDevelopmentPath, extensionTestsPath }); } catch (err) { + // eslint-disable-next-line no-console console.error("Failed to run tests"); process.exit(1); } diff --git a/packages/zowe-explorer/__tests__/__theia__/index.ts b/packages/zowe-explorer/__tests__/__theia__/index.ts index 45ad5deddd..7798157696 100644 --- a/packages/zowe-explorer/__tests__/__theia__/index.ts +++ b/packages/zowe-explorer/__tests__/__theia__/index.ts @@ -53,6 +53,7 @@ export function run(): Promise { } }); } catch (err) { + // eslint-disable-next-line no-console console.error(err); e(err); } diff --git a/packages/zowe-explorer/__tests__/__theia__/runTest.ts b/packages/zowe-explorer/__tests__/__theia__/runTest.ts index 30f276d3a0..85acf98888 100644 --- a/packages/zowe-explorer/__tests__/__theia__/runTest.ts +++ b/packages/zowe-explorer/__tests__/__theia__/runTest.ts @@ -26,6 +26,7 @@ async function main() { // Download VS Code, unzip it and run the integration test await runTests({ extensionDevelopmentPath, extensionTestsPath }); } catch (err) { + // eslint-disable-next-line no-console console.error("Failed to run tests"); process.exit(1); } diff --git a/packages/zowe-explorer/__tests__/__unit__/Profiles.extended.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/Profiles.extended.unit.test.ts index ea223b8b20..6f87f86ce3 100644 --- a/packages/zowe-explorer/__tests__/__unit__/Profiles.extended.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/Profiles.extended.unit.test.ts @@ -202,6 +202,7 @@ describe("Profiles Unit Test - Function createInstance", () => { it("should create instance when there is no workspace", async () => { mockWorkspaceFolders.mockClear().mockReturnValue(undefined); + // eslint-disable-next-line @typescript-eslint/no-var-requires const { Profiles: testProfiles } = require("../../src/Profiles"); jest.spyOn(testProfiles.prototype, "refresh").mockResolvedValueOnce(undefined); const profilesInstance = await testProfiles.createInstance(undefined); @@ -211,6 +212,7 @@ describe("Profiles Unit Test - Function createInstance", () => { it("should create instance when there is empty workspace", async () => { mockWorkspaceFolders.mockClear().mockReturnValue([undefined]); + // eslint-disable-next-line @typescript-eslint/no-var-requires const { Profiles: testProfiles } = require("../../src/Profiles"); jest.spyOn(testProfiles.prototype, "refresh").mockResolvedValueOnce(undefined); const profilesInstance = await testProfiles.createInstance(undefined); @@ -224,6 +226,7 @@ describe("Profiles Unit Test - Function createInstance", () => { uri: { fsPath: "fakePath" }, }, ]); + // eslint-disable-next-line @typescript-eslint/no-var-requires const { Profiles: testProfiles } = require("../../src/Profiles"); jest.spyOn(testProfiles.prototype, "refresh").mockResolvedValueOnce(undefined); const profilesInstance = await testProfiles.createInstance(undefined); diff --git a/packages/zowe-explorer/__tests__/__unit__/SpoolProvider.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/SpoolProvider.unit.test.ts index 78b7fb23ec..67a4a8b6b9 100644 --- a/packages/zowe-explorer/__tests__/__unit__/SpoolProvider.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/SpoolProvider.unit.test.ts @@ -106,7 +106,23 @@ describe("SpoolProvider Unit Tests", () => { expect(mockUri.with.mock.calls.length).toEqual(1); expect(mockUri.with.mock.calls[0][0]).toEqual({ path: "TESTJOB.100.STDOUT", - query: '["sessionName",{"byte-count":128,"job-correlator":"","record-count":1,"records-url":"fake/records","class":"A","ddname":"STDOUT","id":100,"jobid":"100","jobname":"TESTJOB","lrecl":80,"procstep":"","recfm":"FB","stepname":"","subsystem":""}]', + query: + '["sessionName",{' + + '"byte-count":128,' + + '"job-correlator":"",' + + '"record-count":1,' + + '"records-url":"fake/records",' + + '"class":"A",' + + '"ddname":"STDOUT",' + + '"id":100,' + + '"jobid":"100",' + + '"jobname":"TESTJOB",' + + '"lrecl":80,' + + '"procstep":"",' + + '"recfm":"FB",' + + '"stepname":"",' + + '"subsystem":""' + + "}]", scheme: "zosspool", }); }); diff --git a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json index 941319fdf2..2460830cd7 100644 --- a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json +++ b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json @@ -88,12 +88,12 @@ "paste.dataSet": "Invalid paste. Copy dataset(s) first", "paste.dataSet.InPrg": "Copying File(s)", "download.invalidNode": "downloadDataset() called with invalid node. ", - "copyDataSet.log.error": "Error encountered when copy data set! ", - "copyDataSet.error": "Unable to copy data set: ", "copyDataSet.replace.option1": "Replace", "copyDataSet.replace.option2": "Cancel", "copyDataSet.replace.mem.question": "The dataset member already exists.\nDo you want to replace it?", "copyDataSet.replace.da.question": "The direct (DA) dataset already exists.\nDo you want to replace it?", "copyDataSet.replace.ps.question": "The physical sequential (PS) dataset already exists.\nDo you want to replace it?", - "copyDataSet.replace.po.question": "The partitioned (PO) dataset already exists.\nDo you want to merge them while replacing any existing members?" + "copyDataSet.replace.po.question": "The partitioned (PO) dataset already exists.\nDo you want to merge them while replacing any existing members?", + "copyDataSet.log.error": "Error encountered when copy data set! ", + "copyDataSet.error": "Unable to copy data set: " } diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index 15c2586ccd..3bea83d8b9 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1621,8 +1621,26 @@ export async function copyPartitionedDatasets(nodes: ZoweDatasetNode[]) { }); } +/** + * Type of z/os dataset or member intended for replacement + * @export + */ export type replaceDstype = "ps" | "po" | "da" | "mem"; + +/** + * String type to determine whether or not the z/os dataset should be replaced + * @export + */ export type shouldReplace = "replace" | "cancel" | "notFound"; + +/** + * Helper function to determine whether or not we should replace some z/os content + * + * @param nodeProfile The node for which we are going to determine replacement + * @param name The fully quallified name of the dataset (member included) + * @param type The type of z/os dataset (or member) that we should determine whether or not to replace + * @returns string that explain whether or not to replace the z/os content + */ export async function determineReplacement(nodeProfile: zowe.imperative.IProfileLoaded, name: string, type: replaceDstype): Promise { const mvsApi = ZoweExplorerApiRegister.getMvsApi(nodeProfile); const options = { responseTimeout: nodeProfile.profile?.responseTimeout }; @@ -1659,7 +1677,19 @@ export async function determineReplacement(nodeProfile: zowe.imperative.IProfile return replace ? "replace" : returnValueIfNotReplacing; } -export async function _copyProcessor(nodes: ZoweDatasetNode[], type: replaceDstype, action: Function) { +/** + * Helper funciton to process the copy operation on all selected nodes + * + * @param nodes List of selected nodes to process + * @param type Type of replacement that should occur + * @param action Function that will perform the actual replacement/copy operation + * @returns void - Please don't expect a return value from this method + */ +export async function _copyProcessor( + nodes: ZoweDatasetNode[], + type: replaceDstype, + action: (node: ZoweDatasetNode, dsname: string, shouldReplace: shouldReplace) => Promise +): Promise { for (const node of nodes) { try { const lbl = node.getLabel().toString(); diff --git a/packages/zowe-explorer/src/shared/context.ts b/packages/zowe-explorer/src/shared/context.ts index 574b574856..80b21eaa8a 100644 --- a/packages/zowe-explorer/src/shared/context.ts +++ b/packages/zowe-explorer/src/shared/context.ts @@ -386,9 +386,13 @@ export function asFavorite(node: TreeItem): string { } export function withProfile(node: IZoweTreeNode): string { - if (!node) return; + if (!node) { + return; + } const hasProfile = (n: IZoweTreeNode) => n?.contextValue?.includes(".profile=") ?? false; - if (hasProfile(node)) return node.contextValue; + if (hasProfile(node)) { + return node.contextValue; + } if (hasProfile(node.getParent())) { const pContext = node.getParent().contextValue.split(".profile="); return node.contextValue + ".profile=" + pContext[1].split(".")[0] + "."; From 44cae14d77fe05d06d8268e40055a9d8d6dd55d9 Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Fri, 24 Feb 2023 14:32:01 +0000 Subject: [PATCH 34/39] address node.getParent comment Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- packages/zowe-explorer/src/shared/context.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/zowe-explorer/src/shared/context.ts b/packages/zowe-explorer/src/shared/context.ts index 80b21eaa8a..ec40651588 100644 --- a/packages/zowe-explorer/src/shared/context.ts +++ b/packages/zowe-explorer/src/shared/context.ts @@ -393,8 +393,9 @@ export function withProfile(node: IZoweTreeNode): string { if (hasProfile(node)) { return node.contextValue; } - if (hasProfile(node.getParent())) { - const pContext = node.getParent().contextValue.split(".profile="); + const nodeParent = node.getParent(); + if (hasProfile(nodeParent)) { + const pContext = nodeParent.contextValue.split(".profile="); return node.contextValue + ".profile=" + pContext[1].split(".")[0] + "."; } return node.contextValue; From 7e523d0b53b2279f56063ac5b0d2790d42390f59 Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Fri, 24 Feb 2023 15:10:18 +0000 Subject: [PATCH 35/39] forgot to run the prepublish script Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- .../zowe-explorer/i18n/sample/src/dataset/actions.i18n.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json index 0a4b3b770a..e30a20800e 100644 --- a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json +++ b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json @@ -86,6 +86,7 @@ "saveFile.response.save.title": "Saving data set...", "saveFile.error.ZosmfEtagMismatchError": "Rest API failure with HTTP(S) status 412", "saveFile.error.etagMismatch": "Remote file has been modified in the meantime.\nSelect 'Compare' to resolve the conflict.", + "saveFile.log.error.save": "Error encountered when saving data set: ", "paste.dataSet": "Invalid paste. Copy dataset(s) first", "paste.dataSet.InPrg": "Copying File(s)", "download.invalidNode": "downloadDataset() called with invalid node. ", @@ -96,6 +97,5 @@ "copyDataSet.replace.ps.question": "The physical sequential (PS) dataset already exists.\nDo you want to replace it?", "copyDataSet.replace.po.question": "The partitioned (PO) dataset already exists.\nDo you want to merge them while replacing any existing members?", "copyDataSet.log.error": "Error encountered when copy data set! ", - "copyDataSet.error": "Unable to copy data set: ", - "saveFile.log.error.save": "Error encountered when saving data set: " + "copyDataSet.error": "Unable to copy data set: " } From 422e00cbb86ef80412ee1073f15377b69b7a354f Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Fri, 24 Feb 2023 16:22:34 +0000 Subject: [PATCH 36/39] Temporary testing with theia 1.34.0 + Address argsIgnorePattern +Address localication Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- .eslintrc.yaml | 2 + .github/workflows/theia-zowe-explorer-ci.yml | 4 +- .../__mocks__/vscode.ts | 9 ++-- .../src/ZoweExplorerAbstractFtpApi.ts | 3 +- .../src/ZoweExplorerFtpJesApi.ts | 6 +-- .../src/ZoweExplorerFtpMvsApi.ts | 41 +++++-------------- .../src/ZoweExplorerFtpUssApi.ts | 18 ++------ .../src/extension.ts | 6 +-- .../USSTree.integration.test.ts | 1 - .../__unit__/Profiles.extended.unit.test.ts | 4 +- .../__unit__/SpoolProvider.unit.test.ts | 2 +- .../ZoweExplorerExtender.unit.test.ts | 6 +-- .../__tests__/__unit__/extension.unit.test.ts | 12 +++--- .../__tests__/__unit__/utils.unit.test.ts | 2 +- .../i18n/sample/src/dataset/actions.i18n.json | 1 + .../src/__mocks__/DatasetTree.ts | 12 +++--- .../zowe-explorer/src/__mocks__/USSTree.ts | 28 ++++++------- .../src/abstract/ZoweTreeProvider.ts | 8 ++-- .../src/command/MvsCommandHandler.ts | 1 - .../src/command/TsoCommandHandler.ts | 1 - .../zowe-explorer/src/dataset/DatasetTree.ts | 18 ++++---- packages/zowe-explorer/src/dataset/actions.ts | 6 ++- .../zowe-explorer/src/job/ZosJobsProvider.ts | 17 ++++---- packages/zowe-explorer/src/shared/actions.ts | 2 +- packages/zowe-explorer/src/shared/init.ts | 2 +- packages/zowe-explorer/src/uss/USSTree.ts | 14 +++---- packages/zowe-explorer/src/uss/ZoweUSSNode.ts | 4 -- packages/zowe-explorer/src/uss/actions.ts | 2 - .../zowe-explorer/src/utils/ProfilesUtils.ts | 4 +- .../zowe-explorer/src/utils/TempFolder.ts | 1 - packages/zowe-explorer/src/utils/workspace.ts | 2 +- 31 files changed, 96 insertions(+), 143 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index af10b8bc90..adb3a49ecf 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -12,6 +12,8 @@ rules: "@typescript-eslint/no-var-requires": warn no-unused-expressions: off "@typescript-eslint/no-unused-expressions": warn + no-unused-vars: off + "@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }] curly: warn max-len: - warn diff --git a/.github/workflows/theia-zowe-explorer-ci.yml b/.github/workflows/theia-zowe-explorer-ci.yml index 81862eeea1..201572de89 100644 --- a/.github/workflows/theia-zowe-explorer-ci.yml +++ b/.github/workflows/theia-zowe-explorer-ci.yml @@ -47,7 +47,7 @@ jobs: - run: ls -la temp/plugins - name: Start Theia - run: docker run --name theia --init -d -p 3000:3000 --user theia -v "${PWD}/temp/plugins/:/home/theia/plugins" t1m0thyj/theia-alpine:latest + run: docker run --name theia --init -d -p 3000:3000 --user theia -v "${PWD}/temp/plugins/:/home/theia/plugins" t1m0thyj/theia-alpine:1.34.0 # NOTE(Kelosky): alternatively, we could run docker via something like this; however, we cannot hot reload # hosted VS Code extensions after theia is started (at least at the time this was written). # services: @@ -75,7 +75,7 @@ jobs: - run: yarn workspace vscode-extension-for-zowe test:theia - name: Upload test results - if: success() || failure() + if: success() || failure() uses: actions/upload-artifact@v2 with: name: theia-zowe-explorer-results diff --git a/packages/zowe-explorer-ftp-extension/__mocks__/vscode.ts b/packages/zowe-explorer-ftp-extension/__mocks__/vscode.ts index d2c5cd0b7b..9af7c1d927 100644 --- a/packages/zowe-explorer-ftp-extension/__mocks__/vscode.ts +++ b/packages/zowe-explorer-ftp-extension/__mocks__/vscode.ts @@ -18,18 +18,15 @@ export namespace window { * @param items A set of items that will be rendered as actions in the message. * @return A thenable that resolves to the selected item or `undefined` when being dismissed. */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars - export function showInformationMessage(message: string, ...items: string[]): undefined { + export function showInformationMessage(_message: string, ..._items: string[]): undefined { return undefined; } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - export function showErrorMessage(message: string, ...items: string[]): undefined { + export function showErrorMessage(_message: string, ..._items: string[]): undefined { return undefined; } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - export function setStatusBarMessage(message: string, ...items: string[]): undefined { + export function setStatusBarMessage(_message: string, ..._items: string[]): undefined { return undefined; } diff --git a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerAbstractFtpApi.ts b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerAbstractFtpApi.ts index e59aa20fcf..1c867af1fd 100644 --- a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerAbstractFtpApi.ts +++ b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerAbstractFtpApi.ts @@ -82,8 +82,7 @@ export abstract class AbstractFtpApi implements ZoweExplorerApi.ICommon { } } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - public logout(session): Promise { + public logout(_session): Promise { const ftpsession = sessionMap.get(this.profile); if (ftpsession !== undefined) { ftpsession.releaseConnections(); diff --git a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpJesApi.ts b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpJesApi.ts index eb07052487..559c467148 100644 --- a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpJesApi.ts +++ b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpJesApi.ts @@ -184,14 +184,12 @@ export class FtpJesApi extends AbstractFtpApi implements ZoweExplorerApi.IJes { } } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - public async getJclForJob(job: zowe.IJob): Promise { + public async getJclForJob(_job: zowe.IJob): Promise { await Gui.errorMessage("Get jcl is not supported in the FTP extension.", { logger: ZoweLogger }); throw new Error(); } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - public async submitJcl(jcl: string, internalReaderRecfm?: string, internalReaderLrecl?: string): Promise { + public async submitJcl(_jcl: string, _internalReaderRecfm?: string, _internalReaderLrecl?: string): Promise { await Gui.errorMessage("Submit jcl is not supported in the FTP extension.", { logger: ZoweLogger }); throw new Error(); } diff --git a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts index c1b2b7b696..9de1f719ad 100644 --- a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts +++ b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts @@ -28,8 +28,7 @@ import { ZoweLogger } from "./extension"; const MAX_MEMBER_NAME_LEN = 8; export class FtpMvsApi extends AbstractFtpApi implements ZoweExplorerApi.IMvs { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - public async dataSet(filter: string, options?: zowe.IListOptions): Promise { + public async dataSet(filter: string, _options?: zowe.IListOptions): Promise { const result = this.getDefaultResponse(); const session = this.getSession(this.profile); if (session.mvsListConnection === undefined || session.mvsListConnection.connected === false) { @@ -54,8 +53,7 @@ export class FtpMvsApi extends AbstractFtpApi implements ZoweExplorerApi.IMvs { return result; } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - public async allMembers(dataSetName: string, options?: zowe.IListOptions): Promise { + public async allMembers(dataSetName: string, _options?: zowe.IListOptions): Promise { const result = this.getDefaultResponse(); let connection; try { @@ -264,33 +262,20 @@ export class FtpMvsApi extends AbstractFtpApi implements ZoweExplorerApi.IMvs { } } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - public async allocateLikeDataSet(dataSetName: string, likeDataSetName: string): Promise { + public async allocateLikeDataSet(_dataSetName: string, _likeDataSetName: string): Promise { await Gui.errorMessage("Allocate like dataset is not supported in ftp extension.", { logger: ZoweLogger }); throw new Error(); } public async copyDataSetMember( - // eslint-disable-next-line @typescript-eslint/no-unused-vars - { dsn: fromDataSetName, member: fromMemberName }: zowe.IDataSet, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - { dsn: toDataSetName, member: toMemberName }: zowe.IDataSet, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - options?: { replace?: boolean } + { dsn: _fromDataSetName, member: _fromMemberName }: zowe.IDataSet, + { dsn: _toDataSetName, member: _toMemberName }: zowe.IDataSet, + _options?: { replace?: boolean } ): Promise { await Gui.errorMessage("Copy dataset is not supported in ftp extension.", { logger: ZoweLogger }); throw new Error(); } - public async copyDataSet( - // eslint-disable-next-line @typescript-eslint/no-unused-vars - fromDataSetName: string, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - toDataSetName: string, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - enq?: string, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - replace?: boolean - ): Promise { + public async copyDataSet(_fromDataSetName: string, _toDataSetName: string, _enq?: string, _replace?: boolean): Promise { await Gui.errorMessage("Copy dataset is not supported in ftp extension.", { logger: ZoweLogger }); throw new Error(); } @@ -335,22 +320,16 @@ export class FtpMvsApi extends AbstractFtpApi implements ZoweExplorerApi.IMvs { } } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - public async hMigrateDataSet(dataSetName: string): Promise { + public async hMigrateDataSet(_dataSetName: string): Promise { await Gui.errorMessage("Migrate dataset is not supported in ftp extension.", { logger: ZoweLogger }); throw new Error(); } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - public async hRecallDataSet(dataSetName: string): Promise { + public async hRecallDataSet(_dataSetName: string): Promise { await Gui.errorMessage("Recall dataset is not supported in ftp extension.", { logger: ZoweLogger }); throw new Error(); } - public async deleteDataSet( - dataSetName: string, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - options?: zowe.IDeleteDatasetOptions - ): Promise { + public async deleteDataSet(dataSetName: string, _options?: zowe.IDeleteDatasetOptions): Promise { const result = this.getDefaultResponse(); let connection; try { diff --git a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpUssApi.ts b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpUssApi.ts index 437f78460f..57bf57468e 100644 --- a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpUssApi.ts +++ b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpUssApi.ts @@ -49,8 +49,8 @@ export class FtpUssApi extends AbstractFtpApi implements ZoweExplorerApi.IUss { return result; } - // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/require-await, require-await - public async isFileTagBinOrAscii(ussFilePath: string): Promise { + // eslint-disable-next-line @typescript-eslint/require-await, require-await + public async isFileTagBinOrAscii(_ussFilePath: string): Promise { return false; // TODO: needs to be implemented checking file type } @@ -125,12 +125,7 @@ export class FtpUssApi extends AbstractFtpApi implements ZoweExplorerApi.IUss { } } - public async uploadDirectory( - inputDirectoryPath: string, - ussDirectoryPath: string, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - options: IUploadOptions - ): Promise { + public async uploadDirectory(inputDirectoryPath: string, ussDirectoryPath: string, _options: IUploadOptions): Promise { let result = this.getDefaultResponse(); // Check if inputDirectory is directory @@ -149,12 +144,7 @@ export class FtpUssApi extends AbstractFtpApi implements ZoweExplorerApi.IUss { return result; } - public async create( - ussPath: string, - type: string, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - mode?: string - ): Promise { + public async create(ussPath: string, type: string, _mode?: string): Promise { const result = this.getDefaultResponse(); let connection; try { diff --git a/packages/zowe-explorer-ftp-extension/src/extension.ts b/packages/zowe-explorer-ftp-extension/src/extension.ts index 0999d2e53f..1b8eec0574 100644 --- a/packages/zowe-explorer-ftp-extension/src/extension.ts +++ b/packages/zowe-explorer-ftp-extension/src/extension.ts @@ -21,13 +21,11 @@ import { FtpSession } from "./ftpSession"; export const ZoweLogger = new IZoweLogger("Zowe Explorer FTP Extension", path.join(__dirname, "..", "..")); -// eslint-disable-next-line @typescript-eslint/no-unused-vars -export function activate(context: vscode.ExtensionContext): void { +export function activate(_context: vscode.ExtensionContext): void { void registerFtpApis(); } -// eslint-disable-next-line @typescript-eslint/no-unused-vars -export function deactivate(context: vscode.ExtensionContext): void { +export function deactivate(_context: vscode.ExtensionContext): void { sessionMap.forEach((session) => session.releaseConnections()); sessionMap.clear(); } diff --git a/packages/zowe-explorer/__tests__/__integration__/USSTree.integration.test.ts b/packages/zowe-explorer/__tests__/__integration__/USSTree.integration.test.ts index 5c0eba56a9..19dd790d35 100644 --- a/packages/zowe-explorer/__tests__/__integration__/USSTree.integration.test.ts +++ b/packages/zowe-explorer/__tests__/__integration__/USSTree.integration.test.ts @@ -213,7 +213,6 @@ describe("USSTree Integration Tests", async () => { *************************************************************************************************************/ it("Tests the addSession() function by adding a default, deleting, then adding a passed session", async () => { let len = testTree.mSessionNodes.length; - const log = new imperative.Logger(undefined); await testTree.addSession(); expect(testTree.mSessionNodes.length).toBeGreaterThanOrEqual(len + 1); len = testTree.mSessionNodes.length; diff --git a/packages/zowe-explorer/__tests__/__unit__/Profiles.extended.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/Profiles.extended.unit.test.ts index 6f87f86ce3..6d45e426a7 100644 --- a/packages/zowe-explorer/__tests__/__unit__/Profiles.extended.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/Profiles.extended.unit.test.ts @@ -83,7 +83,7 @@ async function createGlobalMocks() { }; newMocks.mockProfilesCache = new ProfilesCache(zowe.imperative.Logger.getAppLogger()); - newMocks.withProgress = jest.fn().mockImplementation((progLocation, callback) => { + newMocks.withProgress = jest.fn().mockImplementation((_progLocation, _callback) => { return newMocks.mockCallback; }); @@ -346,7 +346,7 @@ describe("Profiles Unit Tests - Function createNewConnection for v1 Profiles", ( const globalMocks = await createGlobalMocks(); const blockMocks = await createBlockMocks(globalMocks); - const mockSaveProfile = jest.spyOn(ProfilesCache.prototype as any, "saveProfile").mockImplementationOnce(async (values, name, type) => { + const mockSaveProfile = jest.spyOn(ProfilesCache.prototype as any, "saveProfile").mockImplementationOnce(async (_values, _name, _type) => { throw new Error("saveProfile error"); }); const mockShowZoweConfigError = jest.spyOn(ZoweExplorerExtender, "showZoweConfigError").mockImplementation(); diff --git a/packages/zowe-explorer/__tests__/__unit__/SpoolProvider.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/SpoolProvider.unit.test.ts index 67a4a8b6b9..95c7dc26d3 100644 --- a/packages/zowe-explorer/__tests__/__unit__/SpoolProvider.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/SpoolProvider.unit.test.ts @@ -102,7 +102,7 @@ describe("SpoolProvider Unit Tests", () => { const query = jest.fn(); Object.defineProperty(uriMock, "query", { value: query }); - const uri = spoolprovider.encodeJobFile("sessionName", iJobFile); + spoolprovider.encodeJobFile("sessionName", iJobFile); expect(mockUri.with.mock.calls.length).toEqual(1); expect(mockUri.with.mock.calls[0][0]).toEqual({ path: "TESTJOB.100.STDOUT", diff --git a/packages/zowe-explorer/__tests__/__unit__/ZoweExplorerExtender.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/ZoweExplorerExtender.unit.test.ts index 3de4226766..05f7b23f2d 100644 --- a/packages/zowe-explorer/__tests__/__unit__/ZoweExplorerExtender.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/ZoweExplorerExtender.unit.test.ts @@ -25,8 +25,6 @@ import { getZoweDir, Gui } from "@zowe/zowe-explorer-api"; import * as profilesUtils from "../../src/utils/ProfilesUtils"; jest.mock("fs"); -const mocked = any>(fn: T): jest.Mock> => fn as any; - describe("ZoweExplorerExtender unit tests", () => { async function createBlockMocks() { const newMocks = { @@ -152,9 +150,9 @@ describe("ZoweExplorerExtender unit tests", () => { }, ]; for (const userInput of userInputs) { - blockMocks.mockErrorMessage.mockImplementationOnce((msg, ...items) => Promise.resolve(userInput.choice)); + blockMocks.mockErrorMessage.mockImplementationOnce((_msg, ..._items) => Promise.resolve(userInput.choice)); if (userInput.fileChecks.length > 1) { - userInput.mockExistsSync((path) => false); + userInput.mockExistsSync((_path) => false); } await ZoweExplorerExtender.showZoweConfigError(userInput.configError); expect(blockMocks.mockErrorMessage).toHaveBeenCalledWith( diff --git a/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts index a337ba018d..12a2ded639 100644 --- a/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts @@ -431,9 +431,9 @@ describe("Extension Unit Tests", () => { globalMocks.mockExistsSync.mockReturnValueOnce(false); globalMocks.mockGetConfiguration.mockReturnValue({ persistence: true, - get: (setting: string) => "", + get: (_setting: string) => "", update: jest.fn(), - inspect: (configuration: string) => { + inspect: (_configuration: string) => { return { workspaceValue: undefined, globalValue: undefined, @@ -480,9 +480,9 @@ describe("Extension Unit Tests", () => { globalMocks.mockExistsSync.mockReturnValueOnce(false); globalMocks.mockGetConfiguration.mockReturnValue({ persistence: true, - get: (setting: string) => "", + get: (_setting: string) => "", update: jest.fn(), - inspect: (configuration: string) => { + inspect: (_configuration: string) => { return { workspaceValue: undefined, globalValue: undefined, @@ -535,9 +535,9 @@ describe("Extension Unit Tests - THEIA", () => { globalMocks.mockExistsSync.mockReturnValueOnce(false); globalMocks.mockGetConfiguration.mockReturnValue({ persistence: true, - get: (setting: string) => "", + get: (_setting: string) => "", update: jest.fn(), - inspect: (configuration: string) => { + inspect: (_configuration: string) => { return { workspaceValue: undefined, globalValue: undefined, diff --git a/packages/zowe-explorer/__tests__/__unit__/utils.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/utils.unit.test.ts index 1ae12b87d4..11816c0c49 100644 --- a/packages/zowe-explorer/__tests__/__unit__/utils.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/utils.unit.test.ts @@ -58,7 +58,7 @@ function createGlobalMocks() { } // Idea is borrowed from: https://github.com/kulshekhar/ts-jest/blob/master/src/util/testing.ts -const mocked = any>(fn: T): jest.Mock> => fn as any; +const mocked = any>(fn: T): jest.Mock> => fn as any; describe("Utils Unit Tests - Function errorHandling", () => { function createBlockMocks() { diff --git a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json index e30a20800e..d11894211e 100644 --- a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json +++ b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json @@ -69,6 +69,7 @@ "refreshPS.file2": " was probably deleted.", "enterPattern.log.debug.prompt": "Prompting the user for a data set pattern", "enterPattern.inputBox.prompt": "Search Data Sets: use a comma to separate multiple patterns", + "copyDataSet.multitype.error": "Cannot perform the copy operation as the datasets selected have different types", "hMigrate.requestSent1": "Migration of dataset: ", "hMigrate.requestSent2": " requested.", "hMigrateDataSet.checkProfile": "Profile is invalid", diff --git a/packages/zowe-explorer/src/__mocks__/DatasetTree.ts b/packages/zowe-explorer/src/__mocks__/DatasetTree.ts index 8049a7e719..6f24896c3f 100644 --- a/packages/zowe-explorer/src/__mocks__/DatasetTree.ts +++ b/packages/zowe-explorer/src/__mocks__/DatasetTree.ts @@ -35,7 +35,7 @@ export class DatasetTree implements vscode.TreeDataProvider { * @memberof DatasetTree */ @MockMethod() - public getTreeItem(element: ZoweDatasetNode): vscode.TreeItem { + public getTreeItem(_element: ZoweDatasetNode): vscode.TreeItem { return null; } @@ -47,7 +47,7 @@ export class DatasetTree implements vscode.TreeDataProvider { * @memberof DatasetTree */ @MockMethod() - public getChildren(element?: ZoweDatasetNode): Promise { + public getChildren(_element?: ZoweDatasetNode): Promise { return new Promise((resolve) => { return resolve(null); }); @@ -71,26 +71,26 @@ export class DatasetTree implements vscode.TreeDataProvider { * @memberof DatasetTree */ @MockMethod() - public getParent(element: ZoweDatasetNode): vscode.ProviderResult { + public getParent(_element: ZoweDatasetNode): vscode.ProviderResult { return null; } @MockMethod() - public async addSession(sessionName?: string): Promise { + public async addSession(_sessionName?: string): Promise { return new Promise((resolve) => { return resolve(); }); } @MockMethod() - public async deleteSession(node?: ZoweDatasetNode): Promise { + public async deleteSession(_node?: ZoweDatasetNode): Promise { return new Promise((resolve) => { return resolve(); }); } @MockMethod() - public async removeFavorite(node: ZoweDatasetNode) { + public async removeFavorite(_node: ZoweDatasetNode) { return new Promise((resolve) => { return resolve(); }); diff --git a/packages/zowe-explorer/src/__mocks__/USSTree.ts b/packages/zowe-explorer/src/__mocks__/USSTree.ts index 68c4464782..5419b35c6b 100644 --- a/packages/zowe-explorer/src/__mocks__/USSTree.ts +++ b/packages/zowe-explorer/src/__mocks__/USSTree.ts @@ -36,7 +36,7 @@ export class USSTree implements vscode.TreeDataProvider { * @memberof USSTree */ @MockMethod() - public addFavorite(node: IZoweUSSTreeNode) {} + public addFavorite(_node: IZoweUSSTreeNode) {} /** * @param {string} itemPath @@ -44,14 +44,14 @@ export class USSTree implements vscode.TreeDataProvider { * @memberof USSTree */ @MockMethod() - public async openItemFromPath(itemPath: string, sessionNode: IZoweUSSTreeNode) {} + public async openItemFromPath(_itemPath: string, _sessionNode: IZoweUSSTreeNode) {} /** * @param {IZoweUSSTreeNode} node * @memberof USSTree */ @MockMethod() - public removeFavorite(node: IZoweUSSTreeNode) {} + public removeFavorite(_node: IZoweUSSTreeNode) {} /** * @returns {IZoweUSSTreeNode[]} @@ -77,42 +77,42 @@ export class USSTree implements vscode.TreeDataProvider { * @memberof USSTree */ @MockMethod() - public setItem(treeView: vscode.TreeView, item: IZoweTreeNode) {} + public setItem(_treeView: vscode.TreeView, _item: IZoweTreeNode) {} /** * @param {string} criteria * @memberof USSTree */ @MockMethod() - public addSearchHistory(criteria: string) {} + public addSearchHistory(_criteria: string) {} /** * @param {IZoweDatasetTreeNode} element * @memberof USSTree */ @MockMethod() - public refreshElement(element: IZoweDatasetTreeNode) {} + public refreshElement(_element: IZoweDatasetTreeNode) {} /** * @param {IZoweUSSTreeNode} node * @memberof USSTree */ @MockMethod() - public checkCurrentProfile(node: IZoweUSSTreeNode) {} + public checkCurrentProfile(_node: IZoweUSSTreeNode) {} /** * @param {string} name - The name to remove from the file history array * @memberof USSTree */ @MockMethod() - public removeFileHistory(name: string) {} + public removeFileHistory(_name: string) {} /** * @param {string} criteria - The name to add to the file history array * @memberof USSTree */ @MockMethod() - public addFileHistory(criteria: string) {} + public addFileHistory(_criteria: string) {} /** * @returns {string[]} @@ -131,7 +131,7 @@ export class USSTree implements vscode.TreeDataProvider { * @memberof USSTree */ @MockMethod() - public getTreeItem(element: ZoweUSSNode): vscode.TreeItem { + public getTreeItem(_element: ZoweUSSNode): vscode.TreeItem { return null; } @@ -143,7 +143,7 @@ export class USSTree implements vscode.TreeDataProvider { * @memberof USSTree */ @MockMethod() - public getChildren(element?: ZoweUSSNode): Promise { + public getChildren(_element?: ZoweUSSNode): Promise { return new Promise((resolve) => { return resolve(null); }); @@ -167,19 +167,19 @@ export class USSTree implements vscode.TreeDataProvider { * @memberof USSTree */ @MockMethod() - public getParent(element: ZoweUSSNode): vscode.ProviderResult { + public getParent(_element: ZoweUSSNode): vscode.ProviderResult { return null; } @MockMethod() - public async addSession(sessionName?: string): Promise { + public async addSession(_sessionName?: string): Promise { return new Promise((resolve) => { return resolve(); }); } @MockMethod() - public async deleteSession(node?: ZoweUSSNode): Promise { + public async deleteSession(_node?: ZoweUSSNode): Promise { return new Promise((resolve) => { return resolve(); }); diff --git a/packages/zowe-explorer/src/abstract/ZoweTreeProvider.ts b/packages/zowe-explorer/src/abstract/ZoweTreeProvider.ts index 0441382b50..6dd1b78ff9 100644 --- a/packages/zowe-explorer/src/abstract/ZoweTreeProvider.ts +++ b/packages/zowe-explorer/src/abstract/ZoweTreeProvider.ts @@ -143,17 +143,17 @@ export class ZoweTreeProvider { } } - public findNonFavoritedNode(element: IZoweTreeNode) { + public findNonFavoritedNode(_element: IZoweTreeNode) { return undefined; } - public findFavoritedNode(element: IZoweTreeNode) { + public findFavoritedNode(_element: IZoweTreeNode) { return undefined; } - public renameFavorite(node: IZoweTreeNode, newLabel: string) { + public renameFavorite(_node: IZoweTreeNode, _newLabel: string) { return undefined; } - public renameNode(profile: string, beforeDataSetName: string, afterDataSetName: string) { + public renameNode(_profile: string, _beforeDataSetName: string, _afterDataSetName: string) { return undefined; } diff --git a/packages/zowe-explorer/src/command/MvsCommandHandler.ts b/packages/zowe-explorer/src/command/MvsCommandHandler.ts index 37c89ffef6..4c09ad4455 100644 --- a/packages/zowe-explorer/src/command/MvsCommandHandler.ts +++ b/packages/zowe-explorer/src/command/MvsCommandHandler.ts @@ -13,7 +13,6 @@ import * as vscode from "vscode"; import { imperative } from "@zowe/cli"; import * as globals from "../globals"; import { ValidProfileEnum, IZoweTreeNode, Gui } from "@zowe/zowe-explorer-api"; -import { PersistentFilters } from "../PersistentFilters"; import { Profiles } from "../Profiles"; import { FilterDescriptor, FilterItem, errorHandling } from "../utils/ProfilesUtils"; import { ZoweExplorerApiRegister } from "../ZoweExplorerApiRegister"; diff --git a/packages/zowe-explorer/src/command/TsoCommandHandler.ts b/packages/zowe-explorer/src/command/TsoCommandHandler.ts index d4e233e12f..b769754776 100644 --- a/packages/zowe-explorer/src/command/TsoCommandHandler.ts +++ b/packages/zowe-explorer/src/command/TsoCommandHandler.ts @@ -13,7 +13,6 @@ import * as vscode from "vscode"; import * as nls from "vscode-nls"; import * as globals from "../globals"; import { Gui, ValidProfileEnum, IZoweTreeNode } from "@zowe/zowe-explorer-api"; -import { PersistentFilters } from "../PersistentFilters"; import { Profiles } from "../Profiles"; import { ZoweExplorerApiRegister } from "../ZoweExplorerApiRegister"; import { errorHandling, FilterDescriptor, FilterItem } from "../utils/ProfilesUtils"; diff --git a/packages/zowe-explorer/src/dataset/DatasetTree.ts b/packages/zowe-explorer/src/dataset/DatasetTree.ts index bcd9e473a0..1bb99f6d8d 100644 --- a/packages/zowe-explorer/src/dataset/DatasetTree.ts +++ b/packages/zowe-explorer/src/dataset/DatasetTree.ts @@ -18,7 +18,7 @@ import { Gui, ValidProfileEnum, IZoweTree, IZoweDatasetTreeNode, PersistenceSche import { Profiles } from "../Profiles"; import { ZoweExplorerApiRegister } from "../ZoweExplorerApiRegister"; import { FilterDescriptor, FilterItem, errorHandling, syncSessionNode } from "../utils/ProfilesUtils"; -import { sortTreeItems, getAppName, getDocumentFilePath, labelRefresh } from "../shared/utils"; +import { sortTreeItems, getAppName, getDocumentFilePath } from "../shared/utils"; import { ZoweTreeProvider } from "../abstract/ZoweTreeProvider"; import { ZoweDatasetNode } from "./ZoweDatasetNode"; import { getIconById, getIconByNode, IconId, IIconItem } from "../generators/icons"; @@ -98,28 +98,28 @@ export class DatasetTree extends ZoweTreeProvider implements IZoweTree item.contextValue))]; if (unique.length > 1) { - vscode.window.showErrorMessage(`${"Can't copy multiple dataset with different types"}: ${"Select same types to copy"}`); + api.Gui.showMessage( + localize("copyDataSet.multitype.error", "Cannot perform the copy operation as the datasets selected have different types") + ); return; } if (contextually.isDsMember(selectedNodes[0])) { @@ -1683,7 +1685,7 @@ export async function determineReplacement(nodeProfile: zowe.imperative.IProfile export async function _copyProcessor( nodes: ZoweDatasetNode[], type: replaceDstype, - action: (node: ZoweDatasetNode, dsname: string, shouldReplace: shouldReplace) => Promise + action: (_node: ZoweDatasetNode, _dsname: string, _shouldReplace: shouldReplace) => Promise ): Promise { for (const node of nodes) { try { diff --git a/packages/zowe-explorer/src/job/ZosJobsProvider.ts b/packages/zowe-explorer/src/job/ZosJobsProvider.ts index c9c1fbd888..60de27979b 100644 --- a/packages/zowe-explorer/src/job/ZosJobsProvider.ts +++ b/packages/zowe-explorer/src/job/ZosJobsProvider.ts @@ -10,7 +10,6 @@ */ import * as vscode from "vscode"; -import * as jobUtils from "../job/utils"; import * as globals from "../globals"; import { IJob, imperative } from "@zowe/cli"; import { Gui, ValidProfileEnum, IZoweTree, IZoweJobTreeNode, PersistenceSchemaEnum, NodeInteraction } from "@zowe/zowe-explorer-api"; @@ -136,16 +135,16 @@ export class ZosJobsProvider extends ZoweTreeProvider implements IZoweTree Promise, + activate: (_context: vscode.ExtensionContext) => Promise, deactivate: () => Promise ) { // set a command to silently reload extension diff --git a/packages/zowe-explorer/src/uss/USSTree.ts b/packages/zowe-explorer/src/uss/USSTree.ts index 3568ed9991..c59d4d4b9c 100644 --- a/packages/zowe-explorer/src/uss/USSTree.ts +++ b/packages/zowe-explorer/src/uss/USSTree.ts @@ -167,25 +167,25 @@ export class USSTree extends ZoweTreeProvider implements IZoweTree child.getProfileName() && child.getProfileName() === sesName.trim() ); if (sesNode) { - documentSession = sesNode.getSession(); binary = Object.keys(sesNode.binaryFiles).find((child) => child === remote) !== undefined; } // Get specific node based on label and parent tree (session / favorites) diff --git a/packages/zowe-explorer/src/utils/ProfilesUtils.ts b/packages/zowe-explorer/src/utils/ProfilesUtils.ts index 3c8329f5d5..cdf6710f38 100644 --- a/packages/zowe-explorer/src/utils/ProfilesUtils.ts +++ b/packages/zowe-explorer/src/utils/ProfilesUtils.ts @@ -134,9 +134,9 @@ export function isTheia(): boolean { * @param getSessionForProfile is a function to build a valid specific session based on provided profile * @param sessionNode is a tree node, containing session information */ -type SessionForProfile = (profile: imperative.IProfileLoaded) => imperative.Session; +type SessionForProfile = (_profile: imperative.IProfileLoaded) => imperative.Session; export const syncSessionNode = - (profiles: Profiles) => + (_profiles: Profiles) => (getSessionForProfile: SessionForProfile) => async (sessionNode: IZoweTreeNode): Promise => { sessionNode.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; diff --git a/packages/zowe-explorer/src/utils/TempFolder.ts b/packages/zowe-explorer/src/utils/TempFolder.ts index d7349a196c..ea1437fa11 100644 --- a/packages/zowe-explorer/src/utils/TempFolder.ts +++ b/packages/zowe-explorer/src/utils/TempFolder.ts @@ -12,7 +12,6 @@ import * as fs from "fs"; import * as path from "path"; import * as globals from "../globals"; -import * as vscode from "vscode"; import { moveSync } from "fs-extra"; import * as nls from "vscode-nls"; import { errorHandling } from "../utils/ProfilesUtils"; diff --git a/packages/zowe-explorer/src/utils/workspace.ts b/packages/zowe-explorer/src/utils/workspace.ts index 1485981ae7..dacc8f9504 100644 --- a/packages/zowe-explorer/src/utils/workspace.ts +++ b/packages/zowe-explorer/src/utils/workspace.ts @@ -138,7 +138,7 @@ const savingQueue = []; let latestSavedFile: vscode.TextDocument; let ongoingSave = false; export async function handleSaving( - uploadRequest: (document, provider) => Promise, + uploadRequest: (_document, _provider) => Promise, savedFile: vscode.TextDocument, fileProvider: IZoweTree ): Promise { From e443eb9702f329db9cbbc16e5fe5f34a75530534 Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Fri, 24 Feb 2023 16:55:54 +0000 Subject: [PATCH 37/39] remove any DA related stuff Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- .../i18n/sample/src/dataset/actions.i18n.json | 1 - packages/zowe-explorer/src/dataset/actions.ts | 8 +------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json index d11894211e..2f5f65152d 100644 --- a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json +++ b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json @@ -94,7 +94,6 @@ "copyDataSet.replace.option1": "Replace", "copyDataSet.replace.option2": "Cancel", "copyDataSet.replace.mem.question": "The dataset member already exists.\nDo you want to replace it?", - "copyDataSet.replace.da.question": "The direct (DA) dataset already exists.\nDo you want to replace it?", "copyDataSet.replace.ps.question": "The physical sequential (PS) dataset already exists.\nDo you want to replace it?", "copyDataSet.replace.po.question": "The partitioned (PO) dataset already exists.\nDo you want to merge them while replacing any existing members?", "copyDataSet.log.error": "Error encountered when copy data set! ", diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index af2753ec92..cbdd76855c 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1173,10 +1173,6 @@ export async function copyDataSets(node, nodeList: ZoweDatasetNode[], datasetPro await copyPartitionedDatasets(selectedNodes); return refreshDataset(selectedNodes[0].getParent(), datasetProvider); } - // else if (contextually.isDirectDs(selectedNodes[0])) { - // await copyDirectDatasets(selectedNodes); - // return refreshDataset(selectedNodes[0].getParent(), datasetProvider); - // } } /** @@ -1622,7 +1618,7 @@ export async function copyPartitionedDatasets(nodes: ZoweDatasetNode[]) { * Type of z/os dataset or member intended for replacement * @export */ -export type replaceDstype = "ps" | "po" | "da" | "mem"; +export type replaceDstype = "ps" | "po" | "mem"; /** * String type to determine whether or not the z/os dataset should be replaced @@ -1656,8 +1652,6 @@ export async function determineReplacement(nodeProfile: zowe.imperative.IProfile } else { const res = await mvsApi.dataSet(name, options); if (res?.success && res.apiResponse?.items.length > 0) { - // Assume DA - q = localize("copyDataSet.replace.da.question", "The direct (DA) dataset already exists.\nDo you want to replace it?"); if (type === "ps") { q = localize("copyDataSet.replace.ps.question", "The physical sequential (PS) dataset already exists.\nDo you want to replace it?"); } else if (type === "po") { From a8dd2feb7bb486ffaa71829518e02f4dd301117d Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Tue, 28 Feb 2023 16:26:20 +0000 Subject: [PATCH 38/39] Update APIs to show an error in case an extender has not implemented the copyDataSet method Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- .../Mvs/ZoweExplorerFtpMvsApi.unit.test.ts | 1 + .../src/ZoweExplorerFtpMvsApi.ts | 1 + .../i18n/sample/src/dataset/actions.i18n.json | 1 + packages/zowe-explorer/src/dataset/actions.ts | 24 +++++++++++-------- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/packages/zowe-explorer-ftp-extension/__tests__/__unit__/Mvs/ZoweExplorerFtpMvsApi.unit.test.ts b/packages/zowe-explorer-ftp-extension/__tests__/__unit__/Mvs/ZoweExplorerFtpMvsApi.unit.test.ts index f2b3b9173b..fa9c2d4169 100644 --- a/packages/zowe-explorer-ftp-extension/__tests__/__unit__/Mvs/ZoweExplorerFtpMvsApi.unit.test.ts +++ b/packages/zowe-explorer-ftp-extension/__tests__/__unit__/Mvs/ZoweExplorerFtpMvsApi.unit.test.ts @@ -208,6 +208,7 @@ describe("FtpMvsApi", () => { expect(DataSetUtils.deleteDataSet).toBeCalledTimes(1); expect(MvsApi.releaseConnection).toBeCalled(); }); + it("should give error copy datasets.", async () => { try { await MvsApi.copyDataSet(null, null); diff --git a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts index 12332f5778..ecffc21760 100644 --- a/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts +++ b/packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts @@ -275,6 +275,7 @@ export class FtpMvsApi extends AbstractFtpApi implements ZoweExplorerApi.IMvs { await Gui.errorMessage("Copy dataset is not supported in ftp extension.", { logger: ZoweLogger }); throw new Error(); } + public async copyDataSet(_fromDataSetName: string, _toDataSetName: string, _enq?: string, _replace?: boolean): Promise { await Gui.errorMessage("Copy dataset is not supported in ftp extension.", { logger: ZoweLogger }); throw new Error(); diff --git a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json index 2f5f65152d..f477cdb3b3 100644 --- a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json +++ b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json @@ -91,6 +91,7 @@ "paste.dataSet": "Invalid paste. Copy dataset(s) first", "paste.dataSet.InPrg": "Copying File(s)", "download.invalidNode": "downloadDataset() called with invalid node. ", + "copyDataSet.error.notSupported": "This operation is not supported at this time.", "copyDataSet.replace.option1": "Replace", "copyDataSet.replace.option2": "Cancel", "copyDataSet.replace.mem.question": "The dataset member already exists.\nDo you want to replace it?", diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index e6b738fd7b..c68887d6a1 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1562,16 +1562,20 @@ export async function downloadDs(node: ZoweDatasetNode) { export async function copySequentialDatasets(nodes: ZoweDatasetNode[]) { await _copyProcessor(nodes, "ps", async (node: ZoweDatasetNode, dsname: string, replace: shouldReplace) => { const lbl = node.getLabel().toString(); - - await api.Gui.withProgress( - { - location: vscode.ProgressLocation.Window, - title: localize("paste.dataSet.InPrg", "Copying File(s)"), - }, - () => { - return ZoweExplorerApiRegister.getMvsApi(nodes[0].getProfile()).copyDataSet(lbl, dsname, null, replace === "replace"); - } - ); + const mvsApi = ZoweExplorerApiRegister.getMvsApi(node.getProfile()); + if (mvsApi?.copyDataSet == null) { + await api.Gui.errorMessage(localize("copyDataSet.error.notSupported", "This operation is not supported at this time.")); + } else { + await api.Gui.withProgress( + { + location: vscode.ProgressLocation.Window, + title: localize("paste.dataSet.InPrg", "Copying File(s)"), + }, + () => { + return mvsApi.copyDataSet(lbl, dsname, null, replace === "replace"); + } + ); + } }); } From 035b7dc6dbcdf44492cdcb8661befb8b7bf3b08e Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Tue, 28 Feb 2023 20:01:43 +0000 Subject: [PATCH 39/39] update message Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- .../zowe-explorer/i18n/sample/src/dataset/actions.i18n.json | 2 +- packages/zowe-explorer/src/dataset/actions.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json index f477cdb3b3..ae892a4146 100644 --- a/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json +++ b/packages/zowe-explorer/i18n/sample/src/dataset/actions.i18n.json @@ -91,7 +91,7 @@ "paste.dataSet": "Invalid paste. Copy dataset(s) first", "paste.dataSet.InPrg": "Copying File(s)", "download.invalidNode": "downloadDataset() called with invalid node. ", - "copyDataSet.error.notSupported": "This operation is not supported at this time.", + "copyDataSet.error.notSupported": "Copying datasets is not supported.", "copyDataSet.replace.option1": "Replace", "copyDataSet.replace.option2": "Cancel", "copyDataSet.replace.mem.question": "The dataset member already exists.\nDo you want to replace it?", diff --git a/packages/zowe-explorer/src/dataset/actions.ts b/packages/zowe-explorer/src/dataset/actions.ts index c68887d6a1..2d60d2e77b 100644 --- a/packages/zowe-explorer/src/dataset/actions.ts +++ b/packages/zowe-explorer/src/dataset/actions.ts @@ -1564,7 +1564,7 @@ export async function copySequentialDatasets(nodes: ZoweDatasetNode[]) { const lbl = node.getLabel().toString(); const mvsApi = ZoweExplorerApiRegister.getMvsApi(node.getProfile()); if (mvsApi?.copyDataSet == null) { - await api.Gui.errorMessage(localize("copyDataSet.error.notSupported", "This operation is not supported at this time.")); + await api.Gui.errorMessage(localize("copyDataSet.error.notSupported", "Copying datasets is not supported.")); } else { await api.Gui.withProgress( {