Skip to content

Commit

Permalink
add labextension to gitignore
Browse files Browse the repository at this point in the history
add dep to coreutils
add token and interface IFavorites
export IFavorites

Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
  • Loading branch information
adriendelsalle and fcollonval committed Jul 30, 2021
1 parent 16bd910 commit fc5cbdf
Show file tree
Hide file tree
Showing 6 changed files with 8,458 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ dist/
*.pyc
tsconfig.tsbuildinfo
geckodriver.log

jupyterlab_favorites/labextension
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ node_modules
**/node_modules
**/lib
**/package.json
jupyterlab-favorites
jupyterlab_favorites
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"@jupyterlab/ui-components": "^3.0.3",
"@lumino/algorithm": "^1.3.3",
"@lumino/commands": "^1.12.0",
"@lumino/coreutils": "^1.5.3",
"@lumino/signaling": "^1.4.3",
"@lumino/widgets": "^1.16.1"
},
Expand Down
13 changes: 9 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,25 @@ import {
} from './utils';
import { PageConfig } from '@jupyterlab/coreutils';

export { IFavorites } from './token';

const TOOLBAR_CLASS = 'jp-FileBrowser-toolbar';

/**
* Initialization data for the jupyterlab-favorites extension.
*/
const favorites: JupyterFrontEndPlugin<void> = {
const favorites: JupyterFrontEndPlugin<IFavorites> = {
id: PluginIDs.favorites,
autoStart: true,
requires: [IFileBrowserFactory, ISettingRegistry],
provides: IFavorites,
optional: [IMainMenu],
activate: async (
activate: (
app: JupyterFrontEnd,
factory: IFileBrowserFactory,
settingsRegistry: ISettingRegistry,
mainMenu: IMainMenu
) => {
): IFavorites => {
console.log('JupyterLab extension jupyterlab-favorites is activated!');
const docRegistry = app.docRegistry;
const filebrowser = factory.defaultBrowser;
Expand Down Expand Up @@ -192,7 +195,7 @@ const favorites: JupyterFrontEndPlugin<void> = {
},
});
commands.addCommand(CommandIDs.toggleFavoritesWidget, {
execute: async (args) => {
execute: (args) => {
const showWidget = args.showWidget as boolean;
favoritesManager.saveSettings({ showWidget: !showWidget });
},
Expand All @@ -210,6 +213,8 @@ const favorites: JupyterFrontEndPlugin<void> = {
execute: () => favoritesManager.clearFavorites(),
label: 'Clear Favorites',
});

return favoritesManager;
},
};

Expand Down
10 changes: 9 additions & 1 deletion src/token.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Token } from '@lumino/coreutils';

export namespace PluginIDs {
export const favorites = 'jupyterlab-favorites';
}
Expand All @@ -13,7 +15,7 @@ export namespace CommandIDs {

export namespace SettingIDs {
export const themes = '@jupyterlab/apputils-extension:themes';
export const favorites = `${PluginIDs.favorites}:favorites`;
export const favorites = `@jlab-enhanced/favorites:favorites`;
}

export namespace IFavorites {
Expand All @@ -32,3 +34,9 @@ export namespace IFavorites {
showWidget?: boolean;
};
}

export const IFavorites = new Token<IFavorites>('jupyterlab-favorites:IFavorites');

export interface IFavorites {
readonly favorites: IFavorites.Favorite[];
}
Loading

0 comments on commit fc5cbdf

Please sign in to comment.