Skip to content

Commit 7b255cd

Browse files
authored
Feature: Copy-and-Paste: 5. Implement Progress Monitoring and Abort Option (#181)
2 parents c41401b + 55dc7f6 commit 7b255cd

6 files changed

Lines changed: 422 additions & 7 deletions

File tree

l10n/bundle.l10n.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"\"registerAzureUtilsExtensionVariables\" must be called before using the vscode-azext-azureutils package.": "\"registerAzureUtilsExtensionVariables\" must be called before using the vscode-azext-azureutils package.",
77
"\"registerUIExtensionVariables\" must be called before using the vscode-azureextensionui package.": "\"registerUIExtensionVariables\" must be called before using the vscode-azureextensionui package.",
88
"(recently used)": "(recently used)",
9+
"{0} completed successfully": "{0} completed successfully",
10+
"{0} failed: {1}": "{0} failed: {1}",
11+
"{0} was stopped": "{0} was stopped",
912
"{countMany} documents have been deleted.": "{countMany} documents have been deleted.",
1013
"{countOne} document has been deleted.": "{countOne} document has been deleted.",
1114
"{documentCount} documents exported…": "{documentCount} documents exported…",
@@ -19,6 +22,8 @@
1922
"⚠ TLS/SSL Disabled": "⚠ TLS/SSL Disabled",
2023
"✅ **Security:** TLS/SSL Enabled": "✅ **Security:** TLS/SSL Enabled",
2124
"$(add) Create...": "$(add) Create...",
25+
"$(check) Success": "$(check) Success",
26+
"$(error) Failure": "$(error) Failure",
2227
"$(info) Some storage accounts were filtered because of their sku. Learn more...": "$(info) Some storage accounts were filtered because of their sku. Learn more...",
2328
"$(keyboard) Manually enter error": "$(keyboard) Manually enter error",
2429
"$(plus) Create new {0}...": "$(plus) Create new {0}...",
@@ -70,6 +75,7 @@
7075
"Choose a Virtual Machine…": "Choose a Virtual Machine…",
7176
"Choose the data migration provider…": "Choose the data migration provider…",
7277
"Choose the migration action…": "Choose the migration action…",
78+
"Choose whether the task should succeed or fail": "Choose whether the task should succeed or fail",
7379
"Choose your provider…": "Choose your provider…",
7480
"Choose your Service Provider": "Choose your Service Provider",
7581
"Click here to retry": "Click here to retry",
@@ -123,6 +129,8 @@
123129
"Delete database \"{databaseId}\" and its contents?": "Delete database \"{databaseId}\" and its contents?",
124130
"Delete selected document(s)": "Delete selected document(s)",
125131
"Deleting...": "Deleting...",
132+
"Demo Task {0}": "Demo Task {0}",
133+
"Demo Task Configuration": "Demo Task Configuration",
126134
"Disable TLS/SSL (Not recommended)": "Disable TLS/SSL (Not recommended)",
127135
"Disable TLS/SSL checks when connecting.": "Disable TLS/SSL checks when connecting.",
128136
"Do not rely on case to distinguish between databases. For example, you cannot use two databases with names like, salesData and SalesData.": "Do not rely on case to distinguish between databases. For example, you cannot use two databases with names like, salesData and SalesData.",
@@ -370,6 +378,7 @@
370378
"Started executable: \"{command}\". Connecting to host…": "Started executable: \"{command}\". Connecting to host…",
371379
"Starting executable: \"{command}\"": "Starting executable: \"{command}\"",
372380
"Starts with mongodb:// or mongodb+srv://": "Starts with mongodb:// or mongodb+srv://",
381+
"Stopping {0}": "Stopping {0}",
373382
"Stopping task...": "Stopping task...",
374383
"subscription": "subscription",
375384
"Successfully created resource group \"{0}\".": "Successfully created resource group \"{0}\".",
@@ -385,6 +394,9 @@
385394
"Task failed": "Task failed",
386395
"Task is running": "Task is running",
387396
"Task stopped": "Task stopped",
397+
"Task stopped during initialization": "Task stopped during initialization",
398+
"Task will complete successfully": "Task will complete successfully",
399+
"Task will fail at a random step for testing": "Task will fail at a random step for testing",
388400
"Task with ID {0} already exists": "Task with ID {0} already exists",
389401
"Task with ID {0} not found": "Task with ID {0} not found",
390402
"The \"{databaseId}\" database has been deleted.": "The \"{databaseId}\" database has been deleted.",

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,12 @@
315315
"title": "Refresh",
316316
"icon": "$(refresh)"
317317
},
318+
{
319+
"//": "[Testing] Start Demo Task",
320+
"category": "DocumentDB",
321+
"command": "vscode-documentdb.command.testing.startDemoTask",
322+
"title": "Start Demo Task"
323+
},
318324
{
319325
"//": "[DiscoveryView] Enable Registry",
320326
"category": "DocumentDB",

src/documentdb/ClustersExtension.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,17 @@ import { ext } from '../extensionVariables';
4747
import { AzureVMDiscoveryProvider } from '../plugins/service-azure-vm/AzureVMDiscoveryProvider';
4848
import { AzureDiscoveryProvider } from '../plugins/service-azure/AzureDiscoveryProvider';
4949
import { DiscoveryService } from '../services/discoveryServices';
50+
import { TaskReportingService } from '../services/taskReportingService';
51+
import { TaskService } from '../services/taskService';
52+
import { DemoTask } from '../services/tasks/DemoTask';
5053
import { MongoVCoreBranchDataProvider } from '../tree/azure-resources-view/documentdb/mongo-vcore/MongoVCoreBranchDataProvider';
5154
import { ConnectionsBranchDataProvider } from '../tree/connections-view/ConnectionsBranchDataProvider';
5255
import { DiscoveryBranchDataProvider } from '../tree/discovery-view/DiscoveryBranchDataProvider';
5356
import { WorkspaceResourceType } from '../tree/workspace-api/SharedWorkspaceResourceProvider';
5457
import { ClustersWorkspaceBranchDataProvider } from '../tree/workspace-view/documentdb/ClustersWorkbenchBranchDataProvider';
58+
import { Views } from './Views';
5559
import { enableMongoVCoreSupport, enableWorkspaceSupport } from './activationConditions';
5660
import { registerScrapbookCommands } from './scrapbook/registerScrapbookCommands';
57-
import { Views } from './Views';
5861

5962
export class ClustersExtension implements vscode.Disposable {
6063
dispose(): Promise<void> {
@@ -128,6 +131,9 @@ export class ClustersExtension implements vscode.Disposable {
128131
this.registerConnectionsTree(activateContext);
129132
this.registerDiscoveryTree(activateContext);
130133

134+
// Initialize TaskService and TaskReportingService
135+
TaskReportingService.attach(TaskService);
136+
131137
//// General Commands:
132138

133139
registerCommandWithTreeNodeUnwrapping('vscode-documentdb.command.refresh', refreshTreeElement);
@@ -254,6 +260,36 @@ export class ClustersExtension implements vscode.Disposable {
254260
'vscode-documentdb.command.exportDocuments',
255261
exportEntireCollection,
256262
);
263+
264+
// Testing command for DemoTask
265+
registerCommand('vscode-documentdb.command.testing.startDemoTask', async (_context: IActionContext) => {
266+
const failureOptions = [
267+
{
268+
label: vscode.l10n.t('$(check) Success'),
269+
description: vscode.l10n.t('Task will complete successfully'),
270+
shouldFail: false,
271+
},
272+
{
273+
label: vscode.l10n.t('$(error) Failure'),
274+
description: vscode.l10n.t('Task will fail at a random step for testing'),
275+
shouldFail: true,
276+
},
277+
];
278+
279+
const selectedOption = await vscode.window.showQuickPick(failureOptions, {
280+
title: vscode.l10n.t('Demo Task Configuration'),
281+
placeHolder: vscode.l10n.t('Choose whether the task should succeed or fail'),
282+
});
283+
284+
if (!selectedOption) {
285+
return; // User cancelled
286+
}
287+
288+
const task = new DemoTask(vscode.l10n.t('Demo Task {0}', Date.now()), selectedOption.shouldFail);
289+
TaskService.registerTask(task);
290+
void task.start();
291+
});
292+
257293
// This is an optional task - if it fails, we don't want to break extension activation,
258294
// but we should log the error for diagnostics
259295
try {

0 commit comments

Comments
 (0)