Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions schema/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
"title": "Hide hidden file warning",
"description": "If true, the warning popup when opening the .gitignore file without hidden files will not be displayed.",
"default": false
},
"popupDuration": {
"type": "integer",
"title": "Popup duration",
"description": "Number of seconds a popup is displayed.",
"default": 10
}
},
"jupyter.lab.shortcuts": [
Expand Down
30 changes: 27 additions & 3 deletions src/cloneCommand.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '@jupyterlab/apputils';
import { IChangedArgs } from '@jupyterlab/coreutils';
import { IDefaultFileBrowser } from '@jupyterlab/filebrowser';
import { ISettingRegistry } from '@jupyterlab/settingregistry';
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
import * as React from 'react';
import {
Expand All @@ -28,20 +29,41 @@ import { CommandIDs, IGitExtension } from './tokens';
import { GitCloneForm } from './widgets/GitCloneForm';
import { showDetails, showError } from './notifications';

const gitClonePluginId = '@jupyterlab/git:clone';

export const gitCloneCommandPlugin: JupyterFrontEndPlugin<void> = {
id: '@jupyterlab/git:clone',
requires: [IGitExtension, IDefaultFileBrowser, IToolbarWidgetRegistry],
id: gitClonePluginId,
requires: [
IGitExtension,
IDefaultFileBrowser,
IToolbarWidgetRegistry,
ISettingRegistry
],
optional: [ICommandPalette, ITranslator],
activate: (
activate: async (
app: JupyterFrontEnd,
gitModel: IGitExtension,
fileBrowser: IDefaultFileBrowser,
toolbarRegistry: IToolbarWidgetRegistry,
settingRegistry: ISettingRegistry,
palette: ICommandPalette | null,
translator: ITranslator | null
) => {
translator = translator ?? nullTranslator;
const trans = translator.load('jupyterlab_git');

// Attempt to load application settings
let settings: ISettingRegistry.ISettings | undefined = undefined;
try {
settings = await settingRegistry.load(gitClonePluginId);
} catch (error) {
console.error(
trans.__('Failed to load settings for the Git Extension.\n%1', error)
);
}
const popupDuration =
((settings?.composite['popupDuration'] as number) ?? 5) * 1000;

const fileBrowserModel = fileBrowser.model;
/** Add git clone command */
app.commands.addCommand(CommandIDs.gitClone, {
Expand Down Expand Up @@ -81,6 +103,7 @@ export const gitCloneCommandPlugin: JupyterFrontEndPlugin<void> = {
id,
message: trans.__('Successfully cloned'),
type: 'success',
autoClose: popupDuration,
...showDetails(details, trans)
});
await fileBrowserModel.refresh();
Expand All @@ -93,6 +116,7 @@ export const gitCloneCommandPlugin: JupyterFrontEndPlugin<void> = {
id,
message: trans.__('Failed to clone'),
type: 'error',
autoClose: popupDuration,
...showError(error as Error, trans)
});
throw error;
Expand Down
17 changes: 15 additions & 2 deletions src/commandsAndMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ export function addCommands(
const { commands, shell, serviceManager } = app;
const trans = translator.load('jupyterlab_git');

const popupDuration = (settings.composite['popupDuration'] as number) * 1000;

/**
* Commit using a keystroke combination when in CommitBox.
*
Expand Down Expand Up @@ -238,7 +240,7 @@ export function addCommands(
id,
message: trans.__('Git repository initialized.'),
type: 'success',
autoClose: 5000
autoClose: popupDuration
});
} catch (error) {
console.error(
Expand All @@ -251,6 +253,7 @@ export function addCommands(
id,
message: trans.__('Failed to initialize the Git repository'),
type: 'error',
autoClose: popupDuration,
...showError(error as Error, trans)
});
}
Expand Down Expand Up @@ -490,6 +493,7 @@ export function addCommands(
id,
message: trans.__('Successfully pushed'),
type: 'success',
autoClose: popupDuration,
...showDetails(details, trans)
});
} catch (error: any) {
Expand All @@ -506,6 +510,7 @@ export function addCommands(
id,
message,
type: 'error',
autoClose: popupDuration,
...options
});
} else {
Expand Down Expand Up @@ -551,6 +556,7 @@ export function addCommands(
id,
message: trans.__('Successfully pulled'),
type: 'success',
autoClose: popupDuration,
...showDetails(details, trans)
});
} catch (error: any) {
Expand Down Expand Up @@ -587,6 +593,7 @@ export function addCommands(
Notification.update({
id,
message,
autoClose: popupDuration,
...options
});
} else {
Expand Down Expand Up @@ -637,7 +644,11 @@ export function addCommands(
}
const message = trans.__('Resetting...');
if (id) {
Notification.update({ id, message });
Notification.update({
id,
message,
autoClose: popupDuration
});
} else {
id = Notification.emit(message, 'in-progress', {
autoClose: false
Expand All @@ -649,6 +660,7 @@ export function addCommands(
id,
message: trans.__('Successfully reset'),
type: 'success',
autoClose: popupDuration,
...showDetails(
trans.__(
'Successfully reset the current branch to its remote state'
Expand All @@ -668,6 +680,7 @@ export function addCommands(
id,
type: 'error',
message,
autoClose: popupDuration,
...options
});
} else {
Expand Down
Loading