Skip to content

Commit d4468f3

Browse files
Show warning dialog when app doesnt exist in mnger
1 parent 52444b6 commit d4468f3

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

labextension/src/restapi.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { URLExt } from "@jupyterlab/coreutils";
2+
import { showDialog, Dialog } from '@jupyterlab/apputils';
23
import { ServerConnection } from "@jupyterlab/services";
4+
import { TranslationBundle } from '@jupyterlab/translation';
35
import { IModel } from "./serverproxy";
46

57
/**
68
* The url for the server proxy service.
79
*/
8-
const SERVER_PROXY_SERVICE_URL = "api/server-proxy";
10+
const SERVER_PROXY_SERVICE_URL = "server-proxy/api/servers/";
911

1012
/**
1113
* List the running server proxy apps.
@@ -43,13 +45,24 @@ export async function listRunning(
4345
*/
4446
export async function shutdown(
4547
name: string,
48+
trans: TranslationBundle,
4649
settings: ServerConnection.ISettings = ServerConnection.makeSettings(),
4750
): Promise<void> {
4851
const url = URLExt.join(settings.baseUrl, SERVER_PROXY_SERVICE_URL, name);
4952
const init = { method: "DELETE" };
5053
const response = await ServerConnection.makeRequest(url, init, settings);
5154
if (response.status === 404) {
52-
const msg = `Server proxy "${name}" does not exist. Are you sure "${name}" is started by jupyter-server-proxy?`;
55+
const msg = trans.__(`Server proxy "${name}" is not running anymore. It will be removed from this list shortly`);
56+
console.warn(msg);
57+
void showDialog({
58+
title: trans.__('Warning'),
59+
body: msg,
60+
buttons: [Dialog.okButton({ label : 'Dismiss'})],
61+
});
62+
} else if (response.status === 403) {
63+
// This request cannot be made via JupyterLab UI and hence we just throw
64+
// console log
65+
const msg = trans.__(`Provide a running server proxy name to terminate`);
5366
console.warn(msg);
5467
} else if (response.status !== 204) {
5568
const err = await ServerConnection.ResponseError.create(response);

0 commit comments

Comments
 (0)