Skip to content

Commit 9088b0b

Browse files
likhithanimma1JillieBeanSimanaxceron
authored
Delete VSAM datasets from Zowe Explorer View (#3845)
* Deletion of Vsam datasets from zowe explorer Signed-off-by: likhithanimma1 <[email protected]> * add changelog entry and ran prepublish Signed-off-by: Billie Simmons <[email protected]> * ze api changelog Signed-off-by: Billie Simmons <[email protected]> * Update packages/zowe-explorer-api/CHANGELOG.md Co-authored-by: anaxceron <[email protected]> Signed-off-by: likhithanimma1 <[email protected]> * Shift changelog entries Signed-off-by: likhithanimma1 <[email protected]> --------- Signed-off-by: likhithanimma1 <[email protected]> Signed-off-by: Billie Simmons <[email protected]> Co-authored-by: Billie Simmons <[email protected]> Co-authored-by: anaxceron <[email protected]>
1 parent ad188a9 commit 9088b0b

File tree

10 files changed

+128
-50
lines changed

10 files changed

+128
-50
lines changed

packages/zowe-explorer-api/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t
88

99
### Bug fixes
1010

11+
- Added support to delete VSAM data sets for z/OSMF type profiles. [#3824](https://github.com/zowe/zowe-explorer-vscode/issues/3824)
12+
1113
## `3.3.0`
1214

1315
### New features and enhancements

packages/zowe-explorer-api/__tests__/__unit__/profiles/ZoweExplorerZosmfApi.unit.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,11 @@ describe("ZosmfMvsApi", () => {
587587
spy: jest.spyOn(zosfiles.Delete, "dataSet"),
588588
args: ["dsname", fakeProperties],
589589
},
590+
{
591+
name: "deleteDataSet",
592+
spy: jest.spyOn(zosfiles.Delete, "vsam"),
593+
args: ["dsname", { volume: "*VSAM*", ...fakeProperties }],
594+
},
590595
{
591596
name: "dataSetsMatchingPattern",
592597
spy: jest.spyOn(zosfiles.List, "dataSetsMatchingPattern"),

packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,17 @@ export namespace ZoweExplorerZosmf {
352352
}
353353

354354
public deleteDataSet(dataSetName: string, options?: zosfiles.IDeleteDatasetOptions): Promise<zosfiles.IZosFilesResponse> {
355-
return zosfiles.Delete.dataSet(this.getSession(), dataSetName, {
356-
responseTimeout: this.profile?.profile?.responseTimeout,
357-
...options,
358-
});
355+
if (options.volume == "*VSAM*") {
356+
return zosfiles.Delete.vsam(this.getSession(), dataSetName, {
357+
responseTimeout: this.profile?.profile?.responseTimeout,
358+
...options,
359+
});
360+
} else {
361+
return zosfiles.Delete.dataSet(this.getSession(), dataSetName, {
362+
responseTimeout: this.profile?.profile?.responseTimeout,
363+
...options,
364+
});
365+
}
359366
}
360367

361368
public dataSetsMatchingPattern(filter: string[], options?: zosfiles.IDsmListOptions): Promise<zosfiles.IZosFilesResponse> {

packages/zowe-explorer/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
66

77
### New features and enhancements
88

9+
- Added support to delete VSAM data sets. [#3824](https://github.com/zowe/zowe-explorer-vscode/issues/3824)
10+
911
### Bug fixes
1012

1113
## `3.3.0`

packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetFSProvider.unit.test.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ const testEntries = {
6464
}),
6565
isMember: true,
6666
} as DsEntry,
67+
vsam: {
68+
...new DsEntry("USER.DATA.PS", false),
69+
metadata: new DsEntryMetadata({
70+
profile: testProfile,
71+
path: "/USER.DATA.PS",
72+
}),
73+
isMember: false,
74+
} as DsEntry,
6775
session: {
6876
...new FilterEntry("sestest"),
6977
metadata: {
@@ -1241,6 +1249,11 @@ describe("DatasetFSProvider", () => {
12411249
fakeSession.entries.set("USER.DATA.PS", fakePs);
12421250
const mockMvsApi = {
12431251
deleteDataSet: jest.fn(),
1252+
dataSet: jest.fn().mockResolvedValue({
1253+
apiResponse: {
1254+
items: [fakePs],
1255+
},
1256+
}),
12441257
};
12451258
jest.spyOn(ZoweExplorerApiRegister, "getMvsApi").mockReturnValue(mockMvsApi as any);
12461259
const _lookupMock = jest.spyOn(DatasetFSProvider.instance as any, "lookup").mockReturnValue(fakePs);
@@ -1261,6 +1274,11 @@ describe("DatasetFSProvider", () => {
12611274
fakePds.entries.set("MEMBER1", fakePdsMember);
12621275
const mockMvsApi = {
12631276
deleteDataSet: jest.fn(),
1277+
dataSet: jest.fn().mockResolvedValue({
1278+
apiResponse: {
1279+
items: [fakePdsMember],
1280+
},
1281+
}),
12641282
};
12651283
jest.spyOn(ZoweExplorerApiRegister, "getMvsApi").mockReturnValue(mockMvsApi as any);
12661284
const _lookupMock = jest.spyOn(DatasetFSProvider.instance as any, "lookup").mockReturnValue(fakePdsMember);
@@ -1279,6 +1297,11 @@ describe("DatasetFSProvider", () => {
12791297
const fakePds = { ...testEntries.pds };
12801298
const mockMvsApi = {
12811299
deleteDataSet: jest.fn(),
1300+
dataSet: jest.fn().mockResolvedValue({
1301+
apiResponse: {
1302+
items: [fakePds],
1303+
},
1304+
}),
12821305
};
12831306
jest.spyOn(ZoweExplorerApiRegister, "getMvsApi").mockReturnValue(mockMvsApi as any);
12841307
const _lookupMock = jest.spyOn(DatasetFSProvider.instance as any, "lookup").mockReturnValue(fakePds);
@@ -1292,6 +1315,28 @@ describe("DatasetFSProvider", () => {
12921315
expect(_fireSoonMock).toHaveBeenCalled();
12931316
});
12941317

1318+
it("successfully deletes a VSAM", async () => {
1319+
const fakeVsam = { ...testEntries.vsam };
1320+
const mockMvsApi = {
1321+
deleteDataSet: jest.fn(),
1322+
dataSet: jest.fn().mockResolvedValue({
1323+
apiResponse: {
1324+
items: [fakeVsam],
1325+
},
1326+
}),
1327+
};
1328+
jest.spyOn(ZoweExplorerApiRegister, "getMvsApi").mockReturnValue(mockMvsApi as any);
1329+
const _lookupMock = jest.spyOn(DatasetFSProvider.instance as any, "lookup").mockReturnValue(fakeVsam);
1330+
const _fireSoonMock = jest.spyOn(DatasetFSProvider.instance as any, "_fireSoon").mockImplementation();
1331+
jest.spyOn(FsDatasetsUtils, "isPdsEntry").mockReturnValue(true);
1332+
jest.spyOn(DatasetFSProvider.instance as any, "lookupParentDirectory").mockReturnValue({ ...testEntries.session });
1333+
1334+
await DatasetFSProvider.instance.delete(testUris.pds, { recursive: false });
1335+
expect(mockMvsApi.deleteDataSet).toHaveBeenCalledWith(fakeVsam.name, { responseTimeout: undefined });
1336+
expect(_lookupMock).toHaveBeenCalledWith(testUris.pds, false);
1337+
expect(_fireSoonMock).toHaveBeenCalled();
1338+
});
1339+
12951340
it("throws an error if it could not delete an entry", async () => {
12961341
const fakePs = { ...testEntries.ps };
12971342
const fakeSession = { ...testEntries.session, entries: new Map() };
@@ -1300,6 +1345,11 @@ describe("DatasetFSProvider", () => {
13001345
const sampleError = new Error("Data set does not exist on remote");
13011346
const mockMvsApi = {
13021347
deleteDataSet: jest.fn().mockRejectedValue(sampleError),
1348+
dataSet: jest.fn().mockResolvedValue({
1349+
apiResponse: {
1350+
items: [fakePs],
1351+
},
1352+
}),
13031353
};
13041354
jest.spyOn(ZoweExplorerApiRegister, "getMvsApi").mockReturnValue(mockMvsApi as any);
13051355
const _lookupMock = jest.spyOn(DatasetFSProvider.instance as any, "lookup").mockReturnValue(fakePs);

packages/zowe-explorer/l10n/bundle.l10n.json

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,42 @@
243243
"Uploading USS files...": "Uploading USS files...",
244244
"Error uploading files": "Error uploading files",
245245
"Retrieving response from USS list API": "Retrieving response from USS list API",
246+
"The 'move' function is not implemented for this USS API.": "The 'move' function is not implemented for this USS API.",
247+
"Failed to move {0}/File path": {
248+
"message": "Failed to move {0}",
249+
"comment": [
250+
"File path"
251+
]
252+
},
253+
"Profile does not exist for this file.": "Profile does not exist for this file.",
254+
"Saving USS file...": "Saving USS file...",
255+
"Failed to rename {0}/File path": {
256+
"message": "Failed to rename {0}",
257+
"comment": [
258+
"File path"
259+
]
260+
},
261+
"Failed to delete {0}/File name": {
262+
"message": "Failed to delete {0}",
263+
"comment": [
264+
"File name"
265+
]
266+
},
267+
"No error details given": "No error details given",
268+
"Error fetching destination {0} for paste action: {1}/USS pathError message": {
269+
"message": "Error fetching destination {0} for paste action: {1}",
270+
"comment": [
271+
"USS path",
272+
"Error message"
273+
]
274+
},
275+
"Failed to copy {0} to {1}/Source pathDestination path": {
276+
"message": "Failed to copy {0} to {1}",
277+
"comment": [
278+
"Source path",
279+
"Destination path"
280+
]
281+
},
246282
"Downloaded: {0}/Download time": {
247283
"message": "Downloaded: {0}",
248284
"comment": [
@@ -305,42 +341,6 @@
305341
"initializeUSSFavorites.error.buttonRemove": "initializeUSSFavorites.error.buttonRemove",
306342
"File does not exist. It may have been deleted.": "File does not exist. It may have been deleted.",
307343
"Pulling from Mainframe...": "Pulling from Mainframe...",
308-
"The 'move' function is not implemented for this USS API.": "The 'move' function is not implemented for this USS API.",
309-
"Failed to move {0}/File path": {
310-
"message": "Failed to move {0}",
311-
"comment": [
312-
"File path"
313-
]
314-
},
315-
"Profile does not exist for this file.": "Profile does not exist for this file.",
316-
"Saving USS file...": "Saving USS file...",
317-
"Failed to rename {0}/File path": {
318-
"message": "Failed to rename {0}",
319-
"comment": [
320-
"File path"
321-
]
322-
},
323-
"Failed to delete {0}/File name": {
324-
"message": "Failed to delete {0}",
325-
"comment": [
326-
"File name"
327-
]
328-
},
329-
"No error details given": "No error details given",
330-
"Error fetching destination {0} for paste action: {1}/USS pathError message": {
331-
"message": "Error fetching destination {0} for paste action: {1}",
332-
"comment": [
333-
"USS path",
334-
"Error message"
335-
]
336-
},
337-
"Failed to copy {0} to {1}/Source pathDestination path": {
338-
"message": "Failed to copy {0} to {1}",
339-
"comment": [
340-
"Source path",
341-
"Destination path"
342-
]
343-
},
344344
"{0} location/Node type": {
345345
"message": "{0} location",
346346
"comment": [

packages/zowe-explorer/l10n/poeditor.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,15 @@
706706
"Uploading USS files...": "",
707707
"Error uploading files": "",
708708
"Retrieving response from USS list API": "",
709+
"The 'move' function is not implemented for this USS API.": "",
710+
"Failed to move {0}": "",
711+
"Profile does not exist for this file.": "",
712+
"Saving USS file...": "",
713+
"Failed to rename {0}": "",
714+
"Failed to delete {0}": "",
715+
"No error details given": "",
716+
"Error fetching destination {0} for paste action: {1}": "",
717+
"Failed to copy {0} to {1}": "",
709718
"Downloaded: {0}": "",
710719
"Encoding: {0}": "",
711720
"Binary": "",
@@ -732,15 +741,6 @@
732741
"initializeUSSFavorites.error.buttonRemove": "",
733742
"File does not exist. It may have been deleted.": "",
734743
"Pulling from Mainframe...": "",
735-
"The 'move' function is not implemented for this USS API.": "",
736-
"Failed to move {0}": "",
737-
"Profile does not exist for this file.": "",
738-
"Saving USS file...": "",
739-
"Failed to rename {0}": "",
740-
"Failed to delete {0}": "",
741-
"No error details given": "",
742-
"Error fetching destination {0} for paste action: {1}": "",
743-
"Failed to copy {0} to {1}": "",
744744
"{0} location": "",
745745
"Choose a location to create the {0}": "",
746746
"Name of file or directory": "",

packages/zowe-explorer/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,11 @@
12491249
"command": "zowe.ds.deleteDataset",
12501250
"group": "099_zowe_dsModification@5"
12511251
},
1252+
{
1253+
"when": "view == zowe.ds.explorer && viewItem =~ /^vsam.*/",
1254+
"command": "zowe.ds.deleteDataset",
1255+
"group": "099_zowe_dsModification@5"
1256+
},
12521257
{
12531258
"when": "view == zowe.ds.explorer && viewItem =~ /^(?!.*_fav.*)session.*/ && !listMultiSelection",
12541259
"command": "zowe.profileManagement",

packages/zowe-explorer/src/trees/dataset/DatasetFSProvider.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,12 @@ export class DatasetFSProvider extends BaseProvider implements vscode.FileSystem
817817
const profile = Profiles.getInstance().loadNamedProfile(entry.metadata.profile.name);
818818
await AuthUtils.reauthenticateIfCancelled(profile);
819819
await AuthHandler.waitForUnlock(entry.metadata.profile);
820+
let attributes = await ZoweExplorerApiRegister.getMvsApi(entry.metadata.profile).dataSet(fullName, {
821+
attributes: true,
822+
});
823+
attributes = attributes.apiResponse.items;
820824
await ZoweExplorerApiRegister.getMvsApi(entry.metadata.profile).deleteDataSet(fullName, {
825+
volume: attributes[0].vols,
821826
responseTimeout: entry.metadata.profile.profile?.responseTimeout,
822827
});
823828
} catch (err) {

packages/zowe-explorer/src/trees/dataset/ZoweDatasetNode.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ export class ZoweDatasetNode extends ZoweTreeNode implements IZoweDatasetTreeNod
133133
this.contextValue === Constants.DS_DS_CONTEXT ||
134134
this.contextValue === Constants.DS_FAV_CONTEXT ||
135135
this.contextValue === Constants.DS_PDS_CONTEXT ||
136-
this.contextValue === Constants.PDS_FAV_CONTEXT
136+
this.contextValue === Constants.PDS_FAV_CONTEXT ||
137+
this.contextValue === Constants.VSAM_CONTEXT
137138
) {
138139
this.resourceUri = vscode.Uri.from({
139140
scheme: ZoweScheme.DS,
@@ -393,6 +394,7 @@ export class ZoweDatasetNode extends ZoweTreeNode implements IZoweDatasetTreeNod
393394
profile: cachedProfile,
394395
});
395396
}
397+
dsNode = elementChildren[altLabel];
396398
} else if (SharedContext.isSession(this)) {
397399
// Creates a ZoweDatasetNode for a PS
398400
const cachedEncoding = this.getEncodingInMap(item.dsname);

0 commit comments

Comments
 (0)