Skip to content

Commit

Permalink
Merge pull request #7654 from blink1073/launcher-metadata
Browse files Browse the repository at this point in the history
Allow metadata for launcher items
  • Loading branch information
Steven Silvester committed Dec 23, 2019
2 parents dfeaf98 + caf3e2b commit ecfe2cb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
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;
}
}

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

0 comments on commit ecfe2cb

Please sign in to comment.