-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
c0d9e5f
commit 63b450d
Showing
12 changed files
with
4,372 additions
and
20 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 @@ | ||
import { LabIcon } from '@jupyterlab/ui-components'; | ||
import nebariLogo from '../style/icons/nebari-logo.svg'; | ||
|
||
export const nebariIcon = new LabIcon({ | ||
name: 'nebari:logo', | ||
svgstr: nebariLogo | ||
}); |
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 |
---|---|---|
@@ -1,18 +1,68 @@ | ||
import { | ||
ILabShell, | ||
JupyterFrontEnd, | ||
JupyterFrontEndPlugin | ||
} from '@jupyterlab/application'; | ||
import { URLExt } from '@jupyterlab/coreutils'; | ||
import { Widget } from '@lumino/widgets'; | ||
import { nebariIcon } from './icons'; | ||
|
||
class NebariLogo extends Widget { | ||
constructor(options: { paths: JupyterFrontEnd.IPaths }) { | ||
super(); | ||
const paths = options.paths; | ||
const link = document.createElement('a'); | ||
const hubHost = paths.urls.hubHost || ''; | ||
const hubPrefix = paths.urls.hubPrefix || ''; | ||
|
||
link.href = hubHost + URLExt.join(hubPrefix, 'home'); | ||
link.target = '_blank'; | ||
link.className = 'nebariLogo-link'; | ||
this.node.appendChild(link); | ||
|
||
nebariIcon.element({ | ||
container: link, | ||
elementPosition: 'center', | ||
margin: '2px 2px 2px 7px', | ||
height: 'auto', | ||
width: '22px', | ||
title: 'Nebari Home' | ||
}); | ||
this.id = 'jp-MainLogo'; | ||
this.node.addEventListener('pointerover', this); | ||
} | ||
|
||
handleEvent(event: Event) { | ||
switch (event.type) { | ||
case 'pointerover': { | ||
const mainMenu = document.querySelector('#jp-MainMenu'); | ||
if (!(mainMenu instanceof HTMLElement)) { | ||
return; | ||
} | ||
// Ensure main menu gets blurred to avoid confusing | ||
// highlight on both the icon AND on the "File" menu entry. | ||
mainMenu.dispatchEvent(new FocusEvent('focusout')); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Initialization data for the jupyterlab-nebari-mode extension. | ||
*/ | ||
const plugin: JupyterFrontEndPlugin<void> = { | ||
id: 'jupyterlab-nebari-mode:plugin', | ||
description: 'Nebari customizations for JupyterLab.', | ||
const logoPlugin: JupyterFrontEndPlugin<void> = { | ||
id: 'jupyterlab-nebari-mode:logo', | ||
description: 'Sets the application logo.', | ||
autoStart: true, | ||
activate: (app: JupyterFrontEnd) => { | ||
console.log('JupyterLab extension jupyterlab-nebari-mode is activated!'); | ||
requires: [ILabShell, JupyterFrontEnd.IPaths], | ||
activate: ( | ||
app: JupyterFrontEnd, | ||
shell: ILabShell, | ||
paths: JupyterFrontEnd.IPaths | ||
) => { | ||
const logo = new NebariLogo({ paths }); | ||
shell.add(logo, 'top', { rank: 0 }); | ||
} | ||
}; | ||
|
||
export default plugin; | ||
export default logoPlugin; |
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,4 @@ | ||
declare module '*.svg' { | ||
const script: string; | ||
export default script; | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,21 +1,28 @@ | ||
import { expect, test } from '@jupyterlab/galata'; | ||
|
||
/** | ||
* Don't load JupyterLab webpage before running the tests. | ||
* This is required to ensure we capture all log messages. | ||
*/ | ||
test.use({ autoGoto: false }); | ||
test('should swap Jupyter logo with clickable Nebari logo', async ({ | ||
page | ||
}) => { | ||
// Jupyter icon should not be in the main logo | ||
const jupyterLogo = page.locator( | ||
'#jp-MainLogo > [data-icon="ui-components:jupyter"]' | ||
); | ||
await expect(jupyterLogo).toHaveCount(0); | ||
|
||
test('should emit an activation console message', async ({ page }) => { | ||
const logs: string[] = []; | ||
// Nebari logo should be in the main logo | ||
const link = page.locator('#jp-MainLogo > .nebariLogo-link'); | ||
await expect(link).toHaveCount(1); | ||
|
||
page.on('console', message => { | ||
logs.push(message.text()); | ||
}); | ||
// It should look nice and clean in the top panel | ||
const topPanel = page.locator('#jp-top-panel'); | ||
expect.soft(await topPanel.screenshot()).toMatchSnapshot('top-panel.png'); | ||
|
||
await page.goto(); | ||
// Link should change background on hover | ||
await link.hover(); | ||
expect.soft(await link.screenshot()).toMatchSnapshot('nebari-logo-hover.png'); | ||
await link.blur(); | ||
|
||
expect( | ||
logs.filter(s => s === 'JupyterLab extension jupyterlab-nebari-mode is activated!') | ||
).toHaveLength(1); | ||
// Link should have a focus indicator | ||
await link.focus(); | ||
expect(await link.screenshot()).toMatchSnapshot('nebari-logo-focus.png'); | ||
}); |
Binary file added
BIN
+823 Bytes
...ests/tests/jupyterlab_nebari_mode.spec.ts-snapshots/nebari-logo-focus-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+684 Bytes
...ests/tests/jupyterlab_nebari_mode.spec.ts-snapshots/nebari-logo-hover-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.32 KB
ui-tests/tests/jupyterlab_nebari_mode.spec.ts-snapshots/top-panel-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.