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 59 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
59 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
d876519
:q
Jingo88 Nov 14, 2024
f32e14e
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Nov 14, 2024
d8f2684
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Nov 15, 2024
c733941
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Nov 18, 2024
529d48d
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Nov 20, 2024
bca5ad5
updated to persist collections with can edit except password permissions
Jingo88 Nov 20, 2024
e6e0743
Merge branch 'main' into PM-11162-assign-to-collections-perm
kejaeger Nov 21, 2024
2594eb0
add check in edit item modal for null value of cipher
Jingo88 Nov 21, 2024
baf52b6
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Nov 21, 2024
5ef20db
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Nov 22, 2024
1444986
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Dec 2, 2024
f3ecbad
remove unavailableCollections logic. Putting that logic inside the seโ€ฆ
Jingo88 Dec 2, 2024
5b875c8
update translation key for no permissions hint in item details collecโ€ฆ
Jingo88 Dec 2, 2024
de90edd
merged latest, fixed conflicts
Jingo88 Dec 3, 2024
3b4b0a2
Merge branch 'main' into PM-11162-assign-to-collections-perm
kejaeger Dec 9, 2024
284dc8a
address resource not found error when user updates a item with only cโ€ฆ
Jingo88 Dec 10, 2024
8d711d9
remove excess import in cipher form
Jingo88 Dec 10, 2024
50a2a22
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Dec 10, 2024
4345e03
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Dec 11, 2024
3b3e51f
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Dec 12, 2024
3cdbee1
merged latest, fix conflicts
Jingo88 Dec 23, 2024
a1136b0
revert changes. keeping can edit except pw collections inside collectโ€ฆ
Jingo88 Dec 23, 2024
2842bfa
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Jan 3, 2025
957dc79
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Jan 6, 2025
82bc3d0
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Jan 6, 2025
13d38b8
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Jan 15, 2025
736f756
move org null check to cipher view
Jingo88 Jan 15, 2025
ce5add0
Merge branch 'main' into PM-11162-assign-to-collections-perm
Jingo88 Jan 15, 2025
01dafe4
Merge branch 'main' into PM-11162-assign-to-collections-perm
kejaeger Jan 16, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ <h1 class="box-header" id="collectionsTitle">
type="checkbox"
[(ngModel)]="$any(c).checked"
name="Collection[{{ i }}].Checked"
[disabled]="!canAssignCollections"
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class VaultCipherRowComponent implements OnInit {
@Input() collections: CollectionView[];
@Input() viewingOrgVault: boolean;
@Input() canEditCipher: boolean;
@Input() canAssignCollections: boolean;

@Output() onEvent = new EventEmitter<VaultItemEvent>();

Expand Down Expand Up @@ -71,7 +72,7 @@ export class VaultCipherRowComponent implements OnInit {
}

protected get showAssignToCollections() {
return this.canEditCipher && !this.cipher.isDeleted;
return this.canAssignCollections && !this.cipher.isDeleted;
}

protected get showClone() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
[collections]="allCollections"
[checked]="selection.isSelected(item)"
[canEditCipher]="canEditCipher(item.cipher)"
[canAssignCollections]="canAssignCollections(item.cipher)"
(checkedToggled)="selection.toggle(item)"
(onEvent)="event($event)"
></tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,18 @@
return (organization.canEditAllCiphers && this.viewingOrgVault) || cipher.edit;
}

protected canAssignCollections(cipher: CipherView) {
if (cipher.organizationId == null) {
return true;

Check warning on line 203 in apps/web/src/app/vault/components/vault-items/vault-items.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/vault/components/vault-items/vault-items.component.ts#L203

Added line #L203 was not covered by tests
}
eliykat marked this conversation as resolved.
Show resolved Hide resolved

const organization = this.allOrganizations.find((o) => o.id === cipher.organizationId);
return (

Check warning on line 207 in apps/web/src/app/vault/components/vault-items/vault-items.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/vault/components/vault-items/vault-items.component.ts#L206-L207

Added lines #L206 - L207 were not covered by tests
shane-melton marked this conversation as resolved.
Show resolved Hide resolved
(organization.canEditAllCiphers && this.viewingOrgVault) ||
(cipher.edit && cipher.viewPassword)
);
}

private refreshItems() {
const collections: VaultItem[] = this.collections.map((collection) => ({ collection }));
const ciphers: VaultItem[] = this.ciphers.map((cipher) => ({ cipher }));
Expand Down
eliykat marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
collections: CollectionView[] = [];
organization: Organization;

// Using to disable collections edit in desktop unless user has "Can Manage" or "Can Edit" permissions
canAssignCollections: boolean;

protected cipherDomain: Cipher;

constructor(
Expand Down Expand Up @@ -52,7 +55,7 @@
await this.cipherService.getKeyForCipherKeyDecryption(this.cipherDomain, activeUserId),
);
this.collections = await this.loadCollections();

this.subscribeAssignCollectionsCheck(this.cipher);

Check warning on line 58 in libs/angular/src/admin-console/components/collections.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/angular/src/admin-console/components/collections.component.ts#L58

Added line #L58 was not covered by tests
this.collections.forEach((c) => ((c as any).checked = false));
if (this.collectionIds != null) {
this.collections.forEach((c) => {
Expand All @@ -65,6 +68,16 @@
}
}

protected subscribeAssignCollectionsCheck(cipher: CipherView): void {
if (cipher?.organizationId == null) {
this.canAssignCollections = true;

Check warning on line 73 in libs/angular/src/admin-console/components/collections.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/angular/src/admin-console/components/collections.component.ts#L73

Added line #L73 was not covered by tests
Copy link
Member

Choose a reason for hiding this comment

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

I don't follow this - if the cipher isn't in an organization, you can't assign it to a collection.

}

this.organizationService.get$(cipher.organizationId).subscribe((org) => {

Check warning on line 76 in libs/angular/src/admin-console/components/collections.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/angular/src/admin-console/components/collections.component.ts#L76

Added line #L76 was not covered by tests
eliykat marked this conversation as resolved.
Show resolved Hide resolved
this.canAssignCollections = org.canEditAllCiphers || (cipher.edit && cipher.viewPassword);
eliykat marked this conversation as resolved.
Show resolved Hide resolved
});
}

async submit(): Promise<boolean> {
const selectedCollectionIds = this.collections
.filter((c) => {
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 @@ -213,6 +213,10 @@ export class ItemDetailsSectionComponent implements OnInit {
(this.originalCipherView.collectionIds as CollectionId[]),
);

if (!(this.originalCipherView?.edit && this.originalCipherView?.viewPassword)) {
this.itemDetailsForm.controls.collectionIds.disable();
}

if (this.partialEdit) {
this.itemDetailsForm.disable();
this.itemDetailsForm.controls.favorite.enable();
Expand Down
Loading