From 48d161009d03f777f62615dfaae9fed7f554d3ca Mon Sep 17 00:00:00 2001 From: Jason Ng Date: Wed, 10 Jan 2024 09:56:23 -0500 Subject: [PATCH] AC-1115 Modify AC Vault/Collections (#6789) * Permissions Column added to Org Vault. Other updates to filter section and Can Manage Permission added and put behind feature flag --------- Co-authored-by: Thomas Rittson Co-authored-by: Vincent Salucci <26154748+vincentsalucci@users.noreply.github.com> --- .../organization-layout.component.html | 16 ++++- .../layouts/organization-layout.component.ts | 10 ++- .../access-selector.component.ts | 18 ++--- .../access-selector/access-selector.models.ts | 19 ++++++ .../vault-cipher-row.component.html | 1 + .../vault-collection-row.component.html | 5 ++ .../vault-collection-row.component.ts | 40 +++++++++-- .../vault-items/vault-items.component.html | 5 ++ .../vault-items/vault-items.component.ts | 3 +- .../vault-filter/vault-filter.component.ts | 66 ++++++++++++++++++- .../vault-header/vault-header.component.ts | 6 +- .../app/vault/org-vault/vault.component.html | 1 + .../app/vault/org-vault/vault.component.ts | 25 ++++++- 13 files changed, 187 insertions(+), 28 deletions(-) diff --git a/apps/web/src/app/admin-console/organizations/layouts/organization-layout.component.html b/apps/web/src/app/admin-console/organizations/layouts/organization-layout.component.html index 0d537a4b2a..4ab0a60701 100644 --- a/apps/web/src/app/admin-console/organizations/layouts/organization-layout.component.html +++ b/apps/web/src/app/admin-console/organizations/layouts/organization-layout.component.html @@ -7,9 +7,19 @@ [activeOrganization]="organization" > - {{ - "vault" | i18n - }} + {{ "collections" | i18n }} + + {{ + "vault" | i18n + }} + {{ "members" | i18n }} diff --git a/apps/web/src/app/admin-console/organizations/layouts/organization-layout.component.ts b/apps/web/src/app/admin-console/organizations/layouts/organization-layout.component.ts index e44017a353..656ea4ae13 100644 --- a/apps/web/src/app/admin-console/organizations/layouts/organization-layout.component.ts +++ b/apps/web/src/app/admin-console/organizations/layouts/organization-layout.component.ts @@ -13,6 +13,8 @@ import { OrganizationService, } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; +import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; +import { ConfigServiceAbstraction } from "@bitwarden/common/platform/abstractions/config/config.service.abstraction"; @Component({ selector: "app-organization-layout", @@ -23,12 +25,18 @@ export class OrganizationLayoutComponent implements OnInit, OnDestroy { private _destroy = new Subject(); + protected flexibleCollectionsEnabled$ = this.configService.getFeatureFlag$( + FeatureFlag.FlexibleCollections, + false, + ); + constructor( private route: ActivatedRoute, private organizationService: OrganizationService, + private configService: ConfigServiceAbstraction, ) {} - ngOnInit() { + async ngOnInit() { document.body.classList.remove("layout_frontend"); this.organization$ = this.route.params diff --git a/apps/web/src/app/admin-console/organizations/shared/components/access-selector/access-selector.component.ts b/apps/web/src/app/admin-console/organizations/shared/components/access-selector/access-selector.component.ts index c0c4ae4b98..69f1713186 100644 --- a/apps/web/src/app/admin-console/organizations/shared/components/access-selector/access-selector.component.ts +++ b/apps/web/src/app/admin-console/organizations/shared/components/access-selector/access-selector.component.ts @@ -18,6 +18,8 @@ import { AccessItemValue, AccessItemView, CollectionPermission, + getPermissionList, + Permission, } from "./access-selector.models"; export enum PermissionMode { @@ -116,16 +118,7 @@ export class AccessSelectorComponent implements ControlValueAccessor, OnInit, On }); protected itemType = AccessItemType; - protected permissionList = [ - { perm: CollectionPermission.View, labelId: "canView" }, - { perm: CollectionPermission.ViewExceptPass, labelId: "canViewExceptPass" }, - { perm: CollectionPermission.Edit, labelId: "canEdit" }, - { perm: CollectionPermission.EditExceptPass, labelId: "canEditExceptPass" }, - ]; - private canManagePermissionListItem = { - perm: CollectionPermission.Manage, - labelId: "canManage", - }; + protected permissionList: Permission[]; protected initialPermission = CollectionPermission.View; disabled: boolean; @@ -264,6 +257,7 @@ export class AccessSelectorComponent implements ControlValueAccessor, OnInit, On } async ngOnInit() { + this.permissionList = getPermissionList(this.flexibleCollectionsEnabled); // Watch the internal formArray for changes and propagate them this.selectionList.formArray.valueChanges.pipe(takeUntil(this.destroy$)).subscribe((v) => { if (!this.notifyOnChange || this.pauseChangeNotification) { @@ -277,10 +271,6 @@ export class AccessSelectorComponent implements ControlValueAccessor, OnInit, On } this.notifyOnChange(v); }); - - if (this.flexibleCollectionsEnabled) { - this.permissionList.push(this.canManagePermissionListItem); - } } ngOnDestroy() { diff --git a/apps/web/src/app/admin-console/organizations/shared/components/access-selector/access-selector.models.ts b/apps/web/src/app/admin-console/organizations/shared/components/access-selector/access-selector.models.ts index 0c09f2125f..8fbca22bc5 100644 --- a/apps/web/src/app/admin-console/organizations/shared/components/access-selector/access-selector.models.ts +++ b/apps/web/src/app/admin-console/organizations/shared/components/access-selector/access-selector.models.ts @@ -77,6 +77,25 @@ export type AccessItemValue = { type: AccessItemType; }; +export type Permission = { + perm: CollectionPermission; + labelId: string; +}; + +export const getPermissionList = (flexibleCollectionsEnabled: boolean): Permission[] => { + const permissions = [ + { perm: CollectionPermission.View, labelId: "canView" }, + { perm: CollectionPermission.ViewExceptPass, labelId: "canViewExceptPass" }, + { perm: CollectionPermission.Edit, labelId: "canEdit" }, + { perm: CollectionPermission.EditExceptPass, labelId: "canEditExceptPass" }, + ]; + if (flexibleCollectionsEnabled) { + permissions.push({ perm: CollectionPermission.Manage, labelId: "canManage" }); + } + + return permissions; +}; + /** * Converts the CollectionAccessSelectionView interface to one of the new CollectionPermission values * for the dropdown in the AccessSelectorComponent 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 2a3a19f1ae..2b4bc1c564 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 @@ -65,6 +65,7 @@ > +