[EC-650] Revert observable usage from ImportComponent (#4010)
This commit is contained in:
parent
6851f406ef
commit
aac33d32b8
|
@ -1,7 +1,7 @@
|
|||
<div class="page-header">
|
||||
<h1>{{ "importData" | i18n }}</h1>
|
||||
</div>
|
||||
<app-callout type="info" *ngIf="importBlockedByPolicy$ | async">
|
||||
<app-callout type="info" *ngIf="importBlockedByPolicy">
|
||||
{{ "personalOwnershipPolicyInEffectImports" | i18n }}
|
||||
</app-callout>
|
||||
<form #form (ngSubmit)="submit()" ngNativeValidate>
|
||||
|
@ -14,7 +14,7 @@
|
|||
name="Format"
|
||||
[(ngModel)]="format"
|
||||
class="form-control"
|
||||
[disabled]="importBlockedByPolicy$ | async"
|
||||
[disabled]="importBlockedByPolicy"
|
||||
required
|
||||
>
|
||||
<option *ngFor="let o of featuredImportOptions" [ngValue]="o.id">{{ o.name }}</option>
|
||||
|
@ -296,7 +296,7 @@
|
|||
id="file"
|
||||
class="form-control-file"
|
||||
name="file"
|
||||
[disabled]="importBlockedByPolicy$ | async"
|
||||
[disabled]="importBlockedByPolicy"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -308,14 +308,14 @@
|
|||
class="form-control"
|
||||
name="FileContents"
|
||||
[(ngModel)]="fileContents"
|
||||
[disabled]="importBlockedByPolicy$ | async"
|
||||
[disabled]="importBlockedByPolicy"
|
||||
></textarea>
|
||||
</div>
|
||||
<button
|
||||
type="submit"
|
||||
class="btn btn-primary btn-submit"
|
||||
[disabled]="loading || (importBlockedByPolicy$ | async)"
|
||||
[ngClass]="{ manual: importBlockedByPolicy$ | async }"
|
||||
[disabled]="loading || importBlockedByPolicy"
|
||||
[ngClass]="{ manual: importBlockedByPolicy }"
|
||||
>
|
||||
<i class="bwi bwi-spinner bwi-spin" title="{{ 'loading' | i18n }}" aria-hidden="true"></i>
|
||||
<span>{{ "importData" | i18n }}</span>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Component, OnDestroy, OnInit } from "@angular/core";
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { Router } from "@angular/router";
|
||||
import * as JSZip from "jszip";
|
||||
import { firstValueFrom, Subject } from "rxjs";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
import Swal, { SweetAlertIcon } from "sweetalert2";
|
||||
|
||||
import { ModalService } from "@bitwarden/angular/services/modal.service";
|
||||
|
@ -20,22 +20,18 @@ import { FilePasswordPromptComponent } from "./file-password-prompt.component";
|
|||
selector: "app-import",
|
||||
templateUrl: "import.component.html",
|
||||
})
|
||||
export class ImportComponent implements OnInit, OnDestroy {
|
||||
export class ImportComponent implements OnInit {
|
||||
featuredImportOptions: ImportOption[];
|
||||
importOptions: ImportOption[];
|
||||
format: ImportType = null;
|
||||
fileContents: string;
|
||||
formPromise: Promise<ImportError>;
|
||||
loading = false;
|
||||
importBlockedByPolicy$ = this.policyService.policyAppliesToActiveUser$(
|
||||
PolicyType.PersonalOwnership
|
||||
);
|
||||
importBlockedByPolicy = false;
|
||||
|
||||
protected organizationId: string = null;
|
||||
protected successNavigate: any[] = ["vault"];
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
constructor(
|
||||
protected i18nService: I18nService,
|
||||
protected importService: ImportService,
|
||||
|
@ -48,15 +44,14 @@ export class ImportComponent implements OnInit, OnDestroy {
|
|||
|
||||
async ngOnInit() {
|
||||
this.setImportOptions();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
this.importBlockedByPolicy = await firstValueFrom(
|
||||
this.policyService.policyAppliesToActiveUser$(PolicyType.PersonalOwnership)
|
||||
);
|
||||
}
|
||||
|
||||
async submit() {
|
||||
if (await firstValueFrom(this.importBlockedByPolicy$)) {
|
||||
if (this.importBlockedByPolicy) {
|
||||
this.platformUtilsService.showToast(
|
||||
"error",
|
||||
null,
|
||||
|
|
Loading…
Reference in New Issue