Skip to content

Commit 5c0e6c6

Browse files
aasimkhan30Aasim Khan
andauthored
Adding log viewer for background tasks. (#21841)
* feat: Implement background tasks feature in MSSQL extension - Added constants for background tasks and related commands in constants.ts. - Integrated BackgroundTasksProvider and BackgroundTasksService in mainController.ts. - Implemented background task initialization and handling in MainController. - Enhanced SqlTasksService to register and manage background tasks. - Created unit tests for BackgroundTasksProvider, MainController, and SqlTasksService to ensure functionality. - Added logic for task completion, cancellation, and progress updates. - Implemented UI updates for background tasks in the VSCode extension. * feat: Add localization for background task statuses and commands * Refactor deployment state management and enhance local containers and fabric provisioning logic - Updated `updateFabricProvisioningState` and `updateLocalContainersState` to use `publishDeploymentState` for state updates. - Enhanced local containers reducer to handle step completion more effectively, allowing for progress tracking across multiple steps. - Introduced new properties in `TaskInfo` and `TaskProgressInfo` for better task management and progress reporting. - Added support for resuming deployments with `resumedDeploymentType` and `resumedWizardPageId` in deployment state. - Implemented tests for background task synchronization and state updates in both local containers and fabric provisioning. - Improved user feedback during deployment processes with detailed progress messages and telemetry events. * Refactor task status and progress message handling in SqlTasksService * Refactor background task handling in tests and localization updates - Removed unused stubs and tests related to background task handling in fabricProvisioningHelpers and localContainersHelpers tests. - Updated assertions to check for state updates instead of direct calls to publishDeploymentState. - Cleaned up localization files by removing obsolete entries and adding necessary translations for background tasks. * Add localization entries for background tasks and connection labels * Refactor background task localization and tooltip handling * Add localization entries for background task source, connection label, and target location * Refactor background task handling to improve focus behavior and remove unused progress notifications * Enhance background task tree view handling by refactoring reveal logic and updating tests for command execution * Add elapsed time tracking for background tasks and update related localization * Add localization entries for elapsed time in various formats * Add background task logging and related localization entries * Add localization entries for task descriptions, statuses, and logs * Refactor notification handling in SqlTasksService to use async/await for improved readability * Remove unused SVG files for completed and failed tasks * Add background task logging features and improve task management - Introduced commands for viewing background task logs and managing Docker containers. - Enhanced background task registration with description and target properties. - Implemented a logging system for background tasks with timestamp formatting. - Updated localization constants for new logging features. - Added tests for background task logging and SQL task service integration. * Enhance background task log functionality by revealing the latest log entry in the editor and adding millisecond precision to timestamps * Add background task log viewing functionality and improve log management * Add detailed JSDoc comments for background task log content provider methods * Enhance document name generation for background task logs using contextual information * Refactor background task log update handling and improve test coverage for URI management * Add confirmation prompt for canceling background tasks and update related UI elements * Add localization for background task cancellation prompts --------- Co-authored-by: Aasim Khan <aasimkhan@gmail.com>
1 parent d2c596e commit 5c0e6c6

15 files changed

Lines changed: 969 additions & 17 deletions

extensions/mssql/l10n/bundle.l10n.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,18 @@
20012001
"Azure: Sign In to Azure Cloud": "Azure: Sign In to Azure Cloud",
20022002
"Sign in to your Azure subscription in one of the sovereign clouds.": "Sign in to your Azure subscription in one of the sovereign clouds.",
20032003
"No background tasks": "No background tasks",
2004+
"Task: {0}/{0} is the task name": {
2005+
"message": "Task: {0}",
2006+
"comment": ["{0} is the task name"]
2007+
},
2008+
"Description: {0}/{0} is the task description": {
2009+
"message": "Description: {0}",
2010+
"comment": ["{0} is the task description"]
2011+
},
2012+
"Status: {0}/{0} is the task status": {
2013+
"message": "Status: {0}",
2014+
"comment": ["{0} is the task status"]
2015+
},
20042016
"Source: {0}/{0} is the task source": {
20052017
"message": "Source: {0}",
20062018
"comment": ["{0} is the task source"]
@@ -2017,6 +2029,31 @@
20172029
"message": "Elapsed time: {0}",
20182030
"comment": ["{0} is the task elapsed time"]
20192031
},
2032+
"Logs": "Logs",
2033+
"No log entries yet.": "No log entries yet.",
2034+
"Task log is unavailable.": "Task log is unavailable.",
2035+
"Are you sure you want to cancel this background task?": "Are you sure you want to cancel this background task?",
2036+
"Cancel Task": "Cancel Task",
2037+
"[{0}] {1}/{0} is the timestamp{1} is the log entry text": {
2038+
"message": "[{0}] {1}",
2039+
"comment": ["{0} is the timestamp", "{1} is the log entry text"]
2040+
},
2041+
"{0}: {1}/{0} is the task status{1} is the task message": {
2042+
"message": "{0}: {1}",
2043+
"comment": ["{0} is the task status", "{1} is the task message"]
2044+
},
2045+
"{0} ({1}%)/{0} is the task status{1} is the completion percent": {
2046+
"message": "{0} ({1}%)",
2047+
"comment": ["{0} is the task status", "{1} is the completion percent"]
2048+
},
2049+
"{0} ({1}%): {2}/{0} is the task status{1} is the completion percent{2} is the task message": {
2050+
"message": "{0} ({1}%): {2}",
2051+
"comment": [
2052+
"{0} is the task status",
2053+
"{1} is the completion percent",
2054+
"{2} is the task message"
2055+
]
2056+
},
20202057
"{0}ms/{0} is the elapsed time in milliseconds": {
20212058
"message": "{0}ms",
20222059
"comment": ["{0} is the elapsed time in milliseconds"]

extensions/mssql/package.json

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -855,38 +855,57 @@
855855
"when": "view == queryHistory && viewItem == queryHistoryNode",
856856
"group": "MS_SQL@3"
857857
},
858+
{
859+
"command": "mssql.stopContainer",
860+
"when": "view == objectExplorer && viewItem =~ /\\bsubType=(DockerContainer|DockerContainerDatabase)\\b/",
861+
"group": "9_MSSQL_container@1"
862+
},
863+
{
864+
"command": "mssql.deleteContainer",
865+
"when": "view == objectExplorer && viewItem =~ /\\bsubType=(DockerContainer|disconnectedDockerContainer|DockerContainerDatabase)\\b/",
866+
"group": "9_MSSQL_container@2"
867+
},
868+
{
869+
"command": "mssql.startContainer",
870+
"when": "view == objectExplorer && viewItem =~ /\\bsubType=(disconnectedDockerContainer|DockerContainerDatabase)\\b/",
871+
"group": "9_MSSQL_container@3"
872+
},
858873
{
859874
"command": "mssql.openBackgroundTask",
860875
"when": "view == backgroundTasks && viewItem =~ /\\bactionable=true\\b/",
861876
"group": "MS_SQL@1"
862877
},
863878
{
864-
"command": "mssql.cancelBackgroundTask",
865-
"when": "view == backgroundTasks && viewItem =~ /\\bcancelable=true\\b/",
879+
"command": "mssql.viewBackgroundTaskLogs",
880+
"when": "view == backgroundTasks && viewItem =~ /\\bbackgroundTaskNode\\b/",
866881
"group": "MS_SQL@2"
867882
},
868883
{
869884
"command": "mssql.cancelBackgroundTask",
870885
"when": "view == backgroundTasks && viewItem =~ /\\bcancelable=true\\b/",
871-
"group": "inline@1"
886+
"group": "MS_SQL@3"
872887
},
873888
{
874-
"command": "mssql.stopContainer",
875-
"when": "view == objectExplorer && viewItem =~ /\\bsubType=(DockerContainer|DockerContainerDatabase)\\b/",
876-
"group": "9_MSSQL_container@1"
889+
"command": "mssql.openBackgroundTask",
890+
"when": "view == backgroundTasks && viewItem =~ /\\bactionable=true\\b/",
891+
"group": "inline@1"
877892
},
878893
{
879-
"command": "mssql.deleteContainer",
880-
"when": "view == objectExplorer && viewItem =~ /\\bsubType=(DockerContainer|disconnectedDockerContainer|DockerContainerDatabase)\\b/",
881-
"group": "9_MSSQL_container@2"
894+
"command": "mssql.viewBackgroundTaskLogs",
895+
"when": "view == backgroundTasks && viewItem =~ /\\bbackgroundTaskNode\\b/",
896+
"group": "inline@2"
882897
},
883898
{
884-
"command": "mssql.startContainer",
885-
"when": "view == objectExplorer && viewItem =~ /\\bsubType=(disconnectedDockerContainer|DockerContainerDatabase)\\b/",
886-
"group": "9_MSSQL_container@3"
899+
"command": "mssql.cancelBackgroundTask",
900+
"when": "view == backgroundTasks && viewItem =~ /\\bcancelable=true\\b/",
901+
"group": "inline@3"
887902
}
888903
],
889904
"commandPalette": [
905+
{
906+
"command": "mssql.viewBackgroundTaskLogs",
907+
"when": "false"
908+
},
890909
{
891910
"command": "mssql.runQueryWithUriOwnership",
892911
"when": "false"
@@ -1371,7 +1390,14 @@
13711390
{
13721391
"command": "mssql.openBackgroundTask",
13731392
"title": "%mssql.openBackgroundTask%",
1374-
"category": "MS SQL"
1393+
"category": "MS SQL",
1394+
"icon": "$(go-to-file)"
1395+
},
1396+
{
1397+
"command": "mssql.viewBackgroundTaskLogs",
1398+
"title": "%mssql.viewBackgroundTaskLogs%",
1399+
"category": "MS SQL",
1400+
"icon": "$(output)"
13751401
},
13761402
{
13771403
"command": "mssql.cancelBackgroundTask",

extensions/mssql/package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"mssql.clearAllQueryHistory": "Clear All Query History",
2828
"mssql.clearFinishedBackgroundTasks": "Clear Finished Tasks",
2929
"mssql.openBackgroundTask": "Open Task Result",
30+
"mssql.viewBackgroundTaskLogs": "View Task Logs",
3031
"mssql.cancelBackgroundTask": "Cancel Task",
3132
"mssql.enableQueryHistoryCapture": "Enable Query History Capture",
3233
"mssql.startQueryHistoryCapture": "Start Query History Capture",

0 commit comments

Comments
 (0)