How to use the vscode-azureextensionui.DialogResponses.cancel function in vscode-azureextensionui

To help you get started, we’ve selected a few vscode-azureextensionui examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / vscode-cosmosdb / src / commands / deleteCosmosDBAccount.ts View on Github external
export async function deleteCosmosDBAccount(node: AzureTreeItem): Promise {
    const message: string = `Are you sure you want to delete account '${node.label}' and its contents?`;
    const result = await ext.ui.showWarningMessage(message, { modal: true }, DialogResponses.deleteResponse, DialogResponses.cancel);
    if (result === DialogResponses.deleteResponse) {
        const client: CosmosDBManagementClient = createAzureClient(node.root, CosmosDBManagementClient);
        const resourceGroup: string = azureUtils.getResourceGroupFromId(node.fullId);
        const accountName: string = azureUtils.getAccountNameFromId(node.fullId);
        const deletingMessage: string = `Deleting account "${accountName}"...`;
        await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, title: deletingMessage }, async () => {
            await client.databaseAccounts.deleteMethod(resourceGroup, accountName);
        });
        // don't wait
        vscode.window.showInformationMessage(`Successfully deleted account "${accountName}".`);
    } else {
        throw new UserCancelledError();
    }
}
github microsoft / vscode-azuretools / appservice / src / deploy / localGitDeploy.ts View on Github external
} catch (err) {
                // tslint:disable-next-line:no-unsafe-any
                if (err.message.indexOf('spawn git ENOENT') >= 0) {
                    const installString: string = localize('Install', 'Install');
                    const input: string | undefined = await vscode.window.showErrorMessage(localize('GitRequired', 'Git must be installed to use Local Git Deploy.'), installString);
                    if (input === installString) {
                        await openUrl('https://git-scm.com/downloads');
                    }
                    context.telemetry.properties.gitNotInstalled = 'true';
                    return undefined;
                    // tslint:disable-next-line:no-unsafe-any
                } else if (err.message.indexOf('error: failed to push') >= 0) {
                    const forcePushMessage: vscode.MessageItem = { title: localize('forcePush', 'Force Push') };
                    const pushReject: string = localize('localGitPush', 'Push rejected due to Git history diverging.');

                    if (await ext.ui.showWarningMessage(pushReject, { modal: true }, forcePushMessage, DialogResponses.cancel) === forcePushMessage) {
                        context.telemetry.properties.forcePush = 'true';
                        await tryPushAndWaitForDeploymentToComplete(true);
                    } else {
                        context.telemetry.properties.cancelStep = 'forcePush';
                        throw new UserCancelledError();
                    }
                } else {
                    throw err;
                }
            }

            async function tryPushAndWaitForDeploymentToComplete(forcePush: boolean = false): Promise {
                const tokenSource: vscode.CancellationTokenSource = new vscode.CancellationTokenSource();
                const token: vscode.CancellationToken = tokenSource.token;
                try {
                    await new Promise((resolve: () => void, reject: (error: Error) => void): void => {
github microsoft / vscode-cosmosdb / src / docdb / tree / DocDBDatabaseTreeItemBase.ts View on Github external
public async deleteTreeItemImpl(): Promise {
        const message: string = `Are you sure you want to delete database '${this.label}' and its contents?`;
        const result = await vscode.window.showWarningMessage(message, { modal: true }, DialogResponses.deleteResponse, DialogResponses.cancel);
        if (result === DialogResponses.deleteResponse) {
            const client = this.root.getDocumentClient();
            await new Promise((resolve, reject) => {
                client.deleteDatabase(this.link, err => err ? reject(err) : resolve());
            });
        } else {
            throw new UserCancelledError();
        }
    }
github microsoft / vscode-cosmosdb / src / docdb / tree / DocDBStoredProcedureTreeItem.ts View on Github external
public async deleteTreeItemImpl(): Promise {
        const message: string = `Are you sure you want to delete stored procedure '${this.label}'?`;
        const result = await vscode.window.showWarningMessage(message, { modal: true }, DialogResponses.deleteResponse, DialogResponses.cancel);
        if (result === DialogResponses.deleteResponse) {
            const client = this.root.getDocumentClient();
            await new Promise((resolve, reject) => {
                client.deleteStoredProcedure(this.link, err => err ? reject(err) : resolve());
            });
        } else {
            throw new UserCancelledError();
        }
    }
}
github microsoft / vscode-cosmosdb / src / mongo / tree / MongoDatabaseTreeItem.ts View on Github external
public async deleteTreeItemImpl(): Promise {
		const message: string = `Are you sure you want to delete database '${this.label}'?`;
		const result = await vscode.window.showWarningMessage(message, { modal: true }, DialogResponses.deleteResponse, DialogResponses.cancel);
		if (result === DialogResponses.deleteResponse) {
			const db = await this.connectToDb();
			await db.dropDatabase();
		} else {
			throw new UserCancelledError();
		}
	}
github microsoft / vscode-cosmosdb / src / docdb / tree / DocDBCollectionTreeItem.ts View on Github external
public async deleteTreeItemImpl(): Promise {
        const message: string = `Are you sure you want to delete collection '${this.label}' and its contents?`;
        const result = await vscode.window.showWarningMessage(message, { modal: true }, DialogResponses.deleteResponse, DialogResponses.cancel);
        if (result === DialogResponses.deleteResponse) {
            const client = this.root.getDocumentClient();
            await new Promise((resolve, reject) => {
                client.deleteCollection(this.link, err => err ? reject(err) : resolve());
            });
        } else {
            throw new UserCancelledError();
        }
    }
github microsoft / vscode-cosmosdb / src / graph / tree / GraphCollectionTreeItem.ts View on Github external
public async deleteTreeItemImpl(): Promise {
        const message: string = `Are you sure you want to delete graph '${this.label}' and its contents?`;
        const result = await vscode.window.showWarningMessage(message, { modal: true }, DialogResponses.deleteResponse, DialogResponses.cancel);
        if (result === DialogResponses.deleteResponse) {
            const client = this.root.getDocumentClient();
            await new Promise((resolve, reject) => {
                client.deleteCollection(this.link, err => err ? reject(err) : resolve());
            });
        } else {
            throw new UserCancelledError();
        }
    }
github microsoft / vscode-cosmosdb / src / mongo / tree / MongoDocumentTreeItem.ts View on Github external
public async deleteTreeItemImpl(): Promise {
        const message: string = `Are you sure you want to delete document '${this._label}'?`;
        const dialogResult = await vscode.window.showWarningMessage(message, { modal: true }, DialogResponses.deleteResponse, DialogResponses.cancel);
        if (dialogResult === DialogResponses.deleteResponse) {
            const deleteResult: DeleteWriteOpResultObject = await this.parent.collection.deleteOne({ "_id": this.document._id });
            if (deleteResult.deletedCount !== 1) {
                throw new Error(`Failed to delete document with _id '${this.document._id}'.`);
            }
        } else {
            throw new UserCancelledError();
        }
    }