Skip to content

Commit

Permalink
feat: Tabular jobs view
Browse files Browse the repository at this point in the history
Signed-off-by: Trae Yelovich <[email protected]>
  • Loading branch information
traeok committed Jul 25, 2024
1 parent 9f2e0e8 commit e008bb0
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 22 deletions.
12 changes: 9 additions & 3 deletions packages/zowe-explorer/l10n/poeditor.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
"viewsContainers.activitybar": {
"Zowe Explorer": ""
},
"viewsContainers.panel.tableView": {
"Zowe": ""
},
"zowe.resources.name": {
"Zowe Resources": ""
},
"zowe.placeholderCommand": {
"Placeholder": ""
},
Expand Down Expand Up @@ -395,12 +401,12 @@
"openWithEncoding": {
"Open with Encoding": ""
},
"zowe.history.deprecationMsg": {
"Changes made here will not be reflected in Zowe Explorer, use right-click Edit History option to access information from local storage.": ""
},
"jobsTableView": {
"Show as table": ""
},
"zowe.history.deprecationMsg": {
"Changes made here will not be reflected in Zowe Explorer, use right-click Edit History option to access information from local storage.": ""
},
"Refresh": "",
"Delete Selected": "",
"Select an item before deleting": "",
Expand Down
33 changes: 16 additions & 17 deletions packages/zowe-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@
"title": "%viewsContainers.activitybar%",
"icon": "resources/zowe.svg"
}
],
"panel": [
{
"id": "zowe-panel",
"icon": "resources/zowe.svg",
"title": "%viewsContainers.panel.tableView%"
}
]
},
"views": {
Expand All @@ -61,6 +68,13 @@
"id": "zowe.jobs.explorer",
"name": "%zowe.jobs.explorer%"
}
],
"zowe-panel": [
{
"type": "webview",
"id": "zowe-resources",
"name": "%zowe.resources.name%"
}
]
},
"keybindings": [
Expand Down Expand Up @@ -165,7 +179,7 @@
}
},
{
"command": "zowe.jobs.tableView",
"command": "zowe.jobs.tabularView",
"title": "%jobsTableView%",
"category": "Zowe Explorer"
},
Expand Down Expand Up @@ -654,21 +668,6 @@
"command": "zowe.placeholderCommand",
"title": "%zowe.placeholderCommand%",
"enablement": "false"
},
{
"command": "zowe.tableView",
"title": "Show table view (basic)",
"category": "Zowe Explorer"
},
{
"command": "zowe.tableView2",
"title": "Show table view (several entries)",
"category": "Zowe Explorer"
},
{
"command": "zowe.tableView3",
"title": "Show table view (all features)",
"category": "Zowe Explorer"
}
],
"menus": {
Expand Down Expand Up @@ -1263,7 +1262,7 @@
},
{
"when": "view == zowe.jobs.explorer && viewItem =~ /^(?!.*_fav.*)server.*/ && !listMultiSelection",
"command": "zowe.jobs.tableView",
"command": "zowe.jobs.tabularView",
"group": "100_zowe_tableview"
},
{
Expand Down
2 changes: 2 additions & 0 deletions packages/zowe-explorer/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"displayName": "Zowe Explorer",
"description": "VS Code extension, powered by Zowe CLI, that streamlines interaction with mainframe data sets, USS files, and jobs",
"viewsContainers.activitybar": "Zowe Explorer",
"viewsContainers.panel.tableView": "Zowe Resources",
"zowe.resources.name": "Zowe Resources",
"zowe.placeholderCommand": "Placeholder",
"zowe.promptCredentials": "Update Credentials",
"zowe.profileManagement": "Manage Profile",
Expand Down
3 changes: 3 additions & 0 deletions packages/zowe-explorer/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { SharedInit } from "./trees/shared/SharedInit";
import { SharedTreeProviders } from "./trees/shared/SharedTreeProviders";
import { USSInit } from "./trees/uss/USSInit";
import { ProfilesUtils } from "./utils/ProfilesUtils";
import { TableViewProvider } from "@zowe/zowe-explorer-api";

/**
* The function that runs when the extension is loaded
Expand All @@ -43,6 +44,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<ZoweEx
uss: () => USSInit.initUSSProvider(context),
job: () => JobInit.initJobsProvider(context),
});

context.subscriptions.push(vscode.window.registerWebviewViewProvider("zowe-resources", TableViewProvider.getInstance()));
SharedInit.registerCommonCommands(context, providers);
SharedInit.registerRefreshCommand(context, activate, deactivate);
ZoweExplorerExtender.createInstance(providers.ds, providers.uss, providers.job);
Expand Down
112 changes: 110 additions & 2 deletions packages/zowe-explorer/src/trees/job/JobInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import * as vscode from "vscode";
import { IZoweJobTreeNode, IZoweTreeNode, ZoweScheme, imperative, Gui } from "@zowe/zowe-explorer-api";
import { IZoweJobTreeNode, IZoweTreeNode, ZoweScheme, imperative, Gui, TableBuilder, Table, TableViewProvider } from "@zowe/zowe-explorer-api";
import { JobTree } from "./JobTree";
import { JobActions } from "./JobActions";
import { ZoweJobNode } from "./ZoweJobNode";
Expand All @@ -21,7 +21,7 @@ import { SharedInit } from "../shared/SharedInit";
import { SharedUtils } from "../shared/SharedUtils";
import { JobFSProvider } from "./JobFSProvider";
import { PollProvider } from "./JobPollProvider";

import { SharedTreeProviders } from "../shared/SharedTreeProviders";
export class JobInit {
/**
* Creates the Job tree that contains nodes of sessions, jobs and spool items
Expand Down Expand Up @@ -145,6 +145,114 @@ export class JobInit {
)
);
context.subscriptions.push(vscode.commands.registerCommand("zowe.jobs.copyName", async (job: IZoweJobTreeNode) => JobActions.copyName(job)));
context.subscriptions.push(
vscode.commands.registerCommand("zowe.jobs.tabularView", async (node, nodeList) => {
const selectedNodes = SharedUtils.getSelectedNodeList(node, nodeList) as IZoweJobTreeNode[];
if (selectedNodes.length !== 1) {
return;
}

const profileNode = selectedNodes[0];
const children = await profileNode.getChildren();

TableViewProvider.getInstance().setTableView(
new TableBuilder(context)
.options({
autoSizeStrategy: { type: "fitCellContents", colIds: ["name", "class", "owner", "id", "retcode", "status"] },
rowSelection: "multiple",
})
.isView()
.title(`Jobs view: ${profileNode.owner} | ${profileNode.prefix} | ${profileNode.status}`)
.rows(
...children.map((item) => ({
name: item.job.jobname,
class: item.job.class,
owner: item.job.owner,
id: item.job.jobid,
retcode: item.job.retcode,
status: item.job.status,
}))
)
.columns(
...[
{ field: "name", checkboxSelection: true, filter: true, sort: "asc" } as Table.ColumnOpts,
{
field: "class",
filter: true,
},
{ field: "owner", filter: true },
{ field: "id", headerName: "ID", filter: true },
{ field: "retcode", headerName: "Return Code", filter: true },
{ field: "status", filter: true },
]
)
.addRowAction("all", {
title: "Get JCL",
command: "get-jcl",
callback: {
fn: async (view: Table.View, data: Table.RowInfo) => {
const child = children.find((c) => data.row.id === c.job?.jobid);
if (child != null) {
await JobActions.downloadJcl(child as ZoweJobNode);
}
},
typ: "row",
},
})
.addRowAction("all", {
title: "Reveal in tree",
type: "primary",
command: "edit",
callback: {
fn: async (view: Table.View, data: Table.RowInfo) => {
const child = children.find((c) => data.row.id === c.job?.jobid);
if (child) {
await jobsProvider.getTreeView().reveal(child, { expand: true });
}
},
typ: "row",
},
})
.addContextOption("all", {
title: "Cancel job",
command: "cancel-job",
callback: {
fn: async (view: Table.View, data: Table.RowInfo) => {
const child = children.find((c) => data.row.id === c.job?.jobid);
if (child) {
await JobActions.cancelJobs(SharedTreeProviders.job, [child]);
await view.updateRow(data.index, {
name: child.job.jobname,
class: child.job.class,
owner: child.job.owner,
id: child.job.jobid,
retcode: child.job.retcode,
status: child.job.status,
});
}
},
typ: "row",
},
condition: (data: Table.RowData) => data["status"] === "ACTIVE",
})
.addContextOption("all", {
title: "Delete job",
command: "delete-job",
callback: {
fn: async (view: Table.View, data: Table.RowInfo) => {
const child = children.find((c) => data.row.id === c.job?.jobid);
if (child) {
await JobActions.deleteCommand(jobsProvider, child);
await view.updateRow(data.index, null);
}
},
typ: "row",
},
})
.build()
);
})
);
context.subscriptions.push(
vscode.workspace.onDidOpenTextDocument((doc) => {
if (doc.uri.scheme !== ZoweScheme.Jobs) {
Expand Down

0 comments on commit e008bb0

Please sign in to comment.