-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
157 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# @jupyterlab/hub-extension | ||
|
||
JupyterLab](https://github.com/jupyterlab/jupyterlab) integration for | ||
[JupyterHub](https://github.com/jupyterhub/jupyterhub). | ||
|
||
This adds a "Hub" menu to JupyterLab that allows a user to log out of JupyterHub | ||
or access their JupyterHub control panel. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "@jupyterlab/hub-extension", | ||
"version": "1.0.0-alpha.8", | ||
"description": "JupyterLab integration for JupyterHub", | ||
"homepage": "https://github.com/jupyterlab/jupyterlab", | ||
"bugs": { | ||
"url": "https://github.com/jupyterlab/jupyterlab/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jupyterlab/jupyterlab.git" | ||
}, | ||
"license": "BSD-3-Clause", | ||
"author": "Project Jupyter", | ||
"files": [ | ||
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", | ||
"schema/*.json", | ||
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" | ||
], | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"directories": { | ||
"lib": "lib/" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"clean": "rimraf lib", | ||
"prepublishOnly": "npm run build", | ||
"watch": "tsc -w --listEmittedFiles" | ||
}, | ||
"devDependencies": { | ||
"rimraf": "~2.6.2", | ||
"typescript": "~3.5.1" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/*----------------------------------------------------------------------------- | ||
| Copyright (c) Jupyter Development Team. | ||
| Distributed under the terms of the Modified BSD License. | ||
|----------------------------------------------------------------------------*/ | ||
|
||
import { Menu } from '@phosphor/widgets'; | ||
|
||
import { ICommandPalette } from '@jupyterlab/apputils'; | ||
|
||
import { | ||
JupyterFrontEnd, | ||
JupyterFrontEndPlugin | ||
} from '@jupyterlab/application'; | ||
|
||
import { PageConfig, URLExt } from '@jupyterlab/coreutils'; | ||
|
||
import { IMainMenu } from '@jupyterlab/mainmenu'; | ||
|
||
/** | ||
* The command IDs used by the plugin. | ||
*/ | ||
export namespace CommandIDs { | ||
export const controlPanel: string = 'hub:control-panel'; | ||
|
||
export const logout: string = 'hub:logout'; | ||
} | ||
|
||
/** | ||
* Activate the jupyterhub extension. | ||
*/ | ||
function activateHubExtension( | ||
app: JupyterFrontEnd, | ||
palette: ICommandPalette, | ||
mainMenu: IMainMenu | ||
): void { | ||
const hubHost = PageConfig.getOption('hub_host'); | ||
const hubPrefix = PageConfig.getOption('hub_prefix'); | ||
const baseUrl = PageConfig.getBaseUrl(); | ||
|
||
// Bail if not running on JupyterHub. | ||
if (!hubPrefix) { | ||
return; | ||
} | ||
|
||
console.log('hub-extension: Found configuration ', { | ||
hubHost: hubHost, | ||
hubPrefix: hubPrefix | ||
}); | ||
|
||
const category = 'Hub'; | ||
const { commands } = app; | ||
|
||
commands.addCommand(CommandIDs.controlPanel, { | ||
label: 'Control Panel', | ||
caption: 'Open the Hub control panel in a new browser tab', | ||
execute: () => { | ||
window.open(hubHost + URLExt.join(hubPrefix, 'home'), '_blank'); | ||
} | ||
}); | ||
|
||
commands.addCommand(CommandIDs.logout, { | ||
label: 'Logout', | ||
caption: 'Log out of the Hub', | ||
execute: () => { | ||
window.location.href = hubHost + URLExt.join(baseUrl, 'logout'); | ||
} | ||
}); | ||
|
||
// Add commands and menu itmes. | ||
let menu = new Menu({ commands }); | ||
menu.title.label = category; | ||
[CommandIDs.controlPanel, CommandIDs.logout].forEach(command => { | ||
palette.addItem({ command, category }); | ||
menu.addItem({ command }); | ||
}); | ||
mainMenu.addMenu(menu, { rank: 100 }); | ||
} | ||
|
||
/** | ||
* Initialization data for the hub-extension. | ||
*/ | ||
const hubExtension: JupyterFrontEndPlugin<void> = { | ||
activate: activateHubExtension, | ||
id: 'jupyter.extensions.hub-extension', | ||
requires: [ICommandPalette, IMainMenu], | ||
autoStart: true | ||
}; | ||
|
||
export default hubExtension; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../../tsconfigbase", | ||
"compilerOptions": { | ||
"outDir": "lib", | ||
"rootDir": "src" | ||
}, | ||
"include": ["src/*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters