Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended 'Accidental Deletion Prevention' Verification #721

Merged
merged 3 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/ServiceBusExplorer/Controls/HandleConsumerGroupControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/ServiceBusExplorer/Controls/HandleEventHubControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/ServiceBusExplorer/Controls/HandleNotificationHubControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions src/ServiceBusExplorer/Controls/HandleQueueControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/ServiceBusExplorer/Controls/HandleRelayControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/ServiceBusExplorer/Controls/HandleRuleControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/ServiceBusExplorer/Controls/HandleSubscriptionControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/ServiceBusExplorer/Controls/HandleTopicControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
35 changes: 35 additions & 0 deletions src/ServiceBusExplorer/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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);
Expand Down Expand Up @@ -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<UserControl>())
{
Expand Down