Skip to content

Commit eacfc19

Browse files
authored
Merge pull request #965 from krassowski/better-notifications
Automatically show and dismiss notifications
2 parents 3bf1c07 + 7f3348d commit eacfc19

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

packages/jupyterlab-lsp/src/features/diagnostics/diagnostics.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,10 @@ class DiagnosticsPanel {
249249
.writeText(message)
250250
.then(() => {
251251
Notification.info(
252-
this.trans.__('Successfully copied "%1" to clipboard', message)
252+
this.trans.__('Successfully copied "%1" to clipboard', message),
253+
{
254+
autoClose: 3 * 1000
255+
}
253256
);
254257
})
255258
.catch(() => {

packages/jupyterlab-lsp/src/features/jump_to.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,9 @@ export class NavigationFeature extends Feature {
368368
const jumper = this.getJumper(adapter);
369369

370370
if (!targetInfo) {
371-
const notificationID = Notification.info(
372-
this._trans.__('No jump targets found')
373-
);
374-
setTimeout(() => Notification.dismiss(notificationID), 2 * 1000);
371+
Notification.info(this._trans.__('No jump targets found'), {
372+
autoClose: 3 * 1000
373+
});
375374
return JumpResult.NoTargetsFound;
376375
}
377376

@@ -564,12 +563,9 @@ export const JUMP_PLUGIN: JupyterFrontEndPlugin<void> = {
564563
const { connection, virtualPosition, document, adapter } = context;
565564

566565
if (!connection) {
567-
const notificationId = Notification.info(
568-
trans.__('Connection not found for jump')
569-
);
570-
setTimeout(() => {
571-
Notification.dismiss(notificationId);
572-
}, 2 * 1000);
566+
Notification.warning(trans.__('Connection not found for jump'), {
567+
autoClose: 4 * 1000
568+
});
573569
return;
574570
}
575571

@@ -610,12 +606,9 @@ export const JUMP_PLUGIN: JupyterFrontEndPlugin<void> = {
610606
const { connection, virtualPosition, document, adapter } = context;
611607

612608
if (!connection) {
613-
const notificationId = Notification.info(
614-
trans.__('Connection not found for jump')
615-
);
616-
setTimeout(() => {
617-
Notification.dismiss(notificationId);
618-
}, 2 * 1000);
609+
Notification.warning(trans.__('Connection not found for jump'), {
610+
autoClose: 5 * 1000
611+
});
619612
return;
620613
}
621614

packages/jupyterlab-lsp/src/features/rename.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ export class RenameFeature extends Feature {
116116
severity = 'error';
117117
}
118118

119-
Notification.emit(status, severity);
119+
Notification.emit(status, severity, {
120+
autoClose: (severity === 'error' ? 5 : 3) * 1000
121+
});
120122
} catch (error) {
121123
this.console.warn(error);
122124
}
@@ -267,9 +269,11 @@ export const RENAME_PLUGIN: JupyterFrontEndPlugin<void> = {
267269
}
268270

269271
if (!status) {
270-
Notification.error(trans.__(`Rename failed: %1`, error));
272+
Notification.error(trans.__(`Rename failed: %1`, error), {
273+
autoClose: 5 * 1000
274+
});
271275
} else {
272-
Notification.info(status);
276+
Notification.warning(status, { autoClose: 3 * 1000 });
273277
}
274278
};
275279

@@ -287,7 +291,8 @@ export const RENAME_PLUGIN: JupyterFrontEndPlugin<void> = {
287291
return;
288292
}
289293
Notification.info(
290-
trans.__('Renaming %1 to %2...', oldValue, newValue)
294+
trans.__('Renaming %1 to %2…', oldValue, newValue),
295+
{ autoClose: 3 * 1000 }
291296
);
292297
const edit = await connection!.clientRequests[
293298
'textDocument/rename'

0 commit comments

Comments
 (0)