1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 23:33:31 +00:00
Files
browser/apps/web/src/app/vault/components/vault-items/vault-cipher-row.component.ts
SmithThe4th 050f8f4bdc [PM-7624] [PM-7625] Bulk management actions on individual vault (#9507)
* fixed issue with clearing search index state

* clear user index before account is totally cleaned up

* added logout clear on option

* removed redundant clear index from logout

* added feature flag

* added new menu drop down and put behind feature flag

* added permanentlyDeleteSelected to the menu

* added permanentlyDeleteSelected to the menu

* wired up logic to show to hide menu drop down items

* modified the bulk collection assignment to work with end user vault

* wired up delete and move to folder

* merged bulk management actions header into old leveraging the feature flag

* added ability to move personal items to an organization and set active collection when user is on a collection

* made collection required by default

* handled organization cipher share when personal items and org items are selected

* moved logic to determine warning text to component class

* moved logic to determine warning text to component class

* Improved hide or show logic for menu

* added bullet point to bulk assignment dialog content

* changed description for move to folder

* Fixed issue were all collections are retrived instead of only can manage, and added logic to get collections associated with a cipher

* added inline assign to collections

* added logic to disable three dot to template

* Updated logic to retreive shared collection ids between ciphers

* Added logic to make attachment view only, show or hide

* Only show menu options when there are options available

* Comments cleanup

* update cipher row to disable menu instead of hide

* Put add to folder behind feature flag

* ensured old menu behaviour is shown when feature flag is turned off

* refactored code base on code review suggestions

* fixed bug with available collections

* Made assign to collections resuable

made pluralize a pipe instead

* Utilized the resuable assign to collections component on the web

* changed description message for collection assignment

* fixed bug with ExpressionChangedAfterItHasBeenCheckedError

* Added changedetectorref markForCheck

* removed redundant startwith as seed value has been added

* made code review suggestions

* fixed bug where assign to collections shows up in trash filter

* removed bitInput

* refactored based on code review comments

* added reference ticket

* [PM-9341] Cannot assign to collections when filtering by My Vault (#9862)

* Add checks for org id myvault

* made myvault id a constant

* show bulk move is set by individual vault and it is needed so assign to collections does not show up in trash filter (#9876)

* Fixed issue where selectedOrgId is null (#9879)

* Fix bug introduced with assigning items to a collection (#9897)

* [PM-9601] [PM-9602] When collection management setting is turned on view only collections and assign to collections menu option show up (#10047)

* Only show collections with edit access on individual vault

* remove unused arguments
2024-07-11 17:39:49 -04:00

133 lines
3.8 KiB
TypeScript

import { Component, EventEmitter, Input, Output } from "@angular/core";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { CollectionView } from "@bitwarden/common/vault/models/view/collection.view";
import { VaultItemEvent } from "./vault-item-event";
import { RowHeightClass } from "./vault-items.component";
@Component({
selector: "tr[appVaultCipherRow]",
templateUrl: "vault-cipher-row.component.html",
})
export class VaultCipherRowComponent {
protected RowHeightClass = RowHeightClass;
@Input() disabled: boolean;
@Input() cipher: CipherView;
@Input() showOwner: boolean;
@Input() showCollections: boolean;
@Input() showGroups: boolean;
@Input() showPremiumFeatures: boolean;
@Input() useEvents: boolean;
@Input() cloneable: boolean;
@Input() organizations: Organization[];
@Input() collections: CollectionView[];
@Input() viewingOrgVault: boolean;
@Input() canEditCipher: boolean;
@Input() vaultBulkManagementActionEnabled: boolean;
@Output() onEvent = new EventEmitter<VaultItemEvent>();
@Input() checked: boolean;
@Output() checkedToggled = new EventEmitter<void>();
protected CipherType = CipherType;
protected get showTotpCopyButton() {
return (
(this.cipher.login?.hasTotp ?? false) &&
(this.cipher.organizationUseTotp || this.showPremiumFeatures)
);
}
protected get showFixOldAttachments() {
return this.cipher.hasOldAttachments && this.cipher.organizationId == null;
}
protected get showAttachments() {
return this.canEditCipher || this.cipher.attachments?.length > 0;
}
protected get showAssignToCollections() {
return this.canEditCipher && !this.cipher.isDeleted;
}
protected get showClone() {
return this.cloneable && !this.cipher.isDeleted;
}
protected get showEventLogs() {
return this.useEvents && this.cipher.organizationId;
}
protected get isNotDeletedLoginCipher() {
return this.cipher.type === this.CipherType.Login && !this.cipher.isDeleted;
}
protected get showCopyPassword(): boolean {
return this.isNotDeletedLoginCipher && this.cipher.viewPassword;
}
protected get showCopyTotp(): boolean {
return this.isNotDeletedLoginCipher && this.showTotpCopyButton;
}
protected get showLaunchUri(): boolean {
return this.isNotDeletedLoginCipher && this.cipher.login.canLaunch;
}
protected get disableMenu() {
return (
!(
this.isNotDeletedLoginCipher ||
this.showCopyPassword ||
this.showCopyTotp ||
this.showLaunchUri ||
this.showAttachments ||
this.showClone ||
this.canEditCipher ||
this.cipher.isDeleted
) && this.vaultBulkManagementActionEnabled
);
}
protected copy(field: "username" | "password" | "totp") {
this.onEvent.emit({ type: "copyField", item: this.cipher, field });
}
protected clone() {
this.onEvent.emit({ type: "clone", item: this.cipher });
}
protected moveToOrganization() {
this.onEvent.emit({ type: "moveToOrganization", items: [this.cipher] });
}
protected editCollections() {
this.onEvent.emit({ type: "viewCipherCollections", item: this.cipher });
}
protected events() {
this.onEvent.emit({ type: "viewEvents", item: this.cipher });
}
protected restore() {
this.onEvent.emit({ type: "restore", items: [this.cipher] });
}
protected deleteCipher() {
this.onEvent.emit({ type: "delete", items: [{ cipher: this.cipher }] });
}
protected attachments() {
this.onEvent.emit({ type: "viewAttachments", item: this.cipher });
}
protected assignToCollections() {
this.onEvent.emit({ type: "assignToCollections", items: [this.cipher] });
}
}