diff --git a/src/ServiceBusExplorer/Controls/HandleConsumerGroupControl.cs b/src/ServiceBusExplorer/Controls/HandleConsumerGroupControl.cs index 7d8f888d..46dd1b85 100644 --- a/src/ServiceBusExplorer/Controls/HandleConsumerGroupControl.cs +++ b/src/ServiceBusExplorer/Controls/HandleConsumerGroupControl.cs @@ -334,6 +334,17 @@ private void btnCreateDelete_Click(object sender, EventArgs e) { using (var deleteForm = new DeleteForm(consumerGroupDescription.Name, ConsumerGroupEntity.ToLower())) { + var configuration = TwoFilesConfiguration.Create(TwoFilesConfiguration.GetCurrentConfigFileUse(), writeToLog); + + bool disableAccidentalDeletionPrevention = configuration.GetBoolValue( + ConfigurationParameters.DisableAccidentalDeletionPrevention, + defaultValue: false); + + if (!disableAccidentalDeletionPrevention) + { + deleteForm.ShowAccidentalDeletionPreventionCheck(configuration, $"Delete {consumerGroupDescription.Name} {ConsumerGroupEntity.ToLower()}"); + } + if (deleteForm.ShowDialog() == DialogResult.OK) { serviceBusHelper.DeleteConsumerGroup(consumerGroupDescription); diff --git a/src/ServiceBusExplorer/Controls/HandleEventHubControl.cs b/src/ServiceBusExplorer/Controls/HandleEventHubControl.cs index 47cd8049..49f02f99 100644 --- a/src/ServiceBusExplorer/Controls/HandleEventHubControl.cs +++ b/src/ServiceBusExplorer/Controls/HandleEventHubControl.cs @@ -334,6 +334,17 @@ private void btnCreateDelete_Click(object sender, EventArgs e) { using (var deleteForm = new DeleteForm(eventHubDescription.Path, EventHubEntity.ToLower())) { + var configuration = TwoFilesConfiguration.Create(TwoFilesConfiguration.GetCurrentConfigFileUse(), writeToLog); + + bool disableAccidentalDeletionPrevention = configuration.GetBoolValue( + ConfigurationParameters.DisableAccidentalDeletionPrevention, + defaultValue: false); + + if (!disableAccidentalDeletionPrevention) + { + deleteForm.ShowAccidentalDeletionPreventionCheck(configuration, $"Delete {eventHubDescription.Path} {EventHubEntity.ToLower()}"); + } + if (deleteForm.ShowDialog() == DialogResult.OK) { serviceBusHelper.DeleteEventHub(eventHubDescription); diff --git a/src/ServiceBusExplorer/Controls/HandleNotificationHubControl.cs b/src/ServiceBusExplorer/Controls/HandleNotificationHubControl.cs index ab100a92..702ee398 100644 --- a/src/ServiceBusExplorer/Controls/HandleNotificationHubControl.cs +++ b/src/ServiceBusExplorer/Controls/HandleNotificationHubControl.cs @@ -2010,6 +2010,17 @@ private async void btnCreateDelete_Click(object sender, EventArgs e) { using (var deleteForm = new DeleteForm(notificationHubDescription.Path, NotificationHubEntity.ToLower())) { + var configuration = TwoFilesConfiguration.Create(TwoFilesConfiguration.GetCurrentConfigFileUse(), writeToLog); + + bool disableAccidentalDeletionPrevention = configuration.GetBoolValue( + ConfigurationParameters.DisableAccidentalDeletionPrevention, + defaultValue: false); + + if (!disableAccidentalDeletionPrevention) + { + deleteForm.ShowAccidentalDeletionPreventionCheck(configuration, $"Delete {notificationHubDescription.Path} {NotificationHubEntity.ToLower()}"); + } + if (deleteForm.ShowDialog() == DialogResult.OK) { await serviceBusHelper.DeleteNotificationHub(notificationHubDescription); diff --git a/src/ServiceBusExplorer/Controls/HandleQueueControl.cs b/src/ServiceBusExplorer/Controls/HandleQueueControl.cs index 711cc116..50ed554e 100644 --- a/src/ServiceBusExplorer/Controls/HandleQueueControl.cs +++ b/src/ServiceBusExplorer/Controls/HandleQueueControl.cs @@ -35,6 +35,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Configuration; using System.Diagnostics; using System.Drawing; using System.Globalization; @@ -2004,6 +2005,17 @@ private async void btnCreateDelete_Click(object sender, EventArgs e) { using (var deleteForm = new DeleteForm(queueDescription.Path, QueueEntity.ToLower())) { + var configuration = TwoFilesConfiguration.Create(TwoFilesConfiguration.GetCurrentConfigFileUse(), writeToLog); + + bool disableAccidentalDeletionPrevention = configuration.GetBoolValue( + ConfigurationParameters.DisableAccidentalDeletionPrevention, + defaultValue: false); + + if (!disableAccidentalDeletionPrevention) + { + deleteForm.ShowAccidentalDeletionPreventionCheck(configuration, $"Delete {queueDescription.Path} {QueueEntity.ToLower()}"); + } + if (deleteForm.ShowDialog() == DialogResult.OK) { await serviceBusHelper.DeleteQueue(queueDescription); diff --git a/src/ServiceBusExplorer/Controls/HandleRelayControl.cs b/src/ServiceBusExplorer/Controls/HandleRelayControl.cs index 8f5d2029..4fa8cd07 100644 --- a/src/ServiceBusExplorer/Controls/HandleRelayControl.cs +++ b/src/ServiceBusExplorer/Controls/HandleRelayControl.cs @@ -410,6 +410,17 @@ private async void btnCreateDelete_Click(object sender, EventArgs e) { using (var deleteForm = new DeleteForm(relayDescription.Path, RelayEntity.ToLower())) { + var configuration = TwoFilesConfiguration.Create(TwoFilesConfiguration.GetCurrentConfigFileUse(), writeToLog); + + bool disableAccidentalDeletionPrevention = configuration.GetBoolValue( + ConfigurationParameters.DisableAccidentalDeletionPrevention, + defaultValue: false); + + if (!disableAccidentalDeletionPrevention) + { + deleteForm.ShowAccidentalDeletionPreventionCheck(configuration, $"Delete {relayDescription.Path} {RelayEntity.ToLower()}"); + } + if (deleteForm.ShowDialog() == DialogResult.OK) { await serviceBusHelper.NamespaceManager.DeleteRelayAsync(relayDescription.Path); diff --git a/src/ServiceBusExplorer/Controls/HandleRuleControl.cs b/src/ServiceBusExplorer/Controls/HandleRuleControl.cs index 269cf14f..abe84a46 100644 --- a/src/ServiceBusExplorer/Controls/HandleRuleControl.cs +++ b/src/ServiceBusExplorer/Controls/HandleRuleControl.cs @@ -250,6 +250,17 @@ void btnCreateDelete_Click(object sender, EventArgs e) { using (var deleteForm = new DeleteForm(ruleWrapper.RuleDescription.Name, RuleEntity.ToLower())) { + var configuration = TwoFilesConfiguration.Create(TwoFilesConfiguration.GetCurrentConfigFileUse(), writeToLog); + + bool disableAccidentalDeletionPrevention = configuration.GetBoolValue( + ConfigurationParameters.DisableAccidentalDeletionPrevention, + defaultValue: false); + + if (!disableAccidentalDeletionPrevention) + { + deleteForm.ShowAccidentalDeletionPreventionCheck(configuration, $"Delete {ruleWrapper.RuleDescription.Name} {RuleEntity.ToLower()}"); + } + if (deleteForm.ShowDialog() == DialogResult.OK) { serviceBusHelper.RemoveRule(ruleWrapper.SubscriptionDescription, ruleWrapper.RuleDescription); diff --git a/src/ServiceBusExplorer/Controls/HandleSubscriptionControl.cs b/src/ServiceBusExplorer/Controls/HandleSubscriptionControl.cs index 24b1ba20..c1c5c1fd 100644 --- a/src/ServiceBusExplorer/Controls/HandleSubscriptionControl.cs +++ b/src/ServiceBusExplorer/Controls/HandleSubscriptionControl.cs @@ -1345,6 +1345,17 @@ private async void btnCreateDelete_Click(object sender, EventArgs e) { using (var deleteForm = new DeleteForm(subscriptionWrapper.SubscriptionDescription.Name, SubscriptionEntity.ToLower())) { + var configuration = TwoFilesConfiguration.Create(TwoFilesConfiguration.GetCurrentConfigFileUse(), writeToLog); + + bool disableAccidentalDeletionPrevention = configuration.GetBoolValue( + ConfigurationParameters.DisableAccidentalDeletionPrevention, + defaultValue: false); + + if (!disableAccidentalDeletionPrevention) + { + deleteForm.ShowAccidentalDeletionPreventionCheck(configuration, $"Delete {subscriptionWrapper.SubscriptionDescription.Name} {SubscriptionEntity.ToLower()}"); + } + if (deleteForm.ShowDialog() == DialogResult.OK) { await serviceBusHelper.DeleteSubscription(subscriptionWrapper.SubscriptionDescription); diff --git a/src/ServiceBusExplorer/Controls/HandleTopicControl.cs b/src/ServiceBusExplorer/Controls/HandleTopicControl.cs index 8123972b..996ae4b5 100644 --- a/src/ServiceBusExplorer/Controls/HandleTopicControl.cs +++ b/src/ServiceBusExplorer/Controls/HandleTopicControl.cs @@ -485,6 +485,17 @@ private async void btnCreateDelete_Click(object sender, EventArgs e) { using (var deleteForm = new DeleteForm(topicDescription.Path, TopicEntity.ToLower())) { + var configuration = TwoFilesConfiguration.Create(TwoFilesConfiguration.GetCurrentConfigFileUse(), writeToLog); + + bool disableAccidentalDeletionPrevention = configuration.GetBoolValue( + ConfigurationParameters.DisableAccidentalDeletionPrevention, + defaultValue: false); + + if (!disableAccidentalDeletionPrevention) + { + deleteForm.ShowAccidentalDeletionPreventionCheck(configuration, $"Delete {topicDescription.Path} {TopicEntity.ToLower()}"); + } + if (deleteForm.ShowDialog() == DialogResult.OK) { await serviceBusHelper.DeleteTopic(topicDescription); diff --git a/src/ServiceBusExplorer/Forms/MainForm.cs b/src/ServiceBusExplorer/Forms/MainForm.cs index 8b5710a4..2c2d3e83 100644 --- a/src/ServiceBusExplorer/Forms/MainForm.cs +++ b/src/ServiceBusExplorer/Forms/MainForm.cs @@ -1947,6 +1947,10 @@ private async void deleteEntity_Click(object sender, EventArgs e) var configuration = TwoFilesConfiguration.Create(configFileUse, WriteToLog); + bool disableAccidentalDeletionPrevention = configuration.GetBoolValue( + ConfigurationParameters.DisableAccidentalDeletionPrevention, + defaultValue: false); + // Root Node if (serviceBusTreeView.SelectedNode == rootNode) { @@ -2139,6 +2143,11 @@ private async void deleteEntity_Click(object sender, EventArgs e) { using (var deleteForm = new DeleteForm(queueDescription.Path, QueueEntity.ToLower())) { + if (!disableAccidentalDeletionPrevention) + { + deleteForm.ShowAccidentalDeletionPreventionCheck(configuration, $"Delete {queueDescription.Path} {QueueEntity.ToLower()}"); + } + if (deleteForm.ShowDialog() == DialogResult.OK) { await serviceBusHelper.DeleteQueue(queueDescription); @@ -2164,6 +2173,11 @@ private async void deleteEntity_Click(object sender, EventArgs e) { using (var deleteForm = new DeleteForm(DeleteAllSubscriptions)) { + if (!disableAccidentalDeletionPrevention) + { + deleteForm.ShowAccidentalDeletionPreventionCheck(configuration, $"Delete {subscriptionDescriptions.Count} subscriptions"); + } + if (deleteForm.ShowDialog() == DialogResult.OK) { await serviceBusHelper.DeleteSubscriptions(subscriptionDescriptions); @@ -2178,6 +2192,11 @@ private async void deleteEntity_Click(object sender, EventArgs e) { using (var deleteForm = new DeleteForm(topicDescription.Path, TopicEntity.ToLower())) { + if (!disableAccidentalDeletionPrevention) + { + deleteForm.ShowAccidentalDeletionPreventionCheck(configuration, $"Delete {TopicEntity.ToLower()} {topicDescription.Path}"); + } + if (deleteForm.ShowDialog() == DialogResult.OK) { await serviceBusHelper.DeleteTopic(topicDescription); @@ -2191,6 +2210,11 @@ private async void deleteEntity_Click(object sender, EventArgs e) { using (var deleteForm = new DeleteForm(relayDescription.Path, RelayEntity.ToLower())) { + if (!disableAccidentalDeletionPrevention) + { + deleteForm.ShowAccidentalDeletionPreventionCheck(configuration, $"Delete {RelayEntity.ToLower()} {relayDescription.Path}"); + } + if (deleteForm.ShowDialog() == DialogResult.OK) { await serviceBusHelper.DeleteRelay(relayDescription.Path); @@ -2278,6 +2302,11 @@ private async void deleteEntity_Click(object sender, EventArgs e) { if (deleteForm.ShowDialog() == DialogResult.OK) { + if (!disableAccidentalDeletionPrevention) + { + deleteForm.ShowAccidentalDeletionPreventionCheck(configuration, $"Delete {subscriptionDescriptions.Count()} subscriptions"); + } + await serviceBusHelper.DeleteSubscriptions(subscriptionDescriptions); } } @@ -2293,6 +2322,11 @@ private async void deleteEntity_Click(object sender, EventArgs e) { using (var deleteForm = new DeleteForm(subscriptionWrapper.SubscriptionDescription.Name, SubscriptionEntity.ToLower())) { + if (!disableAccidentalDeletionPrevention) + { + deleteForm.ShowAccidentalDeletionPreventionCheck(configuration, $"Delete {SubscriptionEntity.ToLower()} {subscriptionWrapper.SubscriptionDescription.Name}"); + } + if (deleteForm.ShowDialog() == DialogResult.OK) { await serviceBusHelper.DeleteSubscription(subscriptionWrapper.SubscriptionDescription); @@ -4691,6 +4725,7 @@ private void ShowQueue(QueueDescription queue, string path, bool duplicateQueue try { + var configuration = TwoFilesConfiguration.Create(configFileUse, WriteToLog); panelMain.SuspendDrawing(); foreach (var userControl in panelMain.Controls.OfType()) {