mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
[PM-17154] Limit item deletion feature flag removal (#15094)
* Refactor components to remove limitItemDeletion feature flag usage This commit simplifies the logic in various components by removing the limitItemDeletion feature flag. The conditions for displaying restore and delete actions are now based solely on the cipher's permissions, enhancing code clarity and maintainability. * Refactor cipher deletion logic to remove the feature flag and collection ID dependency This commit updates the cipher deletion logic across multiple components and services by removing the unnecessary dependency on collection IDs. The `canDeleteCipher$` method now solely relies on the cipher's permissions, simplifying the code and improving maintainability. * Remove LimitItemDeletion feature flag from feature-flag enum and default values * Remove configService from ServiceContainer and MainBackground constructor parameters * Remove configService from RestoreCommand instantiation in OssServeConfigurator and VaultProgram classes
This commit is contained in:
@@ -1325,7 +1325,6 @@ export default class MainBackground {
|
||||
this.collectionService,
|
||||
this.organizationService,
|
||||
this.accountService,
|
||||
this.configService,
|
||||
);
|
||||
|
||||
this.inlineMenuFieldQualificationService = new InlineMenuFieldQualificationService();
|
||||
|
||||
@@ -17,11 +17,7 @@
|
||||
</button>
|
||||
|
||||
<button
|
||||
*ngIf="
|
||||
(limitItemDeletion$ | async)
|
||||
? cipher.isDeleted && cipher.permissions.restore
|
||||
: cipher.isDeleted && cipher.edit
|
||||
"
|
||||
*ngIf="cipher.isDeleted && cipher.permissions.restore"
|
||||
buttonType="primary"
|
||||
type="button"
|
||||
bitButton
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Component } from "@angular/core";
|
||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||
import { FormsModule } from "@angular/forms";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { firstValueFrom, map, Observable, switchMap } from "rxjs";
|
||||
import { firstValueFrom, Observable, switchMap, of } from "rxjs";
|
||||
|
||||
import { CollectionView } from "@bitwarden/admin-console/common";
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
@@ -22,8 +22,6 @@ import {
|
||||
UPDATE_PASSWORD,
|
||||
} from "@bitwarden/common/autofill/constants";
|
||||
import { EventType } from "@bitwarden/common/enums";
|
||||
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 { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { UserId } from "@bitwarden/common/types/guid";
|
||||
@@ -112,7 +110,6 @@ export class ViewV2Component {
|
||||
loadAction: LoadAction;
|
||||
senderTabId?: number;
|
||||
|
||||
protected limitItemDeletion$ = this.configService.getFeatureFlag$(FeatureFlag.LimitItemDeletion);
|
||||
protected showFooter$: Observable<boolean>;
|
||||
|
||||
constructor(
|
||||
@@ -131,7 +128,6 @@ export class ViewV2Component {
|
||||
protected cipherAuthorizationService: CipherAuthorizationService,
|
||||
private copyCipherFieldService: CopyCipherFieldService,
|
||||
private popupScrollPositionService: VaultPopupScrollPositionService,
|
||||
private configService: ConfigService,
|
||||
) {
|
||||
this.subscribeToParams();
|
||||
}
|
||||
@@ -160,17 +156,10 @@ export class ViewV2Component {
|
||||
|
||||
this.canDeleteCipher$ = this.cipherAuthorizationService.canDeleteCipher$(cipher);
|
||||
|
||||
this.showFooter$ = this.limitItemDeletion$.pipe(
|
||||
map((enabled) => {
|
||||
if (enabled) {
|
||||
return (
|
||||
cipher &&
|
||||
(!cipher.isDeleted ||
|
||||
(cipher.isDeleted && (cipher.permissions.restore || cipher.permissions.delete)))
|
||||
);
|
||||
}
|
||||
return this.showFooterLegacy();
|
||||
}),
|
||||
this.showFooter$ = of(
|
||||
cipher &&
|
||||
(!cipher.isDeleted ||
|
||||
(cipher.isDeleted && (cipher.permissions.restore || cipher.permissions.delete))),
|
||||
);
|
||||
|
||||
await this.eventCollectionService.collect(
|
||||
@@ -268,15 +257,6 @@ export class ViewV2Component {
|
||||
: this.cipherService.softDeleteWithServer(this.cipher.id, this.activeUserId);
|
||||
}
|
||||
|
||||
//@TODO: remove this when the LimitItemDeletion feature flag is removed
|
||||
protected showFooterLegacy(): boolean {
|
||||
return (
|
||||
this.cipher &&
|
||||
(!this.cipher.isDeleted ||
|
||||
(this.cipher.isDeleted && this.cipher.edit && this.cipher.viewPassword))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the load action for the view vault item popout. These actions are typically triggered
|
||||
* via the extension context menu. It is necessary to render the view for items that have password
|
||||
|
||||
@@ -31,14 +31,7 @@
|
||||
></i>
|
||||
<span slot="secondary">{{ cipher.subTitle }}</span>
|
||||
</button>
|
||||
<ng-container
|
||||
slot="end"
|
||||
*ngIf="
|
||||
(limitItemDeletion$ | async)
|
||||
? cipher.permissions.restore
|
||||
: cipher.edit && cipher.viewPassword
|
||||
"
|
||||
>
|
||||
<ng-container slot="end" *ngIf="cipher.permissions.restore">
|
||||
<bit-item-action>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -8,8 +8,6 @@ import { firstValueFrom } from "rxjs";
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
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 { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { CipherId } from "@bitwarden/common/types/guid";
|
||||
@@ -70,11 +68,8 @@ export class TrashListItemsContainerComponent {
|
||||
private passwordRepromptService: PasswordRepromptService,
|
||||
private accountService: AccountService,
|
||||
private router: Router,
|
||||
private configService: ConfigService,
|
||||
) {}
|
||||
|
||||
protected limitItemDeletion$ = this.configService.getFeatureFlag$(FeatureFlag.LimitItemDeletion);
|
||||
|
||||
/**
|
||||
* The tooltip text for the organization icon for ciphers that belong to an organization.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { combineLatest, firstValueFrom, map } from "rxjs";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||
import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service";
|
||||
|
||||
@@ -13,7 +11,6 @@ export class RestoreCommand {
|
||||
constructor(
|
||||
private cipherService: CipherService,
|
||||
private accountService: AccountService,
|
||||
private configService: ConfigService,
|
||||
private cipherAuthorizationService: CipherAuthorizationService,
|
||||
) {}
|
||||
|
||||
@@ -42,17 +39,7 @@ export class RestoreCommand {
|
||||
}
|
||||
|
||||
const canRestore = await firstValueFrom(
|
||||
combineLatest([
|
||||
this.configService.getFeatureFlag$(FeatureFlag.LimitItemDeletion),
|
||||
this.cipherAuthorizationService.canRestoreCipher$(cipher),
|
||||
]).pipe(
|
||||
map(([enabled, canRestore]) => {
|
||||
if (enabled && !canRestore) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
),
|
||||
this.cipherAuthorizationService.canRestoreCipher$(cipher),
|
||||
);
|
||||
|
||||
if (!canRestore) {
|
||||
|
||||
@@ -127,7 +127,6 @@ export class OssServeConfigurator {
|
||||
this.restoreCommand = new RestoreCommand(
|
||||
this.serviceContainer.cipherService,
|
||||
this.serviceContainer.accountService,
|
||||
this.serviceContainer.configService,
|
||||
this.serviceContainer.cipherAuthorizationService,
|
||||
);
|
||||
this.shareCommand = new ShareCommand(
|
||||
|
||||
@@ -861,7 +861,6 @@ export class ServiceContainer {
|
||||
this.collectionService,
|
||||
this.organizationService,
|
||||
this.accountService,
|
||||
this.configService,
|
||||
);
|
||||
|
||||
this.masterPasswordApiService = new MasterPasswordApiService(this.apiService, this.logService);
|
||||
|
||||
@@ -350,7 +350,6 @@ export class VaultProgram extends BaseProgram {
|
||||
const command = new RestoreCommand(
|
||||
this.serviceContainer.cipherService,
|
||||
this.serviceContainer.accountService,
|
||||
this.serviceContainer.configService,
|
||||
this.serviceContainer.cipherAuthorizationService,
|
||||
);
|
||||
const response = await command.run(object, id);
|
||||
|
||||
@@ -7,7 +7,7 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { CollectionId, UserId } from "@bitwarden/common/types/guid";
|
||||
import { UserId } from "@bitwarden/common/types/guid";
|
||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||
import { CipherRepromptType } from "@bitwarden/common/vault/enums";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
@@ -49,9 +49,7 @@ export class ItemFooterComponent implements OnInit {
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
this.canDeleteCipher$ = this.cipherAuthorizationService.canDeleteCipher$(this.cipher, [
|
||||
this.collectionId as CollectionId,
|
||||
]);
|
||||
this.canDeleteCipher$ = this.cipherAuthorizationService.canDeleteCipher$(this.cipher);
|
||||
this.activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
|
||||
}
|
||||
|
||||
|
||||
@@ -656,11 +656,7 @@
|
||||
class="primary"
|
||||
(click)="restore()"
|
||||
appA11yTitle="{{ 'restore' | i18n }}"
|
||||
*ngIf="
|
||||
(limitItemDeletion$ | async)
|
||||
? (canRestoreCipher$ | async) && cipher.isDeleted
|
||||
: cipher.isDeleted
|
||||
"
|
||||
*ngIf="(canRestoreCipher$ | async) && cipher.isDeleted"
|
||||
>
|
||||
<i class="bwi bwi-undo bwi-fw bwi-lg" aria-hidden="true"></i>
|
||||
</button>
|
||||
|
||||
@@ -19,7 +19,6 @@ import { EventCollectionService } from "@bitwarden/common/abstractions/event/eve
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
||||
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { EncryptService } from "@bitwarden/common/key-management/crypto/abstractions/encrypt.service";
|
||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
@@ -108,8 +107,6 @@ export class ViewComponent extends BaseViewComponent implements OnInit, OnDestro
|
||||
);
|
||||
}
|
||||
|
||||
protected limitItemDeletion$ = this.configService.getFeatureFlag$(FeatureFlag.LimitItemDeletion);
|
||||
|
||||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
<bit-label>{{ "limitCollectionDeletionDesc" | i18n }}</bit-label>
|
||||
<input type="checkbox" bitCheckbox formControlName="limitCollectionDeletion" />
|
||||
</bit-form-control>
|
||||
<bit-form-control *ngIf="limitItemDeletionFeatureFlagIsEnabled">
|
||||
<bit-form-control>
|
||||
<bit-label>{{ "limitItemDeletionDescription" | i18n }}</bit-label>
|
||||
<input type="checkbox" bitCheckbox formControlName="limitItemDeletion" />
|
||||
</bit-form-control>
|
||||
|
||||
@@ -25,8 +25,6 @@ import { OrganizationUpdateRequest } from "@bitwarden/common/admin-console/model
|
||||
import { OrganizationResponse } from "@bitwarden/common/admin-console/models/response/organization.response";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
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 { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
@@ -51,8 +49,6 @@ export class AccountComponent implements OnInit, OnDestroy {
|
||||
org: OrganizationResponse;
|
||||
taxFormPromise: Promise<unknown>;
|
||||
|
||||
limitItemDeletionFeatureFlagIsEnabled: boolean;
|
||||
|
||||
// FormGroup validators taken from server Organization domain object
|
||||
protected formGroup = this.formBuilder.group({
|
||||
orgName: this.formBuilder.control(
|
||||
@@ -95,17 +91,11 @@ export class AccountComponent implements OnInit, OnDestroy {
|
||||
private dialogService: DialogService,
|
||||
private formBuilder: FormBuilder,
|
||||
private toastService: ToastService,
|
||||
private configService: ConfigService,
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
this.selfHosted = this.platformUtilsService.isSelfHost();
|
||||
|
||||
this.configService
|
||||
.getFeatureFlag$(FeatureFlag.LimitItemDeletion)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((isAble) => (this.limitItemDeletionFeatureFlagIsEnabled = isAble));
|
||||
|
||||
const userId = await firstValueFrom(getUserId(this.accountService.activeAccount$));
|
||||
this.route.params
|
||||
.pipe(
|
||||
|
||||
@@ -15,8 +15,6 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions";
|
||||
import { EventType } from "@bitwarden/common/enums";
|
||||
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 { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||
@@ -228,10 +226,7 @@ export class VaultItemDialogComponent implements OnInit, OnDestroy {
|
||||
* A user may restore items if they have delete permissions and the item is in the trash.
|
||||
*/
|
||||
protected async canUserRestore() {
|
||||
if (await firstValueFrom(this.limitItemDeletion$)) {
|
||||
return this.isTrashFilter && this.cipher?.isDeleted && this.cipher?.permissions.restore;
|
||||
}
|
||||
return this.isTrashFilter && this.cipher?.isDeleted && this.canDelete;
|
||||
return this.isTrashFilter && this.cipher?.isDeleted && this.cipher?.permissions.restore;
|
||||
}
|
||||
|
||||
protected showRestore: boolean;
|
||||
@@ -277,8 +272,6 @@ export class VaultItemDialogComponent implements OnInit, OnDestroy {
|
||||
|
||||
protected canDelete = false;
|
||||
|
||||
protected limitItemDeletion$ = this.configService.getFeatureFlag$(FeatureFlag.LimitItemDeletion);
|
||||
|
||||
constructor(
|
||||
@Inject(DIALOG_DATA) protected params: VaultItemDialogParams,
|
||||
private dialogRef: DialogRef<VaultItemDialogResult>,
|
||||
@@ -296,7 +289,6 @@ export class VaultItemDialogComponent implements OnInit, OnDestroy {
|
||||
private apiService: ApiService,
|
||||
private eventCollectionService: EventCollectionService,
|
||||
private routedVaultFilterService: RoutedVaultFilterService,
|
||||
private configService: ConfigService,
|
||||
) {
|
||||
this.updateTitle();
|
||||
}
|
||||
@@ -323,7 +315,6 @@ export class VaultItemDialogComponent implements OnInit, OnDestroy {
|
||||
this.canDelete = await firstValueFrom(
|
||||
this.cipherAuthorizationService.canDeleteCipher$(
|
||||
this.cipher,
|
||||
[this.params.activeCollectionId],
|
||||
this.params.isAdminConsoleAction,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -86,12 +86,7 @@
|
||||
appStopProp
|
||||
></button>
|
||||
<bit-menu #corruptedCipherOptions>
|
||||
<button
|
||||
bitMenuItem
|
||||
*ngIf="(limitItemDeletion$ | async) ? canDeleteCipher : canManageCollection"
|
||||
(click)="deleteCipher()"
|
||||
type="button"
|
||||
>
|
||||
<button bitMenuItem *ngIf="canDeleteCipher" (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 }}
|
||||
@@ -160,17 +155,12 @@
|
||||
bitMenuItem
|
||||
(click)="restore()"
|
||||
type="button"
|
||||
*ngIf="(limitItemDeletion$ | async) ? cipher.isDeleted && canRestoreCipher : cipher.isDeleted"
|
||||
*ngIf="cipher.isDeleted && canRestoreCipher"
|
||||
>
|
||||
<i class="bwi bwi-fw bwi-undo" aria-hidden="true"></i>
|
||||
{{ "restore" | i18n }}
|
||||
</button>
|
||||
<button
|
||||
bitMenuItem
|
||||
*ngIf="(limitItemDeletion$ | async) ? canDeleteCipher : canManageCollection"
|
||||
(click)="deleteCipher()"
|
||||
type="button"
|
||||
>
|
||||
<button bitMenuItem *ngIf="canDeleteCipher" (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 }}
|
||||
|
||||
@@ -4,8 +4,6 @@ import { Component, EventEmitter, Input, OnInit, Output } from "@angular/core";
|
||||
|
||||
import { CollectionView } from "@bitwarden/admin-console/common";
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
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 { CipherType } from "@bitwarden/common/vault/enums";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
@@ -53,7 +51,6 @@ export class VaultCipherRowComponent implements OnInit {
|
||||
@Input() checked: boolean;
|
||||
@Output() checkedToggled = new EventEmitter<void>();
|
||||
|
||||
protected limitItemDeletion$ = this.configService.getFeatureFlag$(FeatureFlag.LimitItemDeletion);
|
||||
protected CipherType = CipherType;
|
||||
private permissionList = getPermissionList();
|
||||
private permissionPriority = [
|
||||
@@ -65,10 +62,7 @@ export class VaultCipherRowComponent implements OnInit {
|
||||
];
|
||||
protected organization?: Organization;
|
||||
|
||||
constructor(
|
||||
private i18nService: I18nService,
|
||||
private configService: ConfigService,
|
||||
) {}
|
||||
constructor(private i18nService: I18nService) {}
|
||||
|
||||
/**
|
||||
* Lifecycle hook for component initialization.
|
||||
|
||||
@@ -52,12 +52,11 @@
|
||||
{{ "permission" | i18n }}
|
||||
</th>
|
||||
<th bitCell class="tw-w-12 tw-text-right">
|
||||
@let featureFlaggedDisable =
|
||||
(limitItemDeletion$ | async) ? (disableMenu$ | async) : disableMenu;
|
||||
@let menuDisabled = disableMenu$ | async;
|
||||
<button
|
||||
[disabled]="disabled || isEmpty || featureFlaggedDisable"
|
||||
[disabled]="disabled || isEmpty || menuDisabled"
|
||||
[bitMenuTriggerFor]="headerMenu"
|
||||
[attr.title]="featureFlaggedDisable ? ('missingPermissions' | i18n) : ''"
|
||||
[attr.title]="menuDisabled ? ('missingPermissions' | i18n) : ''"
|
||||
bitIconButton="bwi-ellipsis-v"
|
||||
size="small"
|
||||
type="button"
|
||||
@@ -89,9 +88,7 @@
|
||||
{{ "assignToCollections" | i18n }}
|
||||
</button>
|
||||
<button
|
||||
*ngIf="
|
||||
(limitItemDeletion$ | async) ? (canRestoreSelected$ | async) : showBulkTrashOptions
|
||||
"
|
||||
*ngIf="canRestoreSelected$ | async"
|
||||
type="button"
|
||||
bitMenuItem
|
||||
(click)="bulkRestore()"
|
||||
@@ -100,7 +97,7 @@
|
||||
{{ "restoreSelected" | i18n }}
|
||||
</button>
|
||||
<button
|
||||
*ngIf="(limitItemDeletion$ | async) ? (canDeleteSelected$ | async) : showDelete"
|
||||
*ngIf="canDeleteSelected$ | async"
|
||||
type="button"
|
||||
bitMenuItem
|
||||
(click)="bulkDelete()"
|
||||
@@ -161,11 +158,7 @@
|
||||
[canAssignCollections]="canAssignCollections(item.cipher)"
|
||||
[canManageCollection]="canManageCollection(item.cipher)"
|
||||
[canDeleteCipher]="
|
||||
cipherAuthorizationService.canDeleteCipher$(
|
||||
item.cipher,
|
||||
[item.cipher.collectionId],
|
||||
showAdminActions
|
||||
) | async
|
||||
cipherAuthorizationService.canDeleteCipher$(item.cipher, showAdminActions) | async
|
||||
"
|
||||
[canRestoreCipher]="
|
||||
cipherAuthorizationService.canRestoreCipher$(item.cipher, showAdminActions) | async
|
||||
|
||||
@@ -6,8 +6,6 @@ import { Observable, combineLatest, map, of, startWith, switchMap } from "rxjs";
|
||||
|
||||
import { CollectionView, Unassigned, CollectionAdminView } from "@bitwarden/admin-console/common";
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service";
|
||||
import { SortDirection, TableDataSource } from "@bitwarden/components";
|
||||
@@ -78,7 +76,6 @@ export class VaultItemsComponent {
|
||||
|
||||
@Output() onEvent = new EventEmitter<VaultItemEvent>();
|
||||
|
||||
protected limitItemDeletion$ = this.configService.getFeatureFlag$(FeatureFlag.LimitItemDeletion);
|
||||
protected editableItems: VaultItem[] = [];
|
||||
protected dataSource = new TableDataSource<VaultItem>();
|
||||
protected selection = new SelectionModel<VaultItem>(true, [], true);
|
||||
@@ -86,10 +83,7 @@ export class VaultItemsComponent {
|
||||
protected canRestoreSelected$: Observable<boolean>;
|
||||
protected disableMenu$: Observable<boolean>;
|
||||
|
||||
constructor(
|
||||
protected cipherAuthorizationService: CipherAuthorizationService,
|
||||
private configService: ConfigService,
|
||||
) {
|
||||
constructor(protected cipherAuthorizationService: CipherAuthorizationService) {
|
||||
this.canDeleteSelected$ = this.selection.changed.pipe(
|
||||
startWith(null),
|
||||
switchMap(() => {
|
||||
@@ -102,7 +96,7 @@ export class VaultItemsComponent {
|
||||
}
|
||||
|
||||
const canDeleteCiphers$ = ciphers.map((c) =>
|
||||
cipherAuthorizationService.canDeleteCipher$(c, [], this.showAdminActions),
|
||||
cipherAuthorizationService.canDeleteCipher$(c, this.showAdminActions),
|
||||
);
|
||||
|
||||
const canDeleteCollections = this.selection.selected
|
||||
@@ -141,17 +135,14 @@ export class VaultItemsComponent {
|
||||
map((canRestore) => canRestore && this.showBulkTrashOptions),
|
||||
);
|
||||
|
||||
this.disableMenu$ = combineLatest([this.limitItemDeletion$, this.canDeleteSelected$]).pipe(
|
||||
map(([enabled, canDelete]) => {
|
||||
if (enabled) {
|
||||
return (
|
||||
!this.bulkMoveAllowed &&
|
||||
!this.showAssignToCollections() &&
|
||||
!canDelete &&
|
||||
!this.showBulkEditCollectionAccess
|
||||
);
|
||||
}
|
||||
return false;
|
||||
this.disableMenu$ = this.canDeleteSelected$.pipe(
|
||||
map((canDelete) => {
|
||||
return (
|
||||
!this.bulkMoveAllowed &&
|
||||
!this.showAssignToCollections() &&
|
||||
!canDelete &&
|
||||
!this.showBulkEditCollectionAccess
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -205,15 +196,6 @@ export class VaultItemsComponent {
|
||||
return false;
|
||||
}
|
||||
|
||||
get disableMenu() {
|
||||
return (
|
||||
!this.bulkMoveAllowed &&
|
||||
!this.showAssignToCollections() &&
|
||||
!this.showDelete &&
|
||||
!this.showBulkEditCollectionAccess
|
||||
);
|
||||
}
|
||||
|
||||
get bulkAssignToCollectionsAllowed() {
|
||||
return this.showBulkAddToCollections && this.ciphers.length > 0;
|
||||
}
|
||||
|
||||
@@ -123,9 +123,7 @@ export class ViewComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
this.canDeleteCipher$ = this.cipherAuthorizationService.canDeleteCipher$(this.cipher, [
|
||||
this.params.activeCollectionId,
|
||||
]);
|
||||
this.canDeleteCipher$ = this.cipherAuthorizationService.canDeleteCipher$(this.cipher);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user