1
0
mirror of https://github.com/bitwarden/browser synced 2026-03-02 03:21:19 +00:00
Files
browser/libs/vault/src/components/new-cipher-menu/new-cipher-menu.component.ts
Jordan Aasen 60419bd96f add new-cipher-menu component (#15467)
* add new-cipher-menu component

* move new cipher menu to vault. clean up template
2025-07-16 12:39:38 -07:00

39 lines
1.5 KiB
TypeScript

import { CommonModule } from "@angular/common";
import { Component, input, output } from "@angular/core";
import { map, shareReplay } from "rxjs";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import { CipherType } from "@bitwarden/common/vault/enums";
import { RestrictedItemTypesService } from "@bitwarden/common/vault/services/restricted-item-types.service";
import { CIPHER_MENU_ITEMS } from "@bitwarden/common/vault/types/cipher-menu-items";
import { ButtonModule, MenuModule } from "@bitwarden/components";
import { I18nPipe } from "@bitwarden/ui-common";
@Component({
selector: "vault-new-cipher-menu",
templateUrl: "new-cipher-menu.component.html",
imports: [ButtonModule, CommonModule, MenuModule, I18nPipe, JslibModule],
})
export class NewCipherMenuComponent {
canCreateCipher = input(false);
canCreateFolder = input(false);
canCreateCollection = input(false);
folderAdded = output();
collectionAdded = output();
cipherAdded = output<CipherType>();
constructor(private restrictedItemTypesService: RestrictedItemTypesService) {}
/**
* Returns an observable that emits the cipher menu items, filtered by the restricted types.
*/
cipherMenuItems$ = this.restrictedItemTypesService.restricted$.pipe(
map((restrictedTypes) => {
return CIPHER_MENU_ITEMS.filter((item) => {
return !restrictedTypes.some((restrictedType) => restrictedType.cipherType === item.type);
});
}),
shareReplay({ bufferSize: 1, refCount: true }),
);
}