diff --git a/packages/sdk/src/doc/index.ts b/packages/sdk/src/doc/index.ts index ea755c8b..91710ae7 100644 --- a/packages/sdk/src/doc/index.ts +++ b/packages/sdk/src/doc/index.ts @@ -14,6 +14,7 @@ export * from "./ICMCIApiResponse"; export * from "./ICMCIRequestOptions"; export * from "./ICMCIResponseResultSummary"; export * from "./ICSDGroupParms"; +export * from "./IGetResourceUriOptions"; export * from "./IProgramParms"; export * from "./IResourceParms"; export * from "./IResourceQueryParms"; @@ -21,4 +22,5 @@ export * from "./IResultCacheParms"; export * from "./ITransactionParms"; export * from "./IURIMapParms"; export * from "./IWebServiceParms"; -export * from "./IGetResourceUriOptions"; +export * from "./resources"; + diff --git a/packages/sdk/src/doc/resources/ILocalFile.ts b/packages/sdk/src/doc/resources/ILocalFile.ts new file mode 100644 index 00000000..cc55d9c8 --- /dev/null +++ b/packages/sdk/src/doc/resources/ILocalFile.ts @@ -0,0 +1,19 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IResource } from "./IResource"; + +export interface ILocalFile extends IResource { + file: string; + enablestatus: string; + openstatus: string; +} + diff --git a/packages/sdk/src/doc/resources/IPipeline.ts b/packages/sdk/src/doc/resources/IPipeline.ts new file mode 100644 index 00000000..52388326 --- /dev/null +++ b/packages/sdk/src/doc/resources/IPipeline.ts @@ -0,0 +1,16 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IResource } from "./IResource"; + +export interface IPipeline extends IResource { + name: string; +} diff --git a/packages/sdk/src/doc/resources/IProgram.ts b/packages/sdk/src/doc/resources/IProgram.ts new file mode 100644 index 00000000..3196ec46 --- /dev/null +++ b/packages/sdk/src/doc/resources/IProgram.ts @@ -0,0 +1,18 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IResource } from "./IResource"; + +export interface IProgram extends IResource { + program: string; + status: string; + newcopycnt?: string; +} diff --git a/packages/sdk/src/doc/resources/IRegion.ts b/packages/sdk/src/doc/resources/IRegion.ts new file mode 100644 index 00000000..c3e85eb9 --- /dev/null +++ b/packages/sdk/src/doc/resources/IRegion.ts @@ -0,0 +1,20 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IResource } from "./IResource"; + +export interface IRegion extends IResource { + applid: string; + cicsstate: string; + cicsstatus: string; + cicsname: string; +} + diff --git a/packages/sdk/src/doc/resources/IResource.ts b/packages/sdk/src/doc/resources/IResource.ts new file mode 100644 index 00000000..936ab5c8 --- /dev/null +++ b/packages/sdk/src/doc/resources/IResource.ts @@ -0,0 +1,15 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + + +export interface IResource { + eyu_cicsname: string; +} diff --git a/packages/sdk/src/doc/resources/ITCPIP.ts b/packages/sdk/src/doc/resources/ITCPIP.ts new file mode 100644 index 00000000..a67717ae --- /dev/null +++ b/packages/sdk/src/doc/resources/ITCPIP.ts @@ -0,0 +1,17 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IResource } from "./IResource"; + +export interface ITCPIP extends IResource { + name: string; + port: string; +} diff --git a/packages/sdk/src/doc/resources/ITask.ts b/packages/sdk/src/doc/resources/ITask.ts new file mode 100644 index 00000000..6708ecee --- /dev/null +++ b/packages/sdk/src/doc/resources/ITask.ts @@ -0,0 +1,18 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IResource } from "./IResource"; + +export interface ITask extends IResource { + task: string; + runstatus: string; + tranid: string; +} diff --git a/packages/sdk/src/doc/resources/ITransaction.ts b/packages/sdk/src/doc/resources/ITransaction.ts new file mode 100644 index 00000000..46403aca --- /dev/null +++ b/packages/sdk/src/doc/resources/ITransaction.ts @@ -0,0 +1,18 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IResource } from "./IResource"; + +export interface ITransaction extends IResource { + tranid: string; + program: string; + status: string; +} diff --git a/packages/sdk/src/doc/resources/IUriMap.ts b/packages/sdk/src/doc/resources/IUriMap.ts new file mode 100644 index 00000000..27d44c7b --- /dev/null +++ b/packages/sdk/src/doc/resources/IUriMap.ts @@ -0,0 +1,18 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IResource } from "./IResource"; + +export interface IUriMap extends IResource { + name: string; + scheme: string; + path: string; +} diff --git a/packages/sdk/src/doc/resources/IWebService.ts b/packages/sdk/src/doc/resources/IWebService.ts new file mode 100644 index 00000000..18372c0a --- /dev/null +++ b/packages/sdk/src/doc/resources/IWebService.ts @@ -0,0 +1,16 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IResource } from "./IResource"; + +export interface IWebService extends IResource { + name: string; +} diff --git a/packages/sdk/src/doc/resources/index.ts b/packages/sdk/src/doc/resources/index.ts new file mode 100644 index 00000000..d4ca356c --- /dev/null +++ b/packages/sdk/src/doc/resources/index.ts @@ -0,0 +1,24 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + + + +export * from './ILocalFile'; +export * from './IPipeline'; +export * from './IProgram'; +export * from './IRegion'; +export * from './IResource'; +export * from './ITask'; +export * from './ITCPIP'; +export * from './ITransaction'; +export * from './IUriMap'; +export * from './IWebService'; + diff --git a/packages/vsce/CHANGELOG.md b/packages/vsce/CHANGELOG.md index 0862a88e..7d1336da 100644 --- a/packages/vsce/CHANGELOG.md +++ b/packages/vsce/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to the "cics-extension-for-zowe" extension will be documente - BugFix: Editing profile results in exception - removed ability to multi-select profiles. [#222](https://github.com/zowe/cics-for-zowe-client/issues/222) - BugFix: Update documentation to reflect changes to fully support V3 profiles. [#209](https://github.com/zowe/cics-for-zowe-client/issues/209) +- Moved web-based resources in tree out of `Web` folder inline with others. ## `3.3.1` diff --git a/packages/vsce/__tests__/__unit__/doc/meta.localfile.test.ts b/packages/vsce/__tests__/__unit__/doc/meta.localfile.test.ts new file mode 100644 index 00000000..3175a3ef --- /dev/null +++ b/packages/vsce/__tests__/__unit__/doc/meta.localfile.test.ts @@ -0,0 +1,112 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { ILocalFile } from "@zowe/cics-for-zowe-sdk"; +import { LocalFileMeta } from "../../../src/doc/LocalFileMeta"; + +describe("Local File Meta", () => { + + let localFileMock: ILocalFile; + + beforeEach(() => { + localFileMock = { + file: "MYFILE", + enablestatus: "ENABLED", + eyu_cicsname: "MYREG", + openstatus: "OPEN" + }; + }); + + it("should return label", () => { + const label = LocalFileMeta.getLabel(localFileMock); + expect(label).toEqual(`MYFILE`); + }); + it("should return label with disabled", () => { + localFileMock.enablestatus = "DISABLED"; + const label = LocalFileMeta.getLabel(localFileMock); + expect(label).toEqual(`MYFILE (Disabled)`); + }); + it("should return label with unenabled", () => { + localFileMock.enablestatus = "UNENABLED"; + const label = LocalFileMeta.getLabel(localFileMock); + expect(label).toEqual(`MYFILE (Unenabled)`); + }); + it("should return label with closed", () => { + localFileMock.openstatus = "CLOSED"; + const label = LocalFileMeta.getLabel(localFileMock); + expect(label).toEqual(`MYFILE (Closed)`); + }); + it("should return label with disabled and closed", () => { + localFileMock.openstatus = "CLOSED"; + localFileMock.enablestatus = "DISABLED"; + const label = LocalFileMeta.getLabel(localFileMock); + expect(label).toEqual(`MYFILE (Disabled) (Closed)`); + }); + it("should return label with unenabled and closed", () => { + localFileMock.openstatus = "CLOSED"; + localFileMock.enablestatus = "UNENABLED"; + const label = LocalFileMeta.getLabel(localFileMock); + expect(label).toEqual(`MYFILE (Unenabled) (Closed)`); + }); + + it("should return context", () => { + const context = LocalFileMeta.getContext(localFileMock); + expect(context).toEqual(`cicslocalfile.enabled.open.MYFILE`); + }); + it("should return context with disabled", () => { + localFileMock.enablestatus = "DISABLED"; + const context = LocalFileMeta.getContext(localFileMock); + expect(context).toEqual(`cicslocalfile.disabled.open.MYFILE`); + }); + it("should return context with unenabled", () => { + localFileMock.enablestatus = "UNENABLED"; + const context = LocalFileMeta.getContext(localFileMock); + expect(context).toEqual(`cicslocalfile.unenabled.open.MYFILE`); + }); + it("should return context with closed", () => { + localFileMock.openstatus = "closed"; + const context = LocalFileMeta.getContext(localFileMock); + expect(context).toEqual(`cicslocalfile.enabled.closed.MYFILE`); + }); + it("should return context with disabled and closed", () => { + localFileMock.openstatus = "closed"; + localFileMock.enablestatus = "DISABLED"; + const context = LocalFileMeta.getContext(localFileMock); + expect(context).toEqual(`cicslocalfile.disabled.closed.MYFILE`); + }); + it("should return context with unenabled and closed", () => { + localFileMock.openstatus = "closed"; + localFileMock.enablestatus = "UNENABLED"; + const context = LocalFileMeta.getContext(localFileMock); + expect(context).toEqual(`cicslocalfile.unenabled.closed.MYFILE`); + }); + + it("should return icon name", () => { + const iconName = LocalFileMeta.getIconName(localFileMock); + expect(iconName).toEqual(`local-file`); + }); + it("should return icon name with disabled", () => { + localFileMock.enablestatus = "DISABLED"; + const iconName = LocalFileMeta.getIconName(localFileMock); + expect(iconName).toEqual(`local-file-disabled`); + }); + it("should return icon name with closed", () => { + localFileMock.openstatus = "CLOSED"; + const iconName = LocalFileMeta.getIconName(localFileMock); + expect(iconName).toEqual(`local-file-closed`); + }); + it("should return icon name with closed and disabled", () => { + localFileMock.openstatus = "CLOSED"; + localFileMock.enablestatus = "DISABLED"; + const iconName = LocalFileMeta.getIconName(localFileMock); + expect(iconName).toEqual(`local-file-disabled-closed`); + }); +}); diff --git a/packages/vsce/__tests__/__unit__/doc/meta.pipeline.test.ts b/packages/vsce/__tests__/__unit__/doc/meta.pipeline.test.ts new file mode 100644 index 00000000..124236f4 --- /dev/null +++ b/packages/vsce/__tests__/__unit__/doc/meta.pipeline.test.ts @@ -0,0 +1,40 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IPipeline } from "@zowe/cics-for-zowe-sdk"; +import { PipelineMeta } from "../../../src/doc/PipelineMeta"; + +describe("Pipeline Meta", () => { + + let pipelineMock: IPipeline; + + beforeEach(() => { + pipelineMock = { + name: "MYPIPE", + eyu_cicsname: "MYREG" + }; + }); + + it("should return label", () => { + const label = PipelineMeta.getLabel(pipelineMock); + expect(label).toEqual(`MYPIPE`); + }); + + it("should return context", () => { + const context = PipelineMeta.getContext(pipelineMock); + expect(context).toEqual(`cicspipeline.MYPIPE`); + }); + + it("should return icon name", () => { + const iconName = PipelineMeta.getIconName(pipelineMock); + expect(iconName).toEqual(`program`); + }); +}); diff --git a/packages/vsce/__tests__/__unit__/doc/meta.program.test.ts b/packages/vsce/__tests__/__unit__/doc/meta.program.test.ts new file mode 100644 index 00000000..77d89fba --- /dev/null +++ b/packages/vsce/__tests__/__unit__/doc/meta.program.test.ts @@ -0,0 +1,67 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IProgram } from "@zowe/cics-for-zowe-sdk"; +import { ProgramMeta } from "../../../src/doc/ProgramMeta"; + +describe("Program Meta", () => { + + let programMock: IProgram; + + beforeEach(() => { + programMock = { + program: "MYPROG", + status: "ENABLED", + eyu_cicsname: "MYREG" + }; + }); + + it("should return label", () => { + const label = ProgramMeta.getLabel(programMock); + expect(label).toEqual(`MYPROG`); + }); + it("should return label with disabled", () => { + programMock.status = "DISABLED"; + const label = ProgramMeta.getLabel(programMock); + expect(label).toEqual(`MYPROG (Disabled)`); + }); + it("should return label with newcopycount", () => { + programMock.newcopycnt = "2"; + const label = ProgramMeta.getLabel(programMock); + expect(label).toEqual(`MYPROG (New copy count: 2)`); + }); + it("should return label with disabled and newcopycount", () => { + programMock.status = "DISABLED"; + programMock.newcopycnt = "2"; + const label = ProgramMeta.getLabel(programMock); + expect(label).toEqual(`MYPROG (New copy count: 2) (Disabled)`); + }); + + it("should return context", () => { + const context = ProgramMeta.getContext(programMock); + expect(context).toEqual(`cicsprogram.enabled.MYPROG`); + }); + it("should return context with disabled", () => { + programMock.status = "DISABLED"; + const context = ProgramMeta.getContext(programMock); + expect(context).toEqual(`cicsprogram.disabled.MYPROG`); + }); + + it("should return icon name", () => { + const iconName = ProgramMeta.getIconName(programMock); + expect(iconName).toEqual(`program`); + }); + it("should return icon name with disabled", () => { + programMock.status = "DISABLED"; + const iconName = ProgramMeta.getIconName(programMock); + expect(iconName).toEqual(`program-disabled`); + }); +}); diff --git a/packages/vsce/__tests__/__unit__/doc/meta.region.test.ts b/packages/vsce/__tests__/__unit__/doc/meta.region.test.ts new file mode 100644 index 00000000..fc366479 --- /dev/null +++ b/packages/vsce/__tests__/__unit__/doc/meta.region.test.ts @@ -0,0 +1,66 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IRegion } from "@zowe/cics-for-zowe-sdk"; +import { RegionMeta } from "../../../src/doc/RegionMeta"; + +describe("Region Meta", () => { + + let regionMock: IRegion; + + beforeEach(() => { + regionMock = { + applid: "MYREG", + cicsname: "MYREG", + cicsstate: "ACTIVE", + cicsstatus: "ACTIVE", + eyu_cicsname: "MYREG" + }; + }); + + it("should return label", () => { + const label = RegionMeta.getLabel(regionMock); + expect(label).toEqual(`MYREG`); + }); + it("should return label with no applid from cicsname", () => { + // @ts-ignore + regionMock.applid = null; + const label = RegionMeta.getLabel(regionMock); + expect(label).toEqual(`MYREG`); + }); + + it("should return context", () => { + const context = RegionMeta.getContext(regionMock); + expect(context).toEqual(`cicsregion.myreg.active`); + }); + it("should return context when cicsstate inactive", () => { + regionMock.cicsstate = "INACTIVE"; + const context = RegionMeta.getContext(regionMock); + expect(context).toEqual(`cicsregion.myreg.inactive`); + }); + it("should return context when no cicsstate and cicsstatus inactive", () => { + // @ts-ignore + regionMock.cicsstate = null; + regionMock.cicsstatus = "INACTIVE"; + const context = RegionMeta.getContext(regionMock); + expect(context).toEqual(`cicsregion.myreg.inactive`); + }); + + it("should return icon name", () => { + const iconName = RegionMeta.getIconName(regionMock); + expect(iconName).toEqual(`region`); + }); + it("should return icon name with disabled", () => { + regionMock.cicsstate = "INACTIVE"; + const iconName = RegionMeta.getIconName(regionMock); + expect(iconName).toEqual(`region-disabled`); + }); +}); diff --git a/packages/vsce/__tests__/__unit__/doc/meta.task.test.ts b/packages/vsce/__tests__/__unit__/doc/meta.task.test.ts new file mode 100644 index 00000000..add66b19 --- /dev/null +++ b/packages/vsce/__tests__/__unit__/doc/meta.task.test.ts @@ -0,0 +1,57 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { ITask } from "@zowe/cics-for-zowe-sdk"; +import { TaskMeta } from "../../../src/doc/TaskMeta"; + +describe("Task Meta", () => { + + let taskMock: ITask; + + beforeEach(() => { + taskMock = { + task: "MYTASK", + eyu_cicsname: "MYREG", + runstatus: "RUNNING", + tranid: "TRAN" + }; + }); + + it("should return label", () => { + const label = TaskMeta.getLabel(taskMock); + expect(label).toEqual(`MYTASK - TRAN (RUNNING)`); + }); + it("should return label with suspended", () => { + taskMock.runstatus = "SUSPENDED"; + const label = TaskMeta.getLabel(taskMock); + expect(label).toEqual(`MYTASK - TRAN`); + }); + + it("should return context", () => { + const context = TaskMeta.getContext(taskMock); + expect(context).toEqual(`cicstask.MYTASK`); + }); + + it("should return icon name", () => { + const iconName = TaskMeta.getIconName(taskMock); + expect(iconName).toEqual(`task-running`); + }); + it("should return icon name with suspended", () => { + taskMock.runstatus = "SUSPENDED"; + const iconName = TaskMeta.getIconName(taskMock); + expect(iconName).toEqual(`task-suspended`); + }); + it("should return icon name with dispatched", () => { + taskMock.runstatus = "DISPATCHED"; + const iconName = TaskMeta.getIconName(taskMock); + expect(iconName).toEqual(`task-dispatched`); + }); +}); diff --git a/packages/vsce/__tests__/__unit__/doc/meta.tcpip.test.ts b/packages/vsce/__tests__/__unit__/doc/meta.tcpip.test.ts new file mode 100644 index 00000000..5dd27191 --- /dev/null +++ b/packages/vsce/__tests__/__unit__/doc/meta.tcpip.test.ts @@ -0,0 +1,47 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { ITCPIP } from "@zowe/cics-for-zowe-sdk"; +import { TCPIPMeta } from "../../../src/doc/TCPIPMeta"; + +describe("TCP IP Meta", () => { + + let tcpipMock: ITCPIP; + + beforeEach(() => { + tcpipMock = { + name: "MYTCPIP", + eyu_cicsname: "MYREG", + port: "12345" + }; + }); + + it("should return label", () => { + const label = TCPIPMeta.getLabel(tcpipMock); + expect(label).toEqual(`MYTCPIP [Port #12345]`); + }); + it("should return label with no port", () => { + // @ts-ignore + tcpipMock.port = null; + const label = TCPIPMeta.getLabel(tcpipMock); + expect(label).toEqual(`MYTCPIP`); + }); + + it("should return context", () => { + const context = TCPIPMeta.getContext(tcpipMock); + expect(context).toEqual(`cicstcpips.MYTCPIP`); + }); + + it("should return icon name", () => { + const iconName = TCPIPMeta.getIconName(tcpipMock); + expect(iconName).toEqual(`program`); + }); +}); diff --git a/packages/vsce/__tests__/__unit__/doc/meta.transaction.test.ts b/packages/vsce/__tests__/__unit__/doc/meta.transaction.test.ts new file mode 100644 index 00000000..8f8f26b9 --- /dev/null +++ b/packages/vsce/__tests__/__unit__/doc/meta.transaction.test.ts @@ -0,0 +1,57 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { ITransaction } from "@zowe/cics-for-zowe-sdk"; +import { TransactionMeta } from "../../../src/doc/TransactionMeta"; + +describe("Transaction Meta", () => { + + let transactionMock: ITransaction; + + beforeEach(() => { + transactionMock = { + tranid: "TRAN", + eyu_cicsname: "MYREG", + program: "MYPROG", + status: "ENABLED" + }; + }); + + it("should return label", () => { + const label = TransactionMeta.getLabel(transactionMock); + expect(label).toEqual(`TRAN`); + }); + it("should return label with disabled", () => { + transactionMock.status = "DISABLED"; + const label = TransactionMeta.getLabel(transactionMock); + expect(label).toEqual(`TRAN (Disabled)`); + }); + + it("should return context", () => { + const context = TransactionMeta.getContext(transactionMock); + expect(context).toEqual(`cicstransaction.enabled.TRAN`); + }); + it("should return context with disabled", () => { + transactionMock.status = "DISABLED"; + const context = TransactionMeta.getContext(transactionMock); + expect(context).toEqual(`cicstransaction.disabled.TRAN`); + }); + + it("should return icon name", () => { + const iconName = TransactionMeta.getIconName(transactionMock); + expect(iconName).toEqual(`local-transaction`); + }); + it("should return icon name with disabled", () => { + transactionMock.status = "DISABLED"; + const iconName = TransactionMeta.getIconName(transactionMock); + expect(iconName).toEqual(`local-transaction-disabled`); + }); +}); diff --git a/packages/vsce/__tests__/__unit__/doc/meta.urimap.test.ts b/packages/vsce/__tests__/__unit__/doc/meta.urimap.test.ts new file mode 100644 index 00000000..5ebdf99c --- /dev/null +++ b/packages/vsce/__tests__/__unit__/doc/meta.urimap.test.ts @@ -0,0 +1,62 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IUriMap } from "@zowe/cics-for-zowe-sdk"; +import { URIMapMeta } from "../../../src/doc/URIMapMeta"; + +describe("URIMap Meta", () => { + + let urimapMock: IUriMap; + + beforeEach(() => { + urimapMock = { + name: "MYURI", + eyu_cicsname: "MYREG", + path: "/a/b/c", + scheme: "http" + }; + }); + + it("should return label", () => { + const label = URIMapMeta.getLabel(urimapMock); + expect(label).toEqual(`MYURI [http] (/a/b/c)`); + }); + it("should return label with no scheme", () => { + // @ts-ignore + urimapMock.scheme = null; + const label = URIMapMeta.getLabel(urimapMock); + expect(label).toEqual(`MYURI (/a/b/c)`); + }); + it("should return label with no path", () => { + // @ts-ignore + urimapMock.path = null; + const label = URIMapMeta.getLabel(urimapMock); + expect(label).toEqual(`MYURI [http]`); + }); + it("should return label with no scheme or path", () => { + // @ts-ignore + urimapMock.path = null; + // @ts-ignore + urimapMock.scheme = null; + const label = URIMapMeta.getLabel(urimapMock); + expect(label).toEqual(`MYURI`); + }); + + it("should return context", () => { + const context = URIMapMeta.getContext(urimapMock); + expect(context).toEqual(`cicsurimaps.MYURI`); + }); + + it("should return icon name", () => { + const iconName = URIMapMeta.getIconName(urimapMock); + expect(iconName).toEqual(`program`); + }); +}); diff --git a/packages/vsce/__tests__/__unit__/doc/meta.webservice.test.ts b/packages/vsce/__tests__/__unit__/doc/meta.webservice.test.ts new file mode 100644 index 00000000..6caaf099 --- /dev/null +++ b/packages/vsce/__tests__/__unit__/doc/meta.webservice.test.ts @@ -0,0 +1,40 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IWebService } from "@zowe/cics-for-zowe-sdk"; +import { WebServiceMeta } from "../../../src/doc/WebServiceMeta"; + +describe("WebService Meta", () => { + + let webserviceMock: IWebService; + + beforeEach(() => { + webserviceMock = { + name: "WEBSERV", + eyu_cicsname: "MYREG" + }; + }); + + it("should return label", () => { + const label = WebServiceMeta.getLabel(webserviceMock); + expect(label).toEqual(`WEBSERV`); + }); + + it("should return context", () => { + const context = WebServiceMeta.getContext(webserviceMock); + expect(context).toEqual(`cicswebservice.WEBSERV`); + }); + + it("should return icon name", () => { + const iconName = WebServiceMeta.getIconName(webserviceMock); + expect(iconName).toEqual(`program`); + }); +}); diff --git a/packages/vsce/__tests__/__unit__/trees/CICSLocalFileTree.unit.test.ts b/packages/vsce/__tests__/__unit__/trees/CICSLocalFileTree.unit.test.ts deleted file mode 100644 index 3af4524a..00000000 --- a/packages/vsce/__tests__/__unit__/trees/CICSLocalFileTree.unit.test.ts +++ /dev/null @@ -1,138 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -const getFolderIconMock = jest.fn(); - -import { CICSRegionTree } from "../../../src/trees/CICSRegionTree"; -import { CICSLocalFileTreeItem } from "../../../src/trees/treeItems/CICSLocalFileTreeItem"; -import { CICSLocalFileTree } from "../../../src/trees/CICSLocalFileTree"; -import CustomError from "../../__utils__/CustomError"; -import * as vscode from "vscode"; -import * as globalMocks from "../../__utils__/globalMocks"; - -jest.mock("@zowe/cics-for-zowe-sdk"); -jest.mock("../../../src/trees/treeItems/CICSLocalFileTreeItem"); -jest.mock("../../../src/utils/iconUtils", () => { - return { getFolderIcon: getFolderIconMock }; -}); - -const getResourceMock = globalMocks.getResourceMock; -const toEscapedCriteriaString = globalMocks.toEscapedCriteriaString; -const CICSLocalFileTreeItemMock = {}; -const treeResourceMock = globalMocks.getDummyTreeResources("cicslocalfile", "fileName*"); -const record = [{ prop: "test1" }, { prop: "test2" }]; - -const workspaceMock = jest.spyOn(vscode.workspace, "getConfiguration"); -const get = jest.fn(); -const workspaceConfiguration = { - get: get, - update: jest.fn(), -}; - -describe("Test suite for CICSLocalFileTree", () => { - let sut: CICSLocalFileTree; - - beforeEach(() => { - getFolderIconMock.mockReturnValue(treeResourceMock.iconPath); - sut = new CICSLocalFileTree(globalMocks.cicsRegionTreeMock as any as CICSRegionTree); - expect(getFolderIconMock).toHaveBeenCalledWith(false); - }); - - afterEach(() => { - jest.resetAllMocks(); - }); - - describe("Test suite for addProgram()", () => { - it("Should add CICSLocalFileTreeItem into localFile", () => { - sut.addLocalFile(CICSLocalFileTreeItemMock as any as CICSLocalFileTreeItem); - expect(sut.children.length).toBeGreaterThanOrEqual(1); - }); - }); - - describe("Test suite for loadContents()", () => { - beforeEach(() => { - getResourceMock.mockResolvedValue(globalMocks.ICMCIApiResponseMock); - workspaceMock.mockReturnValue(workspaceConfiguration as any as vscode.WorkspaceConfiguration); - }); - afterEach(() => { - jest.resetAllMocks(); - }); - - it("Should add newProgramItem into the addProgram() and activeFilter is undefined", async () => { - globalMocks.ICMCIApiResponseMock.response.records[treeResourceMock.resourceName.toLowerCase()] = record; - get.mockReturnValue(treeResourceMock.defaultCriteria); - - await sut.loadContents(); - expect(workspaceMock).toHaveBeenCalled(); - expect(sut.activeFilter).toBeUndefined(); - expect(sut.children.length).toBeGreaterThanOrEqual(1); - expect(getFolderIconMock).toHaveBeenCalledWith(true); - }); - - it("Should add newProgramItem into the addProgram() and invoke toEscapedCriteriaString when activeFilter is defined", async () => { - sut.activeFilter = "Active"; - globalMocks.ICMCIApiResponseMock.response.records[treeResourceMock.resourceName.toLowerCase()] = record; - toEscapedCriteriaString.mockReturnValueOnce("PROGRAM"); - get.mockReturnValue([]); - - await sut.loadContents(); - expect(toEscapedCriteriaString).toHaveBeenCalled(); - expect(sut.activeFilter).toBeDefined(); - expect(sut.children.length).toBeGreaterThanOrEqual(1); - expect(getFolderIconMock).toHaveBeenCalledWith(true); - expect(workspaceMock).toHaveBeenCalledTimes(2); - }); - - it("Should throw exception when error.mMessage includes {exceeded a resource limit}", async () => { - getResourceMock.mockRejectedValue(new CustomError("Error in the method exceeded a resource limit")); - await sut.loadContents(); - expect(getResourceMock).toHaveBeenCalled(); - }); - - it("Should throw exception when error.mMessage include {exceeded a resource limit}", async () => { - getResourceMock.mockRejectedValue(new CustomError("Error in the method")); - - await sut.loadContents(); - expect(getResourceMock).toHaveBeenCalled(); - expect(sut.label).toEqual("Local Files [0]"); - }); - }); - - describe("Test suite for clearFilter", () => { - it("Should clear active filter to undefined and set contextValue to unfiltered", () => { - sut.activeFilter = "Active"; - - sut.clearFilter(); - expect(sut.activeFilter).toBeUndefined(); - expect(sut.contextValue).toEqual("cicstreelocalfile.unfiltered.localFiles"); - }); - }); - - describe("Test suite for setFilter", () => { - it("Should set active filter and set contextValue to filtered", () => { - sut.setFilter("ActiveFilter"); - expect(sut.activeFilter).toEqual("ActiveFilter"); - expect(sut.contextValue).toEqual("cicstreelocalfile.filtered.localFiles"); - }); - }); - - describe("Test suite for getFilter", () => { - it("Should return activeFilter object", () => { - expect(sut.getFilter()).toBe(sut.activeFilter); - }); - }); - - describe("Test suite for getParent", () => { - it("Should return parentRegion object", () => { - expect(sut.getParent()).toBe(sut.parentRegion); - }); - }); -}); diff --git a/packages/vsce/__tests__/__unit__/trees/CICSPlexTree.unit.test.ts b/packages/vsce/__tests__/__unit__/trees/CICSPlexTree.unit.test.ts index 3b008c5c..2803ca4a 100644 --- a/packages/vsce/__tests__/__unit__/trees/CICSPlexTree.unit.test.ts +++ b/packages/vsce/__tests__/__unit__/trees/CICSPlexTree.unit.test.ts @@ -18,48 +18,13 @@ import { CICSRegionTree } from "../../../src/trees/CICSRegionTree"; import { CICSPlexTree } from "../../../src/trees/CICSPlexTree"; import * as globalMocks from "../../__utils__/globalMocks"; -jest.mock("../../../src/trees/CICSCombinedTrees/CICSCombinedProgramTree", () => ({ - get CICSCombinedProgramTree() { - return cicsCombinedTreeMock; - }, -})); -jest.mock("../../../src/trees/CICSCombinedTrees/CICSCombinedTransactionTree", () => ({ - get CICSCombinedTransactionsTree() { - return cicsCombinedTreeMock; - }, -})); -jest.mock("../../../src/trees/CICSCombinedTrees/CICSCombinedLocalFileTree", () => ({ - get CICSCombinedLocalFileTree() { - return cicsCombinedTreeMock; - }, -})); -jest.mock("../../../src/trees/CICSCombinedTrees/CICSCombinedTaskTree", () => ({ - get CICSCombinedTaskTree() { - return cicsCombinedTreeMock; - }, -})); jest.mock("../../../src/trees/CICSCombinedTrees/CICSCombinedLibraryTree", () => ({ get CICSCombinedLibraryTree() { return cicsCombinedTreeMock; }, })); -jest.mock("../../../src/trees/CICSCombinedTrees/CICSCombinedTCPIPServiceTree", () => ({ - get CICSCombinedTCPIPServiceTree() { - return cicsCombinedTreeMock; - }, -})); -jest.mock("../../../src/trees/CICSCombinedTrees/CICSCombinedURIMapTree", () => ({ - get CICSCombinedURIMapTree() { - return cicsCombinedTreeMock; - }, -})); -jest.mock("../../../src/trees/CICSCombinedTrees/CICSCombinedPipelineTree", () => ({ - get CICSCombinedPipelineTree() { - return cicsCombinedTreeMock; - }, -})); -jest.mock("../../../src/trees/CICSCombinedTrees/CICSCombinedWebServiceTree", () => ({ - get CICSCombinedWebServiceTree() { +jest.mock("../../../src/trees/CICSCombinedTrees/CICSCombinedResourceTree", () => ({ + get CICSCombinedResourceTree() { return cicsCombinedTreeMock; }, })); diff --git a/packages/vsce/__tests__/__unit__/trees/CICSProgramTree.unit.test.ts b/packages/vsce/__tests__/__unit__/trees/CICSProgramTree.unit.test.ts deleted file mode 100644 index f09e430b..00000000 --- a/packages/vsce/__tests__/__unit__/trees/CICSProgramTree.unit.test.ts +++ /dev/null @@ -1,159 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -const getFolderIconMock = jest.fn(); - -import { imperative } from "@zowe/zowe-explorer-api"; -import { CICSRegionTree } from "../../../src/trees/CICSRegionTree"; -import { ICMCIApiResponse } from "@zowe/cics-for-zowe-sdk"; -import { CICSProgramTreeItem } from "../../../src/trees/treeItems/CICSProgramTreeItem"; -import * as filterUtils from "../../../src/utils/filterUtils"; -import { CICSProgramTree } from "../../../src/trees/CICSProgramTree"; -import CustomError from "../../__utils__/CustomError"; - -jest.mock("@zowe/cics-for-zowe-sdk"); -const zoweSdk = require("@zowe/cics-for-zowe-sdk"); - -jest.mock("../../../src/utils/iconUtils", () => { - return { getFolderIcon: getFolderIconMock }; -}); -jest.mock("../../../src/trees/treeItems/CICSProgramTreeItem"); - -const imperativeSession = new imperative.Session({ - user: "user", - password: "pwd", - hostname: "hostname", - protocol: "https", - type: "basic", - rejectUnauthorized: false, -}); -const CICSSessionTreeMock = { - session: imperativeSession, -}; - -const cicsRegionTreeMock = { - parentSession: CICSSessionTreeMock, - getRegionName: () => "IYK2ZXXX", - parentPlex: { - getPlexName: () => "PLEXX", - }, -}; -const CICSProgramTreeItemMock = {}; -const getResourceMock = jest.spyOn(zoweSdk, "getResource"); -const iconPath = "/icon/path"; -const cicsprogram = "cicsprogram"; -const value = "NOT (PROGRAM=CEE* OR PROGRAM=DFH* OR PROGRAM=CJ* OR PROGRAM=EYU* OR PROGRAM=CSQ* OR PROGRAM=CEL* OR PROGRAM=IGZ*)"; -const ICMCIApiResponseMock: ICMCIApiResponse = { - response: { - resultsummary: { api_response1: "1024", api_response2: "0", recordcount: "0", displayed_recordcount: "0" }, - records: {}, - }, -}; - -describe("Test suite for CICSProgramTree", () => { - let sut: CICSProgramTree; - - beforeEach(() => { - getFolderIconMock.mockReturnValue(iconPath); - sut = new CICSProgramTree(cicsRegionTreeMock as any as CICSRegionTree); - expect(getFolderIconMock).toHaveBeenCalledWith(false); - }); - - afterEach(() => { - jest.resetAllMocks(); - }); - - describe("Test suite for addProgram()", () => { - it("Should add CICSProgramTreeItem into program", () => { - sut.addProgram(CICSProgramTreeItemMock as any as CICSProgramTreeItem); - expect(sut.children.length).toBeGreaterThanOrEqual(1); - }); - }); - - describe("Test suite for loadContents()", () => { - let getDefaultProgramFilter: jest.SpyInstance; - - beforeEach(() => { - getDefaultProgramFilter = jest.spyOn(filterUtils, "getDefaultProgramFilter").mockResolvedValueOnce(value); - getResourceMock.mockImplementation(async () => ICMCIApiResponseMock); - }); - afterEach(() => { - getResourceMock.mockClear(); - jest.resetAllMocks(); - }); - - it("Should add newProgramItem into the addProgram() and activeFilter is undefined", async () => { - ICMCIApiResponseMock.response.records[cicsprogram.toLowerCase()] = [{ prop: "test1" }, { prop: "test2" }]; - - await sut.loadContents(); - expect(getDefaultProgramFilter).toHaveBeenCalled(); - expect(sut.activeFilter).toBeUndefined(); - expect(sut.children.length).toBeGreaterThanOrEqual(1); - expect(getFolderIconMock).toHaveBeenCalledWith(true); - }); - - it("Should add newProgramItem into the addProgram() and invoke toEscapedCriteriaString when activeFilter is defined", async () => { - sut.activeFilter = "Active"; - ICMCIApiResponseMock.response.records[cicsprogram.toLowerCase()] = [{ prop: "test1" }, { prop: "test2" }]; - const toEscapedCriteriaString = jest.spyOn(filterUtils, "toEscapedCriteriaString").mockReturnValueOnce("PROGRAM"); - - await sut.loadContents(); - expect(toEscapedCriteriaString).toHaveBeenCalled(); - expect(sut.activeFilter).toBeDefined(); - expect(sut.children.length).toBeGreaterThanOrEqual(1); - expect(getFolderIconMock).toHaveBeenCalledWith(true); - }); - - it("Should throw exception when error.mMessage includes {exceeded a resource limit}", async () => { - getResourceMock.mockRejectedValue(new CustomError("Error in the method exceeded a resource limit")); - await sut.loadContents(); - expect(getResourceMock).toHaveBeenCalled(); - }); - - it("Should throw exception when error.mMessage include {exceeded a resource limit}", async () => { - getResourceMock.mockRejectedValue(new CustomError("Error in the method")); - - await sut.loadContents(); - expect(getResourceMock).toHaveBeenCalled(); - expect(sut.label).toEqual("Programs [0]"); - }); - }); - - describe("Test suite for clearFilter", () => { - it("Should clear active filter to undefined and set contextValue to unfiltered", () => { - sut.activeFilter = "Active"; - - sut.clearFilter(); - expect(sut.activeFilter).toBeUndefined(); - expect(sut.contextValue).toEqual("cicstreeprogram.unfiltered.programs"); - }); - }); - - describe("Test suite for setFilter", () => { - it("Should set active filter and set contextValue to filtered", () => { - sut.setFilter("ActiveFilter"); - expect(sut.activeFilter).toEqual("ActiveFilter"); - expect(sut.contextValue).toEqual("cicstreeprogram.filtered.programs"); - }); - }); - - describe("Test suite for getFilter", () => { - it("Should return activeFilter object", () => { - expect(sut.getFilter()).toBe(sut.activeFilter); - }); - }); - - describe("Test suite for getParent", () => { - it("Should return parentRegion object", () => { - expect(sut.getParent()).toBe(sut.parentRegion); - }); - }); -}); diff --git a/packages/vsce/__tests__/__unit__/trees/CICSRegionTree.unit.test.ts b/packages/vsce/__tests__/__unit__/trees/CICSRegionTree.unit.test.ts index 2abe97e4..ed9fee69 100644 --- a/packages/vsce/__tests__/__unit__/trees/CICSRegionTree.unit.test.ts +++ b/packages/vsce/__tests__/__unit__/trees/CICSRegionTree.unit.test.ts @@ -9,52 +9,53 @@ * */ -const getIconByStatusMock = jest.fn(); - +import { IRegion } from "@zowe/cics-for-zowe-sdk"; import { CICSPlexTree } from "../../../src/trees/CICSPlexTree"; import { CICSRegionTree } from "../../../src/trees/CICSRegionTree"; import { CICSSessionTree } from "../../../src/trees/CICSSessionTree"; import * as globalMocks from "../../__utils__/globalMocks"; -jest.mock("../../../src/trees/CICSProgramTree"); -jest.mock("../../../src/trees/CICSTransactionTree"); -jest.mock("../../../src/trees/CICSLocalFileTree"); -jest.mock("../../../src/trees/CICSTaskTree"); -jest.mock("../../../src/trees/CICSLibraryTree"); -jest.mock("../../../src/trees/CICSWebTree"); - -jest.mock("../../../src/utils/iconUtils", () => { - return { getIconByStatus: getIconByStatusMock }; -}); +jest.mock("../../../src/trees/CICSResourceTree"); -const region = { +const region: IRegion = { cicsname: "cics", cicsstate: "ACTIVE", applid: "APPLID", + cicsstatus: "ACTIVE", + eyu_cicsname: "APPLID" }; -const region_disable = { +const region_disable: IRegion = { cicsname: "cics", - cicsstate: "DISABLE", + cicsstate: "INACTIVE", + applid: "applid", + cicsstatus: "INACTIVE", + eyu_cicsname: "applid" }; -const region_undefined = { +const region_undefined: IRegion = { cicsname: "cics", + cicsstate: "INACTIVE", + applid: "applid", + cicsstatus: "INACTIVE", + eyu_cicsname: "applid" }; -const treeResourceMock = globalMocks.getDummyTreeResources("cicsregion", ""); describe("Test suite for CICSRegionTree", () => { let sut: CICSRegionTree; beforeEach(() => { - getIconByStatusMock.mockReturnValue(treeResourceMock.iconPath); sut = new CICSRegionTree( - "regionName", region, globalMocks.CICSSessionTreeMock as any as CICSSessionTree, globalMocks.CICSPlexTree as any as CICSPlexTree, - "Parent", + globalMocks.CICSPlexTree as any as CICSPlexTree, ); - expect(getIconByStatusMock).toHaveBeenCalledWith("REGION", sut); + expect(sut.iconPath).toHaveProperty("light"); + expect(sut.iconPath).toHaveProperty("dark"); + // @ts-ignore + expect(sut.iconPath?.light).toContain("region-dark.svg"); + // @ts-ignore + expect(sut.iconPath?.dark).toContain("region-light.svg"); expect(sut.isActive).toBeTruthy(); }); @@ -62,29 +63,37 @@ describe("Test suite for CICSRegionTree", () => { jest.resetAllMocks(); }); - it("Should load region Tree when cicsstate is DISABLED", () => { + it("Should load region Tree when cicsstate is INACTIVE", () => { sut = new CICSRegionTree( - "regionName", region_disable, globalMocks.CICSSessionTreeMock as any as CICSSessionTree, globalMocks.CICSPlexTree as any as CICSPlexTree, - region, + globalMocks.CICSPlexTree as any as CICSPlexTree, ); - expect(getIconByStatusMock).toHaveBeenCalledWith("REGION", sut); + expect(sut.iconPath).toHaveProperty("light"); + expect(sut.iconPath).toHaveProperty("dark"); + // @ts-ignore + expect(sut.iconPath?.light).toContain("region-disabled-dark.svg"); + // @ts-ignore + expect(sut.iconPath?.dark).toContain("region-disabled-light.svg"); expect(sut.isActive).toBeFalsy(); }); it("Should load region Tree when cicsstate is ACTIVE", () => { sut = new CICSRegionTree( - "regionName", region_undefined, globalMocks.CICSSessionTreeMock as any as CICSSessionTree, globalMocks.CICSPlexTree as any as CICSPlexTree, - region, + globalMocks.CICSPlexTree as any as CICSPlexTree, ); - expect(getIconByStatusMock).toHaveBeenCalledWith("REGION", sut); + expect(sut.iconPath).toHaveProperty("light"); + expect(sut.iconPath).toHaveProperty("dark"); + // @ts-ignore + expect(sut.iconPath?.light).toContain("region-disabled-dark.svg"); + // @ts-ignore + expect(sut.iconPath?.dark).toContain("region-disabled-light.svg"); expect(sut.isActive).toBeFalsy(); }); @@ -98,7 +107,7 @@ describe("Test suite for CICSRegionTree", () => { }); it("Should return parent", () => { - expect(sut.getParent()).toBe("Parent"); + expect(sut.getParent()).toBe(globalMocks.CICSPlexTree); }); it("Should return isActive", () => { diff --git a/packages/vsce/__tests__/__unit__/trees/CICSResourceTree.unit.test.ts b/packages/vsce/__tests__/__unit__/trees/CICSResourceTree.unit.test.ts new file mode 100644 index 00000000..88ff8d74 --- /dev/null +++ b/packages/vsce/__tests__/__unit__/trees/CICSResourceTree.unit.test.ts @@ -0,0 +1,165 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import * as CICSSDK from "@zowe/cics-for-zowe-sdk"; +import { imperative } from "@zowe/zowe-explorer-api"; +import { ProgramMeta } from "../../../src/doc"; +import { CICSRegionTree } from "../../../src/trees/CICSRegionTree"; +import { CICSResourceTree } from "../../../src/trees/CICSResourceTree"; +import { CICSSessionTree } from "../../../src/trees/CICSSessionTree"; +import * as filterUtils from "../../../src/utils/filterUtils"; +import { window } from "vscode"; + +jest.mock("@zowe/cics-for-zowe-sdk"); +const zoweSdk = require("@zowe/cics-for-zowe-sdk"); + +const mockResponse: CICSSDK.ICMCIApiResponse = { + response: { + resultsummary: { + api_response1: "OK", + api_response2: "", + displayed_recordcount: '2', + recordcount: "2", + }, + records: { + cicsprogram: [ + { + program: "PROG1", + status: "ENABLED", + newcopycnt: "1", + }, + { + program: "PROG2", + status: "DISABLED", + newcopycnt: "2", + }, + ] + } + } +}; + +const getResourceMock = jest.spyOn(zoweSdk, "getResource"); +const filterMock = jest.spyOn(filterUtils, "getDefaultFilter"); +filterMock.mockImplementationOnce(async (params) => new Promise((resolve, reject) => { + resolve("NOT (PROGRAM=CEE* OR PROGRAM=DFH* OR PROGRAM=CJ* OR PROGRAM=EYU* OR PROGRAM=CSQ* OR PROGRAM=CEL* OR PROGRAM=IGZ*)"); +})); + +const profileMock = { + name: "MYPROF", + profile: { + host: "abc.com", + port: 12345 + } +}; +const regionMock: CICSSDK.IRegion = { + applid: "MYREG", + cicsname: "MYREG", + cicsstate: "ACTIVE", + cicsstatus: "ACTIVE", + eyu_cicsname: "MYREG" +}; + +const cicsSessionTreeMock = new CICSSessionTree(profileMock); +const cicsRegionTreeMock: CICSRegionTree = new CICSRegionTree(regionMock, cicsSessionTreeMock, undefined, cicsSessionTreeMock); + +describe("CICSResourceTreeItem", () => { + let resourceTree: CICSResourceTree; + let getDefaultProgramFilter: jest.SpyInstance; + + beforeEach(() => { + resourceTree = new CICSResourceTree(ProgramMeta, cicsRegionTreeMock); + expect(resourceTree.children).toHaveLength(0); + + getDefaultProgramFilter = jest.spyOn(filterUtils, "getDefaultFilter").mockResolvedValueOnce("NOT (PROGRAM=CEE* OR PROGRAM=DFH* OR PROGRAM=CJ* OR PROGRAM=EYU* OR PROGRAM=CSQ* OR PROGRAM=CEL* OR PROGRAM=IGZ*)"); + getResourceMock.mockImplementation(async () => mockResponse); + }); + + afterEach(() => { + jest.resetAllMocks(); + }); + + it("should have the correct label", () => { + expect(resourceTree.label).toEqual("Programs"); + }); + + it("should be able to set filter", () => { + resourceTree.setFilter("abc*"); + expect(resourceTree.activeFilter).toEqual("abc*"); + }); + + it("should be able to get filter", () => { + resourceTree.setFilter("abc*"); + expect(resourceTree.getFilter()).toEqual("abc*"); + }); + + it("should be able to clear filter", () => { + resourceTree.setFilter("abc*"); + expect(resourceTree.getFilter()).toEqual("abc*"); + resourceTree.clearFilter(); + expect(resourceTree.activeFilter).toBeUndefined(); + }); + + it("should be able to get parent", () => { + expect(resourceTree.getParent()).toEqual(cicsRegionTreeMock); + }); + + it("should be able to load contents", async () => { + expect(resourceTree.children).toHaveLength(0); + await resourceTree.loadContents(); + expect(filterMock).toHaveBeenCalled(); + expect(resourceTree.children).toHaveLength(2); + }); + + it("should be able to load contents with filter", async () => { + expect(resourceTree.children).toHaveLength(0); + resourceTree.setFilter("abc*"); + await resourceTree.loadContents(); + expect(filterMock).toHaveBeenCalled(); + expect(resourceTree.children).toHaveLength(2); + }); + + it("should be able to catch load contents resource limit error", async () => { + expect(resourceTree.children).toHaveLength(0); + + const showErrorMessageMock = jest.spyOn(window, 'showErrorMessage'); + + getResourceMock.mockImplementation(async () => { + throw new imperative.ImperativeError({ + msg: "exceeded a resource limit", + }); + }); + + await resourceTree.loadContents(); + expect(filterMock).toHaveBeenCalled(); + expect(showErrorMessageMock).toHaveBeenCalled(); + expect(showErrorMessageMock).toHaveBeenCalledWith(`Resource Limit Exceeded - Set a filter to narrow search`); + expect(resourceTree.children).toHaveLength(0); + }); + + it("should be able to catch load contents none found error", async () => { + expect(resourceTree.children).toHaveLength(0); + + const showInfoMessageMock = jest.spyOn(window, 'showInformationMessage'); + + getResourceMock.mockImplementation(async () => { + throw new imperative.ImperativeError({ + msg: "Something else happened", + }); + }); + + await resourceTree.loadContents(); + expect(filterMock).toHaveBeenCalled(); + expect(showInfoMessageMock).toHaveBeenCalled(); + expect(showInfoMessageMock).toHaveBeenCalledWith(`No Programs found`); + expect(resourceTree.children).toHaveLength(0); + }); + +}); diff --git a/packages/vsce/__tests__/__unit__/trees/CICSResourceTreeItem.unit.test.ts b/packages/vsce/__tests__/__unit__/trees/CICSResourceTreeItem.unit.test.ts new file mode 100644 index 00000000..4bfddb39 --- /dev/null +++ b/packages/vsce/__tests__/__unit__/trees/CICSResourceTreeItem.unit.test.ts @@ -0,0 +1,73 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IProgram, IRegion } from "@zowe/cics-for-zowe-sdk"; +import { ProgramMeta } from "../../../src/doc"; +import { CICSRegionTree } from "../../../src/trees/CICSRegionTree"; +import { CICSResourceTree } from "../../../src/trees/CICSResourceTree"; +import { CICSResourceTreeItem } from "../../../src/trees/treeItems/CICSResourceTreeItem"; +import { CICSSessionTree } from "../../../src/trees/CICSSessionTree"; + +const profileMock = { + name: "MYPROF", + profile: { + host: "abc.com", + port: 12345 + } +}; + +const programMock: IProgram = { + program: "MYPROG", + eyu_cicsname: "MYREG", + status: "ENABLED", + newcopycnt: "2" +}; + +const regionMock: IRegion = { + applid: "MYREG", + cicsname: "MYREG", + cicsstate: "ACTIVE", + cicsstatus: "ACTIVE", + eyu_cicsname: "MYREG" +}; + +const cicsSessionTreeMock = new CICSSessionTree(profileMock); +const cicsRegionTreeMock: CICSRegionTree = new CICSRegionTree(regionMock, cicsSessionTreeMock, undefined, cicsSessionTreeMock); +const resourceTreeMock: CICSResourceTree = new CICSResourceTree(ProgramMeta, cicsRegionTreeMock); + + +describe("CICSResourceTreeItem", () => { + let treeItem: CICSResourceTreeItem; + + beforeEach(() => { + resourceTreeMock.children = []; + treeItem = new CICSResourceTreeItem(programMock, ProgramMeta, cicsRegionTreeMock, resourceTreeMock); + resourceTreeMock.addResource(treeItem); + // expect(getFolderIconMock).toHaveBeenCalledWith(false); + }); + + afterEach(() => { + jest.resetAllMocks(); + }); + + it("should have the correct label", () => { + expect(treeItem.label).toEqual("MYPROG (New copy count: 2)"); + }); + + it("should be able to update label", () => { + treeItem.setLabel("UPDATED LABEL CONTENT"); + expect(treeItem.label).toEqual("UPDATED LABEL CONTENT"); + }); + + it("should return parent tree", () => { + expect(treeItem.getParent()).toEqual(resourceTreeMock); + }); +}); diff --git a/packages/vsce/__tests__/__unit__/trees/CICSTaskTree.unit.test.ts b/packages/vsce/__tests__/__unit__/trees/CICSTaskTree.unit.test.ts deleted file mode 100644 index 351a536c..00000000 --- a/packages/vsce/__tests__/__unit__/trees/CICSTaskTree.unit.test.ts +++ /dev/null @@ -1,147 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -const getFolderIconMock = jest.fn(); - -import { CICSRegionTree } from "../../../src/trees/CICSRegionTree"; -import { CICSTaskTree } from "../../../src/trees/CICSTaskTree"; -import * as globalMocks from "../../__utils__/globalMocks"; -import { CICSTaskTreeItem } from "../../../src/trees/treeItems/CICSTaskTreeItem"; -import * as vscode from "vscode"; -import CustomError from "../../__utils__/CustomError"; - -jest.mock("@zowe/cics-for-zowe-sdk"); -jest.mock("../../../src/utils/iconUtils", () => { - return { getFolderIcon: getFolderIconMock }; -}); -jest.mock("../../../src/trees/treeItems/CICSTaskTreeItem", () => ({ - get CICSTaskTreeItem() { - return jest.fn().mockImplementation(() => { - return { - setLabel: () => { - this.label = "label"; - }, - label: "Label", - }; - }); - }, -})); - -const getResourceMock = globalMocks.getResourceMock; -const treeResourceMock = globalMocks.getDummyTreeResources("cicstask", "fileName*"); -const cicsTaskTreeItemMock = {}; -const workspaceMock = jest.spyOn(vscode.workspace, "getConfiguration"); -const get = jest.fn(); -const workspaceConfiguration = { - get: get, - update: jest.fn(), - isFile: jest.fn().mockReturnValue(true), -}; -const record = [{ prop: "test1" }, { prop: "test2" }]; -const toEscapedCriteriaString = globalMocks.toEscapedCriteriaString; - -describe("Test suite for CICSTaskTree", () => { - let sut: CICSTaskTree; - - beforeEach(() => { - getFolderIconMock.mockReturnValue(treeResourceMock.iconPath); - - sut = new CICSTaskTree(globalMocks.cicsRegionTreeMock as any as CICSRegionTree); - expect(getFolderIconMock).toHaveBeenCalledWith(false); - }); - - afterEach(() => { - jest.resetAllMocks(); - }); - - describe("Test suite for addLibrary()", () => { - it("Should add CICSProgramTreeItem into library", () => { - sut.addTask(cicsTaskTreeItemMock as any as CICSTaskTreeItem); - expect(sut.children.length).toBeGreaterThanOrEqual(1); - }); - }); - - describe("Test suite for loadContents()", () => { - beforeEach(() => { - getResourceMock.mockResolvedValue(globalMocks.ICMCIApiResponseMock); - workspaceMock.mockReturnValue(workspaceConfiguration as any as vscode.WorkspaceConfiguration); - get.mockReturnValue(treeResourceMock.defaultCriteria); - }); - afterEach(() => { - getResourceMock.mockClear(); - jest.resetAllMocks(); - }); - - it("Should add newCICSTaskTreeItem into the addTask() and activeTransactionFilter is undefined", async () => { - globalMocks.ICMCIApiResponseMock.response.records[treeResourceMock.resourceName.toLowerCase()] = record; - - await sut.loadContents(); - expect(sut.children.length).toBeGreaterThanOrEqual(1); - expect(getFolderIconMock).toHaveBeenCalledWith(true); - expect(sut.activeTransactionFilter).toBeUndefined(); - expect(workspaceMock).toHaveBeenCalledTimes(1); - expect(sut.label).toBe("Tasks [2]"); - }); - - it("Should add newProgramItem into the addProgram() and invoke toEscapedCriteriaString when activeTransactionFilter is defined", async () => { - sut.activeTransactionFilter = "Active"; - globalMocks.ICMCIApiResponseMock.response.records[treeResourceMock.resourceName.toLowerCase()] = record; - toEscapedCriteriaString.mockReturnValueOnce("PROGRAM"); - get.mockReturnValue([]); - - await sut.loadContents(); - expect(toEscapedCriteriaString).toHaveBeenCalled(); - expect(sut.activeTransactionFilter).toBeDefined(); - expect(sut.children.length).toBeGreaterThanOrEqual(1); - expect(getFolderIconMock).toHaveBeenCalledWith(true); - expect(workspaceMock).toHaveBeenCalledTimes(2); - expect(sut.label).toBe("Tasks (Active) [2]"); - }); - - it("Should throw exception when error.mMessage includes {exceeded a resource limit}", async () => { - getResourceMock.mockRejectedValue(new CustomError("Error in the method exceeded a resource limit")); - await sut.loadContents(); - expect(getResourceMock).toHaveBeenCalled(); - }); - - it("Should throw exception when error.mMessage include {exceeded a resource limit}", async () => { - getResourceMock.mockRejectedValue(new CustomError("Error in the method")); - - await sut.loadContents(); - expect(getResourceMock).toHaveBeenCalled(); - expect(sut.label).toEqual("Tasks [0]"); - }); - }); - - describe("Test suite for clearFilter", () => { - it("Should clear active filter to undefined and set contextValue to unfiltered", () => { - sut.activeTransactionFilter = "Active"; - - sut.clearFilter(); - expect(sut.activeTransactionFilter).toBeUndefined(); - expect(sut.contextValue).toEqual("cicstreetask.unfiltered.tasks"); - }); - }); - - describe("Test suite for setFilter", () => { - it("Should set active filter and set contextValue to filtered", () => { - sut.setFilter("ActiveFilter"); - expect(sut.activeTransactionFilter).toEqual("ActiveFilter"); - expect(sut.contextValue).toEqual("cicstreetask.filtered.tasks"); - }); - }); - - describe("Test suite for getFilter", () => { - it("Should return activeFilter object", () => { - expect(sut.getFilter()).toBe(sut.activeTransactionFilter); - }); - }); -}); diff --git a/packages/vsce/__tests__/__unit__/trees/CICSTransactionTree.unit.test.ts b/packages/vsce/__tests__/__unit__/trees/CICSTransactionTree.unit.test.ts deleted file mode 100644 index 895a8a08..00000000 --- a/packages/vsce/__tests__/__unit__/trees/CICSTransactionTree.unit.test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -const getFolderIconMock = jest.fn(); - -import { CICSRegionTree } from "../../../src/trees/CICSRegionTree"; -import * as globalMocks from "../../__utils__/globalMocks"; -import CustomError from "../../__utils__/CustomError"; -import { CICSTransactionTree } from "../../../src/trees/CICSTransactionTree"; -import { CICSTransactionTreeItem } from "../../../src/trees/treeItems/CICSTransactionTreeItem"; -import * as filterUtils from "../../../src/utils/filterUtils"; - -jest.mock("@zowe/cics-for-zowe-sdk"); -jest.mock("../../../src/utils/iconUtils", () => { - return { getFolderIcon: getFolderIconMock }; -}); -jest.mock("../../../src/trees/treeItems/CICSTransactionTreeItem"); - -const getResourceMock = globalMocks.getResourceMock; -const treeResourceMock = globalMocks.getDummyTreeResources("cicslocaltransaction", "fileName*"); -const cicsTransactionTreeItemMock = {}; -const record = [{ prop: "test1" }, { prop: "test2" }]; -const toEscapedCriteriaString = globalMocks.toEscapedCriteriaString; -const getDefaultTransactionFilter = jest.spyOn(filterUtils, "getDefaultTransactionFilter"); - -describe("Test suite for CICSTaskTree", () => { - let sut: CICSTransactionTree; - - beforeEach(() => { - getFolderIconMock.mockReturnValue(treeResourceMock.iconPath); - - sut = new CICSTransactionTree(globalMocks.cicsRegionTreeMock as any as CICSRegionTree); - expect(getFolderIconMock).toHaveBeenCalledWith(false); - }); - - afterEach(() => { - jest.resetAllMocks(); - }); - - describe("Test suite for addTransaction()", () => { - it("Should add CICSTransactionTreeItem into transaction", () => { - sut.addTransaction(cicsTransactionTreeItemMock as any as CICSTransactionTreeItem); - expect(sut.children.length).toBeGreaterThanOrEqual(1); - }); - }); - - describe("Test suite for loadContents()", () => { - beforeEach(() => { - getResourceMock.mockResolvedValue(globalMocks.ICMCIApiResponseMock); - getDefaultTransactionFilter.mockResolvedValueOnce("PROGRAM"); - }); - afterEach(() => { - getResourceMock.mockClear(); - jest.resetAllMocks(); - }); - - it("Should add newTransactionItem into the addTransaction() and activeFilter is undefined", async () => { - globalMocks.ICMCIApiResponseMock.response.records[treeResourceMock.resourceName.toLowerCase()] = record; - - await sut.loadContents(); - - expect(sut.children.length).toBeGreaterThanOrEqual(1); - expect(getFolderIconMock).toHaveBeenCalledWith(true); - expect(sut.activeFilter).toBeUndefined(); - expect(sut.label).toBe("Transactions [2]"); - }); - - it("Should add newTransactionItem into the addTransaction() and invoke toEscapedCriteriaString when activeFilter is defined", async () => { - globalMocks.ICMCIApiResponseMock.response.records[treeResourceMock.resourceName.toLowerCase()] = record; - sut.activeFilter = "Active"; - toEscapedCriteriaString.mockReturnValueOnce("PROGRAM"); - - await sut.loadContents(); - expect(toEscapedCriteriaString).toHaveBeenCalled(); - expect(sut.activeFilter).toBeDefined(); - expect(sut.children.length).toBeGreaterThanOrEqual(1); - expect(getFolderIconMock).toHaveBeenCalledWith(true); - expect(sut.label).toBe("Transactions (Active) [2]"); - }); - - it("Should throw exception when error.mMessage includes {exceeded a resource limit}", async () => { - getResourceMock.mockRejectedValue(new CustomError("Error in the method exceeded a resource limit")); - await sut.loadContents(); - expect(getResourceMock).toHaveBeenCalled(); - }); - - it("Should throw exception when error.mMessage include {exceeded a resource limit}", async () => { - getResourceMock.mockRejectedValue(new CustomError("Error in the method")); - - await sut.loadContents(); - expect(getResourceMock).toHaveBeenCalled(); - expect(sut.label).toEqual("Transactions [0]"); - }); - }); - - describe("Test suite for clearFilter", () => { - it("Should clear active filter to undefined and set contextValue to unfiltered", () => { - sut.activeFilter = "Active"; - - sut.clearFilter(); - expect(sut.activeFilter).toBeUndefined(); - expect(sut.contextValue).toEqual("cicstreetransaction.unfiltered.transactions"); - }); - }); - - describe("Test suite for setFilter", () => { - it("Should set active filter and set contextValue to filtered", () => { - sut.setFilter("ActiveFilter"); - - expect(sut.activeFilter).toEqual("ActiveFilter"); - expect(sut.contextValue).toEqual("cicstreetransaction.filtered.transactions"); - }); - }); - - describe("Test suite for getFilter", () => { - it("Should return activeFilter object", () => { - expect(sut.getFilter()).toBe(sut.activeFilter); - }); - }); -}); diff --git a/packages/vsce/__tests__/__unit__/trees/CICSWebTree.unit.test.ts b/packages/vsce/__tests__/__unit__/trees/CICSWebTree.unit.test.ts deleted file mode 100644 index 1d22b0be..00000000 --- a/packages/vsce/__tests__/__unit__/trees/CICSWebTree.unit.test.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -const getFolderIconMock = jest.fn(); - -import { CICSRegionTree } from "../../../src/trees/CICSRegionTree"; -import { CICSWebTree } from "../../../src/trees/CICSWebTree"; -import * as globalMocks from "../../__utils__/globalMocks"; - -jest.mock("../../../src/trees/treeItems/web/CICSTCPIPServiceTree"); -jest.mock("../../../src/trees/treeItems/web/CICSURIMapTree"); -jest.mock("../../../src/trees/treeItems/web/CICSPipelineTree"); -jest.mock("../../../src/trees/treeItems/web/CICSWebServiceTree"); - -jest.mock("../../../src/utils/iconUtils", () => { - return { getFolderIcon: getFolderIconMock }; -}); - -const treeResourceMock = globalMocks.getDummyTreeResources("cicsregion", ""); - -describe("Test suite for CICSRegionTree", () => { - let sut: CICSWebTree; - - beforeEach(() => { - getFolderIconMock.mockReturnValue(treeResourceMock.iconPath); - sut = new CICSWebTree(globalMocks.cicsRegionTreeMock as any as CICSRegionTree); - expect(getFolderIconMock).toHaveBeenCalledWith(false); - }); - - afterEach(() => { - jest.resetAllMocks(); - }); - - it("Should load content", () => { - sut.loadContents(); - - expect(getFolderIconMock).toHaveBeenCalledWith(true); - }); - - it("Should return return all cics tree in children array", () => { - const result = sut.getChildren(); - expect(result?.length).toBeGreaterThanOrEqual(4); - }); - - it("Should return parent", () => { - expect(sut.getParent()).toBe(globalMocks.cicsRegionTreeMock); - }); -}); diff --git a/packages/vsce/__tests__/__unit__/utils/iconUtils.unit.test.ts b/packages/vsce/__tests__/__unit__/utils/iconUtils.unit.test.ts index 6de34dec..38f20e7e 100644 --- a/packages/vsce/__tests__/__unit__/utils/iconUtils.unit.test.ts +++ b/packages/vsce/__tests__/__unit__/utils/iconUtils.unit.test.ts @@ -1,4 +1,15 @@ -import { getIconByStatus, getFolderIcon, getIconFilePathFromName, getIconRootName } from "../../../src/utils/iconUtils"; +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { getFolderIcon, getIconFilePathFromName } from "../../../src/utils/iconUtils"; const iconPath = { light: "program-dark.svg", @@ -26,93 +37,4 @@ describe("Test suite for iconUtils", () => { expect(result.light).toContain("folder-closed-dark"); }); }); - - describe("Test suite for getIconRootName", () => { - // Using the common object for resourcesTreeItem - const resourceTreeItem = { - status: "", - openstatus: "", - enablestatus: "", - runstatus: "", - isActive: true, - }; - it("Should return program-disabled for PROGRAM resource with DISABLED status", () => { - resourceTreeItem.status = "DISABLED"; - const result = getIconRootName("PROGRAM", resourceTreeItem); - expect(result).toBe("program-disabled"); - }); - it("Should return program for PROGRAM resource with ENABLED status", () => { - resourceTreeItem.status = "ENABLED"; - const result = getIconRootName("PROGRAM", resourceTreeItem); - expect(result).toBe("program"); - }); - it("Should return local-transaction-disabled for TRANSACTION resource with DISABLED status", () => { - resourceTreeItem.status = "DISABLED"; - const result = getIconRootName("TRANSACTION", resourceTreeItem); - expect(result).toBe("local-transaction-disabled"); - }); - it("Should return local-transaction for TRANSACTION resource with ENABLED status", () => { - resourceTreeItem.status = "ENABLED"; - const result = getIconRootName("TRANSACTION", resourceTreeItem); - expect(result).toBe("local-transaction"); - }); - it("Should return local-file-disabled-closed for LOCAL_FILE resource with openstatus as CLOSED and enablestatus as CLOSED", () => { - resourceTreeItem.openstatus = "CLOSED"; - resourceTreeItem.enablestatus = "DISABLED"; - const result = getIconRootName("LOCAL_FILE", resourceTreeItem); - expect(result).toBe("local-file-disabled-closed"); - }); - it("Should return local-file-closed for LOCAL_FILE resource with openstatus as CLOSED", () => { - resourceTreeItem.enablestatus = "ENABLED"; - resourceTreeItem.openstatus = "CLOSED"; - const result = getIconRootName("LOCAL_FILE", resourceTreeItem); - expect(result).toBe("local-file-closed"); - }); - it("Should return local-file-disabled for LOCAL_FILE resource with enablestatus as DISABLED", () => { - resourceTreeItem.openstatus = "OPEN"; - resourceTreeItem.enablestatus = "DISABLED"; - const result = getIconRootName("LOCAL_FILE", resourceTreeItem); - expect(result).toBe("local-file-disabled"); - }); - it("Should return local-file for LOCAL_FILE resource with enablestatus as ENABLED and openstatus as OPEM", () => { - resourceTreeItem.enablestatus = "ENABLED"; - resourceTreeItem.openstatus = "OPEN"; - const result = getIconRootName("LOCAL_FILE", resourceTreeItem); - expect(result).toBe("local-file"); - }); - it("Should return task-running for TASK resource with runstatus as RUNNING", () => { - resourceTreeItem.runstatus = "RUNNING"; - const result = getIconRootName("TASK", resourceTreeItem); - expect(result).toBe("task-running"); - }); - it("Should return task-suspended for TASK resource with runstatus as SUSPENDED", () => { - resourceTreeItem.runstatus = "SUSPENDED"; - const result = getIconRootName("TASK", resourceTreeItem); - expect(result).toBe("task-suspended"); - }); - it("Should return task-dispatched for TASK resource with runstatus as DISPATCHED", () => { - resourceTreeItem.runstatus = "DISPATCHED"; - const result = getIconRootName("TASK", resourceTreeItem); - expect(result).toBe("task-dispatched"); - }); - it("Should return region for REGION resource with isActive as true", () => { - const result = getIconRootName("REGION", resourceTreeItem); - expect(result).toBe("region"); - }); - it("Should return region-disabled for REGION resource with isActive as false", () => { - resourceTreeItem.isActive = false; - const result = getIconRootName("REGION", resourceTreeItem); - expect(result).toBe("region-disabled"); - }); - }); - - describe("Test suite for getIconByStatus", () => { - const resource = { - status: "DISABLED", - }; - it("Should return icon based on resource status", () => { - const result = getIconByStatus("PROGRAM", resource); - expect(result.dark).toContain("program-disabled"); - }); - }); }); diff --git a/packages/vsce/package.json b/packages/vsce/package.json index 34d1488e..9b4553bb 100644 --- a/packages/vsce/package.json +++ b/packages/vsce/package.json @@ -15,10 +15,7 @@ "categories": [ "Other" ], - "activationEvents": [ - "onCommand:cics-extension-for-zowe.addSession", - "onView:cics-view" - ], + "activationEvents": [], "extensionDependencies": [ "Zowe.vscode-extension-for-zowe" ], @@ -738,6 +735,216 @@ "command": "cics-extension-for-zowe.purgeTask", "group": "000_zowecics_main@1" } + ], + "commandPalette": [ + { + "command": "cics-extension-for-zowe.addSession", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.refreshTree", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.newCopyProgram", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterPrograms", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterDatasetPrograms", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterLibraries", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterDatasets", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterTCPIPServices", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterURIMaps", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterPipelines", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterWebServices", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterTransactions", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterTasks", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterLocalFiles", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterPlexResources", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterAllPrograms", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterAllLibraries", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterAllPipelines", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterAllWebServices", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterAllTCPIPServices", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterAllURIMaps", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterAllTransactions", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterAllLocalFiles", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.filterAllTasks", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.clearFilter", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.clearPlexFilter", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.showProgramAttributes", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.showLibraryAttributes", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.showLibraryDatasetsAttributes", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.showTCPIPServiceAttributes", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.showURIMapAttributes", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.showTransactionAttributes", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.showLocalFileAttributes", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.showTaskAttributes", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.showPipelineAttributes", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.showWebServiceAttributes", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.showRegionAttributes", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.showRegionParameters", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.enableProgram", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.disableProgram", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.enableTransaction", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.disableTransaction", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.enableLocalFile", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.disableLocalFile", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.disableLibrary", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.closeLocalFile", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.openLocalFile", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.phaseInCommand", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.manageSession", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.inquireTransaction", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.inquireProgram", + "when": "never" + }, + { + "command": "cics-extension-for-zowe.purgeTask", + "when": "never" + } ] }, "configuration": { @@ -785,6 +992,30 @@ "description": "Default filter criteria for Library", "scope": "window" }, + "zowe.cics.tcpips.filter": { + "type": "string", + "default": "(NAME=*)", + "description": "Default filter criteria for TCPIP Services", + "scope": "window" + }, + "zowe.cics.urimaps.filter": { + "type": "string", + "default": "(NAME=*)", + "description": "Default filter criteria for URIMaps", + "scope": "window" + }, + "zowe.cics.pipelines.filter": { + "type": "string", + "default": "(NAME=*)", + "description": "Default filter criteria for Pipelines", + "scope": "window" + }, + "zowe.cics.webservices.filter": { + "type": "string", + "default": "(NAME=*)", + "description": "Default filter criteria for Web Services", + "scope": "window" + }, "zowe.cics.allPrograms.recordCountIncrement": { "type": "number", "default": 500, diff --git a/packages/vsce/src/commands/clearPlexFilterCommand.ts b/packages/vsce/src/commands/clearPlexFilterCommand.ts index 0c29d425..a9ab95b6 100644 --- a/packages/vsce/src/commands/clearPlexFilterCommand.ts +++ b/packages/vsce/src/commands/clearPlexFilterCommand.ts @@ -9,12 +9,49 @@ * */ +import { imperative } from "@zowe/zowe-explorer-api"; import { commands, TreeView, window } from "vscode"; import { CICSRegionsContainer } from "../trees/CICSRegionsContainer"; import { CICSRegionTree } from "../trees/CICSRegionTree"; import { CICSTree } from "../trees/CICSTree"; import { findSelectedNodes } from "../utils/commandUtils"; +const doClear = async (region: CICSRegionTree, context: string) => { + const treeToClear = region.children.filter((child: any) => child.contextValue.includes(`${context}.`))[0]; + treeToClear.clearFilter(); + await treeToClear.loadContents(); +}; + +const clearResourcesMethodMap: { [key: string]: (region: CICSRegionTree) => Promise; } = { + "Programs": async (region: CICSRegionTree) => doClear(region, "cicstreeprogram"), + "Local Transactions": async (region: CICSRegionTree) => doClear(region, "cicstreetransaction"), + "Local Files": async (region: CICSRegionTree) => doClear(region, "cicstreelocalfile"), + "Tasks": async (region: CICSRegionTree) => doClear(region, "cicstreetask"), + "Libraries": async (region: CICSRegionTree) => doClear(region, "cicstreelibrary"), + "TCPIP Services": async (region: CICSRegionTree) => doClear(region, "cicstreetcpips"), + "URI Maps": async (region: CICSRegionTree) => doClear(region, "cicstreeurimaps"), + "All": async (region: CICSRegionTree) => { + for (const child of region.children) { + child.clearFilter(); + await child.loadContents(); + } + }, +}; + +const getResourceToClear = async (profile: imperative.IProfile) => { + let clearOptions = ["Regions", "Programs", "Local Transactions", "Local Files", "Tasks", "Libraries", "All"]; + if (profile.regionName && profile.cicsPlex) { + clearOptions = ["Regions", ...clearOptions]; + } + + const resourceToClear = await window.showQuickPick(clearOptions); + if (!resourceToClear) { + window.showInformationMessage("No option selected"); + return null; + } + return resourceToClear; +}; + /** * Clear filter for a Regions Container (previously this was available on a plex) * @param tree @@ -23,7 +60,7 @@ import { findSelectedNodes } from "../utils/commandUtils"; */ export function getClearPlexFilterCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.clearPlexFilter", async (node) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSRegionsContainer, node); + const allSelectedNodes: CICSRegionsContainer[] = findSelectedNodes(treeview, CICSRegionsContainer, node); if (!allSelectedNodes || !allSelectedNodes.length) { window.showErrorMessage("No CICSPlex tree selected"); return; @@ -31,65 +68,21 @@ export function getClearPlexFilterCommand(tree: CICSTree, treeview: TreeView child.contextValue.includes("cicstreeprogram."))[0]; - treeToClear.clearFilter(); - await treeToClear.loadContents(); - } else if (resourceToClear === "Local Transactions") { - treeToClear = region.children.filter((child: any) => child.contextValue.includes("cicstreetransaction."))[0]; - treeToClear.clearFilter(); - await treeToClear.loadContents(); - } else if (resourceToClear === "Local Files") { - treeToClear = region.children.filter((child: any) => child.contextValue.includes("cicstreelocalfile."))[0]; - treeToClear.clearFilter(); - await treeToClear.loadContents(); - } else if (resourceToClear === "Tasks") { - treeToClear = region.children.filter((child: any) => child.contextValue.includes("cicstreetask."))[0]; - treeToClear.clearFilter(); - await treeToClear.loadContents(); - } else if (resourceToClear === "Libraries") { - treeToClear = region.children.filter((child: any) => child.contextValue.includes("cicstreelibrary."))[0]; - treeToClear.clearFilter(); - await treeToClear.loadContents(); - } else if (resourceToClear === "TCPIP Services") { - treeToClear = region.children.filter((child: any) => child.contextValue.includes("cicstreetcpips."))[0]; - treeToClear.clearFilter(); - await treeToClear.loadContents(); - } else if (resourceToClear === "URI Maps") { - treeToClear = region.children.filter((child: any) => child.contextValue.includes("cicstreeurimaps."))[0]; - treeToClear.clearFilter(); - await treeToClear.loadContents(); - } else if (resourceToClear === "All") { - for (const child of region.children) { - child.clearFilter(); - await child.loadContents(); - } - } - } - } + if (region instanceof CICSRegionTree && region.getIsActive() && region.children && resourceToClear in clearResourcesMethodMap) { + clearResourcesMethodMap[resourceToClear](region); } - tree._onDidChangeTreeData.fire(undefined); } } + tree._onDidChangeTreeData.fire(undefined); } }); } diff --git a/packages/vsce/src/commands/clearResourceFilterCommand.ts b/packages/vsce/src/commands/clearResourceFilterCommand.ts index 6742397f..16d87134 100644 --- a/packages/vsce/src/commands/clearResourceFilterCommand.ts +++ b/packages/vsce/src/commands/clearResourceFilterCommand.ts @@ -11,44 +11,23 @@ import { commands, ProgressLocation, TreeView, window } from "vscode"; import { CICSLibraryTree } from "../trees/CICSLibraryTree"; -import { CICSLocalFileTree } from "../trees/CICSLocalFileTree"; -import { CICSProgramTree } from "../trees/CICSProgramTree"; -import { CICSTaskTree } from "../trees/CICSTaskTree"; -import { CICSTransactionTree } from "../trees/CICSTransactionTree"; +import { CICSResourceTree } from "../trees/CICSResourceTree"; import { CICSTree } from "../trees/CICSTree"; import { CICSLibraryDatasets } from "../trees/treeItems/CICSLibraryDatasets"; import { CICSLibraryTreeItem } from "../trees/treeItems/CICSLibraryTreeItem"; -import { CICSPipelineTree } from "../trees/treeItems/web/CICSPipelineTree"; -import { CICSTCPIPServiceTree } from "../trees/treeItems/web/CICSTCPIPServiceTree"; -import { CICSURIMapTree } from "../trees/treeItems/web/CICSURIMapTree"; -import { CICSWebServiceTree } from "../trees/treeItems/web/CICSWebServiceTree"; import { findSelectedNodes } from "../utils/commandUtils"; export function getClearResourceFilterCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.clearFilter", async (node) => { - const allSelectedProgramTreeNodes = findSelectedNodes(treeview, CICSProgramTree, node); - const allSelectedTransactionTreeNodes = findSelectedNodes(treeview, CICSTransactionTree, node); - const allSelectedLocalFileTreeNodes = findSelectedNodes(treeview, CICSLocalFileTree, node); - const allSelectedTaskTreeNodes = findSelectedNodes(treeview, CICSTaskTree, node); + const allSelectedResourceTreeNodes = findSelectedNodes(treeview, CICSResourceTree, node); const allSelectedLibraryTreeNodes = findSelectedNodes(treeview, CICSLibraryTree, node); const allSelectedDatasetTreeNodes = findSelectedNodes(treeview, CICSLibraryTreeItem, node); const allSelectedDatasetProgramTreeNodes = findSelectedNodes(treeview, CICSLibraryDatasets, node); - const allSelectedTCPIPServicesTreeNodes = findSelectedNodes(treeview, CICSTCPIPServiceTree, node); - const allSelectedURIMapsTreeNodes = findSelectedNodes(treeview, CICSURIMapTree, node); - const allSelectedWebServiceTreeNodes = findSelectedNodes(treeview, CICSWebServiceTree, node); - const allSelectedPipelineTreeNodes = findSelectedNodes(treeview, CICSPipelineTree, node); const allSelectedNodes = [ - ...allSelectedProgramTreeNodes, - ...allSelectedTransactionTreeNodes, - ...allSelectedLocalFileTreeNodes, - ...allSelectedTaskTreeNodes, + ...allSelectedResourceTreeNodes, ...allSelectedLibraryTreeNodes, ...allSelectedDatasetTreeNodes, ...allSelectedDatasetProgramTreeNodes, - ...allSelectedTCPIPServicesTreeNodes, - ...allSelectedURIMapsTreeNodes, - ...allSelectedPipelineTreeNodes, - ...allSelectedWebServiceTreeNodes, ]; if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS resource tree selected"); diff --git a/packages/vsce/src/commands/closeLocalFileCommand.ts b/packages/vsce/src/commands/closeLocalFileCommand.ts index d9c165cb..ea4b2506 100644 --- a/packages/vsce/src/commands/closeLocalFileCommand.ts +++ b/packages/vsce/src/commands/closeLocalFileCommand.ts @@ -9,21 +9,21 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, IGetResourceUriOptions, ILocalFile, Utils } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; -import { CICSCombinedLocalFileTree } from "../trees/CICSCombinedTrees/CICSCombinedLocalFileTree"; +import { CICSCombinedResourceTree } from "../trees/CICSCombinedTrees/CICSCombinedResourceTree"; import { CICSRegionsContainer } from "../trees/CICSRegionsContainer"; import { CICSRegionTree } from "../trees/CICSRegionTree"; import { CICSTree } from "../trees/CICSTree"; -import { CICSLocalFileTreeItem } from "../trees/treeItems/CICSLocalFileTreeItem"; +import { CICSResourceTreeItem } from "../trees/treeItems/CICSResourceTreeItem"; import { findSelectedNodes, splitCmciErrorMessage } from "../utils/commandUtils"; -import { ICommandParams } from "./ICommandParams"; import constants from "../utils/constants"; +import { ICommandParams } from "./ICommandParams"; export function getCloseLocalFileCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.closeLocalFile", async (clickedNode) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSLocalFileTreeItem, clickedNode); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, clickedNode); if (!allSelectedNodes || !allSelectedNodes.length) { window.showErrorMessage("No CICS local file selected"); return; @@ -55,8 +55,8 @@ export function getCloseLocalFileCommand(tree: CICSTree, treeview: TreeView await closeLocalFile( currentNode.parentRegion.parentSession.session, { - name: currentNode.localFile.file, - regionName: currentNode.parentRegion.label, + name: currentNode.resource.file, + regionName: currentNode.parentRegion.region.applid, cicsPlex: currentNode.parentRegion.parentPlex ? currentNode.parentRegion.parentPlex.getPlexName() : undefined, }, busyDecision @@ -71,7 +71,7 @@ export function getCloseLocalFileCommand(tree: CICSTree, treeview: TreeView const [_resp, resp2, respAlt, eibfnAlt] = splitCmciErrorMessage(error.mMessage); window.showErrorMessage( - `Perform CLOSE on local file "${allSelectedNodes[parseInt(index)].localFile.file + `Perform CLOSE on local file "${allSelectedNodes[parseInt(index)].resource.file }" failed: EXEC CICS command (${eibfnAlt}) RESP(${respAlt}) RESP2(${resp2})` ); } else { @@ -95,7 +95,7 @@ export function getCloseLocalFileCommand(tree: CICSTree, treeview: TreeView if (parentRegion.parentPlex && parentRegion.parentPlex.children.some((child) => child instanceof CICSRegionsContainer)) { const allLocalFileTreeTree = parentRegion.parentPlex.children.filter((child: any) => child.contextValue.includes("cicscombinedlocalfiletree.") - )[0] as CICSCombinedLocalFileTree; + )[0] as CICSCombinedResourceTree; if (allLocalFileTreeTree.collapsibleState === 2 && allLocalFileTreeTree.getActiveFilter()) { await allLocalFileTreeTree.loadContents(tree); } diff --git a/packages/vsce/src/commands/disableCommands/disableLocalFileCommand.ts b/packages/vsce/src/commands/disableCommands/disableLocalFileCommand.ts index 8ab01f2e..651dad73 100644 --- a/packages/vsce/src/commands/disableCommands/disableLocalFileCommand.ts +++ b/packages/vsce/src/commands/disableCommands/disableLocalFileCommand.ts @@ -9,26 +9,26 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, IGetResourceUriOptions, ILocalFile, Utils } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; -import { CICSCombinedLocalFileTree } from "../../trees/CICSCombinedTrees/CICSCombinedLocalFileTree"; +import { CICSCombinedResourceTree } from "../../trees/CICSCombinedTrees/CICSCombinedResourceTree"; import { CICSRegionsContainer } from "../../trees/CICSRegionsContainer"; import { CICSRegionTree } from "../../trees/CICSRegionTree"; import { CICSTree } from "../../trees/CICSTree"; +import { CICSResourceTreeItem } from "../../trees/treeItems/CICSResourceTreeItem"; import { findSelectedNodes } from "../../utils/commandUtils"; -import { ICommandParams } from "../ICommandParams"; -import { CICSLocalFileTreeItem } from "../../trees/treeItems/CICSLocalFileTreeItem"; import constants from "../../utils/constants"; +import { ICommandParams } from "../ICommandParams"; export function getDisableLocalFileCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.disableLocalFile", async (clickedNode) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSLocalFileTreeItem, clickedNode); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, clickedNode); if (!allSelectedNodes || !allSelectedNodes.length) { window.showErrorMessage("No CICS local file selected"); return; } - const parentRegions: CICSRegionTree[] = []; + const parentRegions = new Set(); let busyDecision = await window.showInformationMessage( `Choose one of the following for the file busy condition`, ...["Wait", "No Wait", "Force"] @@ -55,15 +55,13 @@ export function getDisableLocalFileCommand(tree: CICSTree, treeview: TreeView child instanceof CICSRegionsContainer)) { const allLocalFileTreeTree = parentRegion.parentPlex.children.filter((child: any) => child.contextValue.includes("cicscombinedlocalfiletree.") - )[0] as CICSCombinedLocalFileTree; + )[0] as CICSCombinedResourceTree; if (allLocalFileTreeTree.collapsibleState === 2 && allLocalFileTreeTree.getActiveFilter()) { await allLocalFileTreeTree.loadContents(tree); } diff --git a/packages/vsce/src/commands/disableCommands/disableProgramCommand.ts b/packages/vsce/src/commands/disableCommands/disableProgramCommand.ts index 0e93cc17..a3aaf1ea 100644 --- a/packages/vsce/src/commands/disableCommands/disableProgramCommand.ts +++ b/packages/vsce/src/commands/disableCommands/disableProgramCommand.ts @@ -9,17 +9,17 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, IGetResourceUriOptions, IProgram, Utils } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; -import { CICSCombinedProgramTree } from "../../trees/CICSCombinedTrees/CICSCombinedProgramTree"; +import { CICSCombinedResourceTree } from "../../trees/CICSCombinedTrees/CICSCombinedResourceTree"; import { CICSRegionsContainer } from "../../trees/CICSRegionsContainer"; import { CICSRegionTree } from "../../trees/CICSRegionTree"; import { CICSTree } from "../../trees/CICSTree"; +import { CICSResourceTreeItem } from "../../trees/treeItems/CICSResourceTreeItem"; import { findSelectedNodes } from "../../utils/commandUtils"; -import { CICSProgramTreeItem } from "../../trees/treeItems/CICSProgramTreeItem"; -import { ICommandParams } from "../ICommandParams"; import constants from "../../utils/constants"; +import { ICommandParams } from "../ICommandParams"; /** * Performs disable on selected CICSProgram nodes. @@ -28,12 +28,12 @@ import constants from "../../utils/constants"; */ export function getDisableProgramCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.disableProgram", async (clickedNode) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSProgramTreeItem, clickedNode); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, clickedNode); if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS program selected"); return; } - const parentRegions: CICSRegionTree[] = []; + const parentRegions = new Set(); await window.withProgress( { title: "Disable", @@ -52,15 +52,12 @@ export function getDisableProgramCommand(tree: CICSTree, treeview: TreeView try { await disableProgram(currentNode.parentRegion.parentSession.session, { - name: currentNode.program.program, - regionName: currentNode.parentRegion.label, + name: currentNode.resource.program, + regionName: currentNode.parentRegion.region.applid, cicsPlex: currentNode.parentRegion.parentPlex ? currentNode.parentRegion.parentPlex.getPlexName() : undefined, }); - if (!parentRegions.includes(currentNode.parentRegion)) { - parentRegions.push(currentNode.parentRegion); - } + parentRegions.add(currentNode.parentRegion); } catch (error) { - // @ts-ignore window.showErrorMessage( `Something went wrong when performing a disable - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( /(\\n\t|\\n|\\t)/gm, @@ -81,7 +78,7 @@ export function getDisableProgramCommand(tree: CICSTree, treeview: TreeView if (parentRegion.parentPlex && parentRegion.parentPlex.children.some((child) => child instanceof CICSRegionsContainer)) { const allProgramsTree = parentRegion.parentPlex.children.filter((child: any) => child.contextValue.includes("cicscombinedprogramtree.") - )[0] as CICSCombinedProgramTree; + )[0] as CICSCombinedResourceTree; if (allProgramsTree.collapsibleState === 2 && allProgramsTree.getActiveFilter()) { await allProgramsTree.loadContents(tree); } diff --git a/packages/vsce/src/commands/disableCommands/disableTransactionCommand.ts b/packages/vsce/src/commands/disableCommands/disableTransactionCommand.ts index 256cb35d..f102c7cc 100644 --- a/packages/vsce/src/commands/disableCommands/disableTransactionCommand.ts +++ b/packages/vsce/src/commands/disableCommands/disableTransactionCommand.ts @@ -9,21 +9,21 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, IGetResourceUriOptions, ITransaction, Utils } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; -import { CICSCombinedTransactionsTree } from "../../trees/CICSCombinedTrees/CICSCombinedTransactionTree"; +import { CICSCombinedResourceTree } from "../../trees/CICSCombinedTrees/CICSCombinedResourceTree"; import { CICSRegionsContainer } from "../../trees/CICSRegionsContainer"; import { CICSRegionTree } from "../../trees/CICSRegionTree"; import { CICSTree } from "../../trees/CICSTree"; +import { CICSResourceTreeItem } from "../../trees/treeItems/CICSResourceTreeItem"; import { findSelectedNodes, splitCmciErrorMessage } from "../../utils/commandUtils"; -import { CICSTransactionTreeItem } from "../../trees/treeItems/CICSTransactionTreeItem"; -import { ICommandParams } from "../ICommandParams"; import constants from "../../utils/constants"; +import { ICommandParams } from "../ICommandParams"; export function getDisableTransactionCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.disableTransaction", async (clickedNode) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSTransactionTreeItem, clickedNode); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, clickedNode); if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS Transaction selected"); return; @@ -47,8 +47,8 @@ export function getDisableTransactionCommand(tree: CICSTree, treeview: TreeView< try { await disableTransaction(currentNode.parentRegion.parentSession.session, { - name: currentNode.transaction.tranid, - regionName: currentNode.parentRegion.label, + name: currentNode.resource.tranid, + regionName: currentNode.parentRegion.region.applid, cicsPlex: currentNode.parentRegion.parentPlex ? currentNode.parentRegion.parentPlex.getPlexName() : undefined, }); if (!parentRegions.includes(currentNode.parentRegion)) { @@ -60,7 +60,7 @@ export function getDisableTransactionCommand(tree: CICSTree, treeview: TreeView< // @ts-ignore const [_resp, resp2, respAlt, eibfnAlt] = splitCmciErrorMessage(error.mMessage); window.showErrorMessage( - `Perform DISABLE on Transaction "${allSelectedNodes[parseInt(index)].transaction.tranid + `Perform DISABLE on Transaction "${allSelectedNodes[parseInt(index)].resource.tranid }" failed: EXEC CICS command (${eibfnAlt}) RESP(${respAlt}) RESP2(${resp2})` ); } else { @@ -85,7 +85,7 @@ export function getDisableTransactionCommand(tree: CICSTree, treeview: TreeView< if (parentRegion.parentPlex && parentRegion.parentPlex.children.some((child) => child instanceof CICSRegionsContainer)) { const allTransactionTree = parentRegion.parentPlex.children.filter((child: any) => child.contextValue.includes("cicscombinedtransactiontree.") - )[0] as CICSCombinedTransactionsTree; + )[0] as CICSCombinedResourceTree; if (allTransactionTree.collapsibleState === 2 && allTransactionTree.getActiveFilter()) { await allTransactionTree.loadContents(tree); } diff --git a/packages/vsce/src/commands/enableCommands/enableLocalFileCommand.ts b/packages/vsce/src/commands/enableCommands/enableLocalFileCommand.ts index d9049b7a..2c2dc940 100644 --- a/packages/vsce/src/commands/enableCommands/enableLocalFileCommand.ts +++ b/packages/vsce/src/commands/enableCommands/enableLocalFileCommand.ts @@ -9,21 +9,21 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, IGetResourceUriOptions, ILocalFile, Utils } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; -import { CICSCombinedLocalFileTree } from "../../trees/CICSCombinedTrees/CICSCombinedLocalFileTree"; +import { CICSCombinedResourceTree } from "../../trees/CICSCombinedTrees/CICSCombinedResourceTree"; import { CICSRegionsContainer } from "../../trees/CICSRegionsContainer"; import { CICSRegionTree } from "../../trees/CICSRegionTree"; import { CICSTree } from "../../trees/CICSTree"; -import { CICSLocalFileTreeItem } from "../../trees/treeItems/CICSLocalFileTreeItem"; +import { CICSResourceTreeItem } from "../../trees/treeItems/CICSResourceTreeItem"; import { findSelectedNodes } from "../../utils/commandUtils"; -import { ICommandParams } from "../ICommandParams"; import constants from "../../utils/constants"; +import { ICommandParams } from "../ICommandParams"; export function getEnableLocalFileCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.enableLocalFile", async (clickedNode) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSLocalFileTreeItem, clickedNode); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, clickedNode); if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS Local File selected"); return; @@ -47,8 +47,8 @@ export function getEnableLocalFileCommand(tree: CICSTree, treeview: TreeView child instanceof CICSRegionsContainer)) { const allLocalFileTreeTree = parentRegion.parentPlex.children.filter((child: any) => child.contextValue.includes("cicscombinedlocalfiletree.") - )[0] as CICSCombinedLocalFileTree; + )[0] as CICSCombinedResourceTree; if (allLocalFileTreeTree.collapsibleState === 2 && allLocalFileTreeTree.getActiveFilter()) { await allLocalFileTreeTree.loadContents(tree); } diff --git a/packages/vsce/src/commands/enableCommands/enableProgramCommand.ts b/packages/vsce/src/commands/enableCommands/enableProgramCommand.ts index 2d024e42..cdd14e68 100644 --- a/packages/vsce/src/commands/enableCommands/enableProgramCommand.ts +++ b/packages/vsce/src/commands/enableCommands/enableProgramCommand.ts @@ -9,17 +9,17 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, IGetResourceUriOptions, IProgram, Utils } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; -import { CICSCombinedProgramTree } from "../../trees/CICSCombinedTrees/CICSCombinedProgramTree"; +import { CICSCombinedResourceTree } from "../../trees/CICSCombinedTrees/CICSCombinedResourceTree"; import { CICSRegionsContainer } from "../../trees/CICSRegionsContainer"; import { CICSRegionTree } from "../../trees/CICSRegionTree"; import { CICSTree } from "../../trees/CICSTree"; -import { CICSProgramTreeItem } from "../../trees/treeItems/CICSProgramTreeItem"; +import { CICSResourceTreeItem } from "../../trees/treeItems/CICSResourceTreeItem"; import { findSelectedNodes } from "../../utils/commandUtils"; -import { ICommandParams } from "../ICommandParams"; import constants from "../../utils/constants"; +import { ICommandParams } from "../ICommandParams"; /** * Performs enable on selected CICSProgram nodes. @@ -28,7 +28,7 @@ import constants from "../../utils/constants"; */ export function getEnableProgramCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.enableProgram", async (clickedNode) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSProgramTreeItem, clickedNode); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, clickedNode); if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS program selected"); return; @@ -51,8 +51,8 @@ export function getEnableProgramCommand(tree: CICSTree, treeview: TreeView) try { await enableProgram(currentNode.parentRegion.parentSession.session, { - name: currentNode.program.program, - regionName: currentNode.parentRegion.label, + name: currentNode.resource.program, + regionName: currentNode.parentRegion.region.applid, cicsPlex: currentNode.parentRegion.parentPlex ? currentNode.parentRegion.parentPlex.getPlexName() : undefined, }); if (!parentRegions.includes(currentNode.parentRegion)) { @@ -79,7 +79,7 @@ export function getEnableProgramCommand(tree: CICSTree, treeview: TreeView) if (parentRegion.parentPlex && parentRegion.parentPlex.children.some((child) => child instanceof CICSRegionsContainer)) { const allProgramsTree = parentRegion.parentPlex.children.filter((child: any) => child.contextValue.includes("cicscombinedprogramtree.") - )[0] as CICSCombinedProgramTree; + )[0] as CICSCombinedResourceTree; if (allProgramsTree.collapsibleState === 2 && allProgramsTree.getActiveFilter()) { await allProgramsTree.loadContents(tree); } diff --git a/packages/vsce/src/commands/enableCommands/enableTransactionCommand.ts b/packages/vsce/src/commands/enableCommands/enableTransactionCommand.ts index 30572421..4c997c1f 100644 --- a/packages/vsce/src/commands/enableCommands/enableTransactionCommand.ts +++ b/packages/vsce/src/commands/enableCommands/enableTransactionCommand.ts @@ -9,21 +9,21 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, IGetResourceUriOptions, ITransaction, Utils } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; -import { CICSCombinedTransactionsTree } from "../../trees/CICSCombinedTrees/CICSCombinedTransactionTree"; +import { CICSCombinedResourceTree } from "../../trees/CICSCombinedTrees/CICSCombinedResourceTree"; import { CICSRegionsContainer } from "../../trees/CICSRegionsContainer"; import { CICSRegionTree } from "../../trees/CICSRegionTree"; import { CICSTree } from "../../trees/CICSTree"; +import { CICSResourceTreeItem } from "../../trees/treeItems/CICSResourceTreeItem"; import { findSelectedNodes } from "../../utils/commandUtils"; -import { CICSTransactionTreeItem } from "../../trees/treeItems/CICSTransactionTreeItem"; -import { ICommandParams } from "../ICommandParams"; import constants from "../../utils/constants"; +import { ICommandParams } from "../ICommandParams"; export function getEnableTransactionCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.enableTransaction", async (clickedNode) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSTransactionTreeItem, clickedNode); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, clickedNode); if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS transaction selected"); return; @@ -48,8 +48,8 @@ export function getEnableTransactionCommand(tree: CICSTree, treeview: TreeView child instanceof CICSRegionsContainer)) { const allTransactionTree = parentRegion.parentPlex.children.filter((child: any) => child.contextValue.includes("cicscombinedtransactiontree.") - )[0] as CICSCombinedTransactionsTree; + )[0] as CICSCombinedResourceTree; if (allTransactionTree.collapsibleState === 2 && allTransactionTree.getActiveFilter()) { await allTransactionTree.loadContents(tree); } diff --git a/packages/vsce/src/commands/filterAllResourceCommand.ts b/packages/vsce/src/commands/filterAllResourceCommand.ts index 29f6a4bb..86e33b1d 100644 --- a/packages/vsce/src/commands/filterAllResourceCommand.ts +++ b/packages/vsce/src/commands/filterAllResourceCommand.ts @@ -11,14 +11,7 @@ import { commands, TreeView, window } from "vscode"; import { CICSCombinedLibraryTree } from "../trees/CICSCombinedTrees/CICSCombinedLibraryTree"; -import { CICSCombinedLocalFileTree } from "../trees/CICSCombinedTrees/CICSCombinedLocalFileTree"; -import { CICSCombinedPipelineTree } from "../trees/CICSCombinedTrees/CICSCombinedPipelineTree"; -import { CICSCombinedProgramTree } from "../trees/CICSCombinedTrees/CICSCombinedProgramTree"; -import { CICSCombinedTaskTree } from "../trees/CICSCombinedTrees/CICSCombinedTaskTree"; -import { CICSCombinedTCPIPServiceTree } from "../trees/CICSCombinedTrees/CICSCombinedTCPIPServiceTree"; -import { CICSCombinedTransactionsTree } from "../trees/CICSCombinedTrees/CICSCombinedTransactionTree"; -import { CICSCombinedURIMapTree } from "../trees/CICSCombinedTrees/CICSCombinedURIMapTree"; -import { CICSCombinedWebServiceTree } from "../trees/CICSCombinedTrees/CICSCombinedWebServiceTree"; +import { CICSCombinedResourceTree } from "../trees/CICSCombinedTrees/CICSCombinedResourceTree"; import { CICSTree } from "../trees/CICSTree"; import { getPatternFromFilter } from "../utils/filterUtils"; import { PersistentStorage } from "../utils/PersistentStorage"; @@ -29,7 +22,7 @@ export function getFilterAllProgramsCommand(tree: CICSTree, treeview: TreeView let chosenNode; if (node) { chosenNode = node; - } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSCombinedTaskTree) { + } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSCombinedResourceTree) { chosenNode = selection[selection.length - 1]; } else { window.showErrorMessage("No CICS 'All Tasks' tree selected"); @@ -101,7 +94,7 @@ export function getFilterAllTCPIPServicesCommand(tree: CICSTree, treeview: TreeV let chosenNode; if (node) { chosenNode = node; - } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSCombinedTCPIPServiceTree) { + } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSCombinedResourceTree) { chosenNode = selection[selection.length - 1]; } else { window.showErrorMessage("No CICS 'All TCPIP Services' tree selected"); @@ -125,7 +118,7 @@ export function getFilterAllTransactionsCommand(tree: CICSTree, treeview: TreeVi let chosenNode; if (node) { chosenNode = node; - } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSCombinedTransactionsTree) { + } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSCombinedResourceTree) { chosenNode = selection[selection.length - 1]; } else { window.showErrorMessage("No CICS 'All Transactions' tree selected"); @@ -149,7 +142,7 @@ export function getFilterAllLocalFilesCommand(tree: CICSTree, treeview: TreeView let chosenNode; if (node) { chosenNode = node; - } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSCombinedLocalFileTree) { + } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSCombinedResourceTree) { chosenNode = selection[selection.length - 1]; } else { window.showErrorMessage("No CICS 'All Local Files' tree selected"); @@ -173,7 +166,7 @@ export function getFilterAllURIMapsCommand(tree: CICSTree, treeview: TreeView export function getFilterProgramsCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.filterPrograms", async (node) => { const selection = treeview.selection; - let chosenNode: CICSProgramTree; + let chosenNode: CICSResourceTree; if (node) { chosenNode = node; - } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSProgramTree) { + } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSResourceTree) { chosenNode = selection[selection.length - 1]; } else { window.showErrorMessage("No CICS program tree selected"); @@ -164,10 +158,10 @@ export function getFilterDatasetProgramsCommand(tree: CICSTree, treeview: TreeVi export function getFilterLocalFilesCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.filterLocalFiles", async (node) => { const selection = treeview.selection; - let chosenNode: CICSLocalFileTree; + let chosenNode: CICSResourceTree; if (node) { chosenNode = node; - } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSLocalFileTree) { + } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSResourceTree) { chosenNode = selection[selection.length - 1]; } else { window.showErrorMessage("No CICS local file tree selected"); @@ -198,10 +192,10 @@ export function getFilterLocalFilesCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.filterTasks", async (node) => { const selection = treeview.selection; - let chosenNode: CICSTaskTree; + let chosenNode: CICSResourceTree; if (node) { chosenNode = node; - } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSTaskTree) { + } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSResourceTree) { chosenNode = selection[selection.length - 1]; } else { window.showErrorMessage("No CICS task tree selected"); @@ -232,10 +226,10 @@ export function getFilterTasksCommand(tree: CICSTree, treeview: TreeView) { export function getFilterTransactionCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.filterTransactions", async (node) => { const selection = treeview.selection; - let chosenNode: CICSTransactionTree; + let chosenNode: CICSResourceTree; if (node) { chosenNode = node; - } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSTransactionTree) { + } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSResourceTree) { chosenNode = selection[selection.length - 1]; } else { window.showErrorMessage("No CICS transaction tree selected"); @@ -266,10 +260,10 @@ export function getFilterTransactionCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.filterTCPIPServices", async (node) => { const selection = treeview.selection; - let chosenNode: CICSTCPIPServiceTree; + let chosenNode: CICSResourceTree; if (node) { chosenNode = node; - } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSTCPIPServiceTree) { + } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSResourceTree) { chosenNode = selection[selection.length - 1]; } else { window.showErrorMessage("No CICS TCPIP Service tree selected"); @@ -300,10 +294,10 @@ export function getFilterTCPIPSCommand(tree: CICSTree, treeview: TreeView) export function getFilterURIMapsCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.filterURIMaps", async (node) => { const selection = treeview.selection; - let chosenNode: CICSURIMapTree; + let chosenNode: CICSResourceTree; if (node) { chosenNode = node; - } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSURIMapTree) { + } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSResourceTree) { chosenNode = selection[selection.length - 1]; } else { window.showErrorMessage("No CICS URI Maps tree selected"); @@ -334,10 +328,10 @@ export function getFilterURIMapsCommand(tree: CICSTree, treeview: TreeView) export function getFilterPipelinesCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.filterPipelines", async (node) => { const selection = treeview.selection; - let chosenNode: CICSPipelineTree; + let chosenNode: CICSResourceTree; if (node) { chosenNode = node; - } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSPipelineTree) { + } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSResourceTree) { chosenNode = selection[selection.length - 1]; } else { window.showErrorMessage("No CICS Pipelines tree selected"); @@ -368,10 +362,10 @@ export function getFilterPipelinesCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.filterWebServices", async (node) => { const selection = treeview.selection; - let chosenNode: CICSWebServiceTree; + let chosenNode: CICSResourceTree; if (node) { chosenNode = node; - } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSWebServiceTree) { + } else if (selection[selection.length - 1] && selection[selection.length - 1] instanceof CICSResourceTree) { chosenNode = selection[selection.length - 1]; } else { window.showErrorMessage("No CICS Web Services tree selected"); diff --git a/packages/vsce/src/commands/getFilterPlexResources.ts b/packages/vsce/src/commands/getFilterPlexResources.ts index 1c5b668d..e3fbc322 100644 --- a/packages/vsce/src/commands/getFilterPlexResources.ts +++ b/packages/vsce/src/commands/getFilterPlexResources.ts @@ -16,6 +16,39 @@ import { CICSTree } from "../trees/CICSTree"; import { getPatternFromFilter } from "../utils/filterUtils"; import { PersistentStorage } from "../utils/PersistentStorage"; + +const getSearchHistory = (persistentStorage: PersistentStorage, resourceToFilter: string): string[] | null => { + + const searchHistoryMap = { + "Programs": () => { return persistentStorage.getProgramSearchHistory(); }, + "Local Transactions": () => { return persistentStorage.getTransactionSearchHistory(); }, + "Local Files": () => { return persistentStorage.getLocalFileSearchHistory(); }, + "Tasks": () => { return persistentStorage.getTransactionSearchHistory(); }, + "Libraries": () => { return persistentStorage.getLibrarySearchHistory(); }, + "Regions": () => { return persistentStorage.getRegionSearchHistory(); }, + }; + + if (resourceToFilter in searchHistoryMap) { + return searchHistoryMap[resourceToFilter as keyof typeof searchHistoryMap](); + } + + window.showInformationMessage("No Selection Made"); + return null; + +}; + +const addSearchHistory = async (persistentStorage: PersistentStorage, resourceToFilter: string, pattern: string) => { + const searchHistoryMap = { + "Programs": async () => { await persistentStorage.addProgramSearchHistory(pattern); }, + "Local Transactions": async () => { await persistentStorage.addTransactionSearchHistory(pattern); }, + "Local Files": async () => { await persistentStorage.addLocalFileSearchHistory(pattern); }, + "Regions": async () => { await persistentStorage.addRegionSearchHistory(pattern); }, + "Tasks": async () => { await persistentStorage.addTransactionSearchHistory(pattern); }, + "Libraries": async () => { await persistentStorage.addLibrarySearchHistory(pattern); }, + }; + await searchHistoryMap[resourceToFilter as keyof typeof searchHistoryMap](); +}; + /** * Apply filter for a Regions Container (previously this was available on a plex) * @param tree @@ -36,45 +69,18 @@ export function getFilterPlexResources(tree: CICSTree, treeview: TreeView) } const plex = chosenNode.getParent(); const plexProfile = plex.getProfile(); - let resourceToFilter: any; + let resourceToFilter: string; if (plexProfile.profile.regionName && plexProfile.profile.cicsPlex) { resourceToFilter = await window.showQuickPick(["Programs", "Local Transactions", "Local Files", "Tasks", "Libraries"]); } else { resourceToFilter = await window.showQuickPick(["Regions", "Programs", "Local Transactions", "Local Files", "Tasks", "Libraries"]); } + const persistentStorage = new PersistentStorage("zowe.cics.persistent"); - let resourceHistory; - if (resourceToFilter === "Programs") { - resourceHistory = persistentStorage.getProgramSearchHistory(); - } else if (resourceToFilter === "Local Transactions") { - resourceHistory = persistentStorage.getTransactionSearchHistory(); - } else if (resourceToFilter === "Local Files") { - resourceHistory = persistentStorage.getLocalFileSearchHistory(); - } else if (resourceToFilter === "Tasks") { - resourceHistory = persistentStorage.getTransactionSearchHistory(); - } else if (resourceToFilter === "Libraries") { - resourceHistory = persistentStorage.getLibrarySearchHistory(); - } else if (resourceToFilter === "Regions") { - resourceHistory = persistentStorage.getRegionSearchHistory(); - } else { - window.showInformationMessage("No Selection Made"); - return; - } + const resourceHistory = getSearchHistory(persistentStorage, resourceToFilter); const pattern = await getPatternFromFilter(resourceToFilter.slice(0, -1), resourceHistory); if (pattern) { - if (resourceToFilter === "Programs") { - await persistentStorage.addProgramSearchHistory(pattern); - } else if (resourceToFilter === "Local Transactions") { - await persistentStorage.addTransactionSearchHistory(pattern); - } else if (resourceToFilter === "Local Files") { - await persistentStorage.addLocalFileSearchHistory(pattern); - } else if (resourceToFilter === "Regions") { - await persistentStorage.addRegionSearchHistory(pattern); - } else if (resourceToFilter === "Tasks") { - await persistentStorage.addTransactionSearchHistory(pattern); - } else if (resourceToFilter === "Libraries") { - await persistentStorage.addLibrarySearchHistory(pattern); - } + await addSearchHistory(persistentStorage, resourceToFilter, pattern); chosenNode.collapsibleState = TreeItemCollapsibleState.Expanded; diff --git a/packages/vsce/src/commands/index.ts b/packages/vsce/src/commands/index.ts index 41096c16..7aaf3b8e 100644 --- a/packages/vsce/src/commands/index.ts +++ b/packages/vsce/src/commands/index.ts @@ -18,12 +18,12 @@ import { getAddSessionCommand } from "./addSessionCommand"; import { getClearPlexFilterCommand } from "./clearPlexFilterCommand"; import { getClearResourceFilterCommand } from "./clearResourceFilterCommand"; import { getCloseLocalFileCommand } from "./closeLocalFileCommand"; -import { getManageSessionCommand } from "./manageSessionCommand"; import * as filterAllResourceCommands from "./filterAllResourceCommand"; import * as filterResourceCommands from "./filterResourceCommands"; import { getFilterPlexResources } from "./getFilterPlexResources"; import { getInquireProgramCommand } from "./inquireProgram"; import { getInquireTransactionCommand } from "./inquireTransaction"; +import { getManageSessionCommand } from "./manageSessionCommand"; import { getNewCopyCommand } from "./newCopyCommand"; import { getOpenLocalFileCommand } from "./openLocalFileCommand"; import { getPhaseInCommand } from "./phaseInCommand"; diff --git a/packages/vsce/src/commands/inquireProgram.ts b/packages/vsce/src/commands/inquireProgram.ts index 680972ee..5b101db1 100644 --- a/packages/vsce/src/commands/inquireProgram.ts +++ b/packages/vsce/src/commands/inquireProgram.ts @@ -9,14 +9,16 @@ * */ +import { IProgram, IResource, ITransaction } from "@zowe/cics-for-zowe-sdk"; import { commands, TreeView, window } from "vscode"; -import { CICSCombinedTransactionsTree } from "../trees/CICSCombinedTrees/CICSCombinedTransactionTree"; +import { CICSCombinedResourceTree } from "../trees/CICSCombinedTrees/CICSCombinedResourceTree"; +import { CICSLibraryTree } from "../trees/CICSLibraryTree"; import { CICSPlexTree } from "../trees/CICSPlexTree"; -import { CICSProgramTree } from "../trees/CICSProgramTree"; import { CICSRegionsContainer } from "../trees/CICSRegionsContainer"; import { CICSRegionTree } from "../trees/CICSRegionTree"; +import { CICSResourceTree } from "../trees/CICSResourceTree"; import { CICSTree } from "../trees/CICSTree"; -import { CICSTransactionTreeItem } from "../trees/treeItems/CICSTransactionTreeItem"; +import { CICSResourceTreeItem } from "../trees/treeItems/CICSResourceTreeItem"; import { findSelectedNodes } from "../utils/commandUtils"; /** @@ -24,13 +26,15 @@ import { findSelectedNodes } from "../utils/commandUtils"; */ export function getInquireProgramCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.inquireProgram", async (node) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSTransactionTreeItem, node) as CICSTransactionTreeItem[]; + const allSelectedNodes: CICSResourceTreeItem[] = + findSelectedNodes(treeview, CICSResourceTreeItem, node) as CICSResourceTreeItem[]; + if (!allSelectedNodes || !allSelectedNodes.length) { window.showErrorMessage("No CICS Transaction selected"); return; } - let resourceFolders; - if (allSelectedNodes[0].getParent() instanceof CICSCombinedTransactionsTree) { + let resourceFolders: (CICSResourceTree | CICSLibraryTree)[]; + if (allSelectedNodes[0].getParent() instanceof CICSCombinedResourceTree) { const cicsPlex: CICSPlexTree = allSelectedNodes[0].getParent().getParent(); const regionsContainer = cicsPlex.getChildren().filter((child) => child instanceof CICSRegionsContainer)[0]; //@ts-ignore @@ -43,17 +47,17 @@ export function getInquireProgramCommand(tree: CICSTree, treeview: TreeView } const tranids = []; for (const localTransactionTreeItem of allSelectedNodes) { - const transaction = localTransactionTreeItem.transaction; + const transaction = localTransactionTreeItem.resource as ITransaction; tranids.push(transaction["program"]); } // Comma separated filter const pattern = tranids.join(", "); - const programTree = resourceFolders.filter((child) => child instanceof CICSProgramTree)[0] as CICSProgramTree; + const programTree = resourceFolders.filter((child) => child instanceof CICSResourceTree)[0]; programTree.setFilter(pattern); await programTree.loadContents(); tree._onDidChangeTreeData.fire(undefined); - if (allSelectedNodes[0].getParent() instanceof CICSCombinedTransactionsTree) { + if (allSelectedNodes[0].getParent() instanceof CICSCombinedResourceTree) { const nodeToExpand: any = programTree; // TODO: Ideal situation would be to do await treeview.reveal(nodeToExpand), however this is resulting in an error, diff --git a/packages/vsce/src/commands/inquireTransaction.ts b/packages/vsce/src/commands/inquireTransaction.ts index 26b90931..7c39ec8e 100644 --- a/packages/vsce/src/commands/inquireTransaction.ts +++ b/packages/vsce/src/commands/inquireTransaction.ts @@ -9,14 +9,15 @@ * */ +import { ITask, ITransaction } from "@zowe/cics-for-zowe-sdk"; import { commands, TreeView, window } from "vscode"; -import { CICSCombinedTaskTree } from "../trees/CICSCombinedTrees/CICSCombinedTaskTree"; +import { CICSCombinedResourceTree } from "../trees/CICSCombinedTrees/CICSCombinedResourceTree"; import { CICSPlexTree } from "../trees/CICSPlexTree"; import { CICSRegionsContainer } from "../trees/CICSRegionsContainer"; import { CICSRegionTree } from "../trees/CICSRegionTree"; -import { CICSTransactionTree } from "../trees/CICSTransactionTree"; +import { CICSResourceTree } from "../trees/CICSResourceTree"; import { CICSTree } from "../trees/CICSTree"; -import { CICSTaskTreeItem } from "../trees/treeItems/CICSTaskTreeItem"; +import { CICSResourceTreeItem } from "../trees/treeItems/CICSResourceTreeItem"; import { findSelectedNodes } from "../utils/commandUtils"; /** @@ -24,13 +25,13 @@ import { findSelectedNodes } from "../utils/commandUtils"; */ export function getInquireTransactionCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.inquireTransaction", async (node) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSTaskTreeItem, node) as CICSTaskTreeItem[]; + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, node) as CICSResourceTreeItem[]; if (!allSelectedNodes || !allSelectedNodes.length) { window.showErrorMessage("No CICS Task selected"); return; } let resourceFolders; - if (allSelectedNodes[0].getParent() instanceof CICSCombinedTaskTree) { + if (allSelectedNodes[0].getParent() instanceof CICSCombinedResourceTree) { const cicsPlex: CICSPlexTree = allSelectedNodes[0].getParent().getParent(); const regionsContainer = cicsPlex.getChildren().filter((child) => child instanceof CICSRegionsContainer)[0]; //@ts-ignore @@ -43,17 +44,18 @@ export function getInquireTransactionCommand(tree: CICSTree, treeview: TreeView< } const tranids = []; for (const localTaskTreeItem of allSelectedNodes) { - const task = localTaskTreeItem.task; + const task = localTaskTreeItem.resource; tranids.push(task["tranid"]); } // Comma separated filter const pattern = tranids.join(", "); - const localTransactionTree = resourceFolders.filter((child) => child instanceof CICSTransactionTree)[0] as CICSTransactionTree; + const localTransactionTree = resourceFolders.filter( + (child) => child instanceof CICSResourceTree && child.resourceMeta.filterAttribute === "tranid")[0] as CICSResourceTree; localTransactionTree.setFilter(pattern); await localTransactionTree.loadContents(); tree._onDidChangeTreeData.fire(undefined); - if (allSelectedNodes[0].getParent() instanceof CICSCombinedTaskTree) { + if (allSelectedNodes[0].getParent() instanceof CICSCombinedResourceTree) { const nodeToExpand: any = localTransactionTree; // TODO: Ideal situation would be to do await treeview.reveal(nodeToExpand), however this is resulting in an error, diff --git a/packages/vsce/src/commands/manageSessionCommand.ts b/packages/vsce/src/commands/manageSessionCommand.ts index b6859cf5..df26d2ee 100644 --- a/packages/vsce/src/commands/manageSessionCommand.ts +++ b/packages/vsce/src/commands/manageSessionCommand.ts @@ -9,7 +9,7 @@ * */ -import { commands, ProgressLocation, TreeView, window } from "vscode"; +import { commands, TreeView } from "vscode"; import { CICSTree } from "../trees/CICSTree"; export function getManageSessionCommand(tree: CICSTree, treeview: TreeView) { diff --git a/packages/vsce/src/commands/newCopyCommand.ts b/packages/vsce/src/commands/newCopyCommand.ts index 599a8e7f..c2e62e4a 100644 --- a/packages/vsce/src/commands/newCopyCommand.ts +++ b/packages/vsce/src/commands/newCopyCommand.ts @@ -9,13 +9,13 @@ * */ -import { programNewcopy } from "@zowe/cics-for-zowe-sdk"; +import { IProgram, programNewcopy } from "@zowe/cics-for-zowe-sdk"; import { commands, ProgressLocation, TreeView, window } from "vscode"; -import { CICSCombinedProgramTree } from "../trees/CICSCombinedTrees/CICSCombinedProgramTree"; +import { CICSCombinedResourceTree } from "../trees/CICSCombinedTrees/CICSCombinedResourceTree"; import { CICSRegionsContainer } from "../trees/CICSRegionsContainer"; import { CICSRegionTree } from "../trees/CICSRegionTree"; import { CICSTree } from "../trees/CICSTree"; -import { CICSProgramTreeItem } from "../trees/treeItems/CICSProgramTreeItem"; +import { CICSResourceTreeItem } from "../trees/treeItems/CICSResourceTreeItem"; import { findSelectedNodes, splitCmciErrorMessage } from "../utils/commandUtils"; import constants from "../utils/constants"; @@ -26,7 +26,7 @@ import constants from "../utils/constants"; */ export function getNewCopyCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.newCopyProgram", async (clickedNode) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSProgramTreeItem, clickedNode); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, clickedNode); if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS program selected"); return; @@ -49,8 +49,8 @@ export function getNewCopyCommand(tree: CICSTree, treeview: TreeView) { try { await programNewcopy(currentNode.parentRegion.parentSession.session, { - name: currentNode.program.program, - regionName: currentNode.parentRegion.label, + name: currentNode.resource.program, + regionName: `${currentNode.parentRegion.label}`, cicsPlex: currentNode.parentRegion.parentPlex ? currentNode.parentRegion.parentPlex.getPlexName() : undefined, }); if (!parentRegions.includes(currentNode.parentRegion)) { @@ -63,7 +63,7 @@ export function getNewCopyCommand(tree: CICSTree, treeview: TreeView) { // @ts-ignore const [_resp, resp2, respAlt, eibfnAlt] = splitCmciErrorMessage(error.mMessage); window.showErrorMessage( - `Perform NEWCOPY on Program "${allSelectedNodes[parseInt(index)].program.program + `Perform NEWCOPY on Program "${allSelectedNodes[parseInt(index)].resource.program }" failed: EXEC CICS command (${eibfnAlt}) RESP(${respAlt}) RESP2(${resp2})` ); } else { @@ -88,7 +88,7 @@ export function getNewCopyCommand(tree: CICSTree, treeview: TreeView) { if (parentRegion.parentPlex && parentRegion.parentPlex.children.some((child) => child instanceof CICSRegionsContainer)) { const allProgramsTree = parentRegion.parentPlex.children.filter((child: any) => child.contextValue.includes("cicscombinedprogramtree.") - )[0] as CICSCombinedProgramTree; + )[0] as CICSCombinedResourceTree; if (allProgramsTree.collapsibleState === 2 && allProgramsTree.getActiveFilter()) { await allProgramsTree.loadContents(tree); } diff --git a/packages/vsce/src/commands/openLocalFileCommand.ts b/packages/vsce/src/commands/openLocalFileCommand.ts index f9a2b7f4..5c176aca 100644 --- a/packages/vsce/src/commands/openLocalFileCommand.ts +++ b/packages/vsce/src/commands/openLocalFileCommand.ts @@ -9,21 +9,21 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, IGetResourceUriOptions, ILocalFile, Utils } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; -import { CICSCombinedLocalFileTree } from "../trees/CICSCombinedTrees/CICSCombinedLocalFileTree"; +import { CICSCombinedResourceTree } from "../trees/CICSCombinedTrees/CICSCombinedResourceTree"; import { CICSRegionsContainer } from "../trees/CICSRegionsContainer"; import { CICSRegionTree } from "../trees/CICSRegionTree"; import { CICSTree } from "../trees/CICSTree"; -import { CICSLocalFileTreeItem } from "../trees/treeItems/CICSLocalFileTreeItem"; +import { CICSResourceTreeItem } from "../trees/treeItems/CICSResourceTreeItem"; import { findSelectedNodes, splitCmciErrorMessage } from "../utils/commandUtils"; -import { ICommandParams } from "./ICommandParams"; import constants from "../utils/constants"; +import { ICommandParams } from "./ICommandParams"; export function getOpenLocalFileCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.openLocalFile", async (clickedNode) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSLocalFileTreeItem, clickedNode); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, clickedNode); if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS local file selected"); return; @@ -46,8 +46,8 @@ export function getOpenLocalFileCommand(tree: CICSTree, treeview: TreeView) try { await openLocalFile(currentNode.parentRegion.parentSession.session, { - name: currentNode.localFile.file, - regionName: currentNode.parentRegion.label, + name: currentNode.resource.file, + regionName: currentNode.parentRegion.region.applid, cicsPlex: currentNode.parentRegion.parentPlex ? currentNode.parentRegion.parentPlex.getPlexName() : undefined, }); if (!parentRegions.includes(currentNode.parentRegion)) { @@ -59,7 +59,7 @@ export function getOpenLocalFileCommand(tree: CICSTree, treeview: TreeView) // @ts-ignore const [_resp, resp2, respAlt, eibfnAlt] = splitCmciErrorMessage(error.mMessage); window.showErrorMessage( - `Perform OPEN on local file "${allSelectedNodes[parseInt(index)].localFile.file + `Perform OPEN on local file "${allSelectedNodes[parseInt(index)].resource.file }" failed: EXEC CICS command (${eibfnAlt}) RESP(${respAlt}) RESP2(${resp2})` ); } else { @@ -83,7 +83,7 @@ export function getOpenLocalFileCommand(tree: CICSTree, treeview: TreeView) if (parentRegion.parentPlex && parentRegion.parentPlex.children.some((child) => child instanceof CICSRegionsContainer)) { const allLocalFileTreeTree = parentRegion.parentPlex.children.filter((child: any) => child.contextValue.includes("cicscombinedlocalfiletree.") - )[0] as CICSCombinedLocalFileTree; + )[0] as CICSCombinedResourceTree; if (allLocalFileTreeTree.collapsibleState === 2 && allLocalFileTreeTree.getActiveFilter()) { await allLocalFileTreeTree.loadContents(tree); } diff --git a/packages/vsce/src/commands/phaseInCommand.ts b/packages/vsce/src/commands/phaseInCommand.ts index 2aac6612..7a45bb9b 100644 --- a/packages/vsce/src/commands/phaseInCommand.ts +++ b/packages/vsce/src/commands/phaseInCommand.ts @@ -9,14 +9,14 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, IGetResourceUriOptions, IProgram, Utils } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; -import { CICSCombinedProgramTree } from "../trees/CICSCombinedTrees/CICSCombinedProgramTree"; +import { CICSCombinedResourceTree } from "../trees/CICSCombinedTrees/CICSCombinedResourceTree"; import { CICSRegionsContainer } from "../trees/CICSRegionsContainer"; import { CICSRegionTree } from "../trees/CICSRegionTree"; import { CICSTree } from "../trees/CICSTree"; -import { CICSProgramTreeItem } from "../trees/treeItems/CICSProgramTreeItem"; +import { CICSResourceTreeItem } from "../trees/treeItems/CICSResourceTreeItem"; import { findSelectedNodes, splitCmciErrorMessage } from "../utils/commandUtils"; import constants from "../utils/constants"; @@ -27,7 +27,7 @@ import constants from "../utils/constants"; */ export function getPhaseInCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.phaseInCommand", async (clickedNode) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSProgramTreeItem, clickedNode); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, clickedNode); if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS program selected"); return; @@ -50,8 +50,8 @@ export function getPhaseInCommand(tree: CICSTree, treeview: TreeView) { try { await performPhaseIn(currentNode.parentRegion.parentSession.session, { - name: currentNode.program.program, - regionName: currentNode.parentRegion.label, + name: currentNode.resource.program, + regionName: currentNode.parentRegion.region.applid, cicsPlex: currentNode.parentRegion.parentPlex ? currentNode.parentRegion.parentPlex.getPlexName() : undefined, }); @@ -64,7 +64,7 @@ export function getPhaseInCommand(tree: CICSTree, treeview: TreeView) { // @ts-ignore const [_resp, resp2, respAlt, eibfnAlt] = splitCmciErrorMessage(error.mMessage); window.showErrorMessage( - `Perform PHASEIN on Program "${allSelectedNodes[parseInt(index)].program.program + `Perform PHASEIN on Program "${allSelectedNodes[parseInt(index)].resource.program }" failed: EXEC CICS command (${eibfnAlt}) RESP(${respAlt}) RESP2(${resp2})` ); } else { @@ -89,7 +89,7 @@ export function getPhaseInCommand(tree: CICSTree, treeview: TreeView) { if (parentRegion.parentPlex && parentRegion.parentPlex.children.some((child) => child instanceof CICSRegionsContainer)) { const allProgramsTree = parentRegion.parentPlex.children.filter((child: any) => child.contextValue.includes("cicscombinedprogramtree.") - )[0] as CICSCombinedProgramTree; + )[0] as CICSCombinedResourceTree; if (allProgramsTree.collapsibleState === 2 && allProgramsTree.getActiveFilter()) { await allProgramsTree.loadContents(tree); } diff --git a/packages/vsce/src/commands/purgeTaskCommand.ts b/packages/vsce/src/commands/purgeTaskCommand.ts index 8d6fe42c..1370748c 100644 --- a/packages/vsce/src/commands/purgeTaskCommand.ts +++ b/packages/vsce/src/commands/purgeTaskCommand.ts @@ -9,17 +9,17 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, IGetResourceUriOptions, ITask, Utils } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; -import { CICSCombinedTaskTree } from "../trees/CICSCombinedTrees/CICSCombinedTaskTree"; +import { CICSCombinedResourceTree } from "../trees/CICSCombinedTrees/CICSCombinedResourceTree"; import { CICSRegionsContainer } from "../trees/CICSRegionsContainer"; import { CICSRegionTree } from "../trees/CICSRegionTree"; import { CICSTree } from "../trees/CICSTree"; +import { CICSResourceTreeItem } from "../trees/treeItems/CICSResourceTreeItem"; import { findSelectedNodes, splitCmciErrorMessage } from "../utils/commandUtils"; -import { CICSTaskTreeItem } from "../trees/treeItems/CICSTaskTreeItem"; -import { ICommandParams } from "./ICommandParams"; import constants from "../utils/constants"; +import { ICommandParams } from "./ICommandParams"; /** * Purge a CICS Task and reload the CICS Task tree contents and the combined Task tree contents @@ -29,7 +29,7 @@ import constants from "../utils/constants"; */ export function getPurgeTaskCommand(tree: CICSTree, treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.purgeTask", async (clickedNode) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSTaskTreeItem, clickedNode); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, clickedNode); if (!allSelectedNodes || !allSelectedNodes.length) { window.showErrorMessage("No CICS task selected"); return; @@ -58,8 +58,8 @@ export function getPurgeTaskCommand(tree: CICSTree, treeview: TreeView) { await purgeTask( currentNode.parentRegion.parentSession.session, { - name: currentNode.task.task, - regionName: currentNode.parentRegion.label, + name: currentNode.resource.task, + regionName: currentNode.parentRegion.region.applid, cicsPlex: currentNode.parentRegion.parentPlex ? currentNode.parentRegion.parentPlex.getPlexName() : undefined, }, purgeType @@ -73,7 +73,7 @@ export function getPurgeTaskCommand(tree: CICSTree, treeview: TreeView) { // @ts-ignore const [_resp, resp2, respAlt, eibfnAlt] = splitCmciErrorMessage(error.mMessage); window.showErrorMessage( - `Perform ${purgeType?.toUpperCase()} on CICSTask "${allSelectedNodes[parseInt(index)].task.task + `Perform ${purgeType?.toUpperCase()} on CICSTask "${allSelectedNodes[parseInt(index)].resource.task }" failed: EXEC CICS command (${eibfnAlt}) RESP(${respAlt}) RESP2(${resp2})` ); } else { @@ -98,8 +98,8 @@ export function getPurgeTaskCommand(tree: CICSTree, treeview: TreeView) { // same task item in a CICS combined task tree of the same profile if (parentRegion.parentPlex && parentRegion.parentPlex.children.some((child) => child instanceof CICSRegionsContainer)) { const allTaskTreeTree = parentRegion.parentPlex.children.filter((child: any) => - child.contextValue.includes("cicscombinedlocalfiletree.") - )[0] as CICSCombinedTaskTree; + child.contextValue.includes("cicscombinedtasktree.") + )[0] as CICSCombinedResourceTree; // If allTasksTree is open if (allTaskTreeTree.collapsibleState === 2 && allTaskTreeTree.getActiveFilter()) { await allTaskTreeTree.loadContents(tree); diff --git a/packages/vsce/src/commands/refreshCommand.ts b/packages/vsce/src/commands/refreshCommand.ts index 65952c7d..e4cc4352 100644 --- a/packages/vsce/src/commands/refreshCommand.ts +++ b/packages/vsce/src/commands/refreshCommand.ts @@ -26,43 +26,6 @@ export function getRefreshCommand(tree: CICSTree) { } ); } finally { - // window.withProgress({ - // title: 'Refresh', - // location: ProgressLocation.Notification, - // cancellable: true - // }, async (progress, token) => { - // token.onCancellationRequested(() => { - // console.log("Cancelling the refresh"); - // }); - // for (const index in tree.loadedProfiles) { - // progress.report({ - // message: `Refreshing session ${parseInt(index) + 1} of ${tree.loadedProfiles.length}`, - // increment: (parseInt(index) / tree.loadedProfiles.length) * 100, - // }); - // let sessionTree = tree.loadedProfiles[parseInt(index)]; - - // sessionTree.collapsibleState = TreeItemCollapsibleState.Collapsed; - - // for (const sessionChild of sessionTree.children) { - // // sessionchhild is plex tree or region tree - // if (sessionChild instanceof CICSPlexTree) { - // // plex tree -> .children is region trees - // for (const region of sessionChild.children) { - // for (const child of region.children!) { - // if (child instanceof CICSProgramTree) { - // await child.loadContents(); - // } - // } - // } - // } else { - // // region tree - // for (const child of sessionChild.children!) { - // await child.loadContents(); - // } - // } - // } - // } - // }); tree._onDidChangeTreeData.fire(undefined); window.showInformationMessage("Refreshed"); } diff --git a/packages/vsce/src/commands/showAttributesCommand.ts b/packages/vsce/src/commands/showAttributesCommand.ts index 11f17670..dff52687 100644 --- a/packages/vsce/src/commands/showAttributesCommand.ts +++ b/packages/vsce/src/commands/showAttributesCommand.ts @@ -9,37 +9,31 @@ * */ +import { ILocalFile, IPipeline, IProgram, ITask, ITCPIP, ITransaction, IUriMap, IWebService } from "@zowe/cics-for-zowe-sdk"; import { commands, TreeView, WebviewPanel, window } from "vscode"; import { CICSRegionTree } from "../trees/CICSRegionTree"; import { CICSLibraryDatasets } from "../trees/treeItems/CICSLibraryDatasets"; import { CICSLibraryTreeItem } from "../trees/treeItems/CICSLibraryTreeItem"; -import { CICSLocalFileTreeItem } from "../trees/treeItems/CICSLocalFileTreeItem"; -import { CICSProgramTreeItem } from "../trees/treeItems/CICSProgramTreeItem"; -import { CICSTaskTreeItem } from "../trees/treeItems/CICSTaskTreeItem"; -import { CICSTransactionTreeItem } from "../trees/treeItems/CICSTransactionTreeItem"; -import { CICSPipelineTreeItem } from "../trees/treeItems/web/treeItems/CICSPipelineTreeItem"; -import { CICSTCPIPServiceTreeItem } from "../trees/treeItems/web/treeItems/CICSTCPIPServiceTreeItem"; -import { CICSURIMapTreeItem } from "../trees/treeItems/web/treeItems/CICSURIMapTreeItem"; -import { CICSWebServiceTreeItem } from "../trees/treeItems/web/treeItems/CICSWebServiceTreeItem"; +import { CICSResourceTreeItem } from "../trees/treeItems/CICSResourceTreeItem"; import { findSelectedNodes } from "../utils/commandUtils"; import { getAttributesHtml } from "../utils/webviewHTML"; export function getShowProgramAttributesCommand(treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.showProgramAttributes", async (node) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSProgramTreeItem, node); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, node); if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS program selected"); return; } for (const programTreeItem of allSelectedNodes) { - const program = programTreeItem.program; + const program = programTreeItem.resource; const attributeHeadings = Object.keys(program); let webText = ``; webText += `Attribute `; webText += `Value`; webText += ``; for (const heading of attributeHeadings) { - webText += `${heading.toUpperCase()}${program[heading]}`; + webText += `${heading.toUpperCase()}${program[heading as keyof IProgram]}`; } webText += ""; @@ -86,18 +80,18 @@ export function getShowRegionAttributes(treeview: TreeView) { export function getShowLocalFileAttributesCommand(treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.showLocalFileAttributes", async (node) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSLocalFileTreeItem, node); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, node); if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS local file selected"); return; } for (const localFileTreeItem of allSelectedNodes) { - const localFile = localFileTreeItem.localFile; + const localFile = localFileTreeItem.resource; const attributeHeadings = Object.keys(localFile); let webText = `Attribute `; webText += `Value`; for (const heading of attributeHeadings) { - webText += `${heading.toUpperCase()}${localFile[heading]}`; + webText += `${heading.toUpperCase()}${localFile[heading as keyof ILocalFile]}`; } webText += ""; @@ -117,18 +111,18 @@ export function getShowLocalFileAttributesCommand(treeview: TreeView) { export function getShowTransactionAttributesCommand(treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.showTransactionAttributes", async (node) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSTransactionTreeItem, node); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, node); if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS transaction selected"); return; } for (const localTransactionTreeItem of allSelectedNodes) { - const transaction = localTransactionTreeItem.transaction; + const transaction = localTransactionTreeItem.resource; const attributeHeadings = Object.keys(transaction); let webText = `Attribute `; webText += `Value`; for (const heading of attributeHeadings) { - webText += `${heading.toUpperCase()}${transaction[heading]}`; + webText += `${heading.toUpperCase()}${transaction[heading as keyof ITransaction]}`; } webText += ""; @@ -149,18 +143,18 @@ export function getShowTransactionAttributesCommand(treeview: TreeView) { ///@@@@@@@@@@@@@@ doesnt fit because actvtyid value is too long - edit css export function getShowTaskAttributesCommand(treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.showTaskAttributes", async (node) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSTaskTreeItem, node); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, node); if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS Task selected"); return; } for (const localTaskTreeItem of allSelectedNodes) { - const task = localTaskTreeItem.task; + const task = localTaskTreeItem.resource; const attributeHeadings = Object.keys(task); let webText = `Attribute `; webText += `Value`; for (const heading of attributeHeadings) { - webText += `${heading.toUpperCase()}${task[heading]}`; + webText += `${heading.toUpperCase()}${task[heading as keyof ITask]}`; } webText += ""; @@ -237,18 +231,18 @@ export function getShowLibraryDatasetsAttributesCommand(treeview: TreeView) export function getShowTCPIPServiceAttributesCommand(treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.showTCPIPServiceAttributes", async (node) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSTCPIPServiceTreeItem, node); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, node); if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS TCPIP Service selected"); return; } for (const tcpipsTreeItem of allSelectedNodes) { - const tcpips = tcpipsTreeItem.tcpips; + const tcpips = tcpipsTreeItem.resource; const attributeHeadings = Object.keys(tcpips); let webText = `Attribute `; webText += `Value`; for (const heading of attributeHeadings) { - webText += `${heading.toUpperCase()}${tcpips[heading]}`; + webText += `${heading.toUpperCase()}${tcpips[heading as keyof ITCPIP]}`; } webText += ""; @@ -264,18 +258,18 @@ export function getShowTCPIPServiceAttributesCommand(treeview: TreeView) { export function getShowURIMapAttributesCommand(treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.showURIMapAttributes", async (node) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSURIMapTreeItem, node); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, node); if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS URIMap selected"); return; } for (const urimapTreeItem of allSelectedNodes) { - const urimap = urimapTreeItem.urimap; + const urimap = urimapTreeItem.resource; const attributeHeadings = Object.keys(urimap); let webText = `Attribute `; webText += `Value`; for (const heading of attributeHeadings) { - webText += `${heading.toUpperCase()}${urimap[heading]}`; + webText += `${heading.toUpperCase()}${urimap[heading as keyof IUriMap]}`; } webText += ""; @@ -291,18 +285,18 @@ export function getShowURIMapAttributesCommand(treeview: TreeView) { export function getShowPipelineAttributesCommand(treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.showPipelineAttributes", async (node) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSPipelineTreeItem, node); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, node); if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS Pipeline selected"); return; } for (const pipelineTreeItem of allSelectedNodes) { - const pipeline = pipelineTreeItem.pipeline; + const pipeline = pipelineTreeItem.resource; const attributeHeadings = Object.keys(pipeline); let webText = `Attribute `; webText += `Value`; for (const heading of attributeHeadings) { - webText += `${heading.toUpperCase()}${pipeline[heading]}`; + webText += `${heading.toUpperCase()}${pipeline[heading as keyof IPipeline]}`; } webText += ""; @@ -321,18 +315,18 @@ export function getShowPipelineAttributesCommand(treeview: TreeView) { export function getShowWebServiceAttributesCommand(treeview: TreeView) { return commands.registerCommand("cics-extension-for-zowe.showWebServiceAttributes", async (node) => { - const allSelectedNodes = findSelectedNodes(treeview, CICSWebServiceTreeItem, node); + const allSelectedNodes: CICSResourceTreeItem[] = findSelectedNodes(treeview, CICSResourceTreeItem, node); if (!allSelectedNodes || !allSelectedNodes.length) { await window.showErrorMessage("No CICS Web Service selected"); return; } for (const webServiceTreeItem of allSelectedNodes) { - const webService = webServiceTreeItem.webservice; + const webService = webServiceTreeItem.resource; const attributeHeadings = Object.keys(webService); let webText = `Attribute `; webText += `Value`; for (const heading of attributeHeadings) { - webText += `${heading.toUpperCase()}${webService[heading]}`; + webText += `${heading.toUpperCase()}${webService[heading as keyof IWebService]}`; } webText += ""; diff --git a/packages/vsce/src/doc/IResourceMeta.ts b/packages/vsce/src/doc/IResourceMeta.ts new file mode 100644 index 00000000..7dd38516 --- /dev/null +++ b/packages/vsce/src/doc/IResourceMeta.ts @@ -0,0 +1,32 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + + +export interface ResourceMeta { + + resourceName: string; + humanReadableName: string; + contextPrefix: string; + combinedContextPrefix: string; + filterAttribute: string; + primaryKeyAttribute: string; + + persistentStorageKey: string; + persistentStorageAllKey: string; + + getDefaultFilter(): Promise; + getLabel(resource: T): string; + getContext(resource: T): string; + getIconName(resource: T): string; + +} + +export default ResourceMeta; diff --git a/packages/vsce/src/doc/LocalFileMeta.ts b/packages/vsce/src/doc/LocalFileMeta.ts new file mode 100644 index 00000000..eb34a19a --- /dev/null +++ b/packages/vsce/src/doc/LocalFileMeta.ts @@ -0,0 +1,66 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { ILocalFile } from "@zowe/cics-for-zowe-sdk"; +import constants from "../utils/constants"; +import { getDefaultFilter } from "../utils/filterUtils"; +import { ResourceMeta } from "./IResourceMeta"; + + +export const LocalFileMeta: ResourceMeta = { + + resourceName: "CICSLocalFile", + humanReadableName: "Local Files", + contextPrefix: "cicstreelocalfile", + combinedContextPrefix: "cicscombinedlocalfiletree", + filterAttribute: "file", + primaryKeyAttribute: "file", + + persistentStorageKey: "localFile", + persistentStorageAllKey: "allLocalFiles", + + getDefaultFilter: function (): Promise { + return getDefaultFilter(constants.PERSISTENT_STORAGE.LOCAL_FILE_FILTER); + }, + + getLabel: function (localFile: ILocalFile): string { + let label = `${localFile.file}`; + + if (localFile.enablestatus.trim().toLowerCase() === "disabled") { + label += ` (Disabled)`; + } else if (localFile.enablestatus.trim().toLowerCase() === "unenabled") { + label += ` (Unenabled)`; + } + + if (localFile.openstatus.trim().toLowerCase() === "closed") { + label += ` (Closed)`; + } + + return label; + }, + + getContext: function (localFile: ILocalFile): string { + return `cicslocalfile.${localFile.enablestatus.trim().toLowerCase()}.${localFile.openstatus.trim().toLowerCase()}.${localFile.file}`; + }, + + getIconName: function (localFile: ILocalFile): string { + let iconName = `local-file`; + if (localFile.enablestatus.trim().toUpperCase() === "DISABLED") { + iconName += `-disabled`; + } + if (localFile.openstatus.trim().toUpperCase() === "CLOSED") { + iconName += `-closed`; + } + + return iconName; + } +}; + diff --git a/packages/vsce/src/doc/PipelineMeta.ts b/packages/vsce/src/doc/PipelineMeta.ts new file mode 100644 index 00000000..7ab3eadc --- /dev/null +++ b/packages/vsce/src/doc/PipelineMeta.ts @@ -0,0 +1,48 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IPipeline } from "@zowe/cics-for-zowe-sdk"; +import constants from "../utils/constants"; +import { getDefaultFilter } from "../utils/filterUtils"; +import { ResourceMeta } from "./IResourceMeta"; + + +export const PipelineMeta: ResourceMeta = { + + resourceName: "CICSPipeline", + humanReadableName: "Pipelines", + contextPrefix: "cicstreepipeline", + combinedContextPrefix: "cicscombinedpipelinetree", + filterAttribute: "NAME", + primaryKeyAttribute: "name", + + persistentStorageKey: "pipelines", + persistentStorageAllKey: "allPipelines", + + getDefaultFilter: function (): Promise { + return getDefaultFilter(constants.PERSISTENT_STORAGE.PIPELINE_FILTER); + }, + + getLabel: function (pipeline: IPipeline): string { + const label = `${pipeline.name}`; + return label; + }, + + getContext: function (pipeline: IPipeline): string { + return `cicspipeline.${pipeline.name}`; + }, + + getIconName: function (_pipeline: IPipeline): string { + return `program`; + } + +}; + diff --git a/packages/vsce/src/doc/ProgramMeta.ts b/packages/vsce/src/doc/ProgramMeta.ts new file mode 100644 index 00000000..40e02f03 --- /dev/null +++ b/packages/vsce/src/doc/ProgramMeta.ts @@ -0,0 +1,59 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IProgram } from "@zowe/cics-for-zowe-sdk"; +import constants from "../utils/constants"; +import { getDefaultFilter } from "../utils/filterUtils"; +import { ResourceMeta } from "./IResourceMeta"; + + +export const ProgramMeta: ResourceMeta = { + + resourceName: "CICSProgram", + humanReadableName: "Programs", + contextPrefix: "cicstreeprogram", + combinedContextPrefix: "cicscombinedprogramtree", + filterAttribute: "PROGRAM", + primaryKeyAttribute: "program", + + persistentStorageKey: "program", + persistentStorageAllKey: "allPrograms", + + getDefaultFilter: function (): Promise { + return getDefaultFilter(constants.PERSISTENT_STORAGE.PROGRAM_FILTER); + }, + + getLabel: function (program: IProgram): string { + let label = `${program.program}`; + if (program.newcopycnt && parseInt(program.newcopycnt) > 0) { + label += ` (New copy count: ${program.newcopycnt})`; + } + if (program.status.trim().toLowerCase() === "disabled") { + label += " (Disabled)"; + } + + return label; + }, + + getContext: function (program: IProgram): string { + return `cicsprogram.${program.status.trim().toLowerCase()}.${program.program}`; + }, + + getIconName: function (program: IProgram): string { + let iconName = `program`; + if (program.status.trim().toUpperCase() === "DISABLED") { + iconName += `-disabled`; + } + return iconName; + } + +}; + diff --git a/packages/vsce/src/doc/RegionMeta.ts b/packages/vsce/src/doc/RegionMeta.ts new file mode 100644 index 00000000..3be272fc --- /dev/null +++ b/packages/vsce/src/doc/RegionMeta.ts @@ -0,0 +1,65 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IRegion } from "@zowe/cics-for-zowe-sdk"; +import { ResourceMeta } from "./IResourceMeta"; + + +export const RegionMeta: ResourceMeta = { + + resourceName: "CICSManagedRegion", + humanReadableName: "Regions", + contextPrefix: "cicsregion", + combinedContextPrefix: null, + filterAttribute: "applid", + primaryKeyAttribute: "applid", + + persistentStorageKey: null, + persistentStorageAllKey: null, + + getDefaultFilter: function (): Promise { + return null; + }, + + getLabel: function (region: IRegion): string { + if (region.applid) { + return `${region.applid.trim()}`; + } + return `${region.cicsname.trim()}`; + }, + + getContext: function (region: IRegion): string { + + let activeContext = `active`; + + const cicsstate = region.cicsstate?.trim().toUpperCase(); + const cicsstatus = region.cicsstatus?.trim().toUpperCase(); + + if ((cicsstate && cicsstate === "INACTIVE") || (cicsstatus && cicsstatus === "INACTIVE")) { + activeContext = `inactive`; + } + + return `cicsregion.${region.applid.trim().toLowerCase()}.${activeContext}`; + }, + + getIconName: function (region: IRegion): string { + let iconName = `region`; + + const cicsstate = region.cicsstate?.trim().toUpperCase(); + const cicsstatus = region.cicsstatus?.trim().toUpperCase(); + + if ((cicsstate && cicsstate === "INACTIVE") || (cicsstatus && cicsstatus === "INACTIVE")) { + iconName += `-disabled`; + } + return iconName; + } +}; + diff --git a/packages/vsce/src/doc/TCPIPMeta.ts b/packages/vsce/src/doc/TCPIPMeta.ts new file mode 100644 index 00000000..254c3f8d --- /dev/null +++ b/packages/vsce/src/doc/TCPIPMeta.ts @@ -0,0 +1,53 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { ITCPIP } from "@zowe/cics-for-zowe-sdk"; +import constants from "../utils/constants"; +import { getDefaultFilter } from "../utils/filterUtils"; +import { ResourceMeta } from "./IResourceMeta"; + + +export const TCPIPMeta: ResourceMeta = { + + resourceName: "CICSTCPIPService", + humanReadableName: "TCPIP Services", + contextPrefix: "cicstreetcpips", + combinedContextPrefix: "cicscombinedtcpipstree", + filterAttribute: "NAME", + primaryKeyAttribute: "name", + + persistentStorageKey: "tcpips", + persistentStorageAllKey: "allTCPIPS", + + getDefaultFilter: function (): Promise { + return getDefaultFilter(constants.PERSISTENT_STORAGE.TCPIP_FILTER); + }, + + getLabel: function (tcpips: ITCPIP): string { + let label = `${tcpips.name}`; + + if (tcpips.port) { + label += ` [Port #${tcpips.port}]`; + } + + return label; + }, + + getContext: function (tcpips: ITCPIP): string { + return `cicstcpips.${tcpips.name}`; + }, + + getIconName: function (_tcpips: ITCPIP): string { + return `program`; + } + +}; + diff --git a/packages/vsce/src/doc/TaskMeta.ts b/packages/vsce/src/doc/TaskMeta.ts new file mode 100644 index 00000000..4cd702be --- /dev/null +++ b/packages/vsce/src/doc/TaskMeta.ts @@ -0,0 +1,66 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { ITask } from "@zowe/cics-for-zowe-sdk"; +import constants from "../utils/constants"; +import { getDefaultFilter } from "../utils/filterUtils"; +import { ResourceMeta } from "./IResourceMeta"; + + +export const TaskMeta: ResourceMeta = { + + resourceName: "CICSTask", + humanReadableName: "Tasks", + contextPrefix: "cicstreetask", + combinedContextPrefix: "cicscombinedtasktree", + filterAttribute: "tranid", + primaryKeyAttribute: "task", + + persistentStorageKey: "tasks", + persistentStorageAllKey: "allTasks", + + + getDefaultFilter: function (): Promise { + return getDefaultFilter(constants.PERSISTENT_STORAGE.TASK_FILTER); + }, + + getLabel: function (task: ITask): string { + let label = `${task.task} - ${task.tranid}`; + + if (task.runstatus !== "SUSPENDED") { + label += ` (${task.runstatus})`; + } + + return label; + }, + + getContext: function (task: ITask): string { + return `cicstask.${task.task}`; + }, + + getIconName: function (task: ITask): string { + let iconName = `task`; + switch (task.runstatus.trim().toUpperCase()) { + case "RUNNING": + iconName += `-running`; + break; + case "SUSPENDED": + iconName += `-suspended`; + break; + case "DISPATCHED": + iconName += `-dispatched`; + break; + } + return iconName; + } + +}; + diff --git a/packages/vsce/src/doc/TransactionMeta.ts b/packages/vsce/src/doc/TransactionMeta.ts new file mode 100644 index 00000000..8a1ca1af --- /dev/null +++ b/packages/vsce/src/doc/TransactionMeta.ts @@ -0,0 +1,57 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { ITransaction } from "@zowe/cics-for-zowe-sdk"; +import constants from "../utils/constants"; +import { getDefaultFilter } from "../utils/filterUtils"; +import { ResourceMeta } from "./IResourceMeta"; + + +export const TransactionMeta: ResourceMeta = { + + resourceName: "CICSLocalTransaction", + humanReadableName: "Transactions", + contextPrefix: "cicstreetransaction", + combinedContextPrefix: "cicscombinedtransactiontree", + filterAttribute: "tranid", + primaryKeyAttribute: "tranid", + + persistentStorageKey: "transaction", + persistentStorageAllKey: "allTransactions", + + getDefaultFilter: function (): Promise { + return getDefaultFilter(constants.PERSISTENT_STORAGE.TRANSACTION_FILTER); + }, + + getLabel: function (transaction: ITransaction): string { + let label = `${transaction.tranid}`; + + if (transaction.status.trim().toLowerCase() === "disabled") { + label += " (Disabled)"; + } + + return label; + }, + + getContext: function (transaction: ITransaction): string { + return `cicstransaction.${transaction.status.toLowerCase()}.${transaction.tranid}`; + }, + + getIconName: function (transaction: ITransaction): string { + let iconName = `local-transaction`; + if (transaction.status.trim().toUpperCase() === "DISABLED") { + iconName += `-disabled`; + } + return iconName; + } + +}; + diff --git a/packages/vsce/src/doc/URIMapMeta.ts b/packages/vsce/src/doc/URIMapMeta.ts new file mode 100644 index 00000000..d0115f77 --- /dev/null +++ b/packages/vsce/src/doc/URIMapMeta.ts @@ -0,0 +1,56 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IUriMap } from "@zowe/cics-for-zowe-sdk"; +import constants from "../utils/constants"; +import { getDefaultFilter } from "../utils/filterUtils"; +import { ResourceMeta } from "./IResourceMeta"; + + +export const URIMapMeta: ResourceMeta = { + + resourceName: "CICSURIMap", + humanReadableName: "URI Maps", + contextPrefix: "cicstreeurimaps", + combinedContextPrefix: "cicscombinedurimapstree", + filterAttribute: "NAME", + primaryKeyAttribute: "name", + + persistentStorageKey: "urimaps", + persistentStorageAllKey: "allURIMaps", + + getDefaultFilter: function (): Promise { + return getDefaultFilter(constants.PERSISTENT_STORAGE.URIMAP_FILTER); + }, + + getLabel: function (urimap: IUriMap): string { + let label = `${urimap.name}`; + + if (urimap.scheme) { + label += ` [${urimap.scheme}]`; + } + if (urimap.path) { + label += ` (${urimap.path})`; + } + + return label; + }, + + getContext: function (urimap: IUriMap): string { + return `cicsurimaps.${urimap.name}`; + }, + + getIconName: function (_urimap: IUriMap): string { + return `program`; + } + +}; + diff --git a/packages/vsce/src/doc/WebServiceMeta.ts b/packages/vsce/src/doc/WebServiceMeta.ts new file mode 100644 index 00000000..f03246f4 --- /dev/null +++ b/packages/vsce/src/doc/WebServiceMeta.ts @@ -0,0 +1,48 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IWebService } from "@zowe/cics-for-zowe-sdk"; +import constants from "../utils/constants"; +import { getDefaultFilter } from "../utils/filterUtils"; +import { ResourceMeta } from "./IResourceMeta"; + + +export const WebServiceMeta: ResourceMeta = { + + resourceName: "CICSWebService", + humanReadableName: "Web Services", + contextPrefix: "cicstreewebservice", + combinedContextPrefix: "cicscombinedwebservicetree", + filterAttribute: "NAME", + primaryKeyAttribute: "name", + + persistentStorageKey: "webservices", + persistentStorageAllKey: "allWebServices", + + getDefaultFilter: function (): Promise { + return getDefaultFilter(constants.PERSISTENT_STORAGE.WEBSERVICE_FILTER); + }, + + getLabel: function (webservice: IWebService): string { + const label = `${webservice.name}`; + return label; + }, + + getContext: function (webservice: IWebService): string { + return `cicswebservice.${webservice.name}`; + }, + + getIconName: function (_webservice: IWebService): string { + return `program`; + } + +}; + diff --git a/packages/vsce/src/doc/index.ts b/packages/vsce/src/doc/index.ts new file mode 100644 index 00000000..a67f0f7c --- /dev/null +++ b/packages/vsce/src/doc/index.ts @@ -0,0 +1,21 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + + +export * from "./IResourceMeta"; +export * from "./LocalFileMeta"; +export * from "./PipelineMeta"; +export * from "./ProgramMeta"; +export * from "./TaskMeta"; +export * from "./TCPIPMeta"; +export * from "./TransactionMeta"; +export * from "./URIMapMeta"; + diff --git a/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedLocalFileTree.ts b/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedLocalFileTree.ts deleted file mode 100644 index a77ecfbd..00000000 --- a/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedLocalFileTree.ts +++ /dev/null @@ -1,201 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window, workspace } from "vscode"; -import { toEscapedCriteriaString } from "../../utils/filterUtils"; -import { ProfileManagement } from "../../utils/profileManagement"; -import { CICSPlexTree } from "../CICSPlexTree"; -import { CICSRegionsContainer } from "../CICSRegionsContainer"; -import { CICSRegionTree } from "../CICSRegionTree"; -import { CICSTree } from "../CICSTree"; -import { CICSLocalFileTreeItem } from "../treeItems/CICSLocalFileTreeItem"; -import { TextTreeItem } from "../treeItems/utils/TextTreeItem"; -import { getFolderIcon } from "../../utils/iconUtils"; -import { ViewMore } from "../treeItems/utils/ViewMore"; - -export class CICSCombinedLocalFileTree extends TreeItem { - children: (CICSLocalFileTreeItem | ViewMore)[] | [TextTreeItem] | null; - parentPlex: CICSPlexTree; - activeFilter: string | undefined; - currentCount: number; - incrementCount: number; - constant: string; - - constructor( - parentPlex: CICSPlexTree, - public iconPath = getFolderIcon(false), - ) { - super("All Local Files", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicscombinedlocalfiletree.`; - this.parentPlex = parentPlex; - this.children = [new TextTreeItem("Use the search button to display local files", "applyfiltertext.")]; - this.activeFilter = undefined; - this.currentCount = 0; - this.incrementCount = +`${workspace.getConfiguration().get("zowe.cics.allLocalFiles.recordCountIncrement")}`; - this.constant = "CICSLocalFile"; - } - - public async loadContents(tree: CICSTree) { - await window.withProgress( - { - title: "Loading Local Files", - location: ProgressLocation.Notification, - cancellable: true, - }, - async (_, token) => { - token.onCancellationRequested(() => {}); - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "file"); - } - let count; - try { - const cacheTokenInfo = await ProfileManagement.generateCacheToken( - this.parentPlex.getProfile(), - this.parentPlex.getPlexName(), - this.constant, - criteria, - this.getParent().getGroupName(), - ); - if (cacheTokenInfo) { - const recordsCount = cacheTokenInfo.recordCount; - if (recordsCount) { - let allLocalFiles; - if (recordsCount <= this.incrementCount) { - allLocalFiles = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - 1, - recordsCount, - ); - } else { - allLocalFiles = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - 1, - this.incrementCount, - ); - count = recordsCount; - } - this.addLocalFilesUtil([], allLocalFiles, count); - this.iconPath = getFolderIcon(true); - tree._onDidChangeTreeData.fire(undefined); - } else { - this.children = []; - this.iconPath = getFolderIcon(true); - tree._onDidChangeTreeData.fire(undefined); - window.showInformationMessage(`No local files found`); - this.label = `All Local Files${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${recordsCount}]`; - } - } - } catch (error) { - window.showErrorMessage( - `Something went wrong when fetching local files - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( - /(\\n\t|\\n|\\t)/gm, - " ", - )}`, - ); - } - }, - ); - } - - public addLocalFilesUtil(newChildren: (CICSLocalFileTreeItem | ViewMore)[], allLocalFiles: any, count: number | undefined) { - for (const localfile of allLocalFiles) { - const regionsContainer = this.parentPlex.children.filter((child) => child instanceof CICSRegionsContainer)?.[0]; - if (regionsContainer == null) { - continue; - } - const parentRegion = regionsContainer - .getChildren()! - .filter((child) => child instanceof CICSRegionTree && child.getRegionName() === localfile.eyu_cicsname)?.[0] as CICSRegionTree; - const localFileTree = new CICSLocalFileTreeItem(localfile, parentRegion, this); - localFileTree.setLabel(localFileTree.label.toString().replace(localfile.file, `${localfile.file} (${localfile.eyu_cicsname})`)); - newChildren.push(localFileTree); - } - if (!count) { - count = newChildren.length; - } - this.currentCount = newChildren.length; - this.label = `All Local Files ${this.activeFilter ? `(${this.activeFilter}) ` : " "}[${this.currentCount} of ${count}]`; - if (count !== this.currentCount) { - newChildren.push(new ViewMore(this, Math.min(this.incrementCount, count - this.currentCount))); - } - this.children = newChildren; - } - - public async addMoreCachedResources(tree: CICSTree) { - await window.withProgress( - { - title: "Loading more local files", - location: ProgressLocation.Notification, - cancellable: false, - }, - async () => { - const cacheTokenInfo = await ProfileManagement.generateCacheToken( - this.parentPlex.getProfile(), - this.parentPlex.getPlexName(), - this.constant, - this.getParent().getGroupName(), - ); - if (cacheTokenInfo) { - // record count may have updated - const recordsCount = cacheTokenInfo.recordCount; - const count = recordsCount; - const allLocalFiles = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - this.currentCount + 1, - this.incrementCount, - ); - if (allLocalFiles) { - // @ts-ignore - this.addLocalFilesUtil( - (this.getChildren()?.filter((child) => child instanceof CICSLocalFileTreeItem) ?? []) as CICSLocalFileTreeItem[], - allLocalFiles, - count, - ); - tree._onDidChangeTreeData.fire(undefined); - } - } - }, - ); - } - - public clearFilter() { - this.activeFilter = undefined; - this.label = `All Local Files`; - this.contextValue = `cicscombinedlocalfiletree.unfiltered`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public setFilter(newFilter: string) { - this.activeFilter = newFilter; - this.label = `All Local Files (${this.activeFilter})`; - this.contextValue = `cicscombinedlocalfiletree.filtered`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public getChildren() { - return this.children ? this.children.filter((child) => !(child instanceof TextTreeItem)) : []; - } - - public getActiveFilter() { - return this.activeFilter; - } - - public getParent() { - return this.parentPlex; - } -} diff --git a/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedPipelineTree.ts b/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedPipelineTree.ts deleted file mode 100644 index dd6405df..00000000 --- a/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedPipelineTree.ts +++ /dev/null @@ -1,206 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window, workspace } from "vscode"; -import { toEscapedCriteriaString } from "../../utils/filterUtils"; -import { ProfileManagement } from "../../utils/profileManagement"; -import { CICSPlexTree } from "../CICSPlexTree"; -import { CICSRegionsContainer } from "../CICSRegionsContainer"; -import { CICSRegionTree } from "../CICSRegionTree"; -import { CICSTree } from "../CICSTree"; -import { TextTreeItem } from "../treeItems/utils/TextTreeItem"; -import { getFolderIcon } from "../../utils/iconUtils"; -import { ViewMore } from "../treeItems/utils/ViewMore"; -import { CICSPipelineTreeItem } from "../treeItems/web/treeItems/CICSPipelineTreeItem"; - -export class CICSCombinedPipelineTree extends TreeItem { - children: (CICSPipelineTreeItem | ViewMore)[] | [TextTreeItem] | null; - parentPlex: CICSPlexTree; - activeFilter: string | undefined; - currentCount: number; - incrementCount: number; - constant: string; - - constructor( - parentPlex: CICSPlexTree, - public iconPath = getFolderIcon(false), - ) { - super("All Pipelines", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicscombinedpipelinetree.`; - this.parentPlex = parentPlex; - this.children = [new TextTreeItem("Use the search button to display pipelines", "applyfiltertext.")]; - this.activeFilter = undefined; - this.currentCount = 0; - this.incrementCount = +`${workspace.getConfiguration().get("zowe.cics.allPipelines.recordCountIncrement")}`; - this.constant = "CICSPipeline"; - } - - public async loadContents(tree: CICSTree) { - await window.withProgress( - { - title: "Loading Pipelines", - location: ProgressLocation.Notification, - cancellable: true, - }, - async (_, token) => { - token.onCancellationRequested(() => {}); - try { - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "NAME"); - } - let count; - const cacheTokenInfo = await ProfileManagement.generateCacheToken( - this.parentPlex.getProfile(), - this.parentPlex.getPlexName(), - this.constant, - criteria, - this.getParent().getGroupName(), - ); - if (cacheTokenInfo) { - const recordsCount = cacheTokenInfo.recordCount; - if (recordsCount) { - let allPipelines; - if (recordsCount <= this.incrementCount) { - allPipelines = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - 1, - recordsCount, - ); - } else { - allPipelines = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - 1, - this.incrementCount, - ); - count = recordsCount; - } - this.addPipelinesUtil([], allPipelines, count); - this.iconPath = getFolderIcon(true); - tree._onDidChangeTreeData.fire(undefined); - } else { - this.children = []; - this.iconPath = getFolderIcon(true); - tree._onDidChangeTreeData.fire(undefined); - window.showInformationMessage(`No pipelines found`); - this.label = `All Pipelines${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${recordsCount}]`; - } - } - } catch (error) { - window.showErrorMessage( - `Something went wrong when fetching pipelines - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( - /(\\n\t|\\n|\\t)/gm, - " ", - )}`, - ); - } - }, - ); - } - - public addPipelinesUtil(newChildren: (CICSPipelineTreeItem | ViewMore)[], allPipelines: any, count: number | undefined) { - for (const pipeline of allPipelines) { - const regionsContainer = this.parentPlex.children.filter((child) => child instanceof CICSRegionsContainer)?.[0]; - if (regionsContainer == null) { - continue; - } - const parentRegion = regionsContainer - .getChildren()! - .filter((child) => child instanceof CICSRegionTree && child.getRegionName() === pipeline.eyu_cicsname)?.[0] as CICSRegionTree; - const pipelineTree = new CICSPipelineTreeItem(pipeline, parentRegion, this); - pipelineTree.setLabel(pipelineTree.label.toString().replace(pipeline.name, `${pipeline.name} (${pipeline.eyu_cicsname})`)); - newChildren.push(pipelineTree); - } - if (!count) { - count = newChildren.length; - } - this.currentCount = newChildren.length; - this.label = `All Pipelines ${this.activeFilter ? `(${this.activeFilter}) ` : " "}[${this.currentCount} of ${count}]`; - if (count !== this.currentCount) { - newChildren.push(new ViewMore(this, Math.min(this.incrementCount, count - this.currentCount))); - } - this.children = newChildren; - } - - public async addMoreCachedResources(tree: CICSTree) { - await window.withProgress( - { - title: "Loading more pipelins", - location: ProgressLocation.Notification, - cancellable: false, - }, - async () => { - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "NAME"); - } - const cacheTokenInfo = await ProfileManagement.generateCacheToken( - this.parentPlex.getProfile(), - this.parentPlex.getPlexName(), - this.constant, - criteria, - this.getParent().getGroupName(), - ); - if (cacheTokenInfo) { - // record count may have updated - const recordsCount = cacheTokenInfo.recordCount; - const count = recordsCount; - const allPipelines = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - this.currentCount + 1, - this.incrementCount, - ); - if (allPipelines) { - // @ts-ignore - this.addPipelinesUtil( - (this.getChildren()?.filter((child) => child instanceof CICSPipelineTreeItem) ?? []) as CICSPipelineTreeItem[], - allPipelines, - count, - ); - tree._onDidChangeTreeData.fire(undefined); - } - } - }, - ); - } - - public clearFilter() { - this.activeFilter = undefined; - this.label = `All Pipelines`; - this.contextValue = `cicscombinedpipelinetree.unfiltered`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public setFilter(newFilter: string) { - this.activeFilter = newFilter; - this.label = `All Pipelines (${this.activeFilter})`; - this.contextValue = `cicscombinedpipelinetree.filtered`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public getChildren() { - return this.children ? this.children.filter((child) => !(child instanceof TextTreeItem)) : []; - } - - public getActiveFilter() { - return this.activeFilter; - } - - public getParent() { - return this.parentPlex; - } -} diff --git a/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedProgramTree.ts b/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedResourceTree.ts similarity index 60% rename from packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedProgramTree.ts rename to packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedResourceTree.ts index c980e662..13ca46e9 100644 --- a/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedProgramTree.ts +++ b/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedResourceTree.ts @@ -9,46 +9,46 @@ * */ -import { CicsCmciConstants } from "@zowe/cics-for-zowe-sdk"; +import { IResource } from "@zowe/cics-for-zowe-sdk"; +import { imperative } from "@zowe/zowe-explorer-api"; import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window, workspace } from "vscode"; +import IResourceMeta from "../../doc/IResourceMeta"; import { toEscapedCriteriaString } from "../../utils/filterUtils"; import { ProfileManagement } from "../../utils/profileManagement"; import { CICSPlexTree } from "../CICSPlexTree"; import { CICSRegionsContainer } from "../CICSRegionsContainer"; import { CICSRegionTree } from "../CICSRegionTree"; import { CICSTree } from "../CICSTree"; -import { CICSProgramTreeItem } from "../treeItems/CICSProgramTreeItem"; +import { CICSResourceTreeItem } from "../treeItems/CICSResourceTreeItem"; import { TextTreeItem } from "../treeItems/utils/TextTreeItem"; import { getFolderIcon } from "../../utils/iconUtils"; -import { imperative } from "@zowe/zowe-explorer-api"; import { ViewMore } from "../treeItems/utils/ViewMore"; -export class CICSCombinedProgramTree extends TreeItem { - children: (CICSProgramTreeItem | ViewMore)[] | [TextTreeItem] | null; +export class CICSCombinedResourceTree extends TreeItem { + children: (CICSResourceTreeItem | ViewMore)[] | [TextTreeItem] | null; parentPlex: CICSPlexTree; activeFilter: string | undefined; currentCount: number; incrementCount: number; - constant: string; + resourceMeta: IResourceMeta; - constructor( - parentPlex: CICSPlexTree, - public iconPath = getFolderIcon(false), - ) { - super("All Programs", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicscombinedprogramtree.`; + constructor(parentPlex: CICSPlexTree, resourceMeta: IResourceMeta, public iconPath = getFolderIcon(false)) { + super(`All ${resourceMeta.humanReadableName}`, TreeItemCollapsibleState.Collapsed); + this.resourceMeta = resourceMeta; + this.contextValue = `${resourceMeta.combinedContextPrefix}.`; this.parentPlex = parentPlex; - this.children = [new TextTreeItem("Use the search button to display programs", "applyfiltertext.")]; + this.children = [new TextTreeItem("Use the search button to display resources", "applyfiltertext.")]; this.activeFilter = undefined; this.currentCount = 0; - this.incrementCount = +`${workspace.getConfiguration().get("zowe.cics.allPrograms.recordCountIncrement")}`; - this.constant = CicsCmciConstants.CICS_PROGRAM_RESOURCE; + this.incrementCount = +`${workspace.getConfiguration().get( + `zowe.cics.${resourceMeta.persistentStorageAllKey}.recordCountIncrement` + )}`; } public async loadContents(tree: CICSTree) { await window.withProgress( { - title: "Loading Programs", + title: "Loading Resources", location: ProgressLocation.Notification, cancellable: true, }, @@ -58,47 +58,47 @@ export class CICSCombinedProgramTree extends TreeItem { try { let criteria; if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "PROGRAM"); + criteria = toEscapedCriteriaString(this.activeFilter, this.resourceMeta.filterAttribute); } let count; const cacheTokenInfo = await ProfileManagement.generateCacheToken( this.parentPlex.getProfile(), this.parentPlex.getPlexName(), - this.constant, + this.resourceMeta.resourceName, criteria, this.getParent().getGroupName(), ); if (cacheTokenInfo) { recordsCount = cacheTokenInfo.recordCount; if (recordsCount) { - let allPrograms; + let allResources; if (recordsCount <= this.incrementCount) { - allPrograms = await ProfileManagement.getCachedResources( + allResources = await ProfileManagement.getCachedResources( this.parentPlex.getProfile(), cacheTokenInfo.cacheToken, - this.constant, + this.resourceMeta.resourceName, 1, recordsCount, ); } else { - allPrograms = await ProfileManagement.getCachedResources( + allResources = await ProfileManagement.getCachedResources( this.parentPlex.getProfile(), cacheTokenInfo.cacheToken, - this.constant, + this.resourceMeta.resourceName, 1, this.incrementCount, ); count = recordsCount; } - this.addProgramsUtil([], allPrograms, count); + this.addResourcesUtil([], allResources, count); this.iconPath = getFolderIcon(true); tree._onDidChangeTreeData.fire(undefined); } else { this.children = []; this.iconPath = getFolderIcon(true); tree._onDidChangeTreeData.fire(undefined); - window.showInformationMessage(`No programs found`); - this.label = `All Programs${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${recordsCount}]`; + window.showInformationMessage(`No resources found`); + this.label = `All ${this.resourceMeta.humanReadableName}${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${recordsCount}]`; } } } catch (error) { @@ -106,11 +106,11 @@ export class CICSCombinedProgramTree extends TreeItem { this.children = []; this.iconPath = getFolderIcon(true); tree._onDidChangeTreeData.fire(undefined); - window.showInformationMessage(`No programs found`); - this.label = `All Programs${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${recordsCount}]`; + window.showInformationMessage(`No resources found`); + this.label = `All ${this.resourceMeta.humanReadableName}${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${recordsCount}]`; } else { window.showErrorMessage( - `Something went wrong when fetching programs - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( + `Something went wrong when fetching resources - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( /(\\n\t|\\n|\\t)/gm, " ", )}`, @@ -121,25 +121,31 @@ export class CICSCombinedProgramTree extends TreeItem { ); } - public addProgramsUtil(newChildren: (CICSProgramTreeItem | ViewMore)[], allPrograms: any, count: number | undefined) { - for (const program of allPrograms) { - // Regions container must exist if all programs tree exists + public addResourcesUtil(newChildren: (CICSResourceTreeItem | ViewMore)[], allResources: T[], count: number | undefined) { + for (const resource of allResources) { const regionsContainer = this.parentPlex.children.filter((child) => child instanceof CICSRegionsContainer)?.[0]; if (regionsContainer == null) { continue; } const parentRegion = regionsContainer .getChildren()! - .filter((child) => child instanceof CICSRegionTree && child.getRegionName() === program.eyu_cicsname)?.[0] as CICSRegionTree; - const progamTree = new CICSProgramTreeItem(program, parentRegion, this); - progamTree.setLabel(progamTree.label.toString().replace(program.program, `${program.program} (${program.eyu_cicsname})`)); - newChildren.push(progamTree); + .filter((child) => + child instanceof CICSRegionTree && + child.getRegionName() === resource.eyu_cicsname)?.[0] as CICSRegionTree; + const resourceTree = new CICSResourceTreeItem(resource, this.resourceMeta, parentRegion, this); + resourceTree.setLabel( + resourceTree.label.toString().replace( + `${resource[this.resourceMeta.primaryKeyAttribute as keyof T]}`, + `${resource[this.resourceMeta.primaryKeyAttribute as keyof T]} (${resource.eyu_cicsname})` + )); + newChildren.push(resourceTree); } if (!count) { count = newChildren.length; } this.currentCount = newChildren.length; - this.label = `All Programs ${this.activeFilter ? `(${this.activeFilter}) ` : " "}[${this.currentCount} of ${count}]`; + this.label = `All ${this.resourceMeta.humanReadableName} ${this.activeFilter ? + `(${this.activeFilter}) ` : " "}[${this.currentCount} of ${count}]`; if (count !== this.currentCount) { newChildren.push(new ViewMore(this, Math.min(this.incrementCount, count - this.currentCount))); } @@ -149,19 +155,19 @@ export class CICSCombinedProgramTree extends TreeItem { public async addMoreCachedResources(tree: CICSTree) { await window.withProgress( { - title: "Loading more programs", + title: "Loading more resources", location: ProgressLocation.Notification, cancellable: false, }, async () => { let criteria; if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "PROGRAM"); + criteria = toEscapedCriteriaString(this.activeFilter, this.resourceMeta.filterAttribute); } const cacheTokenInfo = await ProfileManagement.generateCacheToken( this.parentPlex.getProfile(), this.parentPlex.getPlexName(), - this.constant, + this.resourceMeta.resourceName, criteria, this.getParent().getGroupName(), ); @@ -169,19 +175,18 @@ export class CICSCombinedProgramTree extends TreeItem { // record count may have updated const recordsCount = cacheTokenInfo.recordCount; const count = recordsCount; - const allPrograms = await ProfileManagement.getCachedResources( + const allResources = await ProfileManagement.getCachedResources( this.parentPlex.getProfile(), cacheTokenInfo.cacheToken, - this.constant, + this.resourceMeta.resourceName, this.currentCount + 1, this.incrementCount, ); - if (allPrograms) { - // @ts-ignore - this.addProgramsUtil( - (this.getChildren()?.filter((child) => child instanceof CICSProgramTreeItem) ?? []) as CICSProgramTreeItem[], - allPrograms, - count, + if (allResources) { + this.addResourcesUtil( + (this.getChildren()?.filter((child) => child instanceof CICSResourceTreeItem) ?? []) as CICSResourceTreeItem[], + allResources, + count ); tree._onDidChangeTreeData.fire(undefined); } @@ -192,15 +197,15 @@ export class CICSCombinedProgramTree extends TreeItem { public clearFilter() { this.activeFilter = undefined; - this.label = `All Programs`; - this.contextValue = `cicscombinedprogramtree.unfiltered`; + this.label = `All ${this.resourceMeta.humanReadableName}`; + this.contextValue = `${this.resourceMeta.combinedContextPrefix}.unfiltered`; this.collapsibleState = TreeItemCollapsibleState.Expanded; } public setFilter(newFilter: string) { this.activeFilter = newFilter; - this.label = `All Programs (${this.activeFilter})`; - this.contextValue = `cicscombinedprogramtree.filtered`; + this.label = `All ${this.resourceMeta.humanReadableName} (${this.activeFilter})`; + this.contextValue = `${this.resourceMeta.combinedContextPrefix}.filtered`; this.collapsibleState = TreeItemCollapsibleState.Expanded; } diff --git a/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedTCPIPServiceTree.ts b/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedTCPIPServiceTree.ts deleted file mode 100644 index 1d653089..00000000 --- a/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedTCPIPServiceTree.ts +++ /dev/null @@ -1,209 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window, workspace } from "vscode"; -import { toEscapedCriteriaString } from "../../utils/filterUtils"; -import { ProfileManagement } from "../../utils/profileManagement"; -import { CICSPlexTree } from "../CICSPlexTree"; -import { CICSRegionsContainer } from "../CICSRegionsContainer"; -import { CICSRegionTree } from "../CICSRegionTree"; -import { CICSTree } from "../CICSTree"; -import { TextTreeItem } from "../treeItems/utils/TextTreeItem"; -import { getFolderIcon } from "../../utils/iconUtils"; -import { ViewMore } from "../treeItems/utils/ViewMore"; -import { CICSTCPIPServiceTreeItem } from "../treeItems/web/treeItems/CICSTCPIPServiceTreeItem"; - -export class CICSCombinedTCPIPServiceTree extends TreeItem { - children: (CICSTCPIPServiceTreeItem | ViewMore)[] | [TextTreeItem] | null; - parentPlex: CICSPlexTree; - activeFilter: string | undefined; - currentCount: number; - incrementCount: number; - constant: string; - - constructor( - parentPlex: CICSPlexTree, - public iconPath = getFolderIcon(false), - ) { - super("All TCPIP Services", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicscombinedtcpipstree.`; - this.parentPlex = parentPlex; - this.children = [new TextTreeItem("Use the search button to display TCPIP Services", "applyfiltertext.")]; - this.activeFilter = undefined; - this.currentCount = 0; - this.incrementCount = +`${workspace.getConfiguration().get("zowe.cics.allTCPIPS.recordCountIncrement")}`; - this.constant = "CICSTCPIPService"; - } - - public async loadContents(tree: CICSTree) { - await window.withProgress( - { - title: "Loading TCPIP Services", - location: ProgressLocation.Notification, - cancellable: true, - }, - async (_, token) => { - token.onCancellationRequested(() => {}); - try { - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "NAME"); - } - let count; - const cacheTokenInfo = await ProfileManagement.generateCacheToken( - this.parentPlex.getProfile(), - this.parentPlex.getPlexName(), - this.constant, - criteria, - this.getParent().getGroupName(), - ); - if (cacheTokenInfo) { - const recordsCount = cacheTokenInfo.recordCount; - if (recordsCount) { - let allTCPIPS; - if (recordsCount <= this.incrementCount) { - allTCPIPS = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - 1, - recordsCount, - ); - } else { - allTCPIPS = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - 1, - this.incrementCount, - ); - count = recordsCount; - } - this.addTCPIPSUtil([], allTCPIPS, count); - this.iconPath = getFolderIcon(true); - tree._onDidChangeTreeData.fire(undefined); - } else { - this.children = []; - this.iconPath = getFolderIcon(true); - tree._onDidChangeTreeData.fire(undefined); - window.showInformationMessage(`No TCPIP Services found`); - this.label = `All TCPIP Services${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${recordsCount}]`; - } - } - } catch (error) { - window.showErrorMessage( - `Something went wrong when fetching TCPIP Services TEST - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( - /(\\n\t|\\n|\\t)/gm, - " ", - )}`, - ); - } - }, - ); - } - - public addTCPIPSUtil(newChildren: (CICSTCPIPServiceTreeItem | ViewMore)[], allTCPIPS: any, count: number | undefined) { - for (const tcpips of allTCPIPS) { - // Regions container must exist if all TCPIP Services tree exists - const regionsContainer = this.parentPlex.children.filter((child) => child instanceof CICSRegionsContainer)?.[0]; - if (regionsContainer == null) { - continue; - } - const parentRegion = regionsContainer - .getChildren()! - .filter((child) => child instanceof CICSRegionTree && child.getRegionName() === tcpips.eyu_cicsname)?.[0] as CICSRegionTree; - const tcpipsTree = new CICSTCPIPServiceTreeItem(tcpips, parentRegion, this); - tcpipsTree.setLabel( - tcpipsTree.label.toString().replace(tcpips.name, `${tcpips.name} (${tcpips.eyu_cicsname}) [Port #${tcpipsTree.tcpips.port}]`), - ); - newChildren.push(tcpipsTree); - } - if (!count) { - count = newChildren.length; - } - this.currentCount = newChildren.length; - this.label = `All TCPIP Services ${this.activeFilter ? `(${this.activeFilter}) ` : " "}[${this.currentCount} of ${count}]`; - if (count !== this.currentCount) { - newChildren.push(new ViewMore(this, Math.min(this.incrementCount, count - this.currentCount))); - } - this.children = newChildren; - } - - public async addMoreCachedResources(tree: CICSTree) { - await window.withProgress( - { - title: "Loading more TCPIP Services", - location: ProgressLocation.Notification, - cancellable: false, - }, - async () => { - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "NAME"); - } - const cacheTokenInfo = await ProfileManagement.generateCacheToken( - this.parentPlex.getProfile(), - this.parentPlex.getPlexName(), - this.constant, - criteria, - this.getParent().getGroupName(), - ); - if (cacheTokenInfo) { - // record count may have updated - const recordsCount = cacheTokenInfo.recordCount; - const count = recordsCount; - const allTCPIPS = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - this.currentCount + 1, - this.incrementCount, - ); - if (allTCPIPS) { - // @ts-ignore - this.addTCPIPSUtil( - (this.getChildren()?.filter((child) => child instanceof CICSTCPIPServiceTreeItem) ?? []) as CICSTCPIPServiceTreeItem[], - allTCPIPS, - count, - ); - tree._onDidChangeTreeData.fire(undefined); - } - } - }, - ); - } - - public clearFilter() { - this.activeFilter = undefined; - this.label = `All TCPIP Services`; - this.contextValue = `cicscombinedtcpipstree.unfiltered`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public setFilter(newFilter: string) { - this.activeFilter = newFilter; - this.label = `All TCPIP Services (${this.activeFilter})`; - this.contextValue = `cicscombinedtcpipstree.filtered`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public getChildren() { - return this.children ? this.children.filter((child) => !(child instanceof TextTreeItem)) : []; - } - - public getActiveFilter() { - return this.activeFilter; - } - - public getParent() { - return this.parentPlex; - } -} diff --git a/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedTaskTree.ts b/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedTaskTree.ts deleted file mode 100644 index ca7a638d..00000000 --- a/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedTaskTree.ts +++ /dev/null @@ -1,203 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window, workspace } from "vscode"; -import { toEscapedCriteriaString } from "../../utils/filterUtils"; -import { ProfileManagement } from "../../utils/profileManagement"; -import { CICSPlexTree } from "../CICSPlexTree"; -import { CICSRegionsContainer } from "../CICSRegionsContainer"; -import { CICSRegionTree } from "../CICSRegionTree"; -import { CICSTree } from "../CICSTree"; -import { ViewMore } from "../treeItems/utils/ViewMore"; -import { TextTreeItem } from "../treeItems/utils/TextTreeItem"; -import { getFolderIcon } from "../../utils/iconUtils"; -import { CICSTaskTreeItem } from "../treeItems/CICSTaskTreeItem"; - -export class CICSCombinedTaskTree extends TreeItem { - children: (CICSTaskTreeItem | ViewMore)[] | [TextTreeItem] | null; - parentPlex: CICSPlexTree; - activeFilter: string | undefined; - currentCount: number; - incrementCount: number; - constant: string; - - constructor( - parentPlex: CICSPlexTree, - public iconPath = getFolderIcon(false), - ) { - super("All Tasks", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicscombinedtasktree.`; - this.parentPlex = parentPlex; - this.children = [new TextTreeItem("Use the search button to display tasks", "applyfiltertext.")]; - this.activeFilter = undefined; - this.currentCount = 0; - this.incrementCount = +`${workspace.getConfiguration().get("zowe.cics.allTasks.recordCountIncrement")}`; - this.constant = "CICSTask"; - } - - public async loadContents(tree: CICSTree) { - await window.withProgress( - { - title: "Loading Task", - location: ProgressLocation.Notification, - cancellable: true, - }, - async (_, token) => { - token.onCancellationRequested(() => {}); - try { - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "tranid"); - } - let count; - const cacheTokenInfo = await ProfileManagement.generateCacheToken( - this.parentPlex.getProfile(), - this.parentPlex.getPlexName(), - this.constant, - criteria, - this.getParent().getGroupName(), - ); - if (cacheTokenInfo) { - const recordsCount = cacheTokenInfo.recordCount; - if (recordsCount) { - let allTasks; - if (recordsCount <= this.incrementCount) { - allTasks = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - 1, - recordsCount, - ); - } else { - allTasks = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - 1, - this.incrementCount, - ); - count = recordsCount; - } - this.addTasksUtil([], allTasks, count); - this.iconPath = getFolderIcon(true); - tree._onDidChangeTreeData.fire(undefined); - } else { - this.children = []; - this.iconPath = getFolderIcon(true); - tree._onDidChangeTreeData.fire(undefined); - window.showInformationMessage(`No tasks found`); - this.label = `All Tasks${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${recordsCount}]`; - } - } - } catch (error) { - window.showErrorMessage( - `Something went wrong when fetching tasks - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace(/(\\n\t|\\n|\\t)/gm, " ")}`, - ); - } - }, - ); - } - - /** - * Add tasks as children to the combined task tree - */ - public addTasksUtil(newChildren: (CICSTaskTreeItem | ViewMore)[], allTasks: any, count: number | undefined) { - for (const task of allTasks) { - const regionsContainer = this.parentPlex.children.filter((child) => child instanceof CICSRegionsContainer)?.[0]; - if (regionsContainer == null) { - continue; - } - const parentRegion = regionsContainer - .getChildren()! - .filter((child) => child instanceof CICSRegionTree && child.getRegionName() === task.eyu_cicsname)?.[0] as CICSRegionTree; - const taskTree = new CICSTaskTreeItem(task, parentRegion, this); - // Show run status if run status isn't SUSPENDED (assuming SUSPENDED is default runstatus) - taskTree.setLabel( - taskTree.label - .toString() - .replace(task.task, `${task.task} - ${task.tranid} (${task.eyu_cicsname})${task.runstatus !== "SUSPENDED" ? ` (${task.runstatus})` : ""}`), - ); - newChildren.push(taskTree); - } - if (!count) { - count = newChildren.length; - } - this.currentCount = newChildren.length; - this.label = `All Tasks ${this.activeFilter ? `(${this.activeFilter}) ` : " "}[${this.currentCount} of ${count}]`; - if (count !== this.currentCount) { - newChildren.push(new ViewMore(this, Math.min(this.incrementCount, count - this.currentCount))); - } - this.children = newChildren; - } - - public async addMoreCachedResources(tree: CICSTree) { - await window.withProgress( - { - title: "Loading more tasks", - location: ProgressLocation.Notification, - cancellable: false, - }, - async () => { - const cacheTokenInfo = await ProfileManagement.generateCacheToken( - this.parentPlex.getProfile(), - this.parentPlex.getPlexName(), - this.constant, - this.getParent().getGroupName(), - ); - if (cacheTokenInfo) { - // record count may have updated - const recordsCount = cacheTokenInfo.recordCount; - const count = recordsCount; - const allTasks = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - this.currentCount + 1, - this.incrementCount, - ); - if (allTasks) { - // @ts-ignore - this.addTasksUtil(this.getChildren() ? this.getChildren().filter((child) => child instanceof CICSTaskTreeItem) : [], allTasks, count); - tree._onDidChangeTreeData.fire(undefined); - } - } - }, - ); - } - - public clearFilter() { - this.activeFilter = undefined; - this.label = `All Tasks`; - this.contextValue = `cicscombinedtasktree.unfiltered`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public setFilter(newFilter: string) { - this.activeFilter = newFilter; - this.label = `All Tasks (${this.activeFilter})`; - this.contextValue = `cicscombinedtasktree.filtered`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public getChildren() { - return this.children ? this.children.filter((child) => !(child instanceof TextTreeItem)) : []; - } - - public getActiveFilter() { - return this.activeFilter; - } - - public getParent() { - // direct parent - return this.parentPlex; - } -} diff --git a/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedTransactionTree.ts b/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedTransactionTree.ts deleted file mode 100644 index 52b1ef7f..00000000 --- a/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedTransactionTree.ts +++ /dev/null @@ -1,202 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { CicsCmciConstants } from "@zowe/cics-for-zowe-sdk"; -import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window, workspace } from "vscode"; -import { toEscapedCriteriaString } from "../../utils/filterUtils"; -import { ProfileManagement } from "../../utils/profileManagement"; -import { CICSPlexTree } from "../CICSPlexTree"; -import { CICSRegionsContainer } from "../CICSRegionsContainer"; -import { CICSRegionTree } from "../CICSRegionTree"; -import { CICSTree } from "../CICSTree"; -import { CICSTransactionTreeItem } from "../treeItems/CICSTransactionTreeItem"; -import { TextTreeItem } from "../treeItems/utils/TextTreeItem"; -import { getFolderIcon } from "../../utils/iconUtils"; -import { ViewMore } from "../treeItems/utils/ViewMore"; - -export class CICSCombinedTransactionsTree extends TreeItem { - children: (CICSTransactionTreeItem | ViewMore)[] | [TextTreeItem] | null; - parentPlex: CICSPlexTree; - activeFilter: string | undefined; - currentCount: number; - incrementCount: number; - constant: string; - - constructor( - parentPlex: CICSPlexTree, - public iconPath = getFolderIcon(false), - ) { - super("All Local Transactions", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicscombinedtransactiontree.`; - this.parentPlex = parentPlex; - this.children = [new TextTreeItem("Use the search button to display local transactions", "applyfiltertext.")]; - this.activeFilter = undefined; - this.currentCount = 0; - this.incrementCount = +`${workspace.getConfiguration().get("zowe.cics.allTransactions.recordCountIncrement")}`; - this.constant = CicsCmciConstants.CICS_LOCAL_TRANSACTION; - } - - public async loadContents(tree: CICSTree) { - await window.withProgress( - { - title: "Loading Local Transactions", - location: ProgressLocation.Notification, - cancellable: true, - }, - async (_, token) => { - token.onCancellationRequested(() => {}); - try { - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "tranid"); - } - let count; - const cacheTokenInfo = await ProfileManagement.generateCacheToken( - this.parentPlex.getProfile(), - this.parentPlex.getPlexName(), - this.constant, - criteria, - this.getParent().getGroupName(), - ); - if (cacheTokenInfo) { - const recordsCount = cacheTokenInfo.recordCount; - if (recordsCount) { - let allLocalTransactions; - if (recordsCount <= this.incrementCount) { - allLocalTransactions = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - 1, - recordsCount, - ); - } else { - allLocalTransactions = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - 1, - this.incrementCount, - ); - count = recordsCount; - } - this.addLocalTransactionsUtil([], allLocalTransactions, count); - this.iconPath = getFolderIcon(true); - tree._onDidChangeTreeData.fire(undefined); - } else { - this.children = []; - this.iconPath = getFolderIcon(true); - tree._onDidChangeTreeData.fire(undefined); - window.showInformationMessage(`No local transactions found`); - this.label = `All Local Transactions${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${recordsCount}]`; - } - } - } catch (error) { - window.showErrorMessage( - `Something went wrong when fetching local transactions - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( - /(\\n\t|\\n|\\t)/gm, - " ", - )}`, - ); - } - }, - ); - } - - public addLocalTransactionsUtil(newChildren: (CICSTransactionTreeItem | ViewMore)[], allLocalTransactions: any, count: number | undefined) { - for (const transaction of allLocalTransactions) { - const regionsContainer = this.parentPlex.children.filter((child) => child instanceof CICSRegionsContainer)?.[0]; - if (regionsContainer == null) { - continue; - } - const parentRegion = regionsContainer - .getChildren()! - .filter((child) => child instanceof CICSRegionTree && child.getRegionName() === transaction.eyu_cicsname)?.[0] as CICSRegionTree; - const transactionTree = new CICSTransactionTreeItem(transaction, parentRegion, this); - transactionTree.setLabel(transactionTree.label.toString().replace(transaction.tranid, `${transaction.tranid} (${transaction.eyu_cicsname})`)); - newChildren.push(transactionTree); - } - if (!count) { - count = newChildren.length; - } - this.currentCount = newChildren.length; - this.label = `All Local Transactions ${this.activeFilter ? `(${this.activeFilter}) ` : " "}[${this.currentCount} of ${count}]`; - if (count !== this.currentCount) { - newChildren.push(new ViewMore(this, Math.min(this.incrementCount, count - this.currentCount))); - } - this.children = newChildren; - } - - public async addMoreCachedResources(tree: CICSTree) { - await window.withProgress( - { - title: "Loading more local transactions", - location: ProgressLocation.Notification, - cancellable: false, - }, - async () => { - const cacheTokenInfo = await ProfileManagement.generateCacheToken( - this.parentPlex.getProfile(), - this.parentPlex.getPlexName(), - this.constant, - this.getParent().getGroupName(), - ); - if (cacheTokenInfo) { - // record count may have updated - const recordsCount = cacheTokenInfo.recordCount; - const count = recordsCount; - const allLocalTransactions = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - this.currentCount + 1, - this.incrementCount, - ); - if (allLocalTransactions) { - // @ts-ignore - this.addLocalTransactionsUtil( - (this.getChildren()?.filter((child) => child instanceof CICSTransactionTreeItem) ?? []) as CICSTransactionTreeItem[], - allLocalTransactions, - count, - ); - tree._onDidChangeTreeData.fire(undefined); - } - } - }, - ); - } - - public clearFilter() { - this.activeFilter = undefined; - this.label = `All Local Transactions`; - this.contextValue = `cicscombinedtransactiontree.unfiltered`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public setFilter(newFilter: string) { - this.activeFilter = newFilter; - this.label = `All Local Transactions (${this.activeFilter})`; - this.contextValue = `cicscombinedtransactiontree.filtered`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public getChildren() { - return this.children ? this.children.filter((child) => !(child instanceof TextTreeItem)) : []; - } - - public getActiveFilter() { - return this.activeFilter; - } - - public getParent() { - return this.parentPlex; - } -} diff --git a/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedURIMapTree.ts b/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedURIMapTree.ts deleted file mode 100644 index f71143f6..00000000 --- a/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedURIMapTree.ts +++ /dev/null @@ -1,211 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window, workspace } from "vscode"; -import { toEscapedCriteriaString } from "../../utils/filterUtils"; -import { ProfileManagement } from "../../utils/profileManagement"; -import { CICSPlexTree } from "../CICSPlexTree"; -import { CICSRegionsContainer } from "../CICSRegionsContainer"; -import { CICSRegionTree } from "../CICSRegionTree"; -import { CICSTree } from "../CICSTree"; -import { TextTreeItem } from "../treeItems/utils/TextTreeItem"; -import { getFolderIcon } from "../../utils/iconUtils"; -import { ViewMore } from "../treeItems/utils/ViewMore"; -import { CICSURIMapTreeItem } from "../treeItems/web/treeItems/CICSURIMapTreeItem"; - -export class CICSCombinedURIMapTree extends TreeItem { - children: (CICSURIMapTreeItem | ViewMore)[] | [TextTreeItem] | null; - parentPlex: CICSPlexTree; - activeFilter: string | undefined; - currentCount: number; - incrementCount: number; - constant: string; - - constructor( - parentPlex: CICSPlexTree, - public iconPath = getFolderIcon(false), - ) { - super("All URI Maps", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicscombinedurimapstree.`; - this.parentPlex = parentPlex; - this.children = [new TextTreeItem("Use the search button to display URI Maps", "applyfiltertext.")]; - this.activeFilter = undefined; - this.currentCount = 0; - this.incrementCount = +`${workspace.getConfiguration().get("zowe.cics.allURIMaps.recordCountIncrement")}`; - this.constant = "CICSURIMap"; - } - - public async loadContents(tree: CICSTree) { - await window.withProgress( - { - title: "Loading URI Maps", - location: ProgressLocation.Notification, - cancellable: true, - }, - async (_, token) => { - token.onCancellationRequested(() => {}); - try { - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "NAME"); - } - let count; - const cacheTokenInfo = await ProfileManagement.generateCacheToken( - this.parentPlex.getProfile(), - this.parentPlex.getPlexName(), - this.constant, - criteria, - this.getParent().getGroupName(), - ); - if (cacheTokenInfo) { - const recordsCount = cacheTokenInfo.recordCount; - if (recordsCount) { - let allURIMaps; - if (recordsCount <= this.incrementCount) { - allURIMaps = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - 1, - recordsCount, - ); - } else { - allURIMaps = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - 1, - this.incrementCount, - ); - count = recordsCount; - } - this.addURIMapsUtil([], allURIMaps, count); - this.iconPath = getFolderIcon(true); - tree._onDidChangeTreeData.fire(undefined); - } else { - this.children = []; - this.iconPath = getFolderIcon(true); - tree._onDidChangeTreeData.fire(undefined); - window.showInformationMessage(`No URI Maps found`); - this.label = `All URI Maps ${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${recordsCount}]`; - } - } - } catch (error) { - window.showErrorMessage( - `Something went wrong when fetching URI Maps - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( - /(\\n\t|\\n|\\t)/gm, - " ", - )}`, - ); - } - }, - ); - } - - public addURIMapsUtil(newChildren: (CICSURIMapTreeItem | ViewMore)[], allURIMaps: any, count: number | undefined) { - for (const urimaps of allURIMaps) { - // Regions container must exist if all URI Maps tree exists - const regionsContainer = this.parentPlex.children.filter((child) => child instanceof CICSRegionsContainer)?.[0]; - if (regionsContainer == null) { - continue; - } - const parentRegion = regionsContainer - .getChildren()! - .filter((child) => child instanceof CICSRegionTree && child.getRegionName() === urimaps.eyu_cicsname)?.[0] as CICSRegionTree; - const urimapsTree = new CICSURIMapTreeItem(urimaps, parentRegion, this); - urimapsTree.setLabel( - urimapsTree.label - .toString() - .replace(urimaps.name, `${urimaps.name} (${urimaps.eyu_cicsname}) [${urimapsTree.urimap.scheme}] (${urimapsTree.urimap.path})`), - ); - newChildren.push(urimapsTree); - } - if (!count) { - count = newChildren.length; - } - this.currentCount = newChildren.length; - this.label = `All URI Maps ${this.activeFilter ? `(${this.activeFilter}) ` : " "}[${this.currentCount} of ${count}]`; - if (count !== this.currentCount) { - newChildren.push(new ViewMore(this, Math.min(this.incrementCount, count - this.currentCount))); - } - this.children = newChildren; - } - - public async addMoreCachedResources(tree: CICSTree) { - await window.withProgress( - { - title: "Loading more URI Maps", - location: ProgressLocation.Notification, - cancellable: false, - }, - async () => { - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "NAME"); - } - const cacheTokenInfo = await ProfileManagement.generateCacheToken( - this.parentPlex.getProfile(), - this.parentPlex.getPlexName(), - this.constant, - criteria, - this.getParent().getGroupName(), - ); - if (cacheTokenInfo) { - // record count may have updated - const recordsCount = cacheTokenInfo.recordCount; - const count = recordsCount; - const allURIMaps = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - this.currentCount + 1, - this.incrementCount, - ); - if (allURIMaps) { - // @ts-ignore - this.addURIMapsUtil( - (this.getChildren()?.filter((child) => child instanceof CICSURIMapTreeItem) ?? []) as CICSURIMapTreeItem[], - allURIMaps, - count, - ); - tree._onDidChangeTreeData.fire(undefined); - } - } - }, - ); - } - - public clearFilter() { - this.activeFilter = undefined; - this.label = `All URI Maps`; - this.contextValue = `cicscombinedurimapstree.unfiltered`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public setFilter(newFilter: string) { - this.activeFilter = newFilter; - this.label = `All URI Maps (${this.activeFilter})`; - this.contextValue = `cicscombinedurimapstree.filtered`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public getChildren() { - return this.children ? this.children.filter((child) => !(child instanceof TextTreeItem)) : []; - } - - public getActiveFilter() { - return this.activeFilter; - } - - public getParent() { - return this.parentPlex; - } -} diff --git a/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedWebServiceTree.ts b/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedWebServiceTree.ts deleted file mode 100644 index 431876e1..00000000 --- a/packages/vsce/src/trees/CICSCombinedTrees/CICSCombinedWebServiceTree.ts +++ /dev/null @@ -1,207 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window, workspace } from "vscode"; -import { toEscapedCriteriaString } from "../../utils/filterUtils"; -import { ProfileManagement } from "../../utils/profileManagement"; -import { CICSPlexTree } from "../CICSPlexTree"; -import { CICSRegionsContainer } from "../CICSRegionsContainer"; -import { CICSRegionTree } from "../CICSRegionTree"; -import { CICSTree } from "../CICSTree"; -import { TextTreeItem } from "../treeItems/utils/TextTreeItem"; -import { getFolderIcon } from "../../utils/iconUtils"; -import { ViewMore } from "../treeItems/utils/ViewMore"; -import { CICSWebServiceTreeItem } from "../treeItems/web/treeItems/CICSWebServiceTreeItem"; - -export class CICSCombinedWebServiceTree extends TreeItem { - children: (CICSWebServiceTreeItem | ViewMore)[] | [TextTreeItem] | null; - parentPlex: CICSPlexTree; - activeFilter: string | undefined; - currentCount: number; - incrementCount: number; - constant: string; - - constructor( - parentPlex: CICSPlexTree, - public iconPath = getFolderIcon(false), - ) { - super("All Web Services", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicscombinedwebservicetree.`; - this.parentPlex = parentPlex; - this.children = [new TextTreeItem("Use the search button to display web services", "applyfiltertext.")]; - this.activeFilter = undefined; - this.currentCount = 0; - this.incrementCount = +`${workspace.getConfiguration().get("zowe.cics.allWebServices.recordCountIncrement")}`; - this.constant = "CICSWebService"; - } - - public async loadContents(tree: CICSTree) { - await window.withProgress( - { - title: "Loading Web Services", - location: ProgressLocation.Notification, - cancellable: true, - }, - async (_, token) => { - token.onCancellationRequested(() => {}); - try { - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "NAME"); - } - let count; - const cacheTokenInfo = await ProfileManagement.generateCacheToken( - this.parentPlex.getProfile(), - this.parentPlex.getPlexName(), - this.constant, - criteria, - this.getParent().getGroupName(), - ); - if (cacheTokenInfo) { - const recordsCount = cacheTokenInfo.recordCount; - if (recordsCount) { - let allWebServices; - if (recordsCount <= this.incrementCount) { - allWebServices = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - 1, - recordsCount, - ); - } else { - allWebServices = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - 1, - this.incrementCount, - ); - count = recordsCount; - } - this.addWebServicesUtil([], allWebServices, count); - this.iconPath = getFolderIcon(true); - tree._onDidChangeTreeData.fire(undefined); - } else { - this.children = []; - this.iconPath = getFolderIcon(true); - tree._onDidChangeTreeData.fire(undefined); - window.showInformationMessage(`No Web Services found`); - this.label = `All Web Services${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${recordsCount}]`; - } - } - } catch (error) { - await window.showErrorMessage( - `Something went wrong when fetching web services - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( - /(\\n\t|\\n|\\t)/gm, - " ", - )}`, - ); - } - }, - ); - } - - public addWebServicesUtil(newChildren: (CICSWebServiceTreeItem | ViewMore)[], allWebServices: any, count: number | undefined) { - for (const webservice of allWebServices) { - // Regions container must exist if all web services tree exists - const regionsContainer = this.parentPlex.children.filter((child) => child instanceof CICSRegionsContainer)?.[0]; - if (regionsContainer == null) { - continue; - } - const parentRegion = regionsContainer - .getChildren()! - .filter((child) => child instanceof CICSRegionTree && child.getRegionName() === webservice.eyu_cicsname)?.[0] as CICSRegionTree; - const webserviceTree = new CICSWebServiceTreeItem(webservice, parentRegion, this); - webserviceTree.setLabel(webserviceTree.label.toString().replace(webservice.name, `${webservice.name} (${webservice.eyu_cicsname})`)); - newChildren.push(webserviceTree); - } - if (!count) { - count = newChildren.length; - } - this.currentCount = newChildren.length; - this.label = `All Web Services ${this.activeFilter ? `(${this.activeFilter}) ` : " "}[${this.currentCount} of ${count}]`; - if (count !== this.currentCount) { - newChildren.push(new ViewMore(this, Math.min(this.incrementCount, count - this.currentCount))); - } - this.children = newChildren; - } - - public async addMoreCachedResources(tree: CICSTree) { - await window.withProgress( - { - title: "Loading more pipelins", - location: ProgressLocation.Notification, - cancellable: false, - }, - async () => { - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "NAME"); - } - const cacheTokenInfo = await ProfileManagement.generateCacheToken( - this.parentPlex.getProfile(), - this.parentPlex.getPlexName(), - this.constant, - criteria, - this.getParent().getGroupName(), - ); - if (cacheTokenInfo) { - // record count may have updated - const recordsCount = cacheTokenInfo.recordCount; - const count = recordsCount; - const allWebServices = await ProfileManagement.getCachedResources( - this.parentPlex.getProfile(), - cacheTokenInfo.cacheToken, - this.constant, - this.currentCount + 1, - this.incrementCount, - ); - if (allWebServices) { - // @ts-ignore - this.addWebServicesUtil( - (this.getChildren()?.filter((child) => child instanceof CICSWebServiceTreeItem) ?? []) as CICSWebServiceTreeItem[], - allWebServices, - count, - ); - tree._onDidChangeTreeData.fire(undefined); - } - } - }, - ); - } - - public clearFilter() { - this.activeFilter = undefined; - this.label = `All Web Services`; - this.contextValue = `cicscombinedwebservicetree.unfiltered`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public setFilter(newFilter: string) { - this.activeFilter = newFilter; - this.label = `All Web Services (${this.activeFilter})`; - this.contextValue = `cicscombinedwebservicetree.filtered`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public getChildren() { - return this.children ? this.children.filter((child) => !(child instanceof TextTreeItem)) : []; - } - - public getActiveFilter() { - return this.activeFilter; - } - - public getParent() { - return this.parentPlex; - } -} diff --git a/packages/vsce/src/trees/CICSLocalFileTree.ts b/packages/vsce/src/trees/CICSLocalFileTree.ts deleted file mode 100644 index a72987cf..00000000 --- a/packages/vsce/src/trees/CICSLocalFileTree.ts +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem, window, workspace } from "vscode"; -import { CICSLocalFileTreeItem } from "./treeItems/CICSLocalFileTreeItem"; -import { getResource } from "@zowe/cics-for-zowe-sdk"; -import { CICSRegionTree } from "./CICSRegionTree"; -import { toEscapedCriteriaString } from "../utils/filterUtils"; -import { getFolderIcon } from "../utils/iconUtils"; -import { toArray } from "../utils/commandUtils"; - -export class CICSLocalFileTree extends TreeItem { - children: CICSLocalFileTreeItem[] = []; - parentRegion: CICSRegionTree; - activeFilter: string | undefined = undefined; - - constructor(parentRegion: CICSRegionTree, public iconPath = getFolderIcon(false)) { - super("Local Files", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicstreelocalfile.${this.activeFilter ? "filtered" : "unfiltered"}.localFiles`; - this.parentRegion = parentRegion; - } - - public addLocalFile(localFile: CICSLocalFileTreeItem) { - this.children.push(localFile); - } - - public async loadContents() { - let defaultCriteria = `${await workspace.getConfiguration().get("zowe.cics.localFile.filter")}`; - if (!defaultCriteria || defaultCriteria.length === 0) { - await workspace.getConfiguration().update("zowe.cics.localFile.filter", "file=*"); - defaultCriteria = "file=*"; - } - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "file"); - } else { - criteria = defaultCriteria; - } - this.children = []; - try { - - const localFileResponse = await getResource(this.parentRegion.parentSession.session, { - name: "CICSLocalFile", - regionName: this.parentRegion.getRegionName(), - cicsPlex: this.parentRegion.parentPlex ? this.parentRegion.parentPlex.getPlexName() : undefined, - criteria: criteria, - }); - const localFileArray = toArray(localFileResponse.response.records.cicslocalfile); - this.label = `Local Files${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${localFileArray.length}]`; - for (const localFile of localFileArray) { - const newLocalFileItem = new CICSLocalFileTreeItem(localFile, this.parentRegion, this); - this.addLocalFile(newLocalFileItem); - } - this.iconPath = getFolderIcon(true); - } catch (error) { - // @ts-ignore - if (error.mMessage!.includes("exceeded a resource limit")) { - window.showErrorMessage(`Resource Limit Exceeded - Set a local file filter to narrow search`); - // @ts-ignore - } else if (this.children.length === 0) { - window.showInformationMessage(`No local files found`); - this.label = `Local Files${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[0]`; - this.iconPath = getFolderIcon(true); - } else { - window.showErrorMessage( - `Something went wrong when fetching local files - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( - /(\\n\t|\\n|\\t)/gm, - " " - )}` - ); - } - } - } - - public clearFilter() { - this.activeFilter = undefined; - this.contextValue = `cicstreelocalfile.${this.activeFilter ? "filtered" : "unfiltered"}.localFiles`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public setFilter(newFilter: string) { - this.activeFilter = newFilter; - this.contextValue = `cicstreelocalfile.${this.activeFilter ? "filtered" : "unfiltered"}.localFiles`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public getFilter() { - return this.activeFilter; - } - - public getParent() { - return this.parentRegion; - } -} diff --git a/packages/vsce/src/trees/CICSPlexTree.ts b/packages/vsce/src/trees/CICSPlexTree.ts index 33e28ff4..0ac326f8 100644 --- a/packages/vsce/src/trees/CICSPlexTree.ts +++ b/packages/vsce/src/trees/CICSPlexTree.ts @@ -9,36 +9,24 @@ * */ -import { TreeItemCollapsibleState, TreeItem } from "vscode"; -import { CICSRegionTree } from "./CICSRegionTree"; -import { imperative } from "@zowe/zowe-explorer-api"; -import { CICSSessionTree } from "./CICSSessionTree"; -import { getResource } from "@zowe/cics-for-zowe-sdk"; -import { CICSCombinedProgramTree } from "./CICSCombinedTrees/CICSCombinedProgramTree"; -import { CICSCombinedTransactionsTree } from "./CICSCombinedTrees/CICSCombinedTransactionTree"; -import { CICSCombinedLocalFileTree } from "./CICSCombinedTrees/CICSCombinedLocalFileTree"; import { CICSRegionsContainer } from "./CICSRegionsContainer"; import { getIconFilePathFromName } from "../utils/iconUtils"; -import { CICSCombinedTaskTree } from "./CICSCombinedTrees/CICSCombinedTaskTree"; +import { getResource, IResource } from "@zowe/cics-for-zowe-sdk"; +import { imperative } from "@zowe/zowe-explorer-api"; +import { TreeItem, TreeItemCollapsibleState } from "vscode"; +import { LocalFileMeta, PipelineMeta, ProgramMeta, TaskMeta, TCPIPMeta, TransactionMeta, URIMapMeta } from "../doc"; +import { WebServiceMeta } from "../doc/WebServiceMeta"; import { CICSCombinedLibraryTree } from "./CICSCombinedTrees/CICSCombinedLibraryTree"; -import { CICSCombinedTCPIPServiceTree } from "./CICSCombinedTrees/CICSCombinedTCPIPServiceTree"; -import { CICSCombinedURIMapTree } from "./CICSCombinedTrees/CICSCombinedURIMapTree"; -import { CICSCombinedPipelineTree } from "./CICSCombinedTrees/CICSCombinedPipelineTree"; -import { CICSCombinedWebServiceTree } from "./CICSCombinedTrees/CICSCombinedWebServiceTree"; +import { CICSCombinedResourceTree } from "./CICSCombinedTrees/CICSCombinedResourceTree"; +import { CICSRegionTree } from "./CICSRegionTree"; +import { CICSSessionTree } from "./CICSSessionTree"; export class CICSPlexTree extends TreeItem { children: ( | CICSRegionTree - | CICSCombinedProgramTree - | CICSCombinedTransactionsTree - | CICSCombinedLocalFileTree - | CICSCombinedTaskTree + | CICSCombinedResourceTree | CICSCombinedLibraryTree | CICSRegionsContainer - | CICSCombinedTCPIPServiceTree - | CICSCombinedURIMapTree - | CICSCombinedPipelineTree - | CICSCombinedWebServiceTree )[] = []; plexName: string; profile: imperative.IProfileLoaded; @@ -75,7 +63,6 @@ export class CICSPlexTree extends TreeItem { regionName: plexProfile.profile.regionName, }); const newRegionTree = new CICSRegionTree( - plexProfile.profile.regionName, regionsObtained.response.records.cicsregion, this.getParent(), this, @@ -158,15 +145,15 @@ export class CICSPlexTree extends TreeItem { } public addNewCombinedTrees() { - this.children.push(new CICSCombinedProgramTree(this)); - this.children.push(new CICSCombinedTransactionsTree(this)); - this.children.push(new CICSCombinedLocalFileTree(this)); - this.children.push(new CICSCombinedTaskTree(this)); + this.children.push(new CICSCombinedResourceTree(this, ProgramMeta)); + this.children.push(new CICSCombinedResourceTree(this, TransactionMeta)); + this.children.push(new CICSCombinedResourceTree(this, LocalFileMeta)); + this.children.push(new CICSCombinedResourceTree(this, TaskMeta)); this.children.push(new CICSCombinedLibraryTree(this)); - this.children.push(new CICSCombinedTCPIPServiceTree(this)); - this.children.push(new CICSCombinedURIMapTree(this)); - this.children.push(new CICSCombinedWebServiceTree(this)); - this.children.push(new CICSCombinedPipelineTree(this)); + this.children.push(new CICSCombinedResourceTree(this, TCPIPMeta)); + this.children.push(new CICSCombinedResourceTree(this, URIMapMeta)); + this.children.push(new CICSCombinedResourceTree(this, WebServiceMeta)); + this.children.push(new CICSCombinedResourceTree(this, PipelineMeta)); } public addRegionContainer(): CICSRegionsContainer { diff --git a/packages/vsce/src/trees/CICSProgramTree.ts b/packages/vsce/src/trees/CICSProgramTree.ts deleted file mode 100644 index 3702b632..00000000 --- a/packages/vsce/src/trees/CICSProgramTree.ts +++ /dev/null @@ -1,98 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem, window } from "vscode"; -import { CICSProgramTreeItem } from "./treeItems/CICSProgramTreeItem"; -import { CICSRegionTree } from "./CICSRegionTree"; -import { getResource } from "@zowe/cics-for-zowe-sdk"; -import { getDefaultProgramFilter, toEscapedCriteriaString } from "../utils/filterUtils"; -import { getFolderIcon } from "../utils/iconUtils"; -import { toArray } from "../utils/commandUtils"; - -export class CICSProgramTree extends TreeItem { - children: CICSProgramTreeItem[] = []; - parentRegion: CICSRegionTree; - activeFilter: string | undefined = undefined; - - constructor( - parentRegion: CICSRegionTree, - public iconPath = getFolderIcon(false), - ) { - super("Programs", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicstreeprogram.${this.activeFilter ? "filtered" : "unfiltered"}.programs`; - this.parentRegion = parentRegion; - } - - public addProgram(program: CICSProgramTreeItem) { - this.children.push(program); - } - - public async loadContents() { - const defaultCriteria = await getDefaultProgramFilter(); - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "PROGRAM"); - } else { - criteria = defaultCriteria; - } - this.children = []; - try { - const programResponse = await getResource(this.parentRegion.parentSession.session, { - name: "CICSProgram", - regionName: this.parentRegion.getRegionName(), - cicsPlex: this.parentRegion.parentPlex ? this.parentRegion.parentPlex.getPlexName() : undefined, - criteria: criteria, - }); - const programsArray = toArray(programResponse.response.records.cicsprogram); - this.label = `Programs${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${programsArray.length}]`; - for (const program of programsArray) { - const newProgramItem = new CICSProgramTreeItem(program, this.parentRegion, this); - this.addProgram(newProgramItem); - } - this.iconPath = getFolderIcon(true); - } catch (error) { - if (error.mMessage!.includes("exceeded a resource limit")) { - window.showErrorMessage(`Resource Limit Exceeded - Set a program filter to narrow search`); - } else if (this.children.length === 0) { - window.showInformationMessage(`No programs found`); - this.label = `Programs${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[0]`; - this.iconPath = getFolderIcon(true); - } else { - window.showErrorMessage( - `Something went wrong when fetching programs - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( - /(\\n\t|\\n|\\t)/gm, - " ", - )}`, - ); - } - } - } - - public clearFilter() { - this.activeFilter = undefined; - this.contextValue = `cicstreeprogram.${this.activeFilter ? "filtered" : "unfiltered"}.programs`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public setFilter(newFilter: string) { - this.activeFilter = newFilter; - this.contextValue = `cicstreeprogram.${this.activeFilter ? "filtered" : "unfiltered"}.programs`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public getFilter() { - return this.activeFilter; - } - - public getParent() { - return this.parentRegion; - } -} diff --git a/packages/vsce/src/trees/CICSRegionTree.ts b/packages/vsce/src/trees/CICSRegionTree.ts index 9fbbf3d8..f4da98dc 100644 --- a/packages/vsce/src/trees/CICSRegionTree.ts +++ b/packages/vsce/src/trees/CICSRegionTree.ts @@ -10,28 +10,35 @@ */ import { TreeItemCollapsibleState, TreeItem } from "vscode"; -import { CICSProgramTree } from "./CICSProgramTree"; -import { CICSTransactionTree } from "./CICSTransactionTree"; -import { CICSLocalFileTree } from "./CICSLocalFileTree"; import { CICSSessionTree } from "./CICSSessionTree"; import { CICSPlexTree } from "./CICSPlexTree"; -import { getIconByStatus } from "../utils/iconUtils"; -import { CICSTaskTree } from "./CICSTaskTree"; +import { getIconFilePathFromName } from "../utils/iconUtils"; +import { IRegion, IResource } from "@zowe/cics-for-zowe-sdk"; import { CICSLibraryTree } from "./CICSLibraryTree"; -import { CICSWebTree } from "./CICSWebTree"; +import { CICSResourceTree } from "./CICSResourceTree"; +import { LocalFileMeta, PipelineMeta, ProgramMeta, TaskMeta, TransactionMeta, URIMapMeta } from "../doc"; +import { TCPIPMeta } from "../doc/TCPIPMeta"; +import { WebServiceMeta } from "../doc/WebServiceMeta"; +import { CICSRegionsContainer } from "./CICSRegionsContainer"; +import { RegionMeta } from "../doc/RegionMeta"; export class CICSRegionTree extends TreeItem { - children: [CICSProgramTree, CICSTransactionTree, CICSLocalFileTree, CICSTaskTree, CICSLibraryTree, CICSWebTree] | null; - region: any; + children: (CICSResourceTree | CICSLibraryTree)[] | null; + region: IRegion; parentSession: CICSSessionTree; parentPlex: CICSPlexTree | undefined; - directParent: any; + directParent: CICSPlexTree | CICSRegionsContainer | CICSSessionTree; isActive: true | false; - constructor(regionName: string, region: any, parentSession: CICSSessionTree, parentPlex: CICSPlexTree | undefined, directParent: any) { - super(regionName, TreeItemCollapsibleState.Collapsed); + constructor( + region: IRegion, + parentSession: CICSSessionTree, + parentPlex: CICSPlexTree | undefined, + directParent: CICSPlexTree | CICSRegionsContainer | CICSSessionTree + ) { + super(RegionMeta.getLabel(region), TreeItemCollapsibleState.Collapsed); this.region = region; - this.contextValue = `cicsregion.${regionName}`; + this.contextValue = RegionMeta.getContext(region); this.parentSession = parentSession; this.directParent = directParent; if (parentPlex) { @@ -43,22 +50,24 @@ export class CICSRegionTree extends TreeItem { } else { this.isActive = region.cicsstatus === "ACTIVE" ? true : false; } - this.iconPath = getIconByStatus("REGION", this); - if (!this.isActive) { - this.children = null; - this.collapsibleState = TreeItemCollapsibleState.None; - this.iconPath = getIconByStatus("REGION", this); - this.contextValue += ".inactive"; - } else { - this.contextValue += ".active"; + this.iconPath = getIconFilePathFromName(RegionMeta.getIconName(region)); + if (this.isActive) { this.children = [ - new CICSProgramTree(this), - new CICSTransactionTree(this), - new CICSLocalFileTree(this), - new CICSTaskTree(this), + new CICSResourceTree(ProgramMeta, this), + new CICSResourceTree(TransactionMeta, this), + new CICSResourceTree(LocalFileMeta, this), + new CICSResourceTree(TaskMeta, this), new CICSLibraryTree(this), - new CICSWebTree(this), + // new CICSWebTree(this), + new CICSResourceTree(TCPIPMeta, this), + new CICSResourceTree(URIMapMeta, this), + new CICSResourceTree(PipelineMeta, this), + new CICSResourceTree(WebServiceMeta, this), ]; + } else { + this.children = null; + this.collapsibleState = TreeItemCollapsibleState.None; + this.iconPath = getIconFilePathFromName(RegionMeta.getIconName(region)); } } diff --git a/packages/vsce/src/trees/CICSRegionsContainer.ts b/packages/vsce/src/trees/CICSRegionsContainer.ts index 4dd82fb0..31477fe9 100644 --- a/packages/vsce/src/trees/CICSRegionsContainer.ts +++ b/packages/vsce/src/trees/CICSRegionsContainer.ts @@ -99,7 +99,7 @@ export class CICSRegionsContainer extends TreeItem { for (const region of regionsArray) { // If region filter exists then match it if (!regionFilterRegex || region.cicsname.match(regionFilterRegex)) { - const newRegionTree = new CICSRegionTree(region.cicsname, region, parentPlex.getParent(), parentPlex, this); + const newRegionTree = new CICSRegionTree(region, parentPlex.getParent(), parentPlex, this); this.addRegion(newRegionTree); totalCount += 1; if (region.cicsstate === "ACTIVE") { diff --git a/packages/vsce/src/trees/CICSResourceTree.ts b/packages/vsce/src/trees/CICSResourceTree.ts new file mode 100644 index 00000000..dbd2a29c --- /dev/null +++ b/packages/vsce/src/trees/CICSResourceTree.ts @@ -0,0 +1,111 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { getResource, IResource } from "@zowe/cics-for-zowe-sdk"; +import { TreeItem, TreeItemCollapsibleState, window } from "vscode"; +import IResourceMeta from "../doc/IResourceMeta"; +import { toArray } from "../utils/commandUtils"; +import { toEscapedCriteriaString } from "../utils/filterUtils"; +import { getFolderIcon } from "../utils/iconUtils"; +import { CICSRegionTree } from "./CICSRegionTree"; +import { CICSResourceTreeItem } from "./treeItems/CICSResourceTreeItem"; + + +export class CICSResourceTree extends TreeItem { + children: CICSResourceTreeItem[] = []; + parentRegion: CICSRegionTree; + activeFilter: string | undefined = undefined; + + resourceMeta: IResourceMeta; + + constructor(resourceMeta: IResourceMeta, parentRegion: CICSRegionTree, public iconPath = getFolderIcon(false)) { + super(resourceMeta.humanReadableName, TreeItemCollapsibleState.Collapsed); + this.contextValue = `${resourceMeta.contextPrefix}.${this.activeFilter ? "filtered" : "unfiltered"}.${resourceMeta.resourceName}`; + this.parentRegion = parentRegion; + this.resourceMeta = resourceMeta; + } + + public addResource(resource: CICSResourceTreeItem) { + this.children.push(resource); + } + + public async loadContents() { + + let criteria = await this.resourceMeta.getDefaultFilter(); + if (this.activeFilter) { + criteria = toEscapedCriteriaString(this.activeFilter, this.resourceMeta.filterAttribute); + } + + this.children = []; + try { + + const { response } = await getResource(this.parentRegion.parentSession.session, { + name: this.resourceMeta.resourceName, + regionName: this.parentRegion.getRegionName(), + cicsPlex: this.parentRegion.parentPlex ? this.parentRegion.parentPlex.getPlexName() : undefined, + criteria: criteria, + }); + const results = toArray(response.records[this.resourceMeta.resourceName.toLowerCase()]); + + this.label = `${this.resourceMeta.humanReadableName}${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${results.length}]`; + + for (const resource of results) { + const newResourceItem = new CICSResourceTreeItem( + resource as T, + this.resourceMeta, + this.parentRegion, + this, + ); + this.addResource(newResourceItem); + } + + this.iconPath = getFolderIcon(true); + + } catch (error) { + if (error.mMessage?.includes("exceeded a resource limit")) { + window.showErrorMessage(`Resource Limit Exceeded - Set a filter to narrow search`); + } else if (this.children.length === 0) { + window.showInformationMessage(`No ${this.resourceMeta.humanReadableName} found`); + + this.label = `${this.resourceMeta.humanReadableName}${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[0]`; + this.iconPath = getFolderIcon(true); + + } else { + window.showErrorMessage( + `Something went wrong when fetching resources - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( + /(\\n\t|\\n|\\t)/gm, + " " + )}` + ); + } + } + } + + public clearFilter() { + this.activeFilter = undefined; + this.contextValue = `${this.resourceMeta.contextPrefix}.${this.activeFilter ? "filtered" : "unfiltered"}.${this.resourceMeta.resourceName}`; + this.collapsibleState = TreeItemCollapsibleState.Expanded; + } + + public setFilter(newFilter: string) { + this.activeFilter = newFilter; + this.contextValue = `${this.resourceMeta.contextPrefix}.${this.activeFilter ? "filtered" : "unfiltered"}.${this.resourceMeta.resourceName}`; + this.collapsibleState = TreeItemCollapsibleState.Expanded; + } + + public getFilter() { + return this.activeFilter; + } + + public getParent() { + return this.parentRegion; + } +} diff --git a/packages/vsce/src/trees/CICSTaskTree.ts b/packages/vsce/src/trees/CICSTaskTree.ts deleted file mode 100644 index aa74d5ca..00000000 --- a/packages/vsce/src/trees/CICSTaskTree.ts +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem, window, workspace } from "vscode"; -import { CICSRegionTree } from "./CICSRegionTree"; -import { getResource } from "@zowe/cics-for-zowe-sdk"; -import { toEscapedCriteriaString } from "../utils/filterUtils"; -import { getFolderIcon } from "../utils/iconUtils"; -import { CICSTaskTreeItem } from "./treeItems/CICSTaskTreeItem"; -import { toArray } from "../utils/commandUtils"; - -export class CICSTaskTree extends TreeItem { - children: CICSTaskTreeItem[] = []; - parentRegion: CICSRegionTree; - activeTransactionFilter: string | undefined = undefined; - - constructor( - parentRegion: CICSRegionTree, - public iconPath = getFolderIcon(false), - ) { - super("Tasks", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicstreetask.${this.activeTransactionFilter ? "filtered" : "unfiltered"}.tasks`; - this.parentRegion = parentRegion; - } - - public addTask(task: CICSTaskTreeItem) { - this.children.push(task); - } - - public async loadContents() { - let defaultCriteria = `${await workspace.getConfiguration().get("zowe.cics.tasks.filter")}`; - if (!defaultCriteria || defaultCriteria.length === 0) { - await workspace.getConfiguration().update("zowe.cics.tasks.filter", "(TRANID=*)"); - defaultCriteria = "(TRANID=*)"; - } - let criteria; - if (this.activeTransactionFilter) { - criteria = toEscapedCriteriaString(this.activeTransactionFilter, "TRANID"); - } else { - criteria = defaultCriteria; - } - this.children = []; - try { - const taskResponse = await getResource(this.parentRegion.parentSession.session, { - name: "CICSTASK", - regionName: this.parentRegion.getRegionName(), - cicsPlex: this.parentRegion.parentPlex ? this.parentRegion.parentPlex.getPlexName() : undefined, - criteria: criteria, - }); - - const tasksArray = toArray(taskResponse.response.records.cicstask); - this.label = `Tasks${this.activeTransactionFilter ? ` (${this.activeTransactionFilter}) ` : " "}[${tasksArray.length}]`; - for (const task of tasksArray) { - const newTaskItem = new CICSTaskTreeItem(task, this.parentRegion, this); - // Show run status if run status isn't SUSPENDED (assuming SUSPENDED is default runstatus) - newTaskItem.setLabel( - newTaskItem.label - .toString() - .replace(task.task, `${task.task} - ${task.tranid}${task.runstatus !== "SUSPENDED" ? ` (${task.runstatus})` : ""}`), - ); - this.addTask(newTaskItem); - } - this.iconPath = getFolderIcon(true); - } catch (error) { - if (error.mMessage!.includes("exceeded a resource limit")) { - window.showErrorMessage(`Resource Limit Exceeded - Set a task filter to narrow search`); - } else if (this.children.length === 0) { - window.showInformationMessage(`No tasks found`); - this.label = `Tasks${this.activeTransactionFilter ? ` (${this.activeTransactionFilter}) ` : " "}[0]`; - this.iconPath = getFolderIcon(true); - } else { - window.showErrorMessage( - `Something went wrong when fetching tasks - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace(/(\\n\t|\\n|\\t)/gm, " ")}`, - ); - } - } - } - - public clearFilter() { - this.activeTransactionFilter = undefined; - this.contextValue = `cicstreetask.${this.activeTransactionFilter ? "filtered" : "unfiltered"}.tasks`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public setFilter(newFilter: string) { - this.activeTransactionFilter = newFilter; - this.contextValue = `cicstreetask.${this.activeTransactionFilter ? "filtered" : "unfiltered"}.tasks`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public getFilter() { - return this.activeTransactionFilter; - } -} diff --git a/packages/vsce/src/trees/CICSTransactionTree.ts b/packages/vsce/src/trees/CICSTransactionTree.ts deleted file mode 100644 index 2dbf1423..00000000 --- a/packages/vsce/src/trees/CICSTransactionTree.ts +++ /dev/null @@ -1,100 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem, window } from "vscode"; -import { CICSTransactionTreeItem } from "./treeItems/CICSTransactionTreeItem"; -import { CICSRegionTree } from "./CICSRegionTree"; -import { getResource } from "@zowe/cics-for-zowe-sdk"; -import { getDefaultTransactionFilter, toEscapedCriteriaString } from "../utils/filterUtils"; -import { getFolderIcon } from "../utils/iconUtils"; -import { toArray } from "../utils/commandUtils"; - -export class CICSTransactionTree extends TreeItem { - children: CICSTransactionTreeItem[] = []; - parentRegion: CICSRegionTree; - activeFilter: string | undefined = undefined; - - constructor( - parentRegion: CICSRegionTree, - public iconPath = getFolderIcon(false), - ) { - super("Transactions", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicstreetransaction.${this.activeFilter ? "filtered" : "unfiltered"}.transactions`; - this.parentRegion = parentRegion; - } - - public addTransaction(program: CICSTransactionTreeItem) { - this.children.push(program); - } - - public async loadContents() { - const defaultCriteria = await getDefaultTransactionFilter(); - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "tranid"); - } else { - criteria = defaultCriteria; - } - this.children = []; - try { - const transactionResponse = await getResource(this.parentRegion.parentSession.session, { - name: "CICSLocalTransaction", - regionName: this.parentRegion.getRegionName(), - cicsPlex: this.parentRegion.parentPlex ? this.parentRegion.parentPlex.getPlexName() : undefined, - criteria: criteria, - }); - const transactionArray = toArray(transactionResponse.response.records.cicslocaltransaction); - this.label = `Transactions${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${transactionArray.length}]`; - for (const transaction of transactionArray) { - const newTransactionItem = new CICSTransactionTreeItem(transaction, this.parentRegion, this); - this.addTransaction(newTransactionItem); - } - this.iconPath = getFolderIcon(true); - } catch (error) { - // @ts-ignore - if (error.mMessage!.includes("exceeded a resource limit")) { - window.showErrorMessage(`Resource Limit Exceeded - Set a transaction filter to narrow search`); - // @ts-ignore - } else if (this.children.length === 0) { - window.showInformationMessage(`No transactions found`); - this.label = `Transactions${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[0]`; - this.iconPath = getFolderIcon(true); - } else { - window.showErrorMessage( - `Something went wrong when fetching transaction - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( - /(\\n\t|\\n|\\t)/gm, - " ", - )}`, - ); - } - } - } - - public clearFilter() { - this.activeFilter = undefined; - this.contextValue = `cicstreetransaction.${this.activeFilter ? "filtered" : "unfiltered"}.transactions`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public setFilter(newFilter: string) { - this.activeFilter = newFilter; - this.contextValue = `cicstreetransaction.${this.activeFilter ? "filtered" : "unfiltered"}.transactions`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public getFilter() { - return this.activeFilter; - } - - public getParent() { - return this.parentRegion; - } -} diff --git a/packages/vsce/src/trees/CICSTree.ts b/packages/vsce/src/trees/CICSTree.ts index b7062256..725849c2 100644 --- a/packages/vsce/src/trees/CICSTree.ts +++ b/packages/vsce/src/trees/CICSTree.ts @@ -38,10 +38,13 @@ import { CICSRegionTree } from "./CICSRegionTree"; import { CICSSessionTree } from "./CICSSessionTree"; export class CICSTree implements TreeDataProvider { + loadedProfiles: CICSSessionTree[] = []; + constructor() { this.loadStoredProfileNames(); } + public getLoadedProfiles() { return this.loadedProfiles; } @@ -51,6 +54,7 @@ export class CICSTree implements TreeDataProvider { await this.loadStoredProfileNames(); commands.executeCommand("workbench.actions.treeView.cics-view.collapseAll"); } + public clearLoadedProfiles() { this.loadedProfiles = []; this._onDidChangeTreeData.fire(undefined); @@ -62,21 +66,20 @@ export class CICSTree implements TreeDataProvider { * these as children to the CICSTree (TreeDataProvider) */ public async loadStoredProfileNames() { - const persistentStorage = new PersistentStorage("zowe.cics.persistent"); await ProfileManagement.profilesCacheRefresh(); - // Retrieve previously added profiles from persistent storage - for (const profilename of persistentStorage.getLoadedCICSProfile()) { - try { - const profileToLoad = await ProfileManagement.getProfilesCache().loadNamedProfile(profilename, "cics"); - // avoid accidental repeats - if (!this.loadedProfiles.filter((sessionTree) => sessionTree.label === profilename).length) { - const newSessionTree = new CICSSessionTree(profileToLoad); - this.loadedProfiles.push(newSessionTree); + const persistentStorage = new PersistentStorage("zowe.cics.persistent"); + const uniqueProfileNamesToLoad = [...new Set(persistentStorage.getLoadedCICSProfile())]; + + this.loadedProfiles = uniqueProfileNamesToLoad.flatMap( + (profileName: string) => { + try { + const profile = ProfileManagement.getProfilesCache().loadNamedProfile(profileName, "cics"); + return [new CICSSessionTree(profile)]; + } catch (error) { + return []; } - } catch { - continue; } - } + ); this._onDidChangeTreeData.fire(undefined); } @@ -222,7 +225,7 @@ export class CICSTree implements TreeDataProvider { cancellable: true, }, async (progress, token) => { - token.onCancellationRequested(() => {}); + token.onCancellationRequested(() => { }); progress.report({ message: `Loading ${profile.name}`, @@ -280,7 +283,6 @@ export class CICSTree implements TreeDataProvider { // 200 OK received newSessionTree.setAuthorized(); const newRegionTree = new CICSRegionTree( - item.regions[0].applid, regionsObtained.response.records.cicsregion, newSessionTree, undefined, @@ -348,8 +350,8 @@ export class CICSTree implements TreeDataProvider { if (sessionTree) { const decision = await window.showInformationMessage( `Warning: Your connection is not private (${error.code}) - ` + - `would you still like to proceed to ${profile.profile.host} (unsafe)?`, - ...["Yes", "No"], + `would you still like to proceed to ${profile.profile.host} (unsafe)?`, + ...["Yes", "No"] ); if (decision) { if (decision === "Yes") { @@ -500,6 +502,7 @@ export class CICSTree implements TreeDataProvider { getTreeItem(element: CICSSessionTree): TreeItem | Thenable { return element; } + getChildren(element?: CICSSessionTree): ProviderResult { return element === undefined ? this.loadedProfiles : element.children; } diff --git a/packages/vsce/src/trees/CICSWebTree.ts b/packages/vsce/src/trees/CICSWebTree.ts deleted file mode 100644 index d0cffac8..00000000 --- a/packages/vsce/src/trees/CICSWebTree.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem } from "vscode"; -import { getFolderIcon } from "../utils/iconUtils"; -import { CICSRegionTree } from "./CICSRegionTree"; -import { CICSURIMapTree } from "./treeItems/web/CICSURIMapTree"; -import { CICSTCPIPServiceTree } from "./treeItems/web/CICSTCPIPServiceTree"; -import { CICSPipelineTree } from "./treeItems/web/CICSPipelineTree"; -import { CICSWebServiceTree } from "./treeItems/web/CICSWebServiceTree"; - -export class CICSWebTree extends TreeItem { - children: [CICSTCPIPServiceTree, CICSURIMapTree, CICSPipelineTree, CICSWebServiceTree] | null; - parentRegion: CICSRegionTree | undefined; - //activeFilter: string | undefined = undefined; - - constructor( - parentRegion: CICSRegionTree, - public iconPath = getFolderIcon(false), - ) { - super("Web", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicstreeweb.web`; - this.parentRegion = parentRegion; - - this.children = [ - new CICSTCPIPServiceTree(parentRegion), - new CICSURIMapTree(parentRegion), - new CICSPipelineTree(parentRegion), - new CICSWebServiceTree(parentRegion), - ]; - } - - public loadContents() { - this.iconPath = getFolderIcon(true); - } - - public getChildren() { - return this.children; - } - - public getParent() { - return this.parentRegion; - } - - public clearFilter() { - /*this.activeFilter = undefined; - this.contextValue = `cicstreeweb.${this.activeFilter ? 'filtered' : 'unfiltered'}.web`; - this.collapsibleState = TreeItemCollapsibleState.Expanded;*/ - } - - public setFilter(_newFilter: string) { - /*this.activeFilter = newFilter; - this.contextValue = `cicstreeweb.${this.activeFilter ? 'filtered' : 'unfiltered'}.web`; - this.collapsibleState = TreeItemCollapsibleState.Expanded;*/ - } - - public getFilter() { - //return this.activeFilter; - } -} diff --git a/packages/vsce/src/trees/treeItems/CICSLibraryDatasets.ts b/packages/vsce/src/trees/treeItems/CICSLibraryDatasets.ts index 5004fa8e..e14b8c98 100644 --- a/packages/vsce/src/trees/treeItems/CICSLibraryDatasets.ts +++ b/packages/vsce/src/trees/treeItems/CICSLibraryDatasets.ts @@ -12,13 +12,14 @@ import { TreeItemCollapsibleState, TreeItem, window } from "vscode"; import { CICSRegionTree } from "../CICSRegionTree"; import { getIconFilePathFromName } from "../../utils/iconUtils"; -import { getResource } from "@zowe/cics-for-zowe-sdk"; -import { CICSProgramTreeItem } from "./CICSProgramTreeItem"; -import { toEscapedCriteriaString } from "../../utils/filterUtils"; +import { getResource, IProgram } from "@zowe/cics-for-zowe-sdk"; +import { ProgramMeta } from "../../doc/ProgramMeta"; import { toArray } from "../../utils/commandUtils"; +import { toEscapedCriteriaString } from "../../utils/filterUtils"; +import { CICSResourceTreeItem } from "./CICSResourceTreeItem"; export class CICSLibraryDatasets extends TreeItem { - children: CICSProgramTreeItem[] = []; + children: CICSResourceTreeItem[] = []; dataset: any; parentRegion: CICSRegionTree; directParent: any; @@ -42,7 +43,7 @@ export class CICSLibraryDatasets extends TreeItem { this.label = newlabel; } - public addProgram(program: CICSProgramTreeItem) { + public addProgram(program: CICSResourceTreeItem) { this.children.push(program); } @@ -68,7 +69,7 @@ export class CICSLibraryDatasets extends TreeItem { const programsArray = toArray(datasetResponse.response.records.cicsprogram); this.label = `${this.dataset.dsname}${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${programsArray.length}]`; for (const program of programsArray) { - const newProgramItem = new CICSProgramTreeItem(program, this.parentRegion, this); + const newProgramItem = new CICSResourceTreeItem(program as IProgram, ProgramMeta, this.parentRegion, this); this.addProgram(newProgramItem); } } catch (error) { diff --git a/packages/vsce/src/trees/treeItems/CICSLocalFileTreeItem.ts b/packages/vsce/src/trees/treeItems/CICSLocalFileTreeItem.ts deleted file mode 100644 index 6aaaa491..00000000 --- a/packages/vsce/src/trees/treeItems/CICSLocalFileTreeItem.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem } from "vscode"; -import { CICSRegionTree } from "../CICSRegionTree"; -import { getIconByStatus } from "../../utils/iconUtils"; - -export class CICSLocalFileTreeItem extends TreeItem { - localFile: any; - parentRegion: CICSRegionTree; - directParent: any; - localFileName: string; - - constructor( - localFile: any, - parentRegion: CICSRegionTree, - directParent: any, - public readonly iconPath = getIconByStatus("LOCAL_FILE", localFile) - ) { - super( - `${localFile.file} ${ - localFile.enablestatus.toLowerCase() === "disabled" && localFile.openstatus.toLowerCase() === "closed" - ? "(Disabled) (Closed)" - : localFile.enablestatus.toLowerCase() === "disabled" && localFile.openstatus.toLowerCase() !== "closed" - ? "(Disabled)" - : localFile.enablestatus.toLowerCase() === "unenabled" && localFile.openstatus.toLowerCase() === "closed" - ? "(Unenabled) (Closed)" - : localFile.enablestatus.toLowerCase() === "unenabled" && localFile.openstatus.toLowerCase() !== "closed" - ? "(Unenabled)" - : localFile.enablestatus.toLowerCase() === "enabled" && localFile.openstatus.toLowerCase() === "closed" - ? "(Closed)" - : "" - }`, - TreeItemCollapsibleState.None - ); - this.localFile = localFile; - this.contextValue = `cicslocalfile.${localFile.enablestatus.toLowerCase()}.${localFile.openstatus.toLowerCase()}.${localFile.file}`; - this.parentRegion = parentRegion; - this.directParent = directParent; - this.localFileName = localFile.file; - } - - public setLabel(newLabel: string) { - this.label = newLabel; - } - - public getParent() { - return this.directParent; - } -} diff --git a/packages/vsce/src/trees/treeItems/CICSProgramTreeItem.ts b/packages/vsce/src/trees/treeItems/CICSProgramTreeItem.ts deleted file mode 100644 index 4cd26d54..00000000 --- a/packages/vsce/src/trees/treeItems/CICSProgramTreeItem.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem } from "vscode"; -import { CICSRegionTree } from "../CICSRegionTree"; -import { getIconByStatus } from "../../utils/iconUtils"; - -export class CICSProgramTreeItem extends TreeItem { - program: any; - parentRegion: CICSRegionTree; - directParent: any; - - constructor( - program: any, - parentRegion: CICSRegionTree, - directParent: any, - public readonly iconPath = getIconByStatus("PROGRAM", program) - ) { - super( - `${program.program}${ - program.status.toLowerCase() === "disabled" && parseInt(program.newcopycnt) - ? ` (New copy count: ${program.newcopycnt}) (Disabled)` - : program.status.toLowerCase() === "disabled" && !parseInt(program.newcopycnt) - ? ` (Disabled)` - : program.status.toLowerCase() !== "disabled" && parseInt(program.newcopycnt) - ? ` (New copy count: ${program.newcopycnt})` - : "" - }`, - TreeItemCollapsibleState.None - ); - - this.program = program; - this.parentRegion = parentRegion; - this.directParent = directParent; - this.contextValue = `cicsprogram.${program.status.toLowerCase()}.${program.program}`; - } - - public setLabel(newLabel: string) { - this.label = newLabel; - } - - public getParent() { - return this.directParent; - } -} diff --git a/packages/vsce/src/trees/treeItems/CICSResourceTreeItem.ts b/packages/vsce/src/trees/treeItems/CICSResourceTreeItem.ts new file mode 100644 index 00000000..02797551 --- /dev/null +++ b/packages/vsce/src/trees/treeItems/CICSResourceTreeItem.ts @@ -0,0 +1,52 @@ +/** + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ + +import { IResource } from "@zowe/cics-for-zowe-sdk"; +import { TreeItem, TreeItemCollapsibleState } from "vscode"; +import IResourceMeta from "../../doc/IResourceMeta"; +import { CICSRegionTree } from "../CICSRegionTree"; +import { getIconFilePathFromName } from "../../utils/iconUtils"; +import { CICSCombinedResourceTree } from "../CICSCombinedTrees/CICSCombinedResourceTree"; +import { CICSLibraryDatasets } from "./CICSLibraryDatasets"; +import { CICSResourceTree } from "../CICSResourceTree"; + +export class CICSResourceTreeItem extends TreeItem { + resource: T; + resourceMeta: IResourceMeta; + parentRegion: CICSRegionTree; + directParent: CICSCombinedResourceTree | CICSLibraryDatasets | CICSResourceTree; + + constructor( + resource: T, + resourceMeta: IResourceMeta, + parentRegion: CICSRegionTree, + directParent: CICSCombinedResourceTree | CICSLibraryDatasets | CICSResourceTree + ) { + super( + resourceMeta.getLabel(resource), + TreeItemCollapsibleState.None + ); + + this.resource = resource; + this.parentRegion = parentRegion; + this.directParent = directParent; + this.contextValue = resourceMeta.getContext(resource); + this.iconPath = getIconFilePathFromName(resourceMeta.getIconName(resource)); + } + + public setLabel(newLabel: string) { + this.label = newLabel; + } + + public getParent() { + return this.directParent; + } +} diff --git a/packages/vsce/src/trees/treeItems/CICSTaskTreeItem.ts b/packages/vsce/src/trees/treeItems/CICSTaskTreeItem.ts deleted file mode 100644 index 117112cd..00000000 --- a/packages/vsce/src/trees/treeItems/CICSTaskTreeItem.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem } from "vscode"; -import { CICSRegionTree } from "../CICSRegionTree"; -import { getIconByStatus } from "../../utils/iconUtils"; - -export class CICSTaskTreeItem extends TreeItem { - task: any; - parentRegion: CICSRegionTree; - directParent: any; - - constructor( - task: any, - parentRegion: CICSRegionTree, - directParent: any, - public readonly iconPath = getIconByStatus("TASK", task) - ) { - super(`${task.task}`, TreeItemCollapsibleState.None); - - this.task = task; - this.parentRegion = parentRegion; - this.contextValue = `cicstask.`; - this.directParent = directParent; - } - - public setLabel(newLabel: string) { - this.label = newLabel; - } - - public getParent() { - return this.directParent; - } -} diff --git a/packages/vsce/src/trees/treeItems/CICSTransactionTreeItem.ts b/packages/vsce/src/trees/treeItems/CICSTransactionTreeItem.ts deleted file mode 100644 index 42133186..00000000 --- a/packages/vsce/src/trees/treeItems/CICSTransactionTreeItem.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem } from "vscode"; -import { CICSRegionTree } from "../CICSRegionTree"; -import { getIconByStatus } from "../../utils/iconUtils"; - -export class CICSTransactionTreeItem extends TreeItem { - transaction: any; - parentRegion: CICSRegionTree; - directParent: any; - transactionName: string; - - constructor( - transaction: any, - parentRegion: CICSRegionTree, - directParent: any, - public readonly iconPath = getIconByStatus("TRANSACTION", transaction) - ) { - super(`${transaction.tranid} ${transaction.status.toLowerCase() === "disabled" ? "(Disabled)" : ""}`, TreeItemCollapsibleState.None); - this.transaction = transaction; - this.contextValue = `cicstransaction.${transaction.status.toLowerCase()}.${transaction.tranid}`; - this.parentRegion = parentRegion; - this.directParent = directParent; - this.transactionName = transaction.tranid; - } - - public setLabel(newLabel: string) { - this.label = newLabel; - } - - public getParent() { - return this.directParent; - } -} diff --git a/packages/vsce/src/trees/treeItems/web/CICSPipelineTree.ts b/packages/vsce/src/trees/treeItems/web/CICSPipelineTree.ts deleted file mode 100644 index 8ee61142..00000000 --- a/packages/vsce/src/trees/treeItems/web/CICSPipelineTree.ts +++ /dev/null @@ -1,99 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem, window } from "vscode"; -import { CICSPipelineTreeItem } from "./treeItems/CICSPipelineTreeItem"; -import { CICSRegionTree } from "../../CICSRegionTree"; -import { getResource } from "@zowe/cics-for-zowe-sdk"; -import { toEscapedCriteriaString } from "../../../utils/filterUtils"; -import { getFolderIcon } from "../../../utils/iconUtils"; -import { toArray } from "../../../utils/commandUtils"; - -export class CICSPipelineTree extends TreeItem { - children: CICSPipelineTreeItem[] = []; - parentRegion: CICSRegionTree; - activeFilter: string | undefined = undefined; - - constructor( - parentRegion: CICSRegionTree, - public iconPath = getFolderIcon(false), - ) { - super("Pipelines", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicstreepipeline.${this.activeFilter ? "filtered" : "unfiltered"}.pipelines`; - this.parentRegion = parentRegion; - } - - public addPipeline(pipeline: CICSPipelineTreeItem) { - this.children.push(pipeline); - } - - public async loadContents() { - const defaultCriteria = "(name=*)"; - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "NAME"); - } else { - criteria = defaultCriteria; - } - this.children = []; - try { - const pipelineResponse = await getResource(this.parentRegion.parentSession.session, { - name: "CICSPipeline", - regionName: this.parentRegion.getRegionName(), - cicsPlex: this.parentRegion.parentPlex ? this.parentRegion.parentPlex.getPlexName() : undefined, - criteria: criteria, - }); - const pipelinesArray = toArray(pipelineResponse.response.records.cicspipeline); - this.label = `Pipelines${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${pipelinesArray.length}]`; - for (const pipeline of pipelinesArray) { - const newPipelineItem = new CICSPipelineTreeItem(pipeline, this.parentRegion, this); - newPipelineItem.setLabel(newPipelineItem.label.toString().replace(pipeline.name, `${pipeline.name}`)); - this.addPipeline(newPipelineItem); - } - this.iconPath = getFolderIcon(true); - } catch (error) { - if (error.mMessage!.includes("exceeded a resource limit")) { - window.showErrorMessage(`Resource Limit Exceeded - Set a Pipeline filter to narrow search`); - } else if (this.children.length === 0) { - window.showInformationMessage(`No Pipelines found`); - this.label = `Pipelines${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[0]`; - this.iconPath = getFolderIcon(true); - } else { - window.showErrorMessage( - `Something went wrong when fetching Pipelines - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( - /(\\n\t|\\n|\\t)/gm, - " ", - )}`, - ); - } - } - } - - public clearFilter() { - this.activeFilter = undefined; - this.contextValue = `cicstreepipeline.${this.activeFilter ? "filtered" : "unfiltered"}.pipelines`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public setFilter(newFilter: string) { - this.activeFilter = newFilter; - this.contextValue = `cicstreepipeline.${this.activeFilter ? "filtered" : "unfiltered"}.pipelines`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public getFilter() { - return this.activeFilter; - } - - public getParent() { - return this.parentRegion; - } -} diff --git a/packages/vsce/src/trees/treeItems/web/CICSTCPIPServiceTree.ts b/packages/vsce/src/trees/treeItems/web/CICSTCPIPServiceTree.ts deleted file mode 100644 index dda648ae..00000000 --- a/packages/vsce/src/trees/treeItems/web/CICSTCPIPServiceTree.ts +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem, window } from "vscode"; -import { CICSTCPIPServiceTreeItem } from "./treeItems/CICSTCPIPServiceTreeItem"; -import { CICSRegionTree } from "../../CICSRegionTree"; -import { getResource } from "@zowe/cics-for-zowe-sdk"; -import { toEscapedCriteriaString } from "../../../utils/filterUtils"; -import { getFolderIcon } from "../../../utils/iconUtils"; -import { toArray } from "../../../utils/commandUtils"; - -export class CICSTCPIPServiceTree extends TreeItem { - children: CICSTCPIPServiceTreeItem[] = []; - parentRegion: CICSRegionTree; - activeFilter: string | undefined = undefined; - - constructor( - parentRegion: CICSRegionTree, - public iconPath = getFolderIcon(false), - ) { - super("TCPIP Services", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicstreetcpips.${this.activeFilter ? "filtered" : "unfiltered"}.tcpips`; - this.parentRegion = parentRegion; - } - - public addTCPIPS(tcpips: CICSTCPIPServiceTreeItem) { - this.children.push(tcpips); - } - - public async loadContents() { - const defaultCriteria = "(name=*)"; - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "NAME"); - } else { - criteria = defaultCriteria; - } - this.children = []; - try { - const tcpipsResponse = await getResource(this.parentRegion.parentSession.session, { - name: "CICSTCPIPService", - regionName: this.parentRegion.getRegionName(), - cicsPlex: this.parentRegion.parentPlex ? this.parentRegion.parentPlex.getPlexName() : undefined, - criteria: criteria, - }); - const tcpipservicesArray = toArray(tcpipsResponse.response.records.cicstcpipservice); - this.label = `TCPIP Services${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${tcpipservicesArray.length}]`; - for (const tcpips of tcpipservicesArray) { - const newTCPIPServiceItem = new CICSTCPIPServiceTreeItem(tcpips, this.parentRegion, this); - newTCPIPServiceItem.setLabel( - newTCPIPServiceItem.label.toString().replace(tcpips.name, `${tcpips.name} [Port #${newTCPIPServiceItem.tcpips.port}]`), - ); - this.addTCPIPS(newTCPIPServiceItem); - } - this.iconPath = getFolderIcon(true); - } catch (error) { - if (error.mMessage!.includes("exceeded a resource limit")) { - window.showErrorMessage(`Resource Limit Exceeded - Set a TCPIPService filter to narrow search`); - } else if (this.children.length === 0) { - window.showInformationMessage(`No TCPIP Services found`); - this.label = `TCPIP Services${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[0]`; - this.iconPath = getFolderIcon(true); - } else { - window.showErrorMessage( - `Something went wrong when fetching TCPIP services - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( - /(\\n\t|\\n|\\t)/gm, - " ", - )}`, - ); - } - } - } - - public clearFilter() { - this.activeFilter = undefined; - this.contextValue = `cicstreetcpips.${this.activeFilter ? "filtered" : "unfiltered"}.tcpips`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public setFilter(newFilter: string) { - this.activeFilter = newFilter; - this.contextValue = `cicstreetcpips.${this.activeFilter ? "filtered" : "unfiltered"}.tcpips`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public getFilter() { - return this.activeFilter; - } - - public getParent() { - return this.parentRegion; - } -} diff --git a/packages/vsce/src/trees/treeItems/web/CICSURIMapTree.ts b/packages/vsce/src/trees/treeItems/web/CICSURIMapTree.ts deleted file mode 100644 index 6833f15a..00000000 --- a/packages/vsce/src/trees/treeItems/web/CICSURIMapTree.ts +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem, window } from "vscode"; -import { CICSURIMapTreeItem } from "./treeItems/CICSURIMapTreeItem"; -import { CICSRegionTree } from "../../CICSRegionTree"; -import { getResource } from "@zowe/cics-for-zowe-sdk"; -import { toEscapedCriteriaString } from "../../../utils/filterUtils"; -import { getFolderIcon } from "../../../utils/iconUtils"; -import { toArray } from "../../../utils/commandUtils"; - -export class CICSURIMapTree extends TreeItem { - children: CICSURIMapTreeItem[] = []; - parentRegion: CICSRegionTree; - activeFilter: string | undefined = undefined; - - constructor( - parentRegion: CICSRegionTree, - public iconPath = getFolderIcon(false), - ) { - super("URI Maps", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicstreeurimaps.${this.activeFilter ? "filtered" : "unfiltered"}.urimaps`; - this.parentRegion = parentRegion; - } - - public addURIMAP(urimap: CICSURIMapTreeItem) { - this.children.push(urimap); - } - - public async loadContents() { - const defaultCriteria = "(name=*)"; - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "NAME"); - } else { - criteria = defaultCriteria; - } - this.children = []; - try { - const urimapResponse = await getResource(this.parentRegion.parentSession.session, { - name: "CICSURIMap", - regionName: this.parentRegion.getRegionName(), - cicsPlex: this.parentRegion.parentPlex ? this.parentRegion.parentPlex.getPlexName() : undefined, - criteria: criteria, - }); - const urimapArray = toArray(urimapResponse.response.records.cicsurimap); - this.label = `URI Maps${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${urimapArray.length}]`; - for (const urimap of urimapArray) { - const newURIMapItem = new CICSURIMapTreeItem(urimap, this.parentRegion, this); - newURIMapItem.setLabel( - newURIMapItem.label.toString().replace(urimap.name, `${urimap.name} [${newURIMapItem.urimap.scheme}] (${newURIMapItem.urimap.path})`), - ); - this.addURIMAP(newURIMapItem); - } - this.iconPath = getFolderIcon(true); - } catch (error) { - if (error.mMessage!.includes("exceeded a resource limit")) { - window.showErrorMessage(`Resource Limit Exceeded - Set a URIMap filter to narrow search`); - } else if (this.children.length === 0) { - window.showInformationMessage(`No URI Maps found`); - this.label = `URI Maps${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[0]`; - this.iconPath = getFolderIcon(true); - } else { - window.showErrorMessage( - `Something went wrong when fetching URI Maps - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( - /(\\n\t|\\n|\\t)/gm, - " ", - )}`, - ); - } - } - } - - public clearFilter() { - this.activeFilter = undefined; - this.contextValue = `cicstreeurimaps.${this.activeFilter ? "filtered" : "unfiltered"}.urimaps`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public setFilter(newFilter: string) { - this.activeFilter = newFilter; - this.contextValue = `cicstreeurimaps.${this.activeFilter ? "filtered" : "unfiltered"}.urimaps`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public getFilter() { - return this.activeFilter; - } - - public getParent() { - return this.parentRegion; - } -} diff --git a/packages/vsce/src/trees/treeItems/web/CICSWebServiceTree.ts b/packages/vsce/src/trees/treeItems/web/CICSWebServiceTree.ts deleted file mode 100644 index 08dafadf..00000000 --- a/packages/vsce/src/trees/treeItems/web/CICSWebServiceTree.ts +++ /dev/null @@ -1,99 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem, window } from "vscode"; -import { CICSWebServiceTreeItem } from "./treeItems/CICSWebServiceTreeItem"; -import { CICSRegionTree } from "../../CICSRegionTree"; -import { getResource } from "@zowe/cics-for-zowe-sdk"; -import { toEscapedCriteriaString } from "../../../utils/filterUtils"; -import { getFolderIcon } from "../../../utils/iconUtils"; -import { toArray } from "../../../utils/commandUtils"; - -export class CICSWebServiceTree extends TreeItem { - children: CICSWebServiceTreeItem[] = []; - parentRegion: CICSRegionTree; - activeFilter: string | undefined = undefined; - - constructor( - parentRegion: CICSRegionTree, - public iconPath = getFolderIcon(false), - ) { - super("Web Services", TreeItemCollapsibleState.Collapsed); - this.contextValue = `cicstreewebservice.${this.activeFilter ? "filtered" : "unfiltered"}.webservices`; - this.parentRegion = parentRegion; - } - - public addWebService(webservice: CICSWebServiceTreeItem) { - this.children.push(webservice); - } - - public async loadContents() { - const defaultCriteria = "(name=*)"; - let criteria; - if (this.activeFilter) { - criteria = toEscapedCriteriaString(this.activeFilter, "NAME"); - } else { - criteria = defaultCriteria; - } - this.children = []; - try { - const webserviceResponse = await getResource(this.parentRegion.parentSession.session, { - name: "CICSWebService", - regionName: this.parentRegion.getRegionName(), - cicsPlex: this.parentRegion.parentPlex ? this.parentRegion.parentPlex.getPlexName() : undefined, - criteria: criteria, - }); - const webservicesArray = toArray(webserviceResponse.response.records.cicswebservice); - this.label = `Web Services${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[${webservicesArray.length}]`; - for (const webservice of webservicesArray) { - const newWebServiceItem = new CICSWebServiceTreeItem(webservice, this.parentRegion, this); - newWebServiceItem.setLabel(newWebServiceItem.label.toString().replace(webservice.name, `${webservice.name}`)); - this.addWebService(newWebServiceItem); - } - this.iconPath = getFolderIcon(true); - } catch (error) { - if (error.mMessage!.includes("exceeded a resource limit")) { - window.showErrorMessage(`Resource Limit Exceeded - Set a Web Services filter to narrow search`); - } else if (this.children.length === 0) { - window.showInformationMessage(`No Web Services found`); - this.label = `Web Services${this.activeFilter ? ` (${this.activeFilter}) ` : " "}[0]`; - this.iconPath = getFolderIcon(true); - } else { - window.showErrorMessage( - `Something went wrong when fetching Web Services - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( - /(\\n\t|\\n|\\t)/gm, - " ", - )}`, - ); - } - } - } - - public clearFilter() { - this.activeFilter = undefined; - this.contextValue = `cicstreewebservice.${this.activeFilter ? "filtered" : "unfiltered"}.webservices`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public setFilter(newFilter: string) { - this.activeFilter = newFilter; - this.contextValue = `cicstreewebservice.${this.activeFilter ? "filtered" : "unfiltered"}.webservices`; - this.collapsibleState = TreeItemCollapsibleState.Expanded; - } - - public getFilter() { - return this.activeFilter; - } - - public getParent() { - return this.parentRegion; - } -} diff --git a/packages/vsce/src/trees/treeItems/web/treeItems/CICSPipelineTreeItem.ts b/packages/vsce/src/trees/treeItems/web/treeItems/CICSPipelineTreeItem.ts deleted file mode 100644 index 09b23294..00000000 --- a/packages/vsce/src/trees/treeItems/web/treeItems/CICSPipelineTreeItem.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem } from "vscode"; -import { CICSRegionTree } from "../../../CICSRegionTree"; -import { getIconFilePathFromName } from "../../../../utils/iconUtils"; - -export class CICSPipelineTreeItem extends TreeItem { - pipeline: any; - parentRegion: CICSRegionTree; - directParent: any; - - constructor( - pipeline: any, - parentRegion: CICSRegionTree, - directParent: any, - public readonly iconPath = getIconFilePathFromName("program"), - ) { - super(`${pipeline.name}`, TreeItemCollapsibleState.None); - - this.pipeline = pipeline; - this.parentRegion = parentRegion; - this.directParent = directParent; - this.contextValue = `cicspipeline.${pipeline.name}`; - } - - public setLabel(newLabel: string) { - this.label = newLabel; - } - - public getParent() { - return this.directParent; - } -} diff --git a/packages/vsce/src/trees/treeItems/web/treeItems/CICSTCPIPServiceTreeItem.ts b/packages/vsce/src/trees/treeItems/web/treeItems/CICSTCPIPServiceTreeItem.ts deleted file mode 100644 index f0f4acee..00000000 --- a/packages/vsce/src/trees/treeItems/web/treeItems/CICSTCPIPServiceTreeItem.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem } from "vscode"; -import { CICSRegionTree } from "../../../CICSRegionTree"; -import { getIconFilePathFromName } from "../../../../utils/iconUtils"; - -export class CICSTCPIPServiceTreeItem extends TreeItem { - tcpips: any; - parentRegion: CICSRegionTree; - directParent: any; - - constructor( - tcpips: any, - parentRegion: CICSRegionTree, - directParent: any, - public readonly iconPath = getIconFilePathFromName("program"), - ) { - super(`${tcpips.name}`, TreeItemCollapsibleState.None); - - this.tcpips = tcpips; - this.parentRegion = parentRegion; - this.directParent = directParent; - this.contextValue = `cicstcpips.${tcpips.name}`; - } - - public setLabel(newLabel: string) { - this.label = newLabel; - } - - public getParent() { - return this.directParent; - } -} diff --git a/packages/vsce/src/trees/treeItems/web/treeItems/CICSURIMapTreeItem.ts b/packages/vsce/src/trees/treeItems/web/treeItems/CICSURIMapTreeItem.ts deleted file mode 100644 index cb686643..00000000 --- a/packages/vsce/src/trees/treeItems/web/treeItems/CICSURIMapTreeItem.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem } from "vscode"; -import { CICSRegionTree } from "../../../CICSRegionTree"; -import { getIconFilePathFromName } from "../../../../utils/iconUtils"; - -export class CICSURIMapTreeItem extends TreeItem { - urimap: any; - parentRegion: CICSRegionTree; - directParent: any; - - constructor( - urimap: any, - parentRegion: CICSRegionTree, - directParent: any, - public readonly iconPath = getIconFilePathFromName("program"), - ) { - super(`${urimap.name}`, TreeItemCollapsibleState.None); - - this.urimap = urimap; - this.parentRegion = parentRegion; - this.directParent = directParent; - this.contextValue = `cicsurimaps.${urimap.name}`; - } - - public setLabel(newLabel: string) { - this.label = newLabel; - } - - public getParent() { - return this.directParent; - } -} diff --git a/packages/vsce/src/trees/treeItems/web/treeItems/CICSWebServiceTreeItem.ts b/packages/vsce/src/trees/treeItems/web/treeItems/CICSWebServiceTreeItem.ts deleted file mode 100644 index 598fb4a3..00000000 --- a/packages/vsce/src/trees/treeItems/web/treeItems/CICSWebServiceTreeItem.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ - -import { TreeItemCollapsibleState, TreeItem } from "vscode"; -import { CICSRegionTree } from "../../../CICSRegionTree"; -import { getIconFilePathFromName } from "../../../../utils/iconUtils"; - -export class CICSWebServiceTreeItem extends TreeItem { - webservice: any; - parentRegion: CICSRegionTree; - directParent: any; - - constructor( - webservice: any, - parentRegion: CICSRegionTree, - directParent: any, - public readonly iconPath = getIconFilePathFromName("program"), - ) { - super(`${webservice.name}`, TreeItemCollapsibleState.None); - - this.webservice = webservice; - this.parentRegion = parentRegion; - this.directParent = directParent; - this.contextValue = `cicswebservice.${webservice.name}`; - } - - public setLabel(newLabel: string) { - this.label = newLabel; - } - - public getParent() { - return this.directParent; - } -} diff --git a/packages/vsce/src/utils/commandUtils.ts b/packages/vsce/src/utils/commandUtils.ts index 7220b6e7..c47fa0da 100644 --- a/packages/vsce/src/utils/commandUtils.ts +++ b/packages/vsce/src/utils/commandUtils.ts @@ -18,7 +18,7 @@ import { TreeView } from "vscode"; * @param clickedNode - Node that was clicked right before the command was executed * @return Array of selected nodes in the treeview. */ -export function findSelectedNodes(treeview: TreeView, instanceOf: any, clickedNode?: any) { +export function findSelectedNodes(treeview: TreeView, instanceOf?: any, clickedNode?: any) { const selection = treeview.selection; let allSelectedNodes = []; if (clickedNode) { @@ -28,7 +28,9 @@ export function findSelectedNodes(treeview: TreeView, instanceOf: any, clic //if user right clicks the node other than selected node allSelectedNodes = [clickedNode]; } - allSelectedNodes = allSelectedNodes.filter((selectedNode) => selectedNode instanceof instanceOf); + if (instanceOf) { + allSelectedNodes = allSelectedNodes.filter((selectedNode) => selectedNode instanceof instanceOf); + } } // executed from command palette else if (selection.length) { diff --git a/packages/vsce/src/utils/constants.ts b/packages/vsce/src/utils/constants.ts index 07e5ec6d..66538aaf 100644 --- a/packages/vsce/src/utils/constants.ts +++ b/packages/vsce/src/utils/constants.ts @@ -45,4 +45,39 @@ export default { * HTTP return code for Server Error */ HTTP_ERROR_SERVER_ERROR: 500, + + PERSISTENT_STORAGE: { + PROGRAM_FILTER: { + ID: "zowe.cics.program.filter", + DEFAULT: "NOT (PROGRAM=CEE* OR PROGRAM=DFH* OR PROGRAM=CJ* OR PROGRAM=EYU* OR PROGRAM=CSQ* OR PROGRAM=CEL* OR PROGRAM=IGZ*)", + }, + TRANSACTION_FILTER: { + ID: "zowe.cics.transaction.filter", + DEFAULT: "NOT (program=DFH* OR program=EYU*)", + }, + LOCAL_FILE_FILTER: { + ID: "zowe.cics.localFile.filter", + DEFAULT: "file=*", + }, + TASK_FILTER: { + ID: "zowe.cics.tasks.filter", + DEFAULT: "TRANID=*", + }, + TCPIP_FILTER: { + ID: "zowe.cics.tcpips.filter", + DEFAULT: "name=*", + }, + URIMAP_FILTER: { + ID: "zowe.cics.urimaps.filter", + DEFAULT: "name=*", + }, + PIPELINE_FILTER: { + ID: "zowe.cics.pipelines.filter", + DEFAULT: "name=*", + }, + WEBSERVICE_FILTER: { + ID: "zowe.cics.webservices.filter", + DEFAULT: "name=*", + }, + } }; diff --git a/packages/vsce/src/utils/filterUtils.ts b/packages/vsce/src/utils/filterUtils.ts index e7a79381..57b70bb1 100644 --- a/packages/vsce/src/utils/filterUtils.ts +++ b/packages/vsce/src/utils/filterUtils.ts @@ -70,25 +70,11 @@ export async function getPatternFromFilter(resourceName: string, resourceHistory return pattern.replace(/\s/g, ""); } -export async function getDefaultProgramFilter() { - let defaultCriteria = `${await workspace.getConfiguration().get("zowe.cics.program.filter")}`; - if (!defaultCriteria || defaultCriteria.length === 0) { - await workspace - .getConfiguration() - .update( - "zowe.cics.program.filter", - "NOT (PROGRAM=CEE* OR PROGRAM=DFH* OR PROGRAM=CJ* OR PROGRAM=EYU* OR PROGRAM=CSQ* OR PROGRAM=CEL* OR PROGRAM=IGZ*)" - ); - defaultCriteria = "NOT (PROGRAM=CEE* OR PROGRAM=DFH* OR PROGRAM=CJ* OR PROGRAM=EYU* OR PROGRAM=CSQ* OR PROGRAM=CEL* OR PROGRAM=IGZ*)"; - } - return defaultCriteria; -} - -export async function getDefaultTransactionFilter() { - let defaultCriteria = `${await workspace.getConfiguration().get("zowe.cics.transaction.filter")}`; - if (!defaultCriteria || defaultCriteria.length === 0) { - await workspace.getConfiguration().update("zowe.cics.transaction.filter", "NOT (program=DFH* OR program=EYU*)"); - defaultCriteria = "NOT (program=DFH* OR program=EYU*)"; +export async function getDefaultFilter(params: { ID: string, DEFAULT: string; }): Promise { + let defaultCriteria: string = await workspace.getConfiguration().get(params.ID); + if (!defaultCriteria || `${defaultCriteria}`.length === 0) { + await workspace.getConfiguration().update(params.ID, params.DEFAULT); + defaultCriteria = params.DEFAULT; } return defaultCriteria; } diff --git a/packages/vsce/src/utils/iconUtils.ts b/packages/vsce/src/utils/iconUtils.ts index d3a1adaf..554c6f0b 100644 --- a/packages/vsce/src/utils/iconUtils.ts +++ b/packages/vsce/src/utils/iconUtils.ts @@ -11,7 +11,7 @@ import { join } from "path"; -export function getIconFilePathFromName(iconFileName: string): { light: string; dark: string } { +export function getIconFilePathFromName(iconFileName: string): { light: string; dark: string; } { return { // We bundle the extension into a single `dist/extension.js` // `__dirname/../resources/imgs === `/path/to/dist/../resources/imgs` @@ -23,32 +23,3 @@ export function getIconFilePathFromName(iconFileName: string): { light: string; export function getFolderIcon(open: boolean = true) { return getIconFilePathFromName(`folder-${open ? "open" : "closed"}`); } - -export function getIconRootName(resourceType: string, resourceTreeItem: any) { - switch (resourceType) { - case "PROGRAM": - return resourceTreeItem.status === "DISABLED" ? "program-disabled" : "program"; - case "TRANSACTION": - return resourceTreeItem.status === "DISABLED" ? "local-transaction-disabled" : "local-transaction"; - case "LOCAL_FILE": - return resourceTreeItem.openstatus === "CLOSED" && resourceTreeItem.enablestatus === "DISABLED" - ? "local-file-disabled-closed" - : resourceTreeItem.openstatus === "CLOSED" - ? "local-file-closed" - : resourceTreeItem.enablestatus === "DISABLED" - ? "local-file-disabled" - : "local-file"; - case "TASK": - return resourceTreeItem.runstatus === "RUNNING" - ? "task-running" - : resourceTreeItem.runstatus === "SUSPENDED" - ? "task-suspended" - : "task-dispatched"; - case "REGION": - return resourceTreeItem.isActive ? "region" : "region-disabled"; - } -} - -export function getIconByStatus(resourceType: string, resourceTreeItem: any) { - return getIconFilePathFromName(getIconRootName(resourceType, resourceTreeItem)); -} \ No newline at end of file diff --git a/packages/vsce/src/utils/profileUtils.ts b/packages/vsce/src/utils/profileUtils.ts index c0c767d5..a71b3d9a 100644 --- a/packages/vsce/src/utils/profileUtils.ts +++ b/packages/vsce/src/utils/profileUtils.ts @@ -24,8 +24,6 @@ export function missingSessionParameters(profileProfile: any): (string | undefin return missing; } - - export async function promptCredentials(sessionName: string, rePrompt?: boolean): Promise { // const mProfileInfo = new ProfileInfo("zowe", { // requireKeytar: () => getSecurityModules("keytar", isTheia())!, diff --git a/packages/vsce/tsup.config.json b/packages/vsce/tsup.config.json index 01265113..4d2e5f48 100644 --- a/packages/vsce/tsup.config.json +++ b/packages/vsce/tsup.config.json @@ -12,4 +12,4 @@ ], "minify": "terser", "noExternal": [] -} \ No newline at end of file +}