Skip to content

Commit

Permalink
feat: Support multi-select for "Add to Workspace" feature (#3325)
Browse files Browse the repository at this point in the history
* feat: support multiselect in 'Add to Workspace'

Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com>

* chore: update changelog

Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com>

* tests: add case for multiple resources

Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com>

* chore: address changelog feedback

Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com>

---------

Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com>
  • Loading branch information
traeok authored Nov 19, 2024
1 parent d5dc428 commit 57db6f3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
- Power users and developers can now build links to efficiently open mainframe resources in Zowe Explorer. Use the **Copy External Link** option in the context menu to get the URL for a data set or USS resource, or create a link in the format `vscode://Zowe.vscode-extension-for-zowe?<ZoweResourceUri>`. For more information on building resource URIs, see the [FileSystemProvider wiki article](https://github.com/zowe/zowe-explorer-vscode/wiki/FileSystemProvider#file-paths-vs-uris). [#3271](https://github.com/zowe/zowe-explorer-vscode/pull/3271)
- Implemented more user-friendly error messages for API or network errors within Zowe Explorer. [#3243](https://github.com/zowe/zowe-explorer-vscode/pull/3243)
- Use the "Troubleshoot" option for certain errors to obtain additional context, tips, and resources for how to resolve the errors. [#3243](https://github.com/zowe/zowe-explorer-vscode/pull/3243)
- You can now add multiple partitioned data sets or USS directories to your workspace at once using the "Add to Workspace" feature. [#3324](https://github.com/zowe/zowe-explorer-vscode/issues/3324)

### Bug fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,9 @@ describe("Shared utils unit tests - function parseFavorites", () => {
describe("Shared utils unit tests - function addToWorkspace", () => {
it("adds a Data Set resource to the workspace", () => {
const datasetNode = new ZoweDatasetNode({
label: "EXAMPLE.DS",
collapsibleState: vscode.TreeItemCollapsibleState.None,
contextOverride: Constants.DS_DS_CONTEXT,
label: "EXAMPLE.PDS",
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
contextOverride: Constants.DS_PDS_CONTEXT,
profile: createIProfile(),
});
const updateWorkspaceFoldersMock = jest.spyOn(vscode.workspace, "updateWorkspaceFolders").mockImplementation();
Expand All @@ -580,6 +580,34 @@ describe("Shared utils unit tests - function addToWorkspace", () => {
SharedUtils.addToWorkspace(ussNode, null as any);
expect(updateWorkspaceFoldersMock).toHaveBeenCalledWith(0, null, { uri: ussNode.resourceUri, name: `[sestest] ${ussNode.fullPath}` });
});
it("adds multiple resources to the workspace at once", () => {
const datasetNode1 = new ZoweDatasetNode({
label: "EXAMPLE.PDS1",
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
contextOverride: Constants.DS_PDS_CONTEXT,
profile: createIProfile(),
});
const datasetNode2 = new ZoweDatasetNode({
label: "EXAMPLE.PDS2",
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
contextOverride: Constants.DS_PDS_CONTEXT,
profile: createIProfile(),
});
const updateWorkspaceFoldersMock = jest.spyOn(vscode.workspace, "updateWorkspaceFolders").mockImplementation();
SharedUtils.addToWorkspace(null as any, [datasetNode1, datasetNode2]);
expect(updateWorkspaceFoldersMock).toHaveBeenCalledWith(
0,
null,
{
uri: datasetNode1.resourceUri,
name: `[sestest] ${datasetNode1.label as string}`,
},
{
uri: datasetNode2.resourceUri,
name: `[sestest] ${datasetNode2.label as string}`,
}
);
});
it("adds a USS session w/ fullPath to the workspace", () => {
const ussNode = new ZoweUSSNode({
label: "sestest",
Expand Down Expand Up @@ -617,9 +645,9 @@ describe("Shared utils unit tests - function addToWorkspace", () => {
});
it("skips adding a resource that's already in the workspace", () => {
const ussNode = new ZoweUSSNode({
label: "textFile.txt",
label: "testFolder",
collapsibleState: vscode.TreeItemCollapsibleState.None,
contextOverride: Constants.USS_TEXT_FILE_CONTEXT,
contextOverride: Constants.USS_DIR_CONTEXT,
profile: createIProfile(),
});
const workspaceFolders = new MockedProperty(vscode.workspace, "workspaceFolders", {
Expand Down
10 changes: 8 additions & 2 deletions packages/zowe-explorer/src/trees/shared/SharedUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ export class SharedUtils {
): void {
const workspaceFolders = vscode.workspace.workspaceFolders;
const selectedNodes = SharedUtils.getSelectedNodeList(node, nodeList);
const urisToAdd: {
name: string;
uri: vscode.Uri;
}[] = [];
for (const item of selectedNodes) {
let resourceUri = item.resourceUri;
const isSession = SharedContext.isSession(item);
Expand All @@ -327,11 +331,13 @@ export class SharedUtils {
continue;
}

vscode.workspace.updateWorkspaceFolders(workspaceFolders?.length ?? 0, null, {
uri: resourceUri,
urisToAdd.push({
name: `[${item.getProfileName()}] ${SharedContext.isDatasetNode(item) ? (item.label as string) : item.fullPath}`,
uri: resourceUri,
});
}

vscode.workspace.updateWorkspaceFolders(workspaceFolders?.length ?? 0, null, ...urisToAdd);
}

/**
Expand Down

0 comments on commit 57db6f3

Please sign in to comment.