Skip to content

Commit 7f3348d

Browse files
committed
Automatically show and dismiss notifications
1 parent 74e0d07 commit 7f3348d

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
@@ -353,10 +353,9 @@ export class NavigationFeature extends Feature {
353353
const jumper = this.getJumper(adapter);
354354

355355
if (!targetInfo) {
356-
const notificationID = Notification.info(
357-
this._trans.__('No jump targets found')
358-
);
359-
setTimeout(() => Notification.dismiss(notificationID), 2 * 1000);
356+
Notification.info(this._trans.__('No jump targets found'), {
357+
autoClose: 3 * 1000
358+
});
360359
return JumpResult.NoTargetsFound;
361360
}
362361

@@ -542,12 +541,9 @@ export const JUMP_PLUGIN: JupyterFrontEndPlugin<void> = {
542541
const { connection, virtualPosition, document, adapter } = context;
543542

544543
if (!connection) {
545-
const notificationId = Notification.info(
546-
trans.__('Connection not found for jump')
547-
);
548-
setTimeout(() => {
549-
Notification.dismiss(notificationId);
550-
}, 2 * 1000);
544+
Notification.warning(trans.__('Connection not found for jump'), {
545+
autoClose: 4 * 1000
546+
});
551547
return;
552548
}
553549

@@ -588,12 +584,9 @@ export const JUMP_PLUGIN: JupyterFrontEndPlugin<void> = {
588584
const { connection, virtualPosition, document, adapter } = context;
589585

590586
if (!connection) {
591-
const notificationId = Notification.info(
592-
trans.__('Connection not found for jump')
593-
);
594-
setTimeout(() => {
595-
Notification.dismiss(notificationId);
596-
}, 2 * 1000);
587+
Notification.warning(trans.__('Connection not found for jump'), {
588+
autoClose: 5 * 1000
589+
});
597590
return;
598591
}
599592

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)