From b5bddd0b06b9a05dedd02197d9aaa7fd0ff2b3c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rui=20Tom=C3=A9?= <108268980+r-tome@users.noreply.github.com> Date: Tue, 10 Jun 2025 09:57:34 +0100 Subject: [PATCH] [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 --- .../browser/src/background/main.background.ts | 1 - .../vault-v2/view-v2/view-v2.component.html | 6 +- .../vault-v2/view-v2/view-v2.component.ts | 30 +--- .../trash-list-items-container.component.html | 9 +- .../trash-list-items-container.component.ts | 5 - apps/cli/src/commands/restore.command.ts | 17 +-- apps/cli/src/oss-serve-configurator.ts | 1 - .../service-container/service-container.ts | 1 - apps/cli/src/vault.program.ts | 1 - .../vault/app/vault/item-footer.component.ts | 6 +- .../src/vault/app/vault/view.component.html | 6 +- .../src/vault/app/vault/view.component.ts | 3 - .../settings/account.component.html | 2 +- .../settings/account.component.ts | 10 -- .../vault-item-dialog.component.ts | 11 +- .../vault-cipher-row.component.html | 16 +-- .../vault-items/vault-cipher-row.component.ts | 8 +- .../vault-items/vault-items.component.html | 19 +-- .../vault-items/vault-items.component.ts | 38 ++--- .../vault/individual-vault/view.component.ts | 4 +- .../src/services/jslib-services.module.ts | 7 +- .../vault/components/add-edit.component.ts | 3 +- .../src/vault/components/view.component.ts | 6 +- libs/common/src/enums/feature-flag.enum.ts | 2 - .../cipher-authorization.service.spec.ts | 136 ++---------------- .../services/cipher-authorization.service.ts | 46 +----- 26 files changed, 55 insertions(+), 339 deletions(-) diff --git a/apps/browser/src/background/main.background.ts b/apps/browser/src/background/main.background.ts index 1b4afabeb66..ac2d2d4116a 100644 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -1325,7 +1325,6 @@ export default class MainBackground { this.collectionService, this.organizationService, this.accountService, - this.configService, ); this.inlineMenuFieldQualificationService = new InlineMenuFieldQualificationService(); diff --git a/apps/browser/src/vault/popup/components/vault-v2/view-v2/view-v2.component.html b/apps/browser/src/vault/popup/components/vault-v2/view-v2/view-v2.component.html index b7ffeb89cc1..8c76db600ae 100644 --- a/apps/browser/src/vault/popup/components/vault-v2/view-v2/view-v2.component.html +++ b/apps/browser/src/vault/popup/components/vault-v2/view-v2/view-v2.component.html @@ -17,11 +17,7 @@ - + diff --git a/apps/desktop/src/vault/app/vault/view.component.ts b/apps/desktop/src/vault/app/vault/view.component.ts index 33dfc600265..7e7f7b57fc8 100644 --- a/apps/desktop/src/vault/app/vault/view.component.ts +++ b/apps/desktop/src/vault/app/vault/view.component.ts @@ -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(); diff --git a/apps/web/src/app/admin-console/organizations/settings/account.component.html b/apps/web/src/app/admin-console/organizations/settings/account.component.html index e6064779ece..4ce4398aadc 100644 --- a/apps/web/src/app/admin-console/organizations/settings/account.component.html +++ b/apps/web/src/app/admin-console/organizations/settings/account.component.html @@ -70,7 +70,7 @@ {{ "limitCollectionDeletionDesc" | i18n }} - + {{ "limitItemDeletionDescription" | i18n }} diff --git a/apps/web/src/app/admin-console/organizations/settings/account.component.ts b/apps/web/src/app/admin-console/organizations/settings/account.component.ts index b376c48b39a..ecb2dbc54a2 100644 --- a/apps/web/src/app/admin-console/organizations/settings/account.component.ts +++ b/apps/web/src/app/admin-console/organizations/settings/account.component.ts @@ -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; - 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( diff --git a/apps/web/src/app/vault/components/vault-item-dialog/vault-item-dialog.component.ts b/apps/web/src/app/vault/components/vault-item-dialog/vault-item-dialog.component.ts index 5ab06cd3337..d79c1c4a8b4 100644 --- a/apps/web/src/app/vault/components/vault-item-dialog/vault-item-dialog.component.ts +++ b/apps/web/src/app/vault/components/vault-item-dialog/vault-item-dialog.component.ts @@ -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, @@ -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, ), ); diff --git a/apps/web/src/app/vault/components/vault-items/vault-cipher-row.component.html b/apps/web/src/app/vault/components/vault-items/vault-cipher-row.component.html index 2860532fce0..678171862ab 100644 --- a/apps/web/src/app/vault/components/vault-items/vault-cipher-row.component.html +++ b/apps/web/src/app/vault/components/vault-items/vault-cipher-row.component.html @@ -86,12 +86,7 @@ appStopProp > - -