mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
[pm-17763] Add limitItemDeletion property to UI. (#13162)
This commit is contained in:
@@ -68,6 +68,10 @@
|
|||||||
<bit-label>{{ "limitCollectionDeletionDesc" | i18n }}</bit-label>
|
<bit-label>{{ "limitCollectionDeletionDesc" | i18n }}</bit-label>
|
||||||
<input type="checkbox" bitCheckbox formControlName="limitCollectionDeletion" />
|
<input type="checkbox" bitCheckbox formControlName="limitCollectionDeletion" />
|
||||||
</bit-form-control>
|
</bit-form-control>
|
||||||
|
<bit-form-control *ngIf="limitItemDeletionFeatureFlagIsEnabled">
|
||||||
|
<bit-label>{{ "limitItemDeletionDesc" | i18n }}</bit-label>
|
||||||
|
<input type="checkbox" bitCheckbox formControlName="limitItemDeletion" />
|
||||||
|
</bit-form-control>
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
bitButton
|
bitButton
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import { OrganizationUpdateRequest } from "@bitwarden/common/admin-console/model
|
|||||||
import { OrganizationResponse } from "@bitwarden/common/admin-console/models/response/organization.response";
|
import { OrganizationResponse } from "@bitwarden/common/admin-console/models/response/organization.response";
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { getUserId } from "@bitwarden/common/auth/services/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 { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
@@ -53,6 +55,8 @@ export class AccountComponent implements OnInit, OnDestroy {
|
|||||||
org: OrganizationResponse;
|
org: OrganizationResponse;
|
||||||
taxFormPromise: Promise<unknown>;
|
taxFormPromise: Promise<unknown>;
|
||||||
|
|
||||||
|
limitItemDeletionFeatureFlagIsEnabled: boolean;
|
||||||
|
|
||||||
// FormGroup validators taken from server Organization domain object
|
// FormGroup validators taken from server Organization domain object
|
||||||
protected formGroup = this.formBuilder.group({
|
protected formGroup = this.formBuilder.group({
|
||||||
orgName: this.formBuilder.control(
|
orgName: this.formBuilder.control(
|
||||||
@@ -71,6 +75,7 @@ export class AccountComponent implements OnInit, OnDestroy {
|
|||||||
protected collectionManagementFormGroup = this.formBuilder.group({
|
protected collectionManagementFormGroup = this.formBuilder.group({
|
||||||
limitCollectionCreation: this.formBuilder.control({ value: false, disabled: false }),
|
limitCollectionCreation: this.formBuilder.control({ value: false, disabled: false }),
|
||||||
limitCollectionDeletion: this.formBuilder.control({ value: false, disabled: false }),
|
limitCollectionDeletion: this.formBuilder.control({ value: false, disabled: false }),
|
||||||
|
limitItemDeletion: this.formBuilder.control({ value: false, disabled: false }),
|
||||||
allowAdminAccessToAllCollectionItems: this.formBuilder.control({
|
allowAdminAccessToAllCollectionItems: this.formBuilder.control({
|
||||||
value: false,
|
value: false,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
@@ -94,11 +99,17 @@ export class AccountComponent implements OnInit, OnDestroy {
|
|||||||
private dialogService: DialogService,
|
private dialogService: DialogService,
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
|
private configService: ConfigService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.selfHosted = this.platformUtilsService.isSelfHost();
|
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$));
|
const userId = await firstValueFrom(getUserId(this.accountService.activeAccount$));
|
||||||
this.route.params
|
this.route.params
|
||||||
.pipe(
|
.pipe(
|
||||||
@@ -143,9 +154,11 @@ export class AccountComponent implements OnInit, OnDestroy {
|
|||||||
orgName: this.org.name,
|
orgName: this.org.name,
|
||||||
billingEmail: this.org.billingEmail,
|
billingEmail: this.org.billingEmail,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.collectionManagementFormGroup.patchValue({
|
this.collectionManagementFormGroup.patchValue({
|
||||||
limitCollectionCreation: this.org.limitCollectionCreation,
|
limitCollectionCreation: this.org.limitCollectionCreation,
|
||||||
limitCollectionDeletion: this.org.limitCollectionDeletion,
|
limitCollectionDeletion: this.org.limitCollectionDeletion,
|
||||||
|
limitItemDeletion: this.org.limitItemDeletion,
|
||||||
allowAdminAccessToAllCollectionItems: this.org.allowAdminAccessToAllCollectionItems,
|
allowAdminAccessToAllCollectionItems: this.org.allowAdminAccessToAllCollectionItems,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -202,6 +215,7 @@ export class AccountComponent implements OnInit, OnDestroy {
|
|||||||
this.collectionManagementFormGroup.value.limitCollectionDeletion;
|
this.collectionManagementFormGroup.value.limitCollectionDeletion;
|
||||||
request.allowAdminAccessToAllCollectionItems =
|
request.allowAdminAccessToAllCollectionItems =
|
||||||
this.collectionManagementFormGroup.value.allowAdminAccessToAllCollectionItems;
|
this.collectionManagementFormGroup.value.allowAdminAccessToAllCollectionItems;
|
||||||
|
request.limitItemDeletion = this.collectionManagementFormGroup.value.limitItemDeletion;
|
||||||
|
|
||||||
await this.organizationApiService.updateCollectionManagement(this.organizationId, request);
|
await this.organizationApiService.updateCollectionManagement(this.organizationId, request);
|
||||||
|
|
||||||
|
|||||||
@@ -8646,6 +8646,9 @@
|
|||||||
"limitCollectionDeletionDesc": {
|
"limitCollectionDeletionDesc": {
|
||||||
"message": "Limit collection deletion to owners and admins"
|
"message": "Limit collection deletion to owners and admins"
|
||||||
},
|
},
|
||||||
|
"limitItemDeletionDesc": {
|
||||||
|
"message": "Limit item deletion to members with the Can manage permission"
|
||||||
|
},
|
||||||
"allowAdminAccessToAllCollectionItemsDesc": {
|
"allowAdminAccessToAllCollectionItemsDesc": {
|
||||||
"message": "Owners and admins can manage all collections and items"
|
"message": "Owners and admins can manage all collections and items"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export enum FeatureFlag {
|
|||||||
ResellerManagedOrgAlert = "PM-15814-alert-owners-of-reseller-managed-orgs",
|
ResellerManagedOrgAlert = "PM-15814-alert-owners-of-reseller-managed-orgs",
|
||||||
NewDeviceVerification = "new-device-verification",
|
NewDeviceVerification = "new-device-verification",
|
||||||
EnableRiskInsightsNotifications = "enable-risk-insights-notifications",
|
EnableRiskInsightsNotifications = "enable-risk-insights-notifications",
|
||||||
|
limitItemDeletion = "pm-15493-restrict-item-deletion-to-can-manage-permission",
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AllowedFeatureFlagTypes = boolean | number | string;
|
export type AllowedFeatureFlagTypes = boolean | number | string;
|
||||||
@@ -106,6 +107,7 @@ export const DefaultFeatureFlagValue = {
|
|||||||
[FeatureFlag.ResellerManagedOrgAlert]: FALSE,
|
[FeatureFlag.ResellerManagedOrgAlert]: FALSE,
|
||||||
[FeatureFlag.NewDeviceVerification]: FALSE,
|
[FeatureFlag.NewDeviceVerification]: FALSE,
|
||||||
[FeatureFlag.EnableRiskInsightsNotifications]: FALSE,
|
[FeatureFlag.EnableRiskInsightsNotifications]: FALSE,
|
||||||
|
[FeatureFlag.limitItemDeletion]: FALSE,
|
||||||
} satisfies Record<FeatureFlag, AllowedFeatureFlagTypes>;
|
} satisfies Record<FeatureFlag, AllowedFeatureFlagTypes>;
|
||||||
|
|
||||||
export type DefaultFeatureFlagValueType = typeof DefaultFeatureFlagValue;
|
export type DefaultFeatureFlagValueType = typeof DefaultFeatureFlagValue;
|
||||||
|
|||||||
Reference in New Issue
Block a user