#228: Add confirmation prompt when deleting resource (#233)

This commit is contained in:
Jun Han 2018-12-25 16:48:29 +08:00 коммит произвёл GitHub
Родитель 533fcef50b
Коммит 976d54af29
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 12 добавлений и 2 удалений

Просмотреть файл

@ -89,10 +89,12 @@ export class Constants {
public static IoTHubAIDeleteModuleDoneEvent = "AZ.Module.Delete.Done";
public static IoTHubAIGetModuleStartEvent = "AZ.Module.Get.Start";
public static IoTHubAIDGetModuleDoneEvent = "AZ.Module.Get.Done";
public static IoTHubAIStartLoadDeviceTreeEvent = "General.StartLoadDeviceTree";
public static IoTHubAIShowWelcomePagetEvent = "General.WelcomePage.Show";
public static DeleteLabel = "Delete";
public static DeleteMessage = "Are you sure you want to delete";
public static ConnectionStringFormat = {
[Constants.IotHubConnectionStringKey]: "HostName=<my-hostname>;SharedAccessKeyName=<my-policy>;SharedAccessKey=<my-policy-key>",
[Constants.DeviceConnectionStringKey]: "HostName=<my-hostname>;DeviceId=<known-device-id>;SharedAccessKey=<known-device-key>",

Просмотреть файл

@ -101,7 +101,10 @@ export class DeviceExplorer extends BaseExplorer {
deviceItem = await Utility.getInputDevice(deviceItem, "AZ.Device.Delete.Start");
if (deviceItem && deviceItem.label) {
return this.deleteDeviceById(deviceItem.label, label, registry);
const result = await vscode.window.showWarningMessage(`${Constants.DeleteMessage} "${deviceItem.label}"?`, { modal: true }, Constants.DeleteLabel);
if (result === Constants.DeleteLabel) {
return this.deleteDeviceById(deviceItem.label, label, registry);
}
}
}

Просмотреть файл

@ -91,6 +91,11 @@ export class IotHubModuleExplorer extends BaseExplorer {
return;
}
const result = await vscode.window.showWarningMessage(`${Constants.DeleteMessage} "${moduleItem.moduleId}"?`, { modal: true }, Constants.DeleteLabel);
if (result !== Constants.DeleteLabel) {
return;
}
const registry: iothub.Registry = iothub.Registry.fromConnectionString(iotHubConnectionString);
this._outputChannel.show();