Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically show and dismiss notifications #965

Merged
merged 1 commit into from
Aug 29, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,10 @@ class DiagnosticsPanel {
.writeText(message)
.then(() => {
Notification.info(
this.trans.__('Successfully copied "%1" to clipboard', message)
this.trans.__('Successfully copied "%1" to clipboard', message),
{
autoClose: 3 * 1000
}
);
})
.catch(() => {
Expand Down
25 changes: 9 additions & 16 deletions packages/jupyterlab-lsp/src/features/jump_to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,9 @@ export class NavigationFeature extends Feature {
const jumper = this.getJumper(adapter);

if (!targetInfo) {
const notificationID = Notification.info(
this._trans.__('No jump targets found')
);
setTimeout(() => Notification.dismiss(notificationID), 2 * 1000);
Notification.info(this._trans.__('No jump targets found'), {
autoClose: 3 * 1000
});
return JumpResult.NoTargetsFound;
}

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

if (!connection) {
const notificationId = Notification.info(
trans.__('Connection not found for jump')
);
setTimeout(() => {
Notification.dismiss(notificationId);
}, 2 * 1000);
Notification.warning(trans.__('Connection not found for jump'), {
autoClose: 4 * 1000
});
return;
}

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

if (!connection) {
const notificationId = Notification.info(
trans.__('Connection not found for jump')
);
setTimeout(() => {
Notification.dismiss(notificationId);
}, 2 * 1000);
Notification.warning(trans.__('Connection not found for jump'), {
autoClose: 5 * 1000
});
return;
}

Expand Down
13 changes: 9 additions & 4 deletions packages/jupyterlab-lsp/src/features/rename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ export class RenameFeature extends Feature {
severity = 'error';
}

Notification.emit(status, severity);
Notification.emit(status, severity, {
autoClose: (severity === 'error' ? 5 : 3) * 1000
});
} catch (error) {
this.console.warn(error);
}
Expand Down Expand Up @@ -267,9 +269,11 @@ export const RENAME_PLUGIN: JupyterFrontEndPlugin<void> = {
}

if (!status) {
Notification.error(trans.__(`Rename failed: %1`, error));
Notification.error(trans.__(`Rename failed: %1`, error), {
autoClose: 5 * 1000
});
} else {
Notification.info(status);
Notification.warning(status, { autoClose: 3 * 1000 });
}
};

Expand All @@ -287,7 +291,8 @@ export const RENAME_PLUGIN: JupyterFrontEndPlugin<void> = {
return;
}
Notification.info(
trans.__('Renaming %1 to %2...', oldValue, newValue)
trans.__('Renaming %1 to %2…', oldValue, newValue),
{ autoClose: 3 * 1000 }
);
const edit = await connection!.clientRequests[
'textDocument/rename'
Expand Down
Loading