Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow metadata for launcher items #7654

Merged
merged 4 commits into from Dec 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 15 additions & 3 deletions packages/console-extension/src/index.ts
Expand Up @@ -40,7 +40,13 @@ import { IRenderMimeRegistry } from '@jupyterlab/rendermime';

import { find } from '@lumino/algorithm';

import { JSONObject, ReadonlyPartialJSONObject, UUID } from '@lumino/coreutils';
import {
JSONExt,
JSONObject,
ReadonlyPartialJSONObject,
UUID,
ReadonlyJSONValue
} from '@lumino/coreutils';

import { DisposableSet } from '@lumino/disposable';

Expand Down Expand Up @@ -181,7 +187,8 @@ async function activateConsole(
let baseUrl = PageConfig.getBaseUrl();
for (let name in specs.kernelspecs) {
let rank = name === specs.default ? 0 : Infinity;
let kernelIconUrl = specs.kernelspecs[name]?.resources['logo-64x64'];
const spec = specs.kernelspecs[name]!;
let kernelIconUrl = spec.resources['logo-64x64'];
if (kernelIconUrl) {
let index = kernelIconUrl.indexOf('kernelspecs');
kernelIconUrl = URLExt.join(baseUrl, kernelIconUrl.slice(index));
Expand All @@ -192,7 +199,12 @@ async function activateConsole(
args: { isLauncher: true, kernelPreference: { name } },
category: 'Console',
rank,
kernelIconUrl
kernelIconUrl,
metadata: {
kernel: JSONExt.deepCopy(
spec.metadata || {}
) as ReadonlyJSONValue
}
})
);
}
Expand Down
6 changes: 6 additions & 0 deletions packages/launcher/src/index.tsx
Expand Up @@ -344,6 +344,12 @@ export namespace ILauncher {
* spec.
*/
kernelIconUrl?: string;

/**
* Metadata about the item. This can be used by the launcher to
* affect how the item is displayed.
*/
metadata?: ReadonlyJSONObject;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the default implementation should display this metadata somewhere? It feels a bit weird to include metadata without using it anywhere. Presumably you have an overridden launcher that actually is using the metadata?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this change was meant to allow experimentation without needing to override core extensions like notebook and console.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, okay.

}
}

Expand Down
18 changes: 15 additions & 3 deletions packages/notebook-extension/src/index.ts
Expand Up @@ -32,7 +32,13 @@ import { IDocumentManager } from '@jupyterlab/docmanager';

import { ArrayExt } from '@lumino/algorithm';

import { UUID, JSONObject, ReadonlyPartialJSONObject } from '@lumino/coreutils';
import {
UUID,
JSONExt,
JSONObject,
ReadonlyPartialJSONObject,
ReadonlyJSONValue
} from '@lumino/coreutils';

import { DisposableSet } from '@lumino/disposable';

Expand Down Expand Up @@ -725,7 +731,8 @@ function activateNotebookHandler(

for (let name in specs.kernelspecs) {
let rank = name === specs.default ? 0 : Infinity;
let kernelIconUrl = specs.kernelspecs[name]?.resources['logo-64x64'];
const spec = specs.kernelspecs[name]!;
let kernelIconUrl = spec.resources['logo-64x64'];
if (kernelIconUrl) {
let index = kernelIconUrl.indexOf('kernelspecs');
kernelIconUrl = URLExt.join(baseUrl, kernelIconUrl.slice(index));
Expand All @@ -736,7 +743,12 @@ function activateNotebookHandler(
args: { isLauncher: true, kernelName: name },
category: 'Notebook',
rank,
kernelIconUrl
kernelIconUrl,
metadata: {
kernel: JSONExt.deepCopy(
spec.metadata || {}
) as ReadonlyJSONValue
}
})
);
}
Expand Down