Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-11162] Assign To Collections Permission Update #11367

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
51d15cd
updated canEditCipher permission logic inside vault-items
Jingo88 Oct 2, 2024
be5ac61
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Oct 2, 2024
c852cd9
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Oct 2, 2024
a7eb84c
add permission logic to assign to collections for browser cipher edit
Jingo88 Oct 4, 2024
3812613
update spec for new perm logic in item details section
Jingo88 Oct 4, 2024
f53b337
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Oct 8, 2024
6308eca
updates to vault items and item details section to only disable and nโ€ฆ
Jingo88 Oct 9, 2024
97efd35
fix reversed logic for canEdit and canAssign in vault-items
Jingo88 Oct 9, 2024
65caab7
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Oct 14, 2024
2a93e72
update collections component to disable collections based on permissiโ€ฆ
Jingo88 Oct 14, 2024
8cd5cac
reduce logic for can assign for desktop
Jingo88 Oct 16, 2024
b94ee53
update naming for new cipherView getter
Jingo88 Oct 16, 2024
704b22f
merged latest, fixed conflicts
Jingo88 Oct 22, 2024
41b2cd4
merge latest, fix conflicts
Jingo88 Oct 28, 2024
a237e95
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Oct 31, 2024
5c598a4
do not show checkbox for cipher that has viewPassword false
Jingo88 Oct 31, 2024
03806ce
remove assign in browser for can edit except password
Jingo88 Nov 4, 2024
6589aa1
update error message for cli edit collections
Jingo88 Nov 5, 2024
7a5f0b1
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Nov 5, 2024
fcb68ce
remove excess space change
Jingo88 Nov 5, 2024
873e16c
updates to catch permissions before API call
Jingo88 Nov 6, 2024
2b8afdb
updated vault items so can edit except password does not get to assigโ€ฆ
Jingo88 Nov 7, 2024
2824e78
remove can edit except pw from assign to collections modal
Jingo88 Nov 8, 2024
4be508a
remove canEdit Except PW collections from edit item dropdown
Jingo88 Nov 8, 2024
ffc38d4
merged latest. fixed conflicts
Jingo88 Nov 8, 2024
b618f49
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Nov 11, 2024
9d2b125
updated CanEditItems helper
Jingo88 Nov 11, 2024
f2be128
Merge branch 'main' into PM-11162-assign-to-collections-perm
withinfocus Nov 11, 2024
0fa9f53
update comment
Jingo88 Nov 12, 2024
3530622
Merge branch 'main' into PM-11162-assign-to-collections-perm
kejaeger Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/src/app/vault/org-vault/vault.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
*ngIf="
filter.type !== 'trash' &&
filter.collectionId !== Unassigned &&
selectedCollection?.node?.canEditItems(organization)
selectedCollection?.node?.canEditItems(organization, false)
"
>
<i aria-hidden="true" class="bwi bwi-plus"></i> {{ "newItem" | i18n }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,17 @@
}

// Applying excludeHidePassword false will remove collections with Can Edit Except Password Permissions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

โ›๏ธ Comment is outdated

canEditItems(org: Organization, excludeHidePassword = true): boolean {
canEditItems(org: Organization, editPassword = true): boolean {
if (org != null && org.id !== this.organizationId) {
throw new Error(
"Id of the organization provided does not match the org id of the collection.",
);
}

return (

Check warning on line 50 in libs/admin-console/src/common/collections/models/collection.view.ts

View check run for this annotation

Codecov / codecov/patch

libs/admin-console/src/common/collections/models/collection.view.ts#L50

Added line #L50 was not covered by tests
org?.canEditAllCiphers ||
this.manage ||
(this.assigned &&
!this.readOnly &&
(excludeHidePassword ? true : this.hidePasswords === false))
(this.assigned && !this.readOnly && (!editPassword || !this.hidePasswords))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,27 +460,6 @@ describe("ItemDetailsSectionComponent", () => {
createMockCollection("col1", "Collection 1", "org1", true, false) as CollectionView,
createMockCollection("col2", "Collection 2", "org1", true, false) as CollectionView,
createMockCollection("col3", "Collection 3", "org1", false, false) as CollectionView,
// {
// id: "col1",
// name: "Collection 1",
// organizationId: "org1",
// readOnly: true,
// canEditItems: (_org) => false,
// } as CollectionView,
// {
// id: "col2",
// name: "Collection 2",
// organizationId: "org1",
// readOnly: true,
// canEditItems: (_org) => false,
// } as CollectionView,
// {
// id: "col3",
// name: "Collection 3",
// organizationId: "org1",
// readOnly: false,
// canEditItems: (_org) => false,
// } as CollectionView,
];

fixture.detectChanges();
Expand Down
shane-melton marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export class ItemDetailsSectionComponent implements OnInit {
// - When viewing as an admin, all collections should be shown, even readonly. When non-admin, filter out readonly collections
return (
c.organizationId === orgId &&
(this.partialEdit || c.canEditItems(organization, false) || this.config.admin)
(this.partialEdit || c.canEditItems(organization) || this.config.admin)
);
})
.map((c) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,13 @@
return;
}

const org = await this.organizationService.get(this.selectedOrgId);

Check warning on line 290 in libs/vault/src/components/assign-collections.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/vault/src/components/assign-collections.component.ts#L290

Added line #L290 was not covered by tests

this.availableCollections = this.params.availableCollections

Check warning on line 292 in libs/vault/src/components/assign-collections.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/vault/src/components/assign-collections.component.ts#L292

Added line #L292 was not covered by tests
.filter((collection) => {
return collection.canEditItems(org, false);
return collection.canEditItems(org);

Check warning on line 294 in libs/vault/src/components/assign-collections.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/vault/src/components/assign-collections.component.ts#L294

Added line #L294 was not covered by tests
})
.map((c) => ({

Check warning on line 296 in libs/vault/src/components/assign-collections.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/vault/src/components/assign-collections.component.ts#L296

Added line #L296 was not covered by tests
icon: "bwi-collection",
id: c.id,
labelName: c.name,
Expand Down
Loading