Skip to content

Commit

Permalink
Merge branch 'main' into PM-11162-assign-to-collections-perm
Browse files Browse the repository at this point in the history
  • Loading branch information
Jingo88 committed Oct 2, 2024
2 parents 51d15cd + c969f61 commit be5ac61
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class PopupTabNavigationComponent {
.pipe(
filter((policyAppliesToActiveUser) => policyAppliesToActiveUser),
switchMap(() => this.sendService.sends$),
map((sends) => sends.length > 1),
map((sends) => sends.length > 0),
takeUntilDestroyed(),
)
.subscribe((hasSends) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ <h2 bitTypography="h6">
</bit-section-header>
<bit-item-group>
<bit-item *ngFor="let cipher of ciphers">
<a
<button
bit-item-content
type="button"
[appA11yTitle]="'viewItemTitle' | i18n: cipher.name"
(click)="onViewCipher(cipher)"
>
<app-vault-icon slot="start" [cipher]="cipher"></app-vault-icon>
<span data-testid="item-name">{{ cipher.name }}</span>
</a>
</button>
<ng-container slot="end" *ngIf="cipher.edit">
<bit-item-action>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,39 +106,14 @@
</a>
</ng-container>

<button
bitMenuItem
*ngIf="showAttachments || !vaultBulkManagementActionEnabled"
type="button"
(click)="attachments()"
>
<button bitMenuItem *ngIf="showAttachments" type="button" (click)="attachments()">
<i class="bwi bwi-fw bwi-paperclip" aria-hidden="true"></i>
{{ "attachments" | i18n }}
</button>
<button bitMenuItem *ngIf="showClone" type="button" (click)="clone()">
<i class="bwi bwi-fw bwi-files" aria-hidden="true"></i>
{{ "clone" | i18n }}
</button>
<!-- This option will be phased out in future releases -->
<button
bitMenuItem
*ngIf="!cipher.organizationId && !cipher.isDeleted && !vaultBulkManagementActionEnabled"
type="button"
(click)="moveToOrganization()"
>
<i class="bwi bwi-fw bwi-arrow-circle-right" aria-hidden="true"></i>
{{ "moveToOrganization" | i18n }}
</button>
<!-- This option will be phased out in future releases -->
<button
bitMenuItem
*ngIf="cipher.organizationId && !cipher.isDeleted && !vaultBulkManagementActionEnabled"
type="button"
(click)="editCollections()"
>
<i class="bwi bwi-fw bwi-collection" aria-hidden="true"></i>
{{ "collections" | i18n }}
</button>
<button
bitMenuItem
*ngIf="showAssignToCollections"
Expand All @@ -156,12 +131,7 @@
<i class="bwi bwi-fw bwi-undo" aria-hidden="true"></i>
{{ "restore" | i18n }}
</button>
<button
bitMenuItem
*ngIf="canEditCipher || !vaultBulkManagementActionEnabled"
(click)="deleteCipher()"
type="button"
>
<button bitMenuItem *ngIf="canEditCipher" (click)="deleteCipher()" type="button">
<span class="tw-text-danger">
<i class="bwi bwi-fw bwi-trash" aria-hidden="true"></i>
{{ (cipher.isDeleted ? "permanentlyDelete" : "delete") | i18n }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export class VaultCipherRowComponent implements OnInit {
@Input() collections: CollectionView[];
@Input() viewingOrgVault: boolean;
@Input() canEditCipher: boolean;
@Input() vaultBulkManagementActionEnabled: boolean;

@Output() onEvent = new EventEmitter<VaultItemEvent>();

Expand Down Expand Up @@ -100,17 +99,15 @@ export class VaultCipherRowComponent implements OnInit {
}

protected get disableMenu() {
return (
!(
this.isNotDeletedLoginCipher ||
this.showCopyPassword ||
this.showCopyTotp ||
this.showLaunchUri ||
this.showAttachments ||
this.showClone ||
this.canEditCipher ||
this.cipher.isDeleted
) && this.vaultBulkManagementActionEnabled
return !(
this.isNotDeletedLoginCipher ||
this.showCopyPassword ||
this.showCopyTotp ||
this.showLaunchUri ||
this.showAttachments ||
this.showClone ||
this.canEditCipher ||
this.cipher.isDeleted
);
}

Expand All @@ -122,14 +119,6 @@ export class VaultCipherRowComponent implements OnInit {
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 });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { VaultItem } from "./vault-item";

export type VaultItemEvent =
| { type: "viewAttachments"; item: CipherView }
| { type: "viewCipherCollections"; item: CipherView }
| { type: "bulkEditCollectionAccess"; items: CollectionView[] }
| { type: "viewCollectionAccess"; item: CollectionView; readonly: boolean }
| { type: "viewEvents"; item: CipherView }
Expand All @@ -15,5 +14,4 @@ export type VaultItemEvent =
| { type: "delete"; items: VaultItem[] }
| { type: "copyField"; item: CipherView; field: "username" | "password" | "totp" }
| { type: "moveToFolder"; items: CipherView[] }
| { type: "moveToOrganization"; items: CipherView[] }
| { type: "assignToCollections"; items: CipherView[] };
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<bit-menu #headerMenu>
<button *ngIf="bulkMoveAllowed" type="button" bitMenuItem (click)="bulkMoveToFolder()">
<i class="bwi bwi-fw bwi-folder" aria-hidden="true"></i>
{{ (vaultBulkManagementActionEnabled ? "addToFolder" : "moveSelected") | i18n }}
{{ "addToFolder" | i18n }}
</button>
<button
*ngIf="showAdminActions && showBulkEditCollectionAccess"
Expand All @@ -60,21 +60,12 @@
<i class="bwi bwi-fw bwi-collection" aria-hidden="true"></i>
{{ "assignToCollections" | i18n }}
</button>
<button
*ngIf="bulkMoveAllowed && !vaultBulkManagementActionEnabled"
type="button"
bitMenuItem
(click)="bulkMoveToOrganization()"
>
<i class="bwi bwi-fw bwi-arrow-circle-right" aria-hidden="true"></i>
{{ "moveSelectedToOrg" | i18n }}
</button>
<button *ngIf="showBulkTrashOptions" type="button" bitMenuItem (click)="bulkRestore()">
<i class="bwi bwi-fw bwi-undo" aria-hidden="true"></i>
{{ "restoreSelected" | i18n }}
</button>
<button
*ngIf="deleteAllowed || showBulkTrashOptions"
*ngIf="showDelete() || showBulkTrashOptions"
type="button"
bitMenuItem
(click)="bulkDelete()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export class VaultItemsComponent {
@Input() viewingOrgVault: boolean;
@Input() addAccessStatus: number;
@Input() addAccessToggle: boolean;
@Input() vaultBulkManagementActionEnabled = false;

private _ciphers?: CipherView[] = [];
@Input() get ciphers(): CipherView[] {
Expand Down Expand Up @@ -93,23 +92,13 @@ export class VaultItemsComponent {
}

get disableMenu() {
return (
this.vaultBulkManagementActionEnabled &&
!this.bulkMoveAllowed &&
!this.showAssignToCollections() &&
!this.showDelete()
);
return !this.bulkMoveAllowed && !this.showAssignToCollections() && !this.showDelete();
}

get bulkAssignToCollectionsAllowed() {
return this.showBulkAddToCollections && this.ciphers.length > 0;
}

// Use new bulk management delete if vaultBulkManagementActionEnabled feature flag is enabled
get deleteAllowed() {
return this.vaultBulkManagementActionEnabled ? this.showDelete() : true;
}

protected canEditCollection(collection: CollectionView): boolean {
// Only allow allow deletion if collection editing is enabled and not deleting "Unassigned"
if (collection.id === Unassigned) {
Expand Down Expand Up @@ -156,15 +145,6 @@ export class VaultItemsComponent {
});
}

protected bulkMoveToOrganization() {
this.event({
type: "moveToOrganization",
items: this.selection.selected
.filter((item) => item.cipher !== undefined)
.map((item) => item.cipher),
});
}

protected bulkRestore() {
this.event({
type: "restore",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<form [formGroup]="formGroup" [bitSubmit]="submit">
<bit-dialog dialogSize="small">
<span bitDialogTitle>
{{ ((vaultBulkManagementActionEnabled$ | async) ? "addToFolder" : "moveSelected") | i18n }}
{{ "addToFolder" | i18n }}
</span>
<span bitDialogContent>
<p>{{ "moveSelectedItemsDesc" | i18n: cipherIds.length }}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { Component, Inject, OnInit } from "@angular/core";
import { FormBuilder, Validators } from "@angular/forms";
import { firstValueFrom, Observable } from "rxjs";

import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
Expand Down Expand Up @@ -47,10 +45,6 @@ export class BulkMoveDialogComponent implements OnInit {
});
folders$: Observable<FolderView[]>;

protected vaultBulkManagementActionEnabled$ = this.configService.getFeatureFlag$(
FeatureFlag.VaultBulkManagementAction,
);

constructor(
@Inject(DIALOG_DATA) params: BulkMoveDialogParams,
private dialogRef: DialogRef<BulkMoveDialogResult>,
Expand All @@ -59,7 +53,6 @@ export class BulkMoveDialogComponent implements OnInit {
private i18nService: I18nService,
private folderService: FolderService,
private formBuilder: FormBuilder,
private configService: ConfigService,
) {
this.cipherIds = params.cipherIds ?? [];
}
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/app/vault/individual-vault/vault.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@
[showBulkTrashOptions]="filter.type === 'trash'"
[useEvents]="false"
[showAdminActions]="false"
[showBulkAddToCollections]="vaultBulkManagementActionEnabled$ | async"
[showBulkAddToCollections]="true"
(onEvent)="onVaultItemsEvent($event)"
[vaultBulkManagementActionEnabled]="vaultBulkManagementActionEnabled$ | async"
>
</app-vault-items>
<div
Expand Down
Loading

0 comments on commit be5ac61

Please sign in to comment.