Skip to content

Commit d6b549f

Browse files
committed
Document & rename spec class to be better
1 parent ffb3884 commit d6b549f

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

binderhub/static/js/components/BuilderLauncher.jsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ async function buildImage(
6464
case "ready": {
6565
setProgressState(PROGRESS_STATES.SUCCESS);
6666
image.close();
67-
redirectToRunningServer(
68-
data.url,
69-
data.token,
70-
spec.runtimeParams.urlPath,
71-
);
67+
redirectToRunningServer(data.url, data.token, spec.launchSpec.urlPath);
7268
console.log(data);
7369
break;
7470
}

binderhub/static/js/pages/HomePage.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BuilderLauncher } from "../components/BuilderLauncher.jsx";
33
import { HowItWorks } from "../components/HowItWorks.jsx";
44
import { useEffect, useState } from "react";
55
import { FaviconUpdater } from "../components/FaviconUpdater.jsx";
6-
import { Spec, RuntimeParams } from "../spec.js";
6+
import { Spec, LaunchSpec } from "../spec.js";
77

88
/**
99
* @typedef {object} HomePageProps

binderhub/static/js/pages/LoadingPage.jsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useSearchParams } from "react-router-dom";
55
import { NBViewerIFrame } from "../components/NBViewerIFrame.jsx";
66
import { LoadingIndicator } from "../components/LoadingIndicator.jsx";
77
import { FaviconUpdater } from "../components/FaviconUpdater.jsx";
8-
import { RuntimeParams, Spec } from "../spec.js";
8+
import { LaunchSpec, Spec } from "../spec.js";
99

1010
/**
1111
* @typedef {object} LoadingPageProps
@@ -23,10 +23,7 @@ export function LoadingPage({ baseUrl }) {
2323

2424
const [isLaunching, setIsLaunching] = useState(false);
2525

26-
const spec = new Spec(
27-
buildSpec,
28-
RuntimeParams.fromSearchParams(searchParams),
29-
);
26+
const spec = new Spec(buildSpec, LaunchSpec.fromSearchParams(searchParams));
3027

3128
useEffect(() => {
3229
// Start launching after the DOM has fully loaded

binderhub/static/js/spec.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export class RuntimeParams {
1+
export class LaunchSpec {
22
/**
33
*
4-
* @param {string} urlPath
4+
* @param {string} urlPath Path inside the Jupyter server to redirect the user to after launching
55
*/
66
constructor(urlPath) {
77
this.urlPath = urlPath;
@@ -10,10 +10,13 @@ export class RuntimeParams {
1010
}
1111

1212
/**
13+
* Create a LaunchSpec from given query parameters in the URL
14+
*
15+
* Handles backwards compatible parameters as needed.
1316
*
1417
* @param {URLSearchParams} searchParams
1518
*
16-
* @returns {RuntimeParams}
19+
* @returns {LaunchSpec}
1720
*/
1821
static fromSearchParams(searchParams) {
1922
let urlPath = searchParams.get("urlpath");
@@ -33,17 +36,23 @@ export class RuntimeParams {
3336
urlPath = `tree/${encodeURI(filePath)}`;
3437
}
3538

36-
return new RuntimeParams(urlPath);
39+
return new LaunchSpec(urlPath);
3740
}
3841
}
3942

43+
/**
44+
* A full binder specification
45+
*
46+
* Includes a *build* specification (determining what is built), and a
47+
* *launch* specification (determining what is launched).
48+
*/
4049
export class Spec {
4150
/**
42-
* @param {string} buildSpec
43-
* @param {RuntimeParams} runtimeParams
51+
* @param {string} buildSpec Build specification, passed directly to binderhub API
52+
* @param {LaunchSpec} launchSpec Launch specification, determining what is launched
4453
*/
45-
constructor(buildSpec, runtimeParams) {
54+
constructor(buildSpec, launchSpec) {
4655
this.buildSpec = buildSpec;
47-
this.runtimeParams = runtimeParams;
56+
this.launchSpec = launchSpec;
4857
}
4958
}

0 commit comments

Comments
 (0)