microsoft / azuredatastudio

Azure Data Studio is a data management and development tool with connectivity to popular cloud and on-premises databases. Azure Data Studio supports Windows, macOS, and Linux, with immediate capability to connect to Azure SQL and SQL Server. Browse the extension library for more database support options including MySQL, PostgreSQL, and MongoDB.
https://learn.microsoft.com/sql/azure-data-studio
MIT License
7.57k stars 901 forks source link

Detecting ADS being closed in order to show a warning popup before closing the window #23239

Open goyal-anjali opened 1 year ago

goyal-anjali commented 1 year ago

Question How can we detect ADS close button getting clicked? Is there an event to track that?

Context With respect to Database Migration Assessment for Oracle extension on ADS, when an assessment is in progress and customer tries to close ADS, we want to give them a popup. Something like - 'Assessment is in progress. Do you want to close Azure Data Studio?'

alanrenmsft commented 1 year ago

@aasimkhan30 let me know if you need any help.

Charles-Gagnon commented 1 year ago

You could use a task for this - it will display a prompt when the user quits if it's still running asking if they want to quit.

https://github.com/microsoft/azuredatastudio/blob/5560b52df1651501623589e0ced226f083e57ab0/src/sql/workbench/services/tasks/common/tasksService.ts#L152

goyal-anjali commented 1 year ago

Our extension repo sits outside ADS, can I still use it? @Charles-Gagnon

Charles-Gagnon commented 1 year ago

Yes, tasks are part of the extensibility API (the code I linked was just showing where in code it does the popup. That isn't something you control directly except by having an actively running task)

See https://github.com/microsoft/azuredatastudio/blob/0fca085ca7c3f2b329d078f2222dd7b1cca387b1/extensions/sql-database-projects/src/models/deploy/deployService.ts#L138 for an example of starting a task