Skip to content

Commit

Permalink
Icon change on status update of resources
Browse files Browse the repository at this point in the history
Signed-off-by: Rushabh Sojitra <[email protected]>
  • Loading branch information
almightyrush committed Jan 13, 2025
1 parent 5d0ceb7 commit 80da3c6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/vsce/src/trees/treeItems/CICSLocalFileTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import { TreeItemCollapsibleState, TreeItem } from "vscode";
import { CICSRegionTree } from "../CICSRegionTree";
import { getIconPathInResources } from "../../utils/profileUtils";
import { getIconByStatus } from "../../utils/profileUtils";

export class CICSLocalFileTreeItem extends TreeItem {
localFile: any;
Expand All @@ -23,7 +23,7 @@ export class CICSLocalFileTreeItem extends TreeItem {
localFile: any,
parentRegion: CICSRegionTree,
directParent: any,
public readonly iconPath = getIconPathInResources("local-file-dark.svg", "local-file-light.svg")
public readonly iconPath = getIconByStatus("LOCAL_FILE", localFile)
) {
super(
`${localFile.file} ${
Expand Down
4 changes: 2 additions & 2 deletions packages/vsce/src/trees/treeItems/CICSProgramTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import { TreeItemCollapsibleState, TreeItem } from "vscode";
import { CICSRegionTree } from "../CICSRegionTree";
import { getIconPathInResources } from "../../utils/profileUtils";
import { getIconByStatus } from "../../utils/profileUtils";

export class CICSProgramTreeItem extends TreeItem {
program: any;
Expand All @@ -22,7 +22,7 @@ export class CICSProgramTreeItem extends TreeItem {
program: any,
parentRegion: CICSRegionTree,
directParent: any,
public readonly iconPath = getIconPathInResources("program-dark.svg", "program-light.svg")
public readonly iconPath = getIconByStatus("PROGRAM", program)
) {
super(
`${program.program}${
Expand Down
8 changes: 2 additions & 6 deletions packages/vsce/src/trees/treeItems/CICSTaskTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import { TreeItemCollapsibleState, TreeItem } from "vscode";
import { CICSRegionTree } from "../CICSRegionTree";
import { getIconPathInResources } from "../../utils/profileUtils";
import { getIconByStatus } from "../../utils/profileUtils";

export class CICSTaskTreeItem extends TreeItem {
task: any;
Expand All @@ -22,11 +22,7 @@ export class CICSTaskTreeItem extends TreeItem {
task: any,
parentRegion: CICSRegionTree,
directParent: any,
public readonly iconPath = task.runstatus === "RUNNING"
? getIconPathInResources("task-running-dark.svg", "task-running-light.svg")
: task.runstatus === "SUSPENDED"
? getIconPathInResources("task-suspended-dark.svg", "task-suspended-light.svg")
: getIconPathInResources("task-dispatched-dark.svg", "task-dispatched-light.svg")
public readonly iconPath = getIconByStatus("TASK", task)
) {
super(`${task.task}`, TreeItemCollapsibleState.None);

Expand Down
4 changes: 2 additions & 2 deletions packages/vsce/src/trees/treeItems/CICSTransactionTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import { TreeItemCollapsibleState, TreeItem } from "vscode";
import { CICSRegionTree } from "../CICSRegionTree";
import { getIconPathInResources } from "../../utils/profileUtils";
import { getIconByStatus } from "../../utils/profileUtils";

export class CICSTransactionTreeItem extends TreeItem {
transaction: any;
Expand All @@ -23,7 +23,7 @@ export class CICSTransactionTreeItem extends TreeItem {
transaction: any,
parentRegion: CICSRegionTree,
directParent: any,
public readonly iconPath = getIconPathInResources("local-transaction-dark.svg", "local-transaction-light.svg")
public readonly iconPath = getIconByStatus("TRANSACTION", transaction)
) {
super(`${transaction.tranid} ${transaction.status.toLowerCase() === "disabled" ? "(Disabled)" : ""}`, TreeItemCollapsibleState.None);
this.transaction = transaction;
Expand Down
27 changes: 27 additions & 0 deletions packages/vsce/src/utils/profileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,30 @@ export function getIconOpen(open: boolean = true) {
`folder-${open ? "open" : "closed"}-dark.svg`,
`folder-${open ? "open" : "closed"}-light.svg`);
}

export function getIconByStatus(resourceType: string, resourceTreeItem: any) {
switch (resourceType) {
case "PROGRAM":
return resourceTreeItem.status === "DISABLED"
? getIconPathInResources("program-disabled-dark.svg", "program-disabled-light.svg")
: getIconPathInResources("program-dark.svg", "program-light.svg");
case "TRANSACTION":
return resourceTreeItem.status === "DISABLED"
? getIconPathInResources("local-transaction-disabled-dark.svg", "local-transaction-disabled-light.svg")
: getIconPathInResources("local-transaction-dark.svg", "local-transaction-light.svg");
case "LOCAL_FILE":
return resourceTreeItem.openstatus === "CLOSED" && resourceTreeItem.enablestatus === "DISABLED"
? getIconPathInResources("local-file-disabled-closed-dark.svg", "local-file-disabled-closed-light.svg")
: resourceTreeItem.openstatus === "CLOSED"
? getIconPathInResources("local-file-closed-dark.svg", "local-file-closed-light.svg")
: resourceTreeItem.enablestatus === "DISABLED"
? getIconPathInResources("local-file-disabled-dark.svg", "local-file-disabled-light.svg")
: getIconPathInResources("local-file-dark.svg", "local-file-light.svg");
case "TASK":
return resourceTreeItem.runstatus === "RUNNING"
? getIconPathInResources("task-running-dark.svg", "task-running-light.svg")
: resourceTreeItem.runstatus === "SUSPENDED"
? getIconPathInResources("task-suspended-dark.svg", "task-suspended-light.svg")
: getIconPathInResources("task-dispatched-dark.svg", "task-dispatched-light.svg");
}
}

0 comments on commit 80da3c6

Please sign in to comment.