Skip to content

Commit

Permalink
refactor: remove static from dataset{Migrated,Recalled}
Browse files Browse the repository at this point in the history
Signed-off-by: Trae Yelovich <[email protected]>
  • Loading branch information
traeok committed Nov 20, 2024
1 parent 9c10f08 commit fe88ffc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ describe("ZoweDatasetNode Unit Tests - function datasetRecalled", () => {
contextOverride: globals.DS_MIGRATED_FILE_CONTEXT,
profile: createIProfile(),
});
await (ZoweDatasetNode as any).datasetRecalled(dsNode, true);
await (dsNode as any).datasetRecalled(true);
expect(dsNode.collapsibleState).toBe(vscode.TreeItemCollapsibleState.Collapsed);
});

Expand All @@ -456,7 +456,7 @@ describe("ZoweDatasetNode Unit Tests - function datasetRecalled", () => {
contextOverride: globals.DS_MIGRATED_FILE_CONTEXT,
profile: createIProfile(),
});
await (ZoweDatasetNode as any).datasetRecalled(dsNode, true);
await (dsNode as any).datasetRecalled(true);
expect(dsNode.iconPath).toBe(getIconById(IconId.folder).path);
});

Expand All @@ -467,7 +467,7 @@ describe("ZoweDatasetNode Unit Tests - function datasetRecalled", () => {
contextOverride: globals.DS_MIGRATED_FILE_CONTEXT,
profile: createIProfile(),
});
await (ZoweDatasetNode as any).datasetRecalled(dsNode, false);
await (dsNode as any).datasetRecalled(false);
expect(dsNode.iconPath).toBe(getIconById(IconId.document).path);
});
});
Expand All @@ -480,7 +480,7 @@ describe("ZoweDatasetNode Unit Tests - function datasetMigrated", () => {
contextOverride: globals.DS_PDS_CONTEXT,
profile: createIProfile(),
});
(ZoweDatasetNode as any).datasetMigrated(dsNode, true);
(dsNode as any).datasetMigrated();
expect(dsNode.collapsibleState).toBe(vscode.TreeItemCollapsibleState.None);
});

Expand All @@ -492,7 +492,7 @@ describe("ZoweDatasetNode Unit Tests - function datasetMigrated", () => {
parentNode: createDatasetSessionNode(createISession(), createIProfile()),
profile: createIProfile(),
});
(ZoweDatasetNode as any).datasetMigrated(dsNode);
(dsNode as any).datasetMigrated();
expect(dsNode.resourceUri).toBeUndefined();
expect(dsNode.command).toBeUndefined();
});
Expand All @@ -504,7 +504,7 @@ describe("ZoweDatasetNode Unit Tests - function datasetMigrated", () => {
contextOverride: globals.DS_MIGRATED_FILE_CONTEXT,
profile: createIProfile(),
});
(ZoweDatasetNode as any).datasetMigrated(dsNode);
(dsNode as any).datasetMigrated();
expect(dsNode.iconPath).toBe(getIconById(IconId.migrated).path);
});
});
28 changes: 14 additions & 14 deletions packages/zowe-explorer/src/dataset/ZoweDatasetNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,35 +135,35 @@ export class ZoweDatasetNode extends ZoweTreeNode implements IZoweDatasetTreeNod
* Updates an existing data set node that was recalled so it can be interacted with.
* @param node The data set node to update (previously marked as migrated)
*/
private static datasetRecalled(node: ZoweDatasetNode, isPds: boolean): void {
private datasetRecalled(isPds: boolean): void {
// Change context value to match dsorg, update collapsible state and assign resource URI
node.contextValue = isPds ? globals.DS_PDS_CONTEXT : globals.DS_DS_CONTEXT;
node.collapsibleState =
node.contextValue === globals.DS_PDS_CONTEXT ? vscode.TreeItemCollapsibleState.Collapsed : vscode.TreeItemCollapsibleState.None;
this.contextValue = isPds ? globals.DS_PDS_CONTEXT : globals.DS_DS_CONTEXT;
this.collapsibleState =
this.contextValue === globals.DS_PDS_CONTEXT ? vscode.TreeItemCollapsibleState.Collapsed : vscode.TreeItemCollapsibleState.None;

// Replace icon on existing node with new one
const icon = getIconByNode(node);
const icon = getIconByNode(this);
if (icon) {
node.setIcon(icon.path);
this.setIcon(icon.path);
}
}

/**
* Updates a data set node so it is marked as migrated.
* @param node The data set node to mark as migrated
*/
private static datasetMigrated(node: ZoweDatasetNode): void {
private datasetMigrated(): void {
// Change the context value and collapsible state to represent a migrated data set
node.contextValue = globals.DS_MIGRATED_FILE_CONTEXT;
node.collapsibleState = vscode.TreeItemCollapsibleState.None;
this.contextValue = globals.DS_MIGRATED_FILE_CONTEXT;
this.collapsibleState = vscode.TreeItemCollapsibleState.None;

// Remove the node's command
node.command = undefined;
this.command = undefined;

// Assign migrated icon to the data set node
const icon = getIconByNode(node);
const icon = getIconByNode(this);
if (icon) {
node.setIcon(icon.path);
this.setIcon(icon.path);
}
}

Expand Down Expand Up @@ -219,9 +219,9 @@ export class ZoweDatasetNode extends ZoweTreeNode implements IZoweDatasetTreeNod
const existing = this.children.find((element) => element.label.toString() === dsEntry);
if (existing) {
if (contextually.isMigrated(existing) && item.migr?.toUpperCase() !== "YES") {
ZoweDatasetNode.datasetRecalled(existing, item.dsorg === "PO" || item.dsorg === "PO-E");
existing.datasetRecalled(item.dsorg === "PO" || item.dsorg === "PO-E");
} else if (!contextually.isMigrated(existing) && item.migr?.toUpperCase() === "YES") {
ZoweDatasetNode.datasetMigrated(existing);
existing.datasetMigrated();
}
existing.updateStats(item);
elementChildren[existing.label.toString()] = existing;
Expand Down

0 comments on commit fe88ffc

Please sign in to comment.