Allow soft-deleting certificate paths from settings.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -466,6 +466,27 @@ public sealed class SetupCoordinator
|
||||
return id;
|
||||
}
|
||||
|
||||
public async Task DeactivateCertificateTargetAsync(
|
||||
int certificateTargetId,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
await _setupRepository.DeactivateCertificateTargetAsync(
|
||||
certificateTargetId,
|
||||
cancellationToken);
|
||||
|
||||
bool stillActive =
|
||||
await _setupRepository.ExistsCertificateTargetAsync(
|
||||
certificateTargetId,
|
||||
cancellationToken);
|
||||
|
||||
if (stillActive)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Zertifikat-Pfad Id {certificateTargetId} "
|
||||
+ "konnte nicht deaktiviert werden.");
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task EnsureExistsAsync(
|
||||
Func<Task<bool>> existsCheck,
|
||||
string errorMessage)
|
||||
|
||||
@@ -414,7 +414,9 @@ public sealed class SetupWizardForm : Form
|
||||
"+ Pfad hinzufügen",
|
||||
async () => await AddPathAsync(),
|
||||
"Pfad prüfen",
|
||||
async () => await ProbeSelectedPathAsync());
|
||||
async () => await ProbeSelectedPathAsync(),
|
||||
"Pfad löschen",
|
||||
async () => await DeleteSelectedPathAsync());
|
||||
|
||||
_lvPaths = SettingsUi.CreateListView();
|
||||
_lvPaths.Dock = DockStyle.Fill;
|
||||
@@ -432,7 +434,9 @@ public sealed class SetupWizardForm : Form
|
||||
string addButtonText,
|
||||
Func<Task> onAdd,
|
||||
string? secondaryText = null,
|
||||
Func<Task>? onSecondary = null)
|
||||
Func<Task>? onSecondary = null,
|
||||
string? tertiaryText = null,
|
||||
Func<Task>? onTertiary = null)
|
||||
{
|
||||
Panel toolbar = new()
|
||||
{
|
||||
@@ -447,6 +451,16 @@ public sealed class SetupWizardForm : Form
|
||||
add.Width = 230;
|
||||
add.Click += async (_, _) => await onAdd();
|
||||
|
||||
if (tertiaryText is not null && onTertiary is not null)
|
||||
{
|
||||
Button tertiary = SettingsUi.CreateGhostButton(tertiaryText);
|
||||
tertiary.Dock = DockStyle.Left;
|
||||
tertiary.Width = 140;
|
||||
tertiary.Margin = new Padding(8, 0, 0, 0);
|
||||
tertiary.Click += async (_, _) => await onTertiary();
|
||||
toolbar.Controls.Add(tertiary);
|
||||
}
|
||||
|
||||
if (secondaryText is not null && onSecondary is not null)
|
||||
{
|
||||
Button secondary = SettingsUi.CreateGhostButton(secondaryText);
|
||||
@@ -927,6 +941,56 @@ public sealed class SetupWizardForm : Form
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
private async Task DeleteSelectedPathAsync()
|
||||
{
|
||||
if (_lvPaths.SelectedItems.Count == 0
|
||||
|| _lvPaths.SelectedItems[0].Tag is not CertificateTargetOption target)
|
||||
{
|
||||
MessageBox.Show(
|
||||
this,
|
||||
"Bitte zuerst einen Zertifikat-Pfad in der Liste wählen.",
|
||||
"Pfad löschen",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
|
||||
DialogResult confirm = MessageBox.Show(
|
||||
this,
|
||||
"Zertifikat-Pfad wirklich aus der Konfiguration entfernen?\n\n"
|
||||
+ $"{target.FullTargetPath}\n\n"
|
||||
+ "Die Datei auf dem Server bleibt unverändert. "
|
||||
+ "Der Eintrag wird in SQL nur deaktiviert (IsActive=0).",
|
||||
"Pfad löschen",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Warning);
|
||||
|
||||
if (confirm != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await _coordinator.DeactivateCertificateTargetAsync(
|
||||
target.CertificateTargetId);
|
||||
|
||||
await LoadPathsListAsync();
|
||||
await RefreshAllAsync();
|
||||
|
||||
MessageBox.Show(
|
||||
this,
|
||||
$"Pfad Id {target.CertificateTargetId} wurde deaktiviert.",
|
||||
"Pfad gelöscht",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowError(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SelectListItem(
|
||||
ListView listView,
|
||||
Func<ListViewItem, bool> match)
|
||||
|
||||
Reference in New Issue
Block a user