Skip to content

Commit

Permalink
ext own view container / add open in web browser (#506)
Browse files Browse the repository at this point in the history
* fix access workflow view in codespaces
  • Loading branch information
ChristopherHX authored Jan 7, 2025
1 parent 4c386cd commit aff186c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/runner-server-vscode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ function activate(context : ExtensionContext) {
var end = sdata.indexOf('\n', i + 1);
var externalAddress = await getExternalIP();
address = sdata.substring(i, end).replace("[::]", externalAddress).replace("0.0.0.0", externalAddress).trim();
var webviewAddress = sdata.substring(i, end).replace("[::]", "localhost").replace("0.0.0.0", "localhost").trim();

window.registerTreeDataProvider("workflow-view", new RSTreeDataProvider(context, address));

Expand Down Expand Up @@ -174,12 +175,13 @@ function activate(context : ExtensionContext) {
return panel;
}

const fullWebServerUri = webviewAddress && await env.asExternalUri(
Uri.parse(webviewAddress)
);

var openPanel = async(name: string, url : string) => {
await getPanel();
panel.title = name;
const fullWebServerUri = address && await env.asExternalUri(
Uri.parse(address)
);
const cspSource = panel.webview.cspSource;
// Get the content Uri
const style = panel.webview.asWebviewUri(
Expand All @@ -206,9 +208,17 @@ function activate(context : ExtensionContext) {
openPanel(name, `?view=allworkflows&extension=1#/0/${runId}/0/${id}`);
});

commands.registerCommand("runner.server.openjobexternal", (obj : TreeItem) => {
env.openExternal(Uri.parse(`${fullWebServerUri}?view=allworkflows#/0/${obj.command.arguments[0]}/0/${obj.command.arguments[1]}`));
});

commands.registerCommand("runner.server.openworkflowrun", runId => {
openPanel(`#${runId}`, `?view=allworkflows&extension=1#/0/${runId}/0`);
});

commands.registerCommand("runner.server.openworkflowrunexternal", (obj : TreeItem) => {
env.openExternal(Uri.parse(`${fullWebServerUri}?view=allworkflows#/0/${obj.command.arguments[0]}/0`));
});
}
});
serverproc.stderr.on('data', async (data) => {
Expand Down
33 changes: 32 additions & 1 deletion src/runner-server-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@
"shortTitle": "Cancel",
"icon": "$(stop-circle)"
},
{
"command": "runner.server.openjobexternal",
"title": "Open in Browser",
"shortTitle": "Open in Browser",
"icon": "$(globe)"
},
{
"command": "runner.server.openworkflowrunexternal",
"title": "Open in Browser",
"shortTitle": "Open in Browser",
"icon": "$(globe)"
},
{
"command": "runner.server.start-client",
"title": "Start Runner.Client"
Expand Down Expand Up @@ -72,7 +84,7 @@
}
],
"views": {
"explorer": [
"runner-server": [
{
"id": "workflow-view",
"name": "Workflow View"
Expand All @@ -97,6 +109,25 @@
"command": "runner.server.workflow.cancel",
"group": "inline",
"when": "view == workflow-view && !(viewItem =~ /completed/) && (viewItem =~ /job/ || viewItem =~ /workflow/ )"
},
{
"command": "runner.server.openjobexternal",
"group": "inline",
"when": "view == workflow-view && viewItem =~ /job/"
},
{
"command": "runner.server.openworkflowrunexternal",
"group": "inline",
"when": "view == workflow-view && viewItem =~ /workflow/"
}
]
},
"viewsContainers": {
"activitybar": [
{
"id": "runner-server",
"title": "Runner.Server",
"icon": "resources/icons/light/run.svg"
}
]
}
Expand Down

0 comments on commit aff186c

Please sign in to comment.