1
0
mirror of https://github.com/bitwarden/directory-connector synced 2025-12-05 23:53:21 +00:00

[AC-1743] pt. 2: Update eslintrc and fix any errors (#393)

* Sync eslintrc with clients repo

* Autofix one eslint error

* Add type attributes to buttons for eslint

* Properly destroy ApiKeyComponent

* Fix eslint issues related to state

* Fix eslint warnings for default named imports

* Ran prettier

* Be more proactive about an unsubscribe

* Rework subscription
This commit is contained in:
Addison Beck
2024-01-04 19:36:19 -06:00
committed by GitHub
parent 95f613d61a
commit eacdb6b8a8
23 changed files with 794 additions and 79 deletions

View File

@@ -1,5 +1,6 @@
import { Component, Input, ViewChild, ViewContainerRef } from "@angular/core";
import { Router } from "@angular/router";
import { takeUntil } from "rxjs";
import { ModalService } from "@/jslib/angular/src/services/modal.service";
import { AuthService } from "@/jslib/common/src/abstractions/auth.service";
@@ -17,6 +18,12 @@ import { EnvironmentComponent } from "./environment.component";
selector: "app-apiKey",
templateUrl: "apiKey.component.html",
})
// There is an eslint exception made here due to semantics.
// The eslint rule expects a typical takeUntil() pattern involving component destruction.
// The only subscription in this component is closed from a child component, confusing eslint.
// https://github.com/cartant/eslint-plugin-rxjs-angular/blob/main/docs/rules/prefer-takeuntil.md
//
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class ApiKeyComponent {
@ViewChild("environment", { read: ViewContainerRef, static: true })
environmentModal: ViewContainerRef;
@@ -87,15 +94,17 @@ export class ApiKeyComponent {
}
async settings() {
const [modalRef, childComponent] = await this.modalService.openViewRef(
const [modalRef, childComponent] = await this.modalService.openViewRef<EnvironmentComponent>(
EnvironmentComponent,
this.environmentModal
);
childComponent.onSaved.subscribe(() => {
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
childComponent.onSaved.pipe(takeUntil(modalRef.onClosed)).subscribe(() => {
modalRef.close();
});
}
toggleSecret() {
this.showSecret = !this.showSecret;
document.getElementById("client_secret").focus();

View File

@@ -16,18 +16,23 @@
<strong *ngIf="!syncRunning" class="text-danger">{{ "stopped" | i18n }}</strong>
</p>
<form #startForm [appApiAction]="startPromise" class="d-inline">
<button (click)="start()" class="btn btn-primary" [disabled]="startForm.loading">
<button
type="button"
(click)="start()"
class="btn btn-primary"
[disabled]="startForm.loading"
>
<i class="bwi bwi-play bwi-fw" [hidden]="startForm.loading"></i>
<i class="bwi bwi-spinner bwi-fw bwi-spin" [hidden]="!startForm.loading"></i>
{{ "startSync" | i18n }}
</button>
</form>
<button (click)="stop()" class="btn btn-primary">
<button type="button" (click)="stop()" class="btn btn-primary">
<i class="bwi bwi-stop bwi-fw"></i>
{{ "stopSync" | i18n }}
</button>
<form #syncForm [appApiAction]="syncPromise" class="d-inline">
<button (click)="sync()" class="btn btn-primary" [disabled]="syncForm.loading">
<button type="button" (click)="sync()" class="btn btn-primary" [disabled]="syncForm.loading">
<i class="bwi bwi-refresh bwi-fw" [ngClass]="{ 'bwi-spin': syncForm.loading }"></i>
{{ "syncNow" | i18n }}
</button>
@@ -39,7 +44,12 @@
<div class="card-body">
<p>{{ "testingDesc" | i18n }}</p>
<form #simForm [appApiAction]="simPromise" class="d-inline">
<button (click)="simulate()" class="btn btn-primary" [disabled]="simForm.loading">
<button
type="button"
(click)="simulate()"
class="btn btn-primary"
[disabled]="simForm.loading"
>
<i class="bwi bwi-spinner bwi-fw bwi-spin" [hidden]="!simForm.loading"></i>
<i class="bwi bwi-bug bwi-fw" [hidden]="simForm.loading"></i>
{{ "testNow" | i18n }}

View File

@@ -561,10 +561,10 @@ export class StateService
protected async pushAccounts(): Promise<void> {
if (this.state?.accounts == null || Object.keys(this.state.accounts).length < 1) {
this.accounts.next(null);
this.accountsSubject.next(null);
return;
}
this.accounts.next(this.state.accounts);
this.accountsSubject.next(this.state.accounts);
}
protected async hasTemporaryStorage(): Promise<boolean> {