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

[AC-2555] Cipher collections dialog merge fixes #9036

Merged
merged 4 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { CollectionsComponent as BaseCollectionsComponent } from "@bitwarden/angular/admin-console/components/collections.component";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";

Check warning on line 8 in apps/browser/src/vault/popup/components/vault/collections.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/vault/popup/components/vault/collections.component.ts#L8

Added line #L8 was not covered by tests
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
Expand All @@ -26,6 +27,7 @@
private route: ActivatedRoute,
private location: Location,
logService: LogService,
configService: ConfigService,
) {
super(
collectionService,
Expand All @@ -34,6 +36,7 @@
cipherService,
organizationService,
logService,
configService,
);
}

Expand Down
3 changes: 3 additions & 0 deletions apps/desktop/src/vault/app/vault/collections.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { CollectionsComponent as BaseCollectionsComponent } from "@bitwarden/angular/admin-console/components/collections.component";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";

Check warning on line 5 in apps/desktop/src/vault/app/vault/collections.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/vault/app/vault/collections.component.ts#L5

Added line #L5 was not covered by tests
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
Expand All @@ -20,14 +21,16 @@
platformUtilsService: PlatformUtilsService,
organizationService: OrganizationService,
logService: LogService,
configService: ConfigService,
) {
super(
collectionService,
platformUtilsService,
i18nService,
cipherService,
organizationService,
logService,
configService,

Check notice on line 33 in apps/desktop/src/vault/app/vault/collections.component.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Excess Number of Function Arguments

CollectionsComponent.constructor increases from 6 to 7 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.
);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { DIALOG_DATA, DialogConfig, DialogRef } from "@angular/cdk/dialog";
import { Component, OnDestroy, Inject } from "@angular/core";
import { Component, Inject, OnDestroy } from "@angular/core";

import { CollectionsComponent as BaseCollectionsComponent } from "@bitwarden/angular/admin-console/components/collections.component";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
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 { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
Expand All @@ -23,6 +24,7 @@ export class CollectionsComponent extends BaseCollectionsComponent implements On
cipherService: CipherService,
organizationSerivce: OrganizationService,
logService: LogService,
configService: ConfigService,
protected dialogRef: DialogRef,
@Inject(DIALOG_DATA) params: CollectionsDialogParams,
) {
Expand All @@ -33,6 +35,7 @@ export class CollectionsComponent extends BaseCollectionsComponent implements On
cipherService,
organizationSerivce,
logService,
configService,
);
this.cipherId = params?.cipherId;
}
Expand Down
3 changes: 3 additions & 0 deletions apps/web/src/app/vault/org-vault/collections.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Component, Inject } from "@angular/core";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
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 { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
Expand Down Expand Up @@ -35,6 +36,7 @@ export class CollectionsComponent extends BaseCollectionsComponent {
organizationService: OrganizationService,
private apiService: ApiService,
logService: LogService,
configService: ConfigService,
protected dialogRef: DialogRef,
@Inject(DIALOG_DATA) params: OrgVaultCollectionsDialogParams,
) {
Expand All @@ -45,6 +47,7 @@ export class CollectionsComponent extends BaseCollectionsComponent {
cipherService,
organizationService,
logService,
configService,
dialogRef,
params,
);
Expand Down
23 changes: 2 additions & 21 deletions apps/web/src/app/vault/org-vault/vault.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {

Check notice on line 1 in apps/web/src/app/vault/org-vault/vault.component.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Overall Code Complexity

The mean cyclomatic complexity decreases from 6.17 to 6.14, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
ChangeDetectorRef,
Component,
NgZone,
Expand Down Expand Up @@ -802,33 +802,14 @@
const dialog = openOrgVaultCollectionsDialog(this.dialogService, {
data: {
collectionIds: cipher.collectionIds,
collections: collections.filter((c) => !c.readOnly && c.id != Unassigned),
collections: collections,
organization: this.organization,
cipherId: cipher.id,
},
});
/**

const [modal] = await this.modalService.openViewRef(
CollectionsComponent,
this.collectionsModalRef,
(comp) => {
comp.flexibleCollectionsV1Enabled = this.flexibleCollectionsV1Enabled;
comp.collectionIds = cipher.collectionIds;
comp.collections = collections;
comp.organization = this.organization;
comp.cipherId = cipher.id;
comp.onSavedCollections.pipe(takeUntil(this.destroy$)).subscribe(() => {
modal.close();
this.refresh();
});
},
);

*/

if ((await lastValueFrom(dialog.closed)) == CollectionsDialogResult.Saved) {
await this.refresh();
this.refresh();

Check warning on line 812 in apps/web/src/app/vault/org-vault/vault.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/vault/org-vault/vault.component.ts#L812

Added line #L812 was not covered by tests
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,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 { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";

Check warning on line 6 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#L5-L6

Added lines #L5 - L6 were not covered by tests
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
Expand Down Expand Up @@ -33,9 +35,13 @@
protected cipherService: CipherService,
protected organizationService: OrganizationService,
private logService: LogService,
private configService: ConfigService,

Check warning on line 38 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#L38

Added line #L38 was not covered by tests
) {}

async ngOnInit() {
this.flexibleCollectionsV1Enabled = await this.configService.getFeatureFlag(

Check warning on line 42 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#L42

Added line #L42 was not covered by tests
FeatureFlag.FlexibleCollectionsV1,
);
await this.load();
}

Expand Down