Skip to content

Commit 9734bf4

Browse files
committed
feat: Hide Profiles category if empty
We want to remove the concept of `Profiles` as they overlap with Cozy's `Contacts` In cozy-keys-browser we will add the concept of `Contacts` to replace old profiles, but in cozy-pass-web we don't need to do this as the `cozy-contact` app already exists This commit hides the `Profile` category if empty (which should be the case after the migration is done on cozy-keys-browser side) Related PR: cozy/cozy-keys-browser#169
1 parent 7c31741 commit 9734bf4

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/app/vault/groupings.component.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ <h2>{{'types' | i18n}}</h2>
6262
&nbsp;{{'typeCard' | i18n}}
6363
</a>
6464
</li>
65-
<li [ngClass]="{active: selectedType === cipherType.Identity}">
65+
<!-- Cozy customization -->
66+
<!-- Disable Profiles if empty as they will be replaced by Cozy Contacts -->
67+
<li [ngClass]="{active: selectedType === cipherType.Identity}" *ngIf="this.typeCounts.get(cipherType.Identity) > 0">
6668
<a href="#" appStopClick appBlurClick (click)="selectType(cipherType.Identity)">
6769
<svg class="icon-type" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 24">
6870
<g fill="none" fill-rule="evenodd">
@@ -73,6 +75,7 @@ <h2>{{'types' | i18n}}</h2>
7375
&nbsp;{{'typeIdentity' | i18n}}
7476
</a>
7577
</li>
78+
<!---->
7679
<li *ngIf="hasNotes" [ngClass]="{active: selectedType === cipherType.SecureNote}">
7780
<a href="#" appStopClick appBlurClick (click)="selectType(cipherType.SecureNote)">
7881
<svg class="icon-type" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">

src/app/vault/groupings.component.ts

+32
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
1212
import { CollectionView } from 'jslib/models/view/collectionView';
1313

1414
import { ServiceUtils } from 'jslib/misc/serviceUtils';
15+
import { CipherType } from 'jslib/enums/cipherType';
16+
import { CipherView } from 'jslib/models/view';
1517

1618
const NestingDelimiter = '/';
1719

@@ -26,6 +28,10 @@ export class GroupingsComponent extends BaseGroupingsComponent {
2628
@Output() onImportClicked = new EventEmitter<void>();
2729
importSelected = false;
2830
collectionsWithUsersToValidateIds: { [id: string]: string[] } = {};
31+
// Cozy customization, Add typeCounts to conditionnaly remove Profiles section
32+
//*
33+
typeCounts = new Map<CipherType, number>();
34+
//*/
2935

3036
hasNotes: boolean;
3137
private prevSelection: any = new Object();
@@ -57,6 +63,10 @@ export class GroupingsComponent extends BaseGroupingsComponent {
5763
return (c.type === 2 && !c.isDeleted);
5864
});
5965
this.hasNotes = (noteIndex > -1) ;
66+
// Cozy customization, Add typeCounts to conditionnaly remove Profiles section
67+
//*
68+
await this.getCounts();
69+
//*/
6070
// run super
6171
super.load(setLoaded);
6272
}
@@ -192,4 +202,26 @@ export class GroupingsComponent extends BaseGroupingsComponent {
192202
// in loadCollections() we set collection.id = collection.organization.id for organizations with no key
193203
return collection.id === collection.organizationId;
194204
}
205+
206+
// Cozy customization, Add typeCounts to conditionnaly remove Profiles section
207+
//*
208+
async getCounts() {
209+
const typeCounts = new Map<CipherType, number>();
210+
211+
const ciphers = await this.cipherService.getAllDecrypted();
212+
ciphers.forEach((c) => {
213+
if (c.isDeleted) {
214+
return;
215+
}
216+
217+
if (typeCounts.has(c.type)) {
218+
typeCounts.set(c.type, typeCounts.get(c.type) + 1);
219+
} else {
220+
typeCounts.set(c.type, 1);
221+
}
222+
});
223+
224+
this.typeCounts = typeCounts;
225+
}
226+
//*/
195227
}

0 commit comments

Comments
 (0)