@jupyterlite/application-extension 0.6.0-alpha.9 → 0.6.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/clear-data-dialog.d.ts +63 -0
- package/lib/clear-data-dialog.js +80 -0
- package/lib/clear-data-dialog.js.map +1 -0
- package/lib/index.js +82 -30
- package/lib/index.js.map +1 -1
- package/package.json +16 -19
- package/schema/clear-browser-data.json +27 -0
- package/schema/share-file.json +16 -0
- package/src/clear-data-dialog.tsx +217 -0
- package/src/index.tsx +111 -32
- package/style/base.css +68 -0
- package/style/index.css +0 -2
- package/style/index.js +0 -2
- package/lib/pluginmanager.d.ts +0 -20
- package/lib/pluginmanager.js +0 -126
- package/lib/pluginmanager.js.map +0 -1
- package/src/pluginmanager.ts +0 -157
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import { ReactWidget } from '@jupyterlab/apputils';
|
|
5
|
+
|
|
6
|
+
import { ITranslator } from '@jupyterlab/translation';
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A widget for displaying a dialog to clear browser data
|
|
12
|
+
*/
|
|
13
|
+
export class ClearDataDialog extends ReactWidget {
|
|
14
|
+
/**
|
|
15
|
+
* Create a new clear data dialog
|
|
16
|
+
*
|
|
17
|
+
* @param options - The options for creating the dialog
|
|
18
|
+
*/
|
|
19
|
+
constructor(options: ClearDataDialog.IClearDataDialogOptions) {
|
|
20
|
+
super();
|
|
21
|
+
this._translator = options.translator;
|
|
22
|
+
this._availability = options.availability || {
|
|
23
|
+
canClearSettings: true,
|
|
24
|
+
canClearContents: true,
|
|
25
|
+
};
|
|
26
|
+
this._settingsChecked = this._availability.canClearSettings;
|
|
27
|
+
this._contentsChecked = this._availability.canClearContents;
|
|
28
|
+
this.addClass('jp-ClearData-dialog');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the current options selected by the user
|
|
33
|
+
*/
|
|
34
|
+
getValue(): ClearDataDialog.IClearOptions {
|
|
35
|
+
return {
|
|
36
|
+
clearSettings: this._settingsChecked && this._availability.canClearSettings,
|
|
37
|
+
clearContents: this._contentsChecked && this._availability.canClearContents,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Render the dialog content
|
|
43
|
+
*/
|
|
44
|
+
protected render(): JSX.Element {
|
|
45
|
+
return (
|
|
46
|
+
<ClearDataDialogComponent
|
|
47
|
+
translator={this._translator}
|
|
48
|
+
settingsChecked={this._settingsChecked}
|
|
49
|
+
contentsChecked={this._contentsChecked}
|
|
50
|
+
availability={this._availability}
|
|
51
|
+
setSettingsChecked={(checked: boolean) => {
|
|
52
|
+
this._settingsChecked = checked;
|
|
53
|
+
this.update();
|
|
54
|
+
}}
|
|
55
|
+
setContentsChecked={(checked: boolean) => {
|
|
56
|
+
this._contentsChecked = checked;
|
|
57
|
+
this.update();
|
|
58
|
+
}}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private _translator: ITranslator;
|
|
64
|
+
private _settingsChecked: boolean;
|
|
65
|
+
private _contentsChecked: boolean;
|
|
66
|
+
private _availability: ClearDataDialog.IClearAvailability;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A namespace for ClearDataDialog statics
|
|
71
|
+
*/
|
|
72
|
+
export namespace ClearDataDialog {
|
|
73
|
+
/**
|
|
74
|
+
* Interface for the clear options
|
|
75
|
+
*/
|
|
76
|
+
export interface IClearOptions {
|
|
77
|
+
/**
|
|
78
|
+
* Whether to clear settings
|
|
79
|
+
*/
|
|
80
|
+
clearSettings: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Whether to clear contents
|
|
83
|
+
*/
|
|
84
|
+
clearContents: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Interface for availability of clear options
|
|
89
|
+
*/
|
|
90
|
+
export interface IClearAvailability {
|
|
91
|
+
canClearSettings: boolean;
|
|
92
|
+
canClearContents: boolean;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Interface for ClearDataDialog constructor options
|
|
97
|
+
*/
|
|
98
|
+
export interface IClearDataDialogOptions {
|
|
99
|
+
/**
|
|
100
|
+
* The translator instance
|
|
101
|
+
*/
|
|
102
|
+
translator: ITranslator;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The availability of clear options
|
|
106
|
+
*/
|
|
107
|
+
availability?: IClearAvailability;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Props for the ClearDataDialog component
|
|
113
|
+
*/
|
|
114
|
+
interface IClearDataDialogProps {
|
|
115
|
+
translator: ITranslator;
|
|
116
|
+
settingsChecked: boolean;
|
|
117
|
+
contentsChecked: boolean;
|
|
118
|
+
availability: ClearDataDialog.IClearAvailability;
|
|
119
|
+
setSettingsChecked: (checked: boolean) => void;
|
|
120
|
+
setContentsChecked: (checked: boolean) => void;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* A React component for displaying a dialog to clear browser data
|
|
125
|
+
*/
|
|
126
|
+
function ClearDataDialogComponent(props: IClearDataDialogProps): JSX.Element {
|
|
127
|
+
const {
|
|
128
|
+
translator,
|
|
129
|
+
settingsChecked,
|
|
130
|
+
contentsChecked,
|
|
131
|
+
availability,
|
|
132
|
+
setSettingsChecked,
|
|
133
|
+
setContentsChecked,
|
|
134
|
+
} = props;
|
|
135
|
+
|
|
136
|
+
const trans = translator.load('@jupyterlite');
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<div className="jp-ClearData-container">
|
|
140
|
+
<div className="jp-ClearData-warning-box">
|
|
141
|
+
<div className="jp-ClearData-warning-icon">⚠️</div>
|
|
142
|
+
<div className="jp-ClearData-warning-text">
|
|
143
|
+
<span className="jp-ClearData-warning-title">
|
|
144
|
+
{trans.__('Warning: Data Loss Risk')}
|
|
145
|
+
</span>
|
|
146
|
+
<p>
|
|
147
|
+
{trans.__(
|
|
148
|
+
'Clearing browser data will permanently remove data stored in your browser. ' +
|
|
149
|
+
'This operation cannot be undone and may result in loss of:',
|
|
150
|
+
)}
|
|
151
|
+
</p>
|
|
152
|
+
<ul>
|
|
153
|
+
<li>{trans.__('User settings and preferences')}</li>
|
|
154
|
+
<li>{trans.__('Notebooks and files stored in the browser')}</li>
|
|
155
|
+
<li>{trans.__('Unsaved work and changes')}</li>
|
|
156
|
+
</ul>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
<div
|
|
161
|
+
className={`jp-ClearData-option ${
|
|
162
|
+
!availability.canClearSettings ? 'jp-mod-disabled' : ''
|
|
163
|
+
}`}
|
|
164
|
+
>
|
|
165
|
+
<input
|
|
166
|
+
id="jp-ClearData-settings"
|
|
167
|
+
type="checkbox"
|
|
168
|
+
checked={settingsChecked}
|
|
169
|
+
onChange={(e) => setSettingsChecked(e.target.checked)}
|
|
170
|
+
disabled={!availability.canClearSettings}
|
|
171
|
+
/>
|
|
172
|
+
<label
|
|
173
|
+
htmlFor="jp-ClearData-settings"
|
|
174
|
+
className={!availability.canClearSettings ? 'jp-mod-disabled' : ''}
|
|
175
|
+
>
|
|
176
|
+
{trans.__('Settings and preferences')}
|
|
177
|
+
{!availability.canClearSettings && (
|
|
178
|
+
<span className="jp-ClearData-unavailable">
|
|
179
|
+
{' '}
|
|
180
|
+
{trans.__('(unavailable)')}
|
|
181
|
+
</span>
|
|
182
|
+
)}
|
|
183
|
+
</label>
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<div
|
|
187
|
+
className={`jp-ClearData-option ${
|
|
188
|
+
!availability.canClearContents ? 'jp-mod-disabled' : ''
|
|
189
|
+
}`}
|
|
190
|
+
>
|
|
191
|
+
<input
|
|
192
|
+
id="jp-ClearData-contents"
|
|
193
|
+
type="checkbox"
|
|
194
|
+
checked={contentsChecked}
|
|
195
|
+
onChange={(e) => setContentsChecked(e.target.checked)}
|
|
196
|
+
disabled={!availability.canClearContents}
|
|
197
|
+
/>
|
|
198
|
+
<label
|
|
199
|
+
htmlFor="jp-ClearData-contents"
|
|
200
|
+
className={!availability.canClearContents ? 'jp-mod-disabled' : ''}
|
|
201
|
+
>
|
|
202
|
+
{trans.__('Files and notebooks')}
|
|
203
|
+
{!availability.canClearContents && (
|
|
204
|
+
<span className="jp-ClearData-unavailable">
|
|
205
|
+
{' '}
|
|
206
|
+
{trans.__('(unavailable)')}
|
|
207
|
+
</span>
|
|
208
|
+
)}
|
|
209
|
+
</label>
|
|
210
|
+
</div>
|
|
211
|
+
|
|
212
|
+
<div className="jp-ClearData-reload-notice">
|
|
213
|
+
{trans.__('This will reload the page after clearing the selected data.')}
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
216
|
+
);
|
|
217
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
Clipboard,
|
|
13
13
|
Dialog,
|
|
14
14
|
ICommandPalette,
|
|
15
|
-
ILicensesClient,
|
|
16
15
|
SessionContext,
|
|
17
16
|
showDialog,
|
|
18
17
|
} from '@jupyterlab/apputils';
|
|
@@ -21,7 +20,7 @@ import { PageConfig, URLExt } from '@jupyterlab/coreutils';
|
|
|
21
20
|
|
|
22
21
|
import { IDocumentManager, IDocumentWidgetOpener } from '@jupyterlab/docmanager';
|
|
23
22
|
|
|
24
|
-
import { IFileBrowserFactory } from '@jupyterlab/filebrowser';
|
|
23
|
+
import { IDefaultFileBrowser, IFileBrowserFactory } from '@jupyterlab/filebrowser';
|
|
25
24
|
|
|
26
25
|
import {
|
|
27
26
|
DocumentConnectionManager,
|
|
@@ -31,28 +30,36 @@ import {
|
|
|
31
30
|
} from '@jupyterlab/lsp';
|
|
32
31
|
|
|
33
32
|
import { IMainMenu } from '@jupyterlab/mainmenu';
|
|
33
|
+
import {
|
|
34
|
+
Contents,
|
|
35
|
+
IDefaultDrive,
|
|
36
|
+
ISettingManager,
|
|
37
|
+
Setting,
|
|
38
|
+
} from '@jupyterlab/services';
|
|
34
39
|
|
|
35
40
|
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
36
41
|
|
|
37
|
-
import { ITranslator
|
|
42
|
+
import { ITranslator } from '@jupyterlab/translation';
|
|
38
43
|
|
|
39
|
-
import { downloadIcon, linkIcon } from '@jupyterlab/ui-components';
|
|
44
|
+
import { clearIcon, downloadIcon, linkIcon } from '@jupyterlab/ui-components';
|
|
40
45
|
|
|
41
|
-
import {
|
|
46
|
+
import { IKernelClient } from '@jupyterlite/kernel';
|
|
42
47
|
|
|
43
48
|
import { IServiceWorkerManager, ServiceWorkerManager } from '@jupyterlite/server';
|
|
44
49
|
|
|
45
|
-
import { LiteTranslatorConnector } from '@jupyterlite/translation';
|
|
46
|
-
|
|
47
50
|
import { liteIcon, liteWordmark } from '@jupyterlite/ui-components';
|
|
48
51
|
|
|
52
|
+
import { BrowserStorageDrive } from '@jupyterlite/contents';
|
|
53
|
+
|
|
54
|
+
import { Settings } from '@jupyterlite/settings';
|
|
55
|
+
|
|
49
56
|
import { filter } from '@lumino/algorithm';
|
|
50
57
|
|
|
51
58
|
import { Widget } from '@lumino/widgets';
|
|
52
59
|
|
|
53
60
|
import React from 'react';
|
|
54
61
|
|
|
55
|
-
import {
|
|
62
|
+
import { ClearDataDialog } from './clear-data-dialog';
|
|
56
63
|
|
|
57
64
|
/**
|
|
58
65
|
* A regular expression to match path to notebooks, documents and consoles
|
|
@@ -75,6 +82,8 @@ namespace CommandIDs {
|
|
|
75
82
|
export const filebrowserDownload = 'filebrowser:download';
|
|
76
83
|
|
|
77
84
|
export const copyShareableLink = 'filebrowser:share-main';
|
|
85
|
+
|
|
86
|
+
export const clearBrowserData = 'application:clear-browser-data';
|
|
78
87
|
}
|
|
79
88
|
|
|
80
89
|
/**
|
|
@@ -304,18 +313,6 @@ const downloadPlugin: JupyterFrontEndPlugin<void> = {
|
|
|
304
313
|
},
|
|
305
314
|
};
|
|
306
315
|
|
|
307
|
-
/**
|
|
308
|
-
* The client for fetching licenses data.
|
|
309
|
-
*/
|
|
310
|
-
const licensesClient: JupyterFrontEndPlugin<ILicensesClient> = {
|
|
311
|
-
id: '@jupyterlite/application-extension:licenses-client',
|
|
312
|
-
autoStart: true,
|
|
313
|
-
provides: ILicensesClient,
|
|
314
|
-
activate: (app: JupyterFrontEnd): ILicensesClient => {
|
|
315
|
-
return new LiteLicensesClient();
|
|
316
|
-
},
|
|
317
|
-
};
|
|
318
|
-
|
|
319
316
|
/**
|
|
320
317
|
* The main application icon.
|
|
321
318
|
*/
|
|
@@ -506,9 +503,17 @@ const serviceWorkerManagerPlugin: JupyterFrontEndPlugin<IServiceWorkerManager> =
|
|
|
506
503
|
id: '@jupyterlite/application-extension:service-worker-manager',
|
|
507
504
|
autoStart: true,
|
|
508
505
|
provides: IServiceWorkerManager,
|
|
509
|
-
|
|
506
|
+
optional: [IKernelClient],
|
|
507
|
+
activate: (app: JupyterFrontEnd, kernelClient?: IKernelClient) => {
|
|
510
508
|
const { contents } = app.serviceManager;
|
|
511
|
-
|
|
509
|
+
const serviceWorkerManager = new ServiceWorkerManager({ contents });
|
|
510
|
+
if (kernelClient !== undefined) {
|
|
511
|
+
serviceWorkerManager.registerStdinHandler(
|
|
512
|
+
'kernel',
|
|
513
|
+
kernelClient.handleStdin.bind(kernelClient),
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
return serviceWorkerManager;
|
|
512
517
|
},
|
|
513
518
|
};
|
|
514
519
|
|
|
@@ -617,31 +622,105 @@ const shareFile: JupyterFrontEndPlugin<void> = {
|
|
|
617
622
|
};
|
|
618
623
|
|
|
619
624
|
/**
|
|
620
|
-
*
|
|
625
|
+
* A plugin to add a command for clearing browser data.
|
|
621
626
|
*/
|
|
622
|
-
const
|
|
623
|
-
id: '@jupyterlite/application-extension:
|
|
624
|
-
description: 'Provides the application translation connector.',
|
|
627
|
+
const clearBrowserData: JupyterFrontEndPlugin<void> = {
|
|
628
|
+
id: '@jupyterlite/application-extension:clear-browser-data',
|
|
625
629
|
autoStart: true,
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
630
|
+
requires: [ITranslator],
|
|
631
|
+
optional: [ICommandPalette, ISettingManager, IDefaultDrive, IDefaultFileBrowser],
|
|
632
|
+
activate: (
|
|
633
|
+
app: JupyterFrontEnd,
|
|
634
|
+
translator: ITranslator,
|
|
635
|
+
palette: ICommandPalette | null,
|
|
636
|
+
settingManager: Setting.IManager | null,
|
|
637
|
+
defaultDrive: Contents.IDrive | null,
|
|
638
|
+
defaultFileBrowser: IDefaultFileBrowser | null,
|
|
639
|
+
): void => {
|
|
640
|
+
const { commands } = app;
|
|
641
|
+
const trans = translator.load(I18N_BUNDLE);
|
|
642
|
+
const category = trans.__('Help');
|
|
643
|
+
|
|
644
|
+
const isBrowserStorageDrive = defaultDrive instanceof BrowserStorageDrive;
|
|
645
|
+
const isLiteSettingsManager = settingManager instanceof Settings;
|
|
646
|
+
|
|
647
|
+
if (!isBrowserStorageDrive && !isLiteSettingsManager) {
|
|
648
|
+
// not available if neither the default drive or the settings manager
|
|
649
|
+
// are the ones provided by JupyterLite by default
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
// Add a CSS class to the drive if it is a BrowserStorageDrive for the context menu entry
|
|
654
|
+
if (isBrowserStorageDrive && defaultFileBrowser) {
|
|
655
|
+
defaultFileBrowser.addClass('jp-BrowserStorageDrive');
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
const clearData = async (options: ClearDataDialog.IClearOptions): Promise<void> => {
|
|
659
|
+
const { clearSettings, clearContents } = options;
|
|
660
|
+
const promises: Promise<void>[] = [];
|
|
661
|
+
|
|
662
|
+
if (clearContents && isBrowserStorageDrive) {
|
|
663
|
+
const browserStorageDrive = defaultDrive as BrowserStorageDrive;
|
|
664
|
+
promises.push(browserStorageDrive.clearStorage());
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
if (clearSettings && isLiteSettingsManager) {
|
|
668
|
+
const settings = settingManager as Settings;
|
|
669
|
+
promises.push(settings.clear());
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
await Promise.all(promises);
|
|
673
|
+
|
|
674
|
+
window.location.reload();
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
commands.addCommand(CommandIDs.clearBrowserData, {
|
|
678
|
+
label: trans.__('Clear Browser Data'),
|
|
679
|
+
icon: (args) => (args['isPalette'] ? undefined : clearIcon),
|
|
680
|
+
execute: async () => {
|
|
681
|
+
// Pass the availability information to the dialog
|
|
682
|
+
const availability = {
|
|
683
|
+
canClearSettings: isLiteSettingsManager && !!settingManager,
|
|
684
|
+
canClearContents: isBrowserStorageDrive && !!defaultDrive,
|
|
685
|
+
};
|
|
686
|
+
|
|
687
|
+
const body = new ClearDataDialog({
|
|
688
|
+
translator,
|
|
689
|
+
availability,
|
|
690
|
+
});
|
|
691
|
+
|
|
692
|
+
const result = await showDialog({
|
|
693
|
+
title: trans.__('Clear Browser Data'),
|
|
694
|
+
body,
|
|
695
|
+
buttons: [
|
|
696
|
+
Dialog.cancelButton({ label: trans.__('Cancel') }),
|
|
697
|
+
Dialog.warnButton({ label: trans.__('Clear') }),
|
|
698
|
+
],
|
|
699
|
+
});
|
|
700
|
+
if (result.button.accept) {
|
|
701
|
+
return clearData(body.getValue());
|
|
702
|
+
}
|
|
703
|
+
return await Promise.resolve();
|
|
704
|
+
},
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
if (palette) {
|
|
708
|
+
palette.addItem({ command: CommandIDs.clearBrowserData, category });
|
|
709
|
+
}
|
|
629
710
|
},
|
|
630
711
|
};
|
|
631
712
|
|
|
632
713
|
const plugins: JupyterFrontEndPlugin<any>[] = [
|
|
633
714
|
about,
|
|
715
|
+
clearBrowserData,
|
|
634
716
|
downloadPlugin,
|
|
635
|
-
licensesClient,
|
|
636
717
|
liteLogo,
|
|
637
718
|
lspConnectionManager,
|
|
638
719
|
notifyCommands,
|
|
639
720
|
opener,
|
|
640
|
-
pluginManagerPlugin,
|
|
641
721
|
serviceWorkerManagerPlugin,
|
|
642
722
|
sessionContextPatch,
|
|
643
723
|
shareFile,
|
|
644
|
-
translatorConnector,
|
|
645
724
|
];
|
|
646
725
|
|
|
647
726
|
export default plugins;
|
package/style/base.css
CHANGED
|
@@ -2,3 +2,71 @@
|
|
|
2
2
|
| Copyright (c) Jupyter Development Team.
|
|
3
3
|
| Distributed under the terms of the Modified BSD License.
|
|
4
4
|
|----------------------------------------------------------------------------*/
|
|
5
|
+
|
|
6
|
+
.jp-ClearData-dialog {
|
|
7
|
+
min-width: 400px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.jp-ClearData-container {
|
|
11
|
+
padding: 10px 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.jp-ClearData-option {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
margin: 12px 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.jp-ClearData-option label {
|
|
21
|
+
margin-left: 8px;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* Enhanced warning styles */
|
|
26
|
+
.jp-ClearData-warning-box {
|
|
27
|
+
display: flex;
|
|
28
|
+
background-color: var(--jp-warn-color1);
|
|
29
|
+
border: 1px solid var(--jp-warn-color1);
|
|
30
|
+
border-radius: 4px;
|
|
31
|
+
padding: 12px;
|
|
32
|
+
margin: 0 0 16px 0;
|
|
33
|
+
align-items: flex-start;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.jp-ClearData-warning-icon {
|
|
37
|
+
font-size: 24px;
|
|
38
|
+
margin-right: 12px;
|
|
39
|
+
flex-shrink: 0;
|
|
40
|
+
color: var(--jp-warn-color0);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.jp-ClearData-warning-text {
|
|
44
|
+
flex: 1;
|
|
45
|
+
color: var(--md-grey-900);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.jp-ClearData-warning-title {
|
|
49
|
+
font-weight: bold;
|
|
50
|
+
display: block;
|
|
51
|
+
margin-bottom: 8px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.jp-ClearData-warning-text ul {
|
|
55
|
+
margin: 8px 0 4px 0;
|
|
56
|
+
padding-left: 24px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.jp-ClearData-warning-text p {
|
|
60
|
+
margin: 4px 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.jp-ClearData-reload-notice {
|
|
64
|
+
margin-top: 16px;
|
|
65
|
+
color: var(--jp-ui-font-color2);
|
|
66
|
+
font-size: 0.9em;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.jp-ClearData-unavailable {
|
|
70
|
+
color: var(--jp-ui-font-color2);
|
|
71
|
+
font-style: italic;
|
|
72
|
+
}
|
package/style/index.css
CHANGED
package/style/index.js
CHANGED
package/lib/pluginmanager.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { JupyterFrontEndPlugin } from '@jupyterlab/application';
|
|
2
|
-
import { IEntry, IPluginManager, PluginListModel } from '@jupyterlab/pluginmanager';
|
|
3
|
-
/**
|
|
4
|
-
* Custom PluginModel for use in JupyterLite
|
|
5
|
-
*/
|
|
6
|
-
export declare class LitePluginListModel extends PluginListModel {
|
|
7
|
-
/**
|
|
8
|
-
* Create a new PluginListModel.
|
|
9
|
-
*/
|
|
10
|
-
constructor(options: PluginListModel.IOptions);
|
|
11
|
-
get available(): ReadonlyArray<IEntry>;
|
|
12
|
-
refresh(): Promise<void>;
|
|
13
|
-
enable(entry: IEntry): Promise<void>;
|
|
14
|
-
disable(entry: IEntry): Promise<void>;
|
|
15
|
-
private _availablePlugins;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* A plugin for managing status of other plugins.
|
|
19
|
-
*/
|
|
20
|
-
export declare const pluginManagerPlugin: JupyterFrontEndPlugin<IPluginManager>;
|
package/lib/pluginmanager.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Jupyter Development Team.
|
|
2
|
-
// Distributed under the terms of the Modified BSD License.
|
|
3
|
-
import { JupyterLab, } from '@jupyterlab/application';
|
|
4
|
-
import { ICommandPalette, MainAreaWidget, WidgetTracker } from '@jupyterlab/apputils';
|
|
5
|
-
import { IPluginManager, PluginListModel, Plugins, } from '@jupyterlab/pluginmanager';
|
|
6
|
-
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
|
|
7
|
-
import { extensionIcon } from '@jupyterlab/ui-components';
|
|
8
|
-
/**
|
|
9
|
-
* The command IDs used by the plugin manager plugin.
|
|
10
|
-
*/
|
|
11
|
-
var CommandIDs;
|
|
12
|
-
(function (CommandIDs) {
|
|
13
|
-
CommandIDs.open = 'plugin-manager:open';
|
|
14
|
-
})(CommandIDs || (CommandIDs = {}));
|
|
15
|
-
/**
|
|
16
|
-
* Custom PluginModel for use in JupyterLite
|
|
17
|
-
*/
|
|
18
|
-
export class LitePluginListModel extends PluginListModel {
|
|
19
|
-
/**
|
|
20
|
-
* Create a new PluginListModel.
|
|
21
|
-
*/
|
|
22
|
-
constructor(options) {
|
|
23
|
-
super(options);
|
|
24
|
-
this._availablePlugins = options.pluginData.availablePlugins.map((plugin) => {
|
|
25
|
-
let tokenLabel = plugin.provides ? plugin.provides.name.split(':')[1] : undefined;
|
|
26
|
-
if (plugin.provides && !tokenLabel) {
|
|
27
|
-
tokenLabel = plugin.provides.name;
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
...plugin,
|
|
31
|
-
tokenLabel,
|
|
32
|
-
// keep all plugins locked and enabled for now until there is
|
|
33
|
-
// a way to enable/disable plugins in JupyterLite
|
|
34
|
-
locked: true,
|
|
35
|
-
enabled: true,
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
get available() {
|
|
40
|
-
return this._availablePlugins;
|
|
41
|
-
}
|
|
42
|
-
async refresh() {
|
|
43
|
-
// no-op
|
|
44
|
-
}
|
|
45
|
-
async enable(entry) {
|
|
46
|
-
// no-op
|
|
47
|
-
}
|
|
48
|
-
async disable(entry) {
|
|
49
|
-
// no-op
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* A plugin for managing status of other plugins.
|
|
54
|
-
*/
|
|
55
|
-
export const pluginManagerPlugin = {
|
|
56
|
-
id: '@jupyterlite/application-extension:plugin-manager',
|
|
57
|
-
description: 'Plugin manager viewer',
|
|
58
|
-
autoStart: true,
|
|
59
|
-
optional: [ITranslator, ICommandPalette],
|
|
60
|
-
provides: IPluginManager,
|
|
61
|
-
activate: (app, translator, palette) => {
|
|
62
|
-
if (!(app instanceof JupyterLab)) {
|
|
63
|
-
// only activate in JupyterLab
|
|
64
|
-
// TODO: require JupyterLab.IInfo instead when the upstream PR is merged and released?
|
|
65
|
-
// https://github.com/jupyterlab/jupyterlab/pull/17367
|
|
66
|
-
return {
|
|
67
|
-
open: async () => {
|
|
68
|
-
// eslint-disable-next-line no-console
|
|
69
|
-
console.info('Plugin manager viewer is only available in JupyterLab');
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
const { commands, serviceManager, shell } = app;
|
|
74
|
-
translator = translator !== null && translator !== void 0 ? translator : nullTranslator;
|
|
75
|
-
const trans = translator.load('jupyterlab');
|
|
76
|
-
const category = trans.__('Plugin Manager');
|
|
77
|
-
const widgetLabel = trans.__('Advanced Plugin Manager');
|
|
78
|
-
const namespace = 'plugin-manager';
|
|
79
|
-
const tracker = new WidgetTracker({
|
|
80
|
-
namespace: namespace,
|
|
81
|
-
});
|
|
82
|
-
const availablePlugins = app.info.availablePlugins;
|
|
83
|
-
function createWidget(args) {
|
|
84
|
-
const model = new LitePluginListModel({
|
|
85
|
-
...args,
|
|
86
|
-
pluginData: {
|
|
87
|
-
availablePlugins,
|
|
88
|
-
},
|
|
89
|
-
serverSettings: serviceManager.serverSettings,
|
|
90
|
-
extraLockedPlugins: [pluginManagerPlugin.id],
|
|
91
|
-
translator: translator !== null && translator !== void 0 ? translator : nullTranslator,
|
|
92
|
-
});
|
|
93
|
-
const content = new Plugins({
|
|
94
|
-
model,
|
|
95
|
-
translator: translator !== null && translator !== void 0 ? translator : nullTranslator,
|
|
96
|
-
});
|
|
97
|
-
content.title.label = widgetLabel;
|
|
98
|
-
content.title.icon = extensionIcon;
|
|
99
|
-
content.title.caption = trans.__('Plugin Manager');
|
|
100
|
-
const main = new MainAreaWidget({ content, reveal: model.ready });
|
|
101
|
-
return main;
|
|
102
|
-
}
|
|
103
|
-
commands.addCommand(CommandIDs.open, {
|
|
104
|
-
label: widgetLabel,
|
|
105
|
-
execute: (args) => {
|
|
106
|
-
const main = createWidget(args);
|
|
107
|
-
shell.add(main, 'main', { type: 'Plugins' });
|
|
108
|
-
// add to tracker so it can be restored, and update when choices change
|
|
109
|
-
void tracker.add(main);
|
|
110
|
-
main.content.model.trackerDataChanged.connect(() => {
|
|
111
|
-
void tracker.save(main);
|
|
112
|
-
});
|
|
113
|
-
return main;
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
if (palette) {
|
|
117
|
-
palette.addItem({ command: CommandIDs.open, category });
|
|
118
|
-
}
|
|
119
|
-
return {
|
|
120
|
-
open: () => {
|
|
121
|
-
return app.commands.execute(CommandIDs.open);
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
//# sourceMappingURL=pluginmanager.js.map
|
package/lib/pluginmanager.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"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