Skip to content

Commit

Permalink
refactor profileManagement, not complete
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Twydell <[email protected]>
  • Loading branch information
AndrewTwydell committed Dec 18, 2024
1 parent 3750e38 commit e9be358
Show file tree
Hide file tree
Showing 3 changed files with 231 additions and 252 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ root = true

[*]
indent_style = space
indent_size = 4
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
*
*/

import { TreeItemCollapsibleState, TreeItem, window, ProgressLocation, workspace } from "vscode";
import { CICSPlexTree } from "../CICSPlexTree";
import { CICSProgramTreeItem } from "../treeItems/CICSProgramTreeItem";
import { CICSRegionTree } from "../CICSRegionTree";
import { CICSTree } from "../CICSTree";
import { ProfileManagement } from "../../utils/profileManagement";
import { ViewMore } from "../treeItems/utils/ViewMore";
import { CicsCmciConstants } from "@zowe/cics-for-zowe-sdk";
import { imperative } from "@zowe/zowe-explorer-api";
import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window, workspace } from "vscode";
import { toEscapedCriteriaString } from "../../utils/filterUtils";
import { ProfileManagement } from "../../utils/profileManagement";
import { getIconPathInResources } from "../../utils/profileUtils";
import { CICSPlexTree } from "../CICSPlexTree";
import { CICSRegionsContainer } from "../CICSRegionsContainer";
import { CICSRegionTree } from "../CICSRegionTree";
import { CICSTree } from "../CICSTree";
import { CICSProgramTreeItem } from "../treeItems/CICSProgramTreeItem";
import { TextTreeItem } from "../treeItems/utils/TextTreeItem";
import { getIconPathInResources } from "../../utils/profileUtils";
import { ViewMore } from "../treeItems/utils/ViewMore";

export class CICSCombinedProgramTree extends TreeItem {
children: (CICSProgramTreeItem | ViewMore)[] | [TextTreeItem] | null;
Expand Down Expand Up @@ -66,16 +67,16 @@ export class CICSCombinedProgramTree extends TreeItem {
this.getParent().getGroupName()
);
if (cacheTokenInfo) {
const recordsCount = cacheTokenInfo.recordCount;
if (parseInt(recordsCount, 10)) {
const recordsCount = parseInt(cacheTokenInfo.recordCount, 10);
if (recordsCount) {
let allPrograms;
if (recordsCount <= this.incrementCount) {
allPrograms = await ProfileManagement.getCachedResources(
this.parentPlex.getProfile(),
cacheTokenInfo.cacheToken,
this.constant,
1,
parseInt(recordsCount, 10)
recordsCount
);
} else {
allPrograms = await ProfileManagement.getCachedResources(
Expand All @@ -85,7 +86,7 @@ export class CICSCombinedProgramTree extends TreeItem {
1,
this.incrementCount
);
count = parseInt(recordsCount);
count = recordsCount;
}
this.addProgramsUtil([], allPrograms, count);
this.iconPath = getIconPathInResources("folder-open-dark.svg", "folder-open-light.svg");
Expand All @@ -99,12 +100,20 @@ export class CICSCombinedProgramTree extends TreeItem {
}
}
} catch (error) {
window.showErrorMessage(
`Something went wrong when fetching programs - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace(
/(\\n\t|\\n|\\t)/gm,
" "
)}`
);
if (error instanceof imperative.ImperativeError && error.mDetails.msg.includes("NOTAVAILABLE")) {
this.children = [];
this.iconPath = getIconPathInResources("folder-open-dark.svg", "folder-open-light.svg");
tree._onDidChangeTreeData.fire(undefined);
window.showInformationMessage(`No programs found`);
this.label = `All Programs${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${recordsCount}]`;
} else {
window.showErrorMessage(
`Something went wrong when fetching programs - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace(
/(\\n\t|\\n|\\t)/gm,
" "
)}`
);
}
}
}
);
Expand Down
Loading

0 comments on commit e9be358

Please sign in to comment.