Skip to content

Commit 2a8a8d5

Browse files
committed
Set notification autoClose to get similar behavior
1 parent 5c16b97 commit 2a8a8d5

File tree

11 files changed

+68
-33
lines changed

11 files changed

+68
-33
lines changed

schema/plugin.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,6 @@
192192
"domain": "jupyterlab_git"
193193
},
194194
"jupyter.lab.toolbars": {
195-
"FileBrowser": [
196-
{ "name": "gitClone", "rank": 31 }
197-
]
195+
"FileBrowser": [{ "name": "gitClone", "rank": 31 }]
198196
}
199197
}

src/cloneCommand.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ export const gitCloneCommandPlugin: JupyterFrontEndPlugin<void> = {
6060
});
6161

6262
if (result.button.accept && result.value?.url) {
63-
const id = Notification.emit(trans.__('Cloning…'), 'in-progress');
63+
const id = Notification.emit(trans.__('Cloning…'), 'in-progress', {
64+
autoClose: false
65+
});
6466
try {
6567
const details = await showGitOperationDialog<IGitCloneArgs>(
6668
gitModel as GitExtension,

src/commandsAndMenu.tsx

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,17 @@ export function addCommands(
216216
});
217217

218218
if (result.button.accept) {
219-
const id = Notification.emit(trans.__('Initializing…'), 'in-progress');
219+
const id = Notification.emit(trans.__('Initializing…'), 'in-progress', {
220+
autoClose: false
221+
});
220222
try {
221223
await gitModel.init(currentPath);
222224
gitModel.pathRepository = currentPath;
223225
Notification.update({
224226
id,
225227
message: trans.__('Git repository initialized.'),
226-
type: 'success'
228+
type: 'success',
229+
autoClose: 5000
227230
});
228231
} catch (error) {
229232
console.error(
@@ -345,7 +348,9 @@ export function addCommands(
345348
}
346349
}
347350

348-
id = Notification.emit(trans.__('Pushing…'), 'in-progress');
351+
id = Notification.emit(trans.__('Pushing…'), 'in-progress', {
352+
autoClose: false
353+
});
349354
const details = await showGitOperationDialog(
350355
gitModel,
351356
force ? Operation.ForcePush : Operation.Push,
@@ -406,7 +411,9 @@ export function addCommands(
406411
if (args.force) {
407412
await discardAllChanges(gitModel, trans, args.fallback as boolean);
408413
}
409-
id = Notification.emit(trans.__('Pulling…'), 'in-progress');
414+
id = Notification.emit(trans.__('Pulling…'), 'in-progress', {
415+
autoClose: false
416+
});
410417
const details = await showGitOperationDialog(
411418
gitModel,
412419
Operation.Pull,
@@ -504,7 +511,9 @@ export function addCommands(
504511
if (id) {
505512
Notification.update({ id, message });
506513
} else {
507-
id = Notification.emit(message, 'in-progress');
514+
id = Notification.emit(message, 'in-progress', {
515+
autoClose: false
516+
});
508517
}
509518

510519
await gitModel.resetToCommit(gitModel.status.remote ?? undefined);
@@ -934,7 +943,9 @@ export function addCommands(
934943
}
935944
})(action) ?? '';
936945

937-
const id = Notification.emit(message, 'in-progress');
946+
const id = Notification.emit(message, 'in-progress', {
947+
autoClose: false
948+
});
938949
try {
939950
await gitModel.resolveRebase(action as any);
940951
} catch (err) {
@@ -972,7 +983,8 @@ export function addCommands(
972983
Notification.update({
973984
id,
974985
type: 'success',
975-
message: message_
986+
message: message_,
987+
autoClose: 5000
976988
});
977989
}
978990
},
@@ -995,15 +1007,17 @@ export function addCommands(
9951007
if (stashDialog.button.accept) {
9961008
const id = Notification.emit(
9971009
trans.__('Stashing changes'),
998-
'in-progress'
1010+
'in-progress',
1011+
{ autoClose: false }
9991012
);
10001013
try {
10011014
await gitModel.stashChanges(stashMsg);
10021015
// Success
10031016
Notification.update({
10041017
id,
10051018
message: trans.__('Successfully stashed'),
1006-
type: 'success'
1019+
type: 'success',
1020+
autoClose: 5000
10071021
});
10081022
} catch (error: any) {
10091023
console.error(

src/components/BranchMenu.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,8 @@ export class BranchMenu extends React.Component<
446446

447447
const id = Notification.emit(
448448
this.props.trans.__('Switching branch…'),
449-
'in-progress'
449+
'in-progress',
450+
{ autoClose: false }
450451
);
451452

452453
try {
@@ -458,7 +459,8 @@ export class BranchMenu extends React.Component<
458459
Notification.update({
459460
id,
460461
message: this.props.trans.__('Switched branch.'),
461-
type: 'success'
462+
type: 'success',
463+
autoClose: 5000
462464
});
463465
};
464466

src/components/GitPanel.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,8 @@ export class GitPanel extends React.Component<IGitPanelProps, IGitPanelState> {
764764
): Promise<void> => {
765765
const id = Notification.emit(
766766
this.props.trans.__('Staging files...'),
767-
'in-progress'
767+
'in-progress',
768+
{ autoClose: false }
768769
);
769770
await this.props.model.reset();
770771
await this.props.model.add(...this._markedFiles.map(file => file.to));
@@ -791,10 +792,11 @@ export class GitPanel extends React.Component<IGitPanelProps, IGitPanelState> {
791792
if (id !== null) {
792793
Notification.update({
793794
id,
794-
message
795+
message,
796+
autoClose: false
795797
});
796798
} else {
797-
id = Notification.emit(message, 'in-progress');
799+
id = Notification.emit(message, 'in-progress', { autoClose: false });
798800
}
799801

800802
if (this.state.commitAmend) {
@@ -806,7 +808,8 @@ export class GitPanel extends React.Component<IGitPanelProps, IGitPanelState> {
806808
Notification.update({
807809
id,
808810
type: 'success',
809-
message: this.props.trans.__('Committed changes.')
811+
message: this.props.trans.__('Committed changes.'),
812+
autoClose: 5000
810813
});
811814

812815
const hasRemote = this.props.model.branches.some(

src/components/NewBranchDialog.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,8 @@ export class NewBranchDialog extends React.Component<
417417

418418
const id = Notification.emit(
419419
this.props.trans.__('Creating branch…'),
420-
'in-progress'
420+
'in-progress',
421+
{ autoClose: false }
421422
);
422423
try {
423424
await this.props.model.checkout(opts);
@@ -428,15 +429,17 @@ export class NewBranchDialog extends React.Component<
428429
Notification.update({
429430
id,
430431
message: this.props.trans.__('Failed to create branch.'),
431-
type: 'error'
432+
type: 'error',
433+
autoClose: false
432434
});
433435
return;
434436
}
435437

436438
Notification.update({
437439
id,
438440
message: this.props.trans.__('Branch created.'),
439-
type: 'success'
441+
type: 'success',
442+
autoClose: 5000
440443
});
441444
// Close the branch dialog:
442445
this.props.onClose();

src/components/NewTagDialog.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ export const NewTagDialogBox: React.FunctionComponent<INewTagDialogProps> = (
363363

364364
const id = Notification.emit(
365365
props.trans.__('Creating tag…'),
366-
'in-progress'
366+
'in-progress',
367+
{ autoClose: false }
367368
);
368369
try {
369370
await props.model.setTag(tagName, baseCommitId);
@@ -372,15 +373,17 @@ export const NewTagDialogBox: React.FunctionComponent<INewTagDialogProps> = (
372373
Notification.update({
373374
id,
374375
message: props.trans.__('Failed to create tag.'),
375-
type: 'error'
376+
type: 'error',
377+
autoClose: false
376378
});
377379
return;
378380
}
379381

380382
Notification.update({
381383
id,
382384
message: props.trans.__('Tag created.'),
383-
type: 'success'
385+
type: 'success',
386+
autoClose: 5000
384387
});
385388
// Close the tag dialog:
386389
props.onClose();

src/components/ResetRevertDialog.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,16 @@ export class ResetRevertDialog extends React.Component<
222222
private async _resetCommit(hash: string): Promise<void> {
223223
const id = Notification.emit(
224224
this.props.trans.__('Discarding changes…'),
225-
'in-progress'
225+
'in-progress',
226+
{ autoClose: false }
226227
);
227228
try {
228229
await this.props.model.resetToCommit(hash);
229230
Notification.update({
230231
id,
231232
message: this.props.trans.__('Successfully discarded changes.'),
232-
type: 'success'
233+
type: 'success',
234+
autoClose: 5000
233235
});
234236
} catch (error) {
235237
Notification.update({
@@ -254,14 +256,16 @@ export class ResetRevertDialog extends React.Component<
254256
private async _revertCommit(hash: string): Promise<void> {
255257
const id = Notification.emit(
256258
this.props.trans.__('Reverting changes…'),
257-
'in-progress'
259+
'in-progress',
260+
{ autoClose: false }
258261
);
259262
try {
260263
await this.props.model.revertCommit(this._commitMessage(), hash);
261264
Notification.update({
262265
id,
263266
message: this.props.trans.__('Successfully reverted changes.'),
264-
type: 'success'
267+
type: 'success',
268+
autoClose: 5000
265269
});
266270
} catch (error) {
267271
Notification.update({

src/components/TagMenu.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ export class TagMenu extends React.Component<ITagMenuProps, ITagMenuState> {
345345

346346
const id = Notification.emit(
347347
this.props.trans.__('Checking tag out…'),
348-
'in-progress'
348+
'in-progress',
349+
{ autoClose: false }
349350
);
350351

351352
try {
@@ -357,7 +358,8 @@ export class TagMenu extends React.Component<ITagMenuProps, ITagMenuState> {
357358
Notification.update({
358359
id,
359360
message: this.props.trans.__('Tag checkout.'),
360-
type: 'success'
361+
type: 'success',
362+
autoClose: 5000
361363
});
362364
};
363365
return onClick;

src/components/Toolbar.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,15 +431,17 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
431431
private _onRefreshClick = async (): Promise<void> => {
432432
const id = Notification.emit(
433433
this.props.trans.__('Refreshing…'),
434-
'in-progress'
434+
'in-progress',
435+
{ autoClose: false }
435436
);
436437
try {
437438
await this.props.model.refresh();
438439

439440
Notification.update({
440441
id,
441442
message: this.props.trans.__('Successfully refreshed.'),
442-
type: 'success'
443+
type: 'success',
444+
autoClose: 5000
443445
});
444446
} catch (error: any) {
445447
console.error(error);

0 commit comments

Comments
 (0)