Skip to content

[PM-19016] Allow for deletion of pending providers #5679

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

Merged
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
20 changes: 13 additions & 7 deletions src/Admin/AdminConsole/Controllers/ProvidersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,19 @@
[RequirePermission(Permission.Provider_Edit)]
public async Task<IActionResult> Delete(Guid id, string providerName)
{
var provider = await _providerRepository.GetByIdAsync(id);

Check warning on line 473 in src/Admin/AdminConsole/Controllers/ProvidersController.cs

View check run for this annotation

Codecov / codecov/patch

src/Admin/AdminConsole/Controllers/ProvidersController.cs#L473

Added line #L473 was not covered by tests

if (provider is null)
{
return BadRequest("Provider does not exist");

Check warning on line 477 in src/Admin/AdminConsole/Controllers/ProvidersController.cs

View check run for this annotation

Codecov / codecov/patch

src/Admin/AdminConsole/Controllers/ProvidersController.cs#L476-L477

Added lines #L476 - L477 were not covered by tests
}

if (provider.Status == ProviderStatusType.Pending)
{
await _providerService.DeleteAsync(provider);
return NoContent();

Check warning on line 483 in src/Admin/AdminConsole/Controllers/ProvidersController.cs

View check run for this annotation

Codecov / codecov/patch

src/Admin/AdminConsole/Controllers/ProvidersController.cs#L481-L483

Added lines #L481 - L483 were not covered by tests
}

if (string.IsNullOrWhiteSpace(providerName))
{
return BadRequest("Invalid provider name");
Expand All @@ -482,13 +495,6 @@
return BadRequest("You must unlink all clients before you can delete a provider");
}

var provider = await _providerRepository.GetByIdAsync(id);

if (provider is null)
{
return BadRequest("Provider does not exist");
}

if (!string.Equals(providerName.Trim(), provider.DisplayName(), StringComparison.OrdinalIgnoreCase))
{
return BadRequest("Invalid provider name");
Expand Down
34 changes: 23 additions & 11 deletions src/Admin/AdminConsole/Views/Providers/Edit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,29 @@
<div class="p-3">
<h4 class="fw-bolder" id="exampleModalLabel">Delete provider</h4>
</div>
<div class="modal-body">
<span class="fw-light">
This action is permanent and irreversible. Enter the provider name to complete deletion of the provider and associated data.
</span>
<form>
<div class="mb-3">
<label for="provider-name" class="col-form-label">Provider name</label>
<input type="text" class="form-control" id="provider-name">
</div>
</form>
</div>

@if (Model.Provider.Status == ProviderStatusType.Pending)
{

Check warning on line 188 in src/Admin/AdminConsole/Views/Providers/Edit.cshtml

View check run for this annotation

Codecov / codecov/patch

src/Admin/AdminConsole/Views/Providers/Edit.cshtml#L188

Added line #L188 was not covered by tests
<div class="modal-body">
<span class="fw-light">
This action is permanent and irreversible.
</span>
</div>
}

Check warning on line 194 in src/Admin/AdminConsole/Views/Providers/Edit.cshtml

View check run for this annotation

Codecov / codecov/patch

src/Admin/AdminConsole/Views/Providers/Edit.cshtml#L194

Added line #L194 was not covered by tests
else
{
<div class="modal-body">
<span class="fw-light">
This action is permanent and irreversible. Enter the provider name to complete deletion of the provider and associated data.
</span>
<form>
<div class="mb-3">
<label for="provider-name" class="col-form-label">Provider name</label>
<input type="text" class="form-control" id="provider-name">
</div>
</form>
</div>
}

Check warning on line 208 in src/Admin/AdminConsole/Views/Providers/Edit.cshtml

View check run for this annotation

Codecov / codecov/patch

src/Admin/AdminConsole/Views/Providers/Edit.cshtml#L208

Added line #L208 was not covered by tests
<div class="modal-footer">
<button type="button" class="btn btn-outline-primary btn-pill" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger btn-pill" onclick="deleteProvider('@Model.Provider.Id');">Delete provider</button>
Expand Down
Loading