Skip to content

Commit 4bc8099

Browse files
authored
Get filebrowser from current tracked widget (#1004)
* Update github action version * Get the filebrowser from the tracked widget * Fix unit test
1 parent 4b9ad43 commit 4bc8099

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/commandsAndMenu.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
WidgetTracker
1111
} from '@jupyterlab/apputils';
1212
import { PathExt, URLExt } from '@jupyterlab/coreutils';
13-
import { FileBrowser } from '@jupyterlab/filebrowser';
13+
import { FileBrowser, FileBrowserModel } from '@jupyterlab/filebrowser';
1414
import { Contents } from '@jupyterlab/services';
1515
import { ISettingRegistry } from '@jupyterlab/settingregistry';
1616
import { ITerminal } from '@jupyterlab/terminal';
@@ -101,7 +101,7 @@ function pluralizedContextLabel(singular: string, plural: string) {
101101
export function addCommands(
102102
app: JupyterFrontEnd,
103103
gitModel: GitExtension,
104-
fileBrowser: FileBrowser,
104+
fileBrowserModel: FileBrowserModel,
105105
settings: ISettingRegistry.ISettings,
106106
trans: TranslationBundle
107107
): void {
@@ -178,7 +178,7 @@ export function addCommands(
178178
'Create an empty Git repository or reinitialize an existing one'
179179
),
180180
execute: async () => {
181-
const currentPath = fileBrowser.model.path;
181+
const currentPath = fileBrowserModel.path;
182182
const result = await showDialog({
183183
title: trans.__('Initialize a Repository'),
184184
body: trans.__('Do you really want to make this directory a Git Repo?'),
@@ -311,14 +311,14 @@ export function addCommands(
311311
gitModel,
312312
Operation.Clone,
313313
trans,
314-
{ path: fileBrowser.model.path, url: result.value }
314+
{ path: fileBrowserModel.path, url: result.value }
315315
);
316316
logger.log({
317317
message: trans.__('Successfully cloned'),
318318
level: Level.SUCCESS,
319319
details
320320
});
321-
await fileBrowser.model.refresh();
321+
await fileBrowserModel.refresh();
322322
} catch (error) {
323323
console.error(
324324
'Encountered an error when cloning the repository. Error: ',

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async function activate(
7474
let settings: ISettingRegistry.ISettings;
7575
let serverSettings: Git.IServerSettings;
7676
// Get a reference to the default file browser extension
77-
const filebrowser = factory.defaultBrowser;
77+
const filebrowser = factory.tracker.currentWidget;
7878
translator = translator || nullTranslator;
7979
const trans = translator.load('jupyterlab_git');
8080

@@ -157,14 +157,14 @@ async function activate(
157157
// Provided we were able to load application settings, create the extension widgets
158158
if (settings) {
159159
// Add JupyterLab commands
160-
addCommands(app, gitExtension, factory.defaultBrowser, settings, trans);
160+
addCommands(app, gitExtension, filebrowser.model, settings, trans);
161161

162162
// Create the Git widget sidebar
163163
const gitPlugin = new GitWidget(
164164
gitExtension,
165165
settings,
166166
app.commands,
167-
factory.defaultBrowser.model,
167+
filebrowser.model,
168168
trans
169169
);
170170
gitPlugin.id = 'jp-git-sessions';
@@ -184,7 +184,7 @@ async function activate(
184184
mainMenu.addMenu(createGitMenu(app.commands, trans), { rank: 60 });
185185

186186
// Add a clone button to the file browser extension toolbar
187-
addCloneButton(gitExtension, factory.defaultBrowser, app.commands);
187+
addCloneButton(gitExtension, filebrowser, app.commands);
188188

189189
// Add the status bar widget
190190
addStatusBarWidget(statusBar, gitExtension, settings, trans);

tests/plugin.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('plugin', () => {
5858
app,
5959
null,
6060
null,
61-
{ defaultBrowser: null },
61+
{ tracker: { currentWidget: null } },
6262
null,
6363
settingRegistry
6464
);
@@ -93,7 +93,7 @@ describe('plugin', () => {
9393
app,
9494
null,
9595
null,
96-
{ defaultBrowser: null },
96+
{ tracker: { currentWidget: null } },
9797
null,
9898
settingRegistry
9999
);
@@ -127,7 +127,7 @@ describe('plugin', () => {
127127
app,
128128
null,
129129
null,
130-
{ defaultBrowser: null },
130+
{ tracker: { currentWidget: null } },
131131
null,
132132
settingRegistry
133133
);
@@ -158,7 +158,7 @@ describe('plugin', () => {
158158
app,
159159
null,
160160
null,
161-
{ defaultBrowser: null },
161+
{ tracker: { currentWidget: null } },
162162
null,
163163
settingRegistry
164164
);

0 commit comments

Comments
 (0)