This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…1726) * [fix] Pull org admin vault collections directly from the API * [refactor] Establish pattern for interfaces in module scoped services * [fix] Remove access modifiers from constructor params for an extended service * [fix] Rename skipFilterCollectionRefresh to firstLoaded * [fix] Simplify hiding unwanted filters in the org vault * Revert "[refactor] Establish pattern for interfaces in module scoped services" This reverts commit f1edae5. * Update src/app/modules/vault-filter/vault-filter.component.ts Co-authored-by: Thomas Rittson <[email protected]> * Update src/app/modules/vault-filter/organization-vault-filter.component.ts Co-authored-by: Thomas Rittson <[email protected]> * [fix] Ran prettier Co-authored-by: Thomas Rittson <[email protected]> Co-authored-by: Thomas Rittson <[email protected]>
- Loading branch information
1 parent
1c09629
commit 66391b4
Showing
8 changed files
with
111 additions
and
57 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/app/modules/vault-filter/organization-vault-filter.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Component, Input } from "@angular/core"; | ||
|
||
import { Organization } from "jslib-common/models/domain/organization"; | ||
|
||
import { VaultFilterComponent } from "./vault-filter.component"; | ||
|
||
@Component({ | ||
selector: "app-organization-vault-filter", | ||
templateUrl: "vault-filter.component.html", | ||
}) | ||
export class OrganizationVaultFilterComponent extends VaultFilterComponent { | ||
hideOrganizations = true; | ||
hideFavorites = true; | ||
hideFolders = true; | ||
|
||
organization: Organization; | ||
|
||
async initCollections() { | ||
if (this.organization.canEditAnyCollection) { | ||
return await this.vaultFilterService.buildAdminCollections(this.organization.id); | ||
} | ||
return await this.vaultFilterService.buildCollections(this.organization.id); | ||
} | ||
|
||
async reloadCollectionsAndFolders() { | ||
this.collections = await this.initCollections(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,54 @@ | ||
import { Injectable } from "@angular/core"; | ||
|
||
import { DynamicTreeNode } from "jslib-angular/modules/vault-filter/models/dynamic-tree-node.model"; | ||
import { VaultFilterService as BaseVaultFilterService } from "jslib-angular/modules/vault-filter/vault-filter.service"; | ||
import { ApiService } from "jslib-common/abstractions/api.service"; | ||
import { CipherService } from "jslib-common/abstractions/cipher.service"; | ||
import { CollectionService } from "jslib-common/abstractions/collection.service"; | ||
import { FolderService } from "jslib-common/abstractions/folder.service"; | ||
import { OrganizationService } from "jslib-common/abstractions/organization.service"; | ||
import { PolicyService } from "jslib-common/abstractions/policy.service"; | ||
import { StateService } from "jslib-common/abstractions/state.service"; | ||
import { CollectionData } from "jslib-common/models/data/collectionData"; | ||
import { Collection } from "jslib-common/models/domain/collection"; | ||
import { CollectionDetailsResponse } from "jslib-common/models/response/collectionResponse"; | ||
import { CollectionView } from "jslib-common/models/view/collectionView"; | ||
|
||
@Injectable() | ||
export class VaultFilterService extends BaseVaultFilterService { | ||
constructor( | ||
stateService: StateService, | ||
organizationService: OrganizationService, | ||
folderService: FolderService, | ||
cipherService: CipherService, | ||
collectionService: CollectionService, | ||
policyService: PolicyService, | ||
protected apiService: ApiService | ||
) { | ||
super( | ||
stateService, | ||
organizationService, | ||
folderService, | ||
cipherService, | ||
collectionService, | ||
policyService | ||
); | ||
} | ||
|
||
async buildAdminCollections(organizationId: string) { | ||
let result: CollectionView[] = []; | ||
const collectionResponse = await this.apiService.getCollections(organizationId); | ||
if (collectionResponse?.data != null && collectionResponse.data.length) { | ||
const collectionDomains = collectionResponse.data.map( | ||
(r: CollectionDetailsResponse) => new Collection(new CollectionData(r)) | ||
); | ||
result = await this.collectionService.decryptMany(collectionDomains); | ||
} | ||
|
||
export class VaultFilterService extends BaseVaultFilterService {} | ||
const nestedCollections = await this.collectionService.getAllNested(result); | ||
return new DynamicTreeNode<CollectionView>({ | ||
fullList: result, | ||
nestedList: nestedCollections, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters