mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-30 13:03:53 +01:00
load manage collections a manager has access to
This commit is contained in:
parent
9b7478c0c7
commit
66b275605c
@ -14,10 +14,15 @@ import { ApiService } from 'jslib/abstractions/api.service';
|
|||||||
import { CollectionService } from 'jslib/abstractions/collection.service';
|
import { CollectionService } from 'jslib/abstractions/collection.service';
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||||
|
import { UserService } from 'jslib/abstractions/user.service';
|
||||||
|
|
||||||
import { CollectionData } from 'jslib/models/data/collectionData';
|
import { CollectionData } from 'jslib/models/data/collectionData';
|
||||||
import { Collection } from 'jslib/models/domain/collection';
|
import { Collection } from 'jslib/models/domain/collection';
|
||||||
import { CollectionDetailsResponse } from 'jslib/models/response/collectionResponse';
|
import {
|
||||||
|
CollectionDetailsResponse,
|
||||||
|
CollectionResponse,
|
||||||
|
} from 'jslib/models/response/collectionResponse';
|
||||||
|
import { ListResponse } from 'jslib/models/response/listResponse';
|
||||||
import { CollectionView } from 'jslib/models/view/collectionView';
|
import { CollectionView } from 'jslib/models/view/collectionView';
|
||||||
|
|
||||||
import { ModalComponent } from '../../modal.component';
|
import { ModalComponent } from '../../modal.component';
|
||||||
@ -42,7 +47,8 @@ export class CollectionsComponent implements OnInit {
|
|||||||
constructor(private apiService: ApiService, private route: ActivatedRoute,
|
constructor(private apiService: ApiService, private route: ActivatedRoute,
|
||||||
private collectionService: CollectionService, private componentFactoryResolver: ComponentFactoryResolver,
|
private collectionService: CollectionService, private componentFactoryResolver: ComponentFactoryResolver,
|
||||||
private analytics: Angulartics2, private toasterService: ToasterService,
|
private analytics: Angulartics2, private toasterService: ToasterService,
|
||||||
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService) { }
|
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
|
||||||
|
private userService: UserService) { }
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.route.parent.parent.params.subscribe(async (params) => {
|
this.route.parent.parent.params.subscribe(async (params) => {
|
||||||
@ -55,7 +61,13 @@ export class CollectionsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
const response = await this.apiService.getCollections(this.organizationId);
|
const organization = await this.userService.getOrganization(this.organizationId);
|
||||||
|
let response: ListResponse<CollectionResponse>;
|
||||||
|
if (organization.isAdmin) {
|
||||||
|
response = await this.apiService.getCollections(this.organizationId);
|
||||||
|
} else {
|
||||||
|
response = await this.apiService.getUserCollections();
|
||||||
|
}
|
||||||
const collections = response.data.map((r) =>
|
const collections = response.data.map((r) =>
|
||||||
new Collection(new CollectionData(r as CollectionDetailsResponse)));
|
new Collection(new CollectionData(r as CollectionDetailsResponse)));
|
||||||
this.collections = await this.collectionService.decryptMany(collections);
|
this.collections = await this.collectionService.decryptMany(collections);
|
||||||
|
Loading…
Reference in New Issue
Block a user