How to use the vscode-azureextensionui.DialogResponses.deleteResponse 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-azuretools / appservice / src / deleteSite.ts View on Github external
export async function deleteSite(client: SiteClient): Promise {
    const confirmMessage: string = localize('deleteConfirmation', 'Are you sure you want to delete "{0}"?', client.fullName);
    await ext.ui.showWarningMessage(confirmMessage, { modal: true }, DialogResponses.deleteResponse, DialogResponses.cancel);

    let plan: AppServicePlan | undefined;
    let deletePlan: boolean = false;

    if (!client.isSlot) {
        // API calls not necessary for deployment slots
        plan = await client.getAppServicePlan();
    }

    if (!client.isSlot && plan && !isNullOrUndefined(plan.numberOfSites) && plan.numberOfSites < 2) {
        const message: string = localize('deleteLastServicePlan', 'This is the last app in the App Service plan "{0}". Do you want to delete this App Service plan to prevent unexpected charges?', plan.name);
        const input: vscode.MessageItem = await ext.ui.showWarningMessage(message, { modal: true }, DialogResponses.yes, DialogResponses.no, DialogResponses.cancel);
        deletePlan = input === DialogResponses.yes;
    }

    const deleting: string = localize('Deleting', 'Deleting "{0}"...', client.fullName);
github microsoft / vscode-cosmosdb / src / docdb / tree / DocDBDocumentTreeItem.ts View on Github external
public async deleteTreeItem(_node: IAzureNode): Promise {
        const message: string = `Are you sure you want to delete document '${this.label}'?`;
        const result = await vscode.window.showWarningMessage(message, { modal: true }, DialogResponses.deleteResponse, DialogResponses.cancel);
        if (result === DialogResponses.deleteResponse) {
            const client = this._collection.getDocumentClient();
            const options = { partitionKey: this.partitionKeyValue }
            await new Promise((resolve, reject) => {
                client.deleteDocument(this.link, options, function (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();
        }
    }
github microsoft / vscode-cosmosdb / src / docdb / tree / DocDBDocumentTreeItem.ts View on Github external
public async deleteTreeItem(_node: IAzureNode): Promise {
        const message: string = `Are you sure you want to delete document '${this.label}'?`;
        const result = await vscode.window.showWarningMessage(message, { modal: true }, DialogResponses.deleteResponse, DialogResponses.cancel);
        if (result === DialogResponses.deleteResponse) {
            const client = this._collection.getDocumentClient();
            const options = { partitionKey: this.partitionKeyValue }
            await new Promise((resolve, reject) => {
                client.deleteDocument(this.link, options, function (err) {
                    err ? reject(err) : resolve();
                });
            });
        } 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 / 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();
        }
    }
}