mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-22 16:29:09 +01:00
[PM-13892] Update item more options component to react to changes to the cipher input (#11914)
This commit is contained in:
parent
72e7e295ba
commit
e91741b146
@ -1,7 +1,8 @@
|
|||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { booleanAttribute, Component, Input, OnInit } from "@angular/core";
|
import { booleanAttribute, Component, Input, OnInit } from "@angular/core";
|
||||||
import { Router, RouterModule } from "@angular/router";
|
import { Router, RouterModule } from "@angular/router";
|
||||||
import { firstValueFrom, map, Observable } from "rxjs";
|
import { BehaviorSubject, firstValueFrom, map, switchMap } from "rxjs";
|
||||||
|
import { filter } from "rxjs/operators";
|
||||||
|
|
||||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||||
@ -30,10 +31,18 @@ import { AddEditQueryParams } from "../add-edit/add-edit-v2.component";
|
|||||||
imports: [ItemModule, IconButtonModule, MenuModule, CommonModule, JslibModule, RouterModule],
|
imports: [ItemModule, IconButtonModule, MenuModule, CommonModule, JslibModule, RouterModule],
|
||||||
})
|
})
|
||||||
export class ItemMoreOptionsComponent implements OnInit {
|
export class ItemMoreOptionsComponent implements OnInit {
|
||||||
|
private _cipher$ = new BehaviorSubject<CipherView>(undefined);
|
||||||
|
|
||||||
@Input({
|
@Input({
|
||||||
required: true,
|
required: true,
|
||||||
})
|
})
|
||||||
cipher: CipherView;
|
set cipher(c: CipherView) {
|
||||||
|
this._cipher$.next(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
get cipher() {
|
||||||
|
return this._cipher$.value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag to hide the autofill menu options. Used for items that are
|
* Flag to hide the autofill menu options. Used for items that are
|
||||||
@ -43,7 +52,15 @@ export class ItemMoreOptionsComponent implements OnInit {
|
|||||||
hideAutofillOptions: boolean;
|
hideAutofillOptions: boolean;
|
||||||
|
|
||||||
protected autofillAllowed$ = this.vaultPopupAutofillService.autofillAllowed$;
|
protected autofillAllowed$ = this.vaultPopupAutofillService.autofillAllowed$;
|
||||||
protected canClone$: Observable<boolean>;
|
|
||||||
|
/**
|
||||||
|
* Observable that emits a boolean value indicating if the user is authorized to clone the cipher.
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
protected canClone$ = this._cipher$.pipe(
|
||||||
|
filter((c) => c != null),
|
||||||
|
switchMap((c) => this.cipherAuthorizationService.canCloneCipher$(c)),
|
||||||
|
);
|
||||||
|
|
||||||
/** Boolean dependent on the current user having access to an organization */
|
/** Boolean dependent on the current user having access to an organization */
|
||||||
protected hasOrganizations = false;
|
protected hasOrganizations = false;
|
||||||
@ -63,7 +80,6 @@ export class ItemMoreOptionsComponent implements OnInit {
|
|||||||
|
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
this.hasOrganizations = await this.organizationService.hasOrganizations();
|
this.hasOrganizations = await this.organizationService.hasOrganizations();
|
||||||
this.canClone$ = this.cipherAuthorizationService.canCloneCipher$(this.cipher);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get canEdit() {
|
get canEdit() {
|
||||||
|
Loading…
Reference in New Issue
Block a user