Files

45 lines
1.7 KiB
Markdown
Raw Permalink Normal View History

2022-07-28 15:27:06 -07:00
# Notifications Sample
2022-07-28 14:48:13 -07:00
2022-07-28 15:27:06 -07:00
This sample showcases a handful of basic configurations for notifications in VS Code:
- Info Notification
- Info Notification as Modal
- Warning Notification
- Warning Notification with Actions
- Progress Notification
2022-07-28 14:48:13 -07:00
2022-07-29 10:12:29 -07:00
Read the [Notifications UX Guidelines](https://code.visualstudio.com/api/ux-guidelines/notifications) to learn how to effectively use notifications in an extension.
2022-07-28 15:27:06 -07:00
## Demo
2022-07-28 14:48:13 -07:00
2022-07-28 15:27:06 -07:00
![demo](demo.gif)
2022-07-28 14:48:13 -07:00
2022-07-28 15:27:06 -07:00
## VS Code API
2022-07-28 14:48:13 -07:00
2022-07-28 15:27:06 -07:00
### `vscode` module
2022-07-28 14:48:13 -07:00
2022-07-28 15:27:06 -07:00
- [`commands.registerCommand`](https://code.visualstudio.com/api/references/vscode-api#commands.registerCommand)
- [`window.showInformationMessage`](https://code.visualstudio.com/api/references/vscode-api#window.showInformationMessage)
- [`window.showWarningMessage`](https://code.visualstudio.com/api/references/vscode-api#window.showWarningMessage)
- [`window.showErrorMessage`](https://code.visualstudio.com/api/references/vscode-api#window.showErrorMessage)
- [`window.withProgress`](https://code.visualstudio.com/api/references/vscode-api#window.withProgress)
2022-07-28 14:48:13 -07:00
2022-07-28 15:27:06 -07:00
### Contribution Points
2022-07-28 14:48:13 -07:00
2022-07-28 15:27:06 -07:00
- [`contributes.commands`](https://code.visualstudio.com/api/references/contribution-points#contributes.commands)
2022-07-28 14:48:13 -07:00
2022-07-28 15:27:06 -07:00
## Running the Sample
2022-07-28 14:48:13 -07:00
2022-07-28 15:27:06 -07:00
- Run `npm install` in terminal to install dependencies
2022-07-28 16:47:55 -07:00
- Press F5 or Run the `Run Extension` target in the Debug View. This will:
2022-07-28 15:27:06 -07:00
- Start a task `npm: watch` to compile the code
- Run the extension in a new VS Code window
- Try running the commands to show the notifications:
2022-07-28 16:47:55 -07:00
2022-07-28 15:27:06 -07:00
```
- Notifications Sample: Show Info Notification
- Notifications Sample: Show Info Notification as Modal
- Notifications Sample: Show Warning Notification
- Notifications Sample: Show Warning Notification with Actions
- Notifications Sample: Show Progress Notification
```