Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
const deleteSucceeded: string = localize('DeleteSucceeded', 'Successfully deleted "{0}".', client.fullName);
await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, title: deleting }, async (): Promise => {
ext.outputChannel.appendLog(deleting);
await client.deleteMethod({ deleteEmptyServerFarm: deletePlan });
vscode.window.showInformationMessage(deleteSucceeded);
ext.outputChannel.appendLog(deleteSucceeded);
});
}
let preserveFocus: boolean = false;
if (options && options.showInNextColumn) {
preserveFocus = true;
const activeEditor = vscode.window.activeTextEditor;
if (activeEditor && activeEditor.viewColumn >= vscode.ViewColumn.One) {
column = activeEditor.viewColumn < ViewColumn.Three ? activeEditor.viewColumn + 1 : ViewColumn.One;
}
}
const localFilename = fileName.replace(/[<>:"\/\\|?*]/g, "-");
const localDocPath = path.join(os.tmpdir(), 'vscode-cosmosdb-editor', localFilename);
await fse.ensureFile(localDocPath);
const document = await vscode.workspace.openTextDocument(localDocPath);
if (document.isDirty) {
const overwriteFlag = await vscode.window.showWarningMessage(`You are about to overwrite "${fileName}", which has unsaved changes. Do you want to continue?`, { modal: true }, DialogResponses.yes, DialogResponses.cancel);
if (overwriteFlag !== DialogResponses.yes) {
throw new UserCancelledError();
}
}
this.fileMap[localDocPath] = editor;
const fileMapLabels = this._globalState.get(this._persistedEditorsKey, {});
Object.keys(this.fileMap).forEach((key) => fileMapLabels[key] = (this.fileMap[key]).id);
this._globalState.update(this._persistedEditorsKey, fileMapLabels);
const data = await editor.getData(context);
const textEditor = await vscode.window.showTextDocument(document, column, preserveFocus);
await this.updateEditor(data, textEditor, editor);
}
const addedKeys: string[] = [];
const updatedKeys: string[] = [];
const userIgnoredKeys: string[] = [];
const matchingKeys: string[] = [];
for (const key of Object.keys(sourceSettings)) {
if (destinationSettings[key] === undefined) {
addedKeys.push(key);
destinationSettings[key] = sourceSettings[key];
} else if (destinationSettings[key] !== sourceSettings[key]) {
if (!suppressPrompt) {
const yesToAll: MessageItem = { title: localize('yesToAll', 'Yes to all') };
const noToAll: MessageItem = { title: localize('noToAll', 'No to all') };
const message: string = localize('overwriteSetting', 'Setting "{0}" already exists in "{1}". Overwrite?', key, destinationName);
const result: MessageItem = await ext.ui.showWarningMessage(message, { modal: true }, DialogResponses.yes, yesToAll, DialogResponses.no, noToAll);
if (result === DialogResponses.yes) {
overwriteSetting = true;
} else if (result === yesToAll) {
overwriteSetting = true;
suppressPrompt = true;
} else if (result === DialogResponses.no) {
overwriteSetting = false;
} else if (result === noToAll) {
overwriteSetting = false;
suppressPrompt = true;
}
}
if (overwriteSetting) {
updatedKeys.push(key);
destinationSettings[key] = sourceSettings[key];
} else {
if (options && options.showInNextColumn) {
preserveFocus = true;
const activeEditor = vscode.window.activeTextEditor;
if (activeEditor && activeEditor.viewColumn >= vscode.ViewColumn.One) {
column = activeEditor.viewColumn < ViewColumn.Three ? activeEditor.viewColumn + 1 : ViewColumn.One;
}
}
const localFilename = fileName.replace(/[<>:"\/\\|?*]/g, "-");
const localDocPath = path.join(os.tmpdir(), 'vscode-cosmosdb-editor', localFilename);
await fse.ensureFile(localDocPath);
const document = await vscode.workspace.openTextDocument(localDocPath);
if (document.isDirty) {
const overwriteFlag = await vscode.window.showWarningMessage(`You are about to overwrite "${fileName}", which has unsaved changes. Do you want to continue?`, { modal: true }, DialogResponses.yes, DialogResponses.cancel);
if (overwriteFlag !== DialogResponses.yes) {
throw new UserCancelledError();
}
}
this.fileMap[localDocPath] = editor;
const fileMapLabels = this._globalState.get(this._persistedEditorsKey, {});
Object.keys(this.fileMap).forEach((key) => fileMapLabels[key] = (this.fileMap[key]).id);
this._globalState.update(this._persistedEditorsKey, fileMapLabels);
const data = await editor.getData(context);
const textEditor = await vscode.window.showTextDocument(document, column, preserveFocus);
await this.updateEditor(data, textEditor, editor);
}