forked from jupyterlab/jupyterlab
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring jupyterlab-recents into the core
Co-authored-by: Frédéric Collonval <[email protected]> Co-authored-by: Shreyas Cholia <[email protected]> Co-authored-by: Matt Henderson <[email protected]> Co-authored-by: Trevor Slaton <[email protected]> Co-authored-by: Adrien Delsalle <[email protected]>
- Loading branch information
1 parent
5d7c44b
commit f5bca42
Showing
22 changed files
with
712 additions
and
11 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
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,73 @@ | ||
/* | ||
* Copyright (c) Jupyter Development Team. | ||
* Distributed under the terms of the Modified BSD License. | ||
*/ | ||
|
||
import { | ||
JupyterFrontEnd, | ||
JupyterFrontEndPlugin | ||
} from '@jupyterlab/application'; | ||
import { IRecentsManager, RecentsManager } from '@jupyterlab/docmanager'; | ||
import { ISettingRegistry } from '@jupyterlab/settingregistry'; | ||
import { IStateDB } from '@jupyterlab/statedb'; | ||
import { ITranslator, nullTranslator } from '@jupyterlab/translation'; | ||
|
||
/** | ||
* A namespace for command IDs. | ||
*/ | ||
namespace CommandIDs { | ||
export const clearRecents = 'docmanager:clear-recents'; | ||
} | ||
|
||
namespace PluginIDs { | ||
export const recentsManager = '@jupyterlab/docmanager-extension:recents'; | ||
export const mainPlugin = '@jupyterlab/docmanager-extension:plugin'; | ||
} | ||
|
||
export const recentsManagerPlugin: JupyterFrontEndPlugin<IRecentsManager> = { | ||
id: PluginIDs.recentsManager, | ||
autoStart: true, | ||
requires: [IStateDB], | ||
optional: [ISettingRegistry, ITranslator], | ||
provides: IRecentsManager, | ||
activate: ( | ||
app: JupyterFrontEnd, | ||
stateDB: IStateDB, | ||
settingRegistry: ISettingRegistry | null, | ||
translator: ITranslator | null | ||
): IRecentsManager => { | ||
const { serviceManager } = app; | ||
const trans = (translator ?? nullTranslator).load('jupyterlab'); | ||
|
||
// Create the manager | ||
const recentsManager = new RecentsManager({ | ||
stateDB: stateDB, | ||
contents: serviceManager.contents | ||
}); | ||
|
||
const updateSettings = (settings: ISettingRegistry.ISettings) => { | ||
recentsManager.maximalRecentsLength = settings.get('maximalRecents') | ||
.composite as number; | ||
}; | ||
|
||
if (settingRegistry) { | ||
Promise.all([ | ||
Check failure on line 54 in packages/docmanager-extension/src/recents.ts GitHub Actions / Linux (lint, 3.11)
|
||
app.restored, | ||
settingRegistry.load(PluginIDs.mainPlugin) | ||
]).then(([_, settings]) => { | ||
settings.changed.connect(updateSettings); | ||
updateSettings(settings); | ||
}); | ||
} | ||
|
||
app.commands.addCommand(CommandIDs.clearRecents, { | ||
execute: () => { | ||
recentsManager.clearRecents(); | ||
}, | ||
label: trans.__('Clear Recently Opened'), | ||
caption: trans.__('Clear the list of recently opened items.') | ||
}); | ||
|
||
return recentsManager; | ||
} | ||
}; |
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 |
---|---|---|
|
@@ -27,6 +27,9 @@ | |
{ | ||
"path": "../settingregistry" | ||
}, | ||
{ | ||
"path": "../statedb" | ||
}, | ||
{ | ||
"path": "../statusbar" | ||
}, | ||
|
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
Oops, something went wrong.