1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-05 10:03:21 +00:00

[AC-1218] Add ability to delete Provider Portals (#8685)

* initial commit

* add changes from running prettier

* resolve the linx issue

* resolve the lint issue

* resolving lint error

* correct the redirect issue

* resolve pr commit

* Add a feature flag

* move the new component to adminconsole

* resolve some pr comments

* move the endpoint from ApiService to providerApiService

* move provider endpoints to the provider-api class

* change the header

* resolve some pr comments
This commit is contained in:
cyprain-okeke
2024-04-17 14:07:26 +01:00
committed by GitHub
parent 4db383850f
commit a72b7f3d21
18 changed files with 359 additions and 83 deletions

View File

@@ -0,0 +1,34 @@
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise" class="container" ngNativeValidate>
<div class="row justify-content-md-center mt-5">
<div class="col-5">
<p class="lead text-center mb-4">{{ "deleteProvider" | i18n }}</p>
<div class="card">
<div class="card-body">
<app-callout type="warning">{{ "deleteProviderWarning" | i18n }}</app-callout>
<p class="text-center">
<strong>{{ name }}</strong>
</p>
<p>{{ "deleteProviderRecoverConfirmDesc" | i18n }}</p>
<hr />
<div class="d-flex">
<button
type="submit"
class="btn btn-danger btn-block btn-submit"
[disabled]="form.loading"
>
<span>{{ "deleteProvider" | i18n }}</span>
<i
class="bwi bwi-spinner bwi-spin"
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
</button>
<a routerLink="/login" class="btn btn-outline-secondary btn-block ml-2 mt-0">
{{ "cancel" | i18n }}
</a>
</div>
</div>
</div>
</div>
</div>
</form>

View File

@@ -0,0 +1,61 @@
import { Component, OnInit } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { firstValueFrom } from "rxjs";
import { ProviderApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/provider/provider-api.service.abstraction";
import { ProviderVerifyRecoverDeleteRequest } from "@bitwarden/common/admin-console/models/request/provider/provider-verify-recover-delete.request";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
@Component({
selector: "app-verify-recover-delete-provider",
templateUrl: "verify-recover-delete-provider.component.html",
})
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class VerifyRecoverDeleteProviderComponent implements OnInit {
name: string;
formPromise: Promise<any>;
private providerId: string;
private token: string;
constructor(
private router: Router,
private providerApiService: ProviderApiServiceAbstraction,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private route: ActivatedRoute,
private logService: LogService,
) {}
async ngOnInit() {
const qParams = await firstValueFrom(this.route.queryParams);
if (qParams.providerId != null && qParams.token != null && qParams.name != null) {
this.providerId = qParams.providerId;
this.token = qParams.token;
this.name = qParams.name;
} else {
await this.router.navigate(["/"]);
}
}
async submit() {
try {
const request = new ProviderVerifyRecoverDeleteRequest(this.token);
this.formPromise = this.providerApiService.providerRecoverDeleteToken(
this.providerId,
request,
);
await this.formPromise;
this.platformUtilsService.showToast(
"success",
this.i18nService.t("providerDeleted"),
this.i18nService.t("providerDeletedDesc"),
);
await this.router.navigate(["/"]);
} catch (e) {
this.logService.error(e);
}
}
}