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

[VER-355] feat: Remove Profiles concept #124

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions src/app/vault/add-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { UserService } from 'jslib/abstractions/user.service';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';

import { AddEditComponent as BaseAddEditComponent } from 'jslib/angular/components/add-edit.component';
import { CipherType } from 'jslib/enums/cipherType';

const BroadcasterSubscriptionId = 'AddEditComponent';

Expand All @@ -44,9 +45,11 @@ export class AddEditComponent extends BaseAddEditComponent implements OnChanges,
}

async ngOnInit() {
// @override by Cozy : remove the notes from the possible types of ciphers
this.typeOptions.pop();
// end override
// Cozy Customization, Remove notes and profiles from available types
// /*
const ignoredTypes = [CipherType.Identity, CipherType.SecureNote];
this.typeOptions = this.typeOptions.filter(type => !ignoredTypes.includes(type.value));
// */
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
this.ngZone.run(() => {
switch (message.command) {
Expand Down
5 changes: 4 additions & 1 deletion src/app/vault/ciphers.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@
</ng-container>
</div>
<div class="footer" [class.readonlyCipher]="isReadOnly">
<!-- Cozy customization -->
<!-- Prevent to create Profiles as they will be replaced by Cozy Contacts -->
<button appBlurClick (click)="addCipher()" (contextmenu)="addCipherOptions()" *ngIf="!isReadOnly"
class="block primary" appA11yTitle="{{'addItem' | i18n}}" [disabled]="deleted">
class="block primary" appA11yTitle="{{'addItem' | i18n}}" [disabled]="deleted || type === cipherType.Identity">
<i class="fa fa-plus fa-lg" aria-hidden="true"></i>
</button>
<!---->
<app-sharing *ngIf="collectionId && !isCozyConnectors" [collectionId]="collectionId"></app-sharing>
<app-bottom-menu
*ngIf="!isReadOnly"
Expand Down
12 changes: 12 additions & 0 deletions src/app/vault/ciphers.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { SearchService } from 'jslib/abstractions/search.service';

import { CiphersComponent as BaseCiphersComponent } from 'jslib/angular/components/ciphers.component';

import { CipherType } from 'jslib/enums/cipherType';
import { CipherView } from 'jslib/models/view/cipherView';

import { UserService } from '../../services/user.service';
Expand All @@ -20,6 +21,12 @@ export class CiphersComponent extends BaseCiphersComponent {
@Output() onDeletedCipher = new EventEmitter();
@Input() collectionId: string = null;

// Cozy customization, Add type to allow disabling profiles creation
// /*
@Input() type: CipherType = null;
cipherType = CipherType;
// */

isReadOnly = false;
isCozyConnectors = false;

Expand Down Expand Up @@ -124,7 +131,12 @@ export class CiphersComponent extends BaseCiphersComponent {

protected restoreCiphers() {
const ids = this.ciphers
// Cozy customization, Prevent to restore deleted Profiles as they will be replaced by Cozy Contacts
/*
.filter(cipher => cipher.isDeleted)
/*/
.filter(cipher => cipher.isDeleted && cipher.type !== CipherType.Identity)
// */
.map(cipher => cipher.id);

return this.cipherService.restoreManyWithServer(ids);
Expand Down
5 changes: 4 additions & 1 deletion src/app/vault/groupings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ <h2>{{'types' | i18n}}</h2>
&nbsp;{{'typeCard' | i18n}}
</a>
</li>
<li [ngClass]="{active: selectedType === cipherType.Identity}">
<!-- Cozy customization -->
<!-- Disable Profiles if empty as they will be replaced by Cozy Contacts -->
<li [ngClass]="{active: selectedType === cipherType.Identity}" *ngIf="this.typeCounts.get(cipherType.Identity) > 0">
<a href="#" appStopClick appBlurClick (click)="selectType(cipherType.Identity)">
<svg class="icon-type" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 24">
<g fill="none" fill-rule="evenodd">
Expand All @@ -73,6 +75,7 @@ <h2>{{'types' | i18n}}</h2>
&nbsp;{{'typeIdentity' | i18n}}
</a>
</li>
<!---->
<li *ngIf="hasNotes" [ngClass]="{active: selectedType === cipherType.SecureNote}">
<a href="#" appStopClick appBlurClick (click)="selectType(cipherType.SecureNote)">
<svg class="icon-type" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
Expand Down
32 changes: 32 additions & 0 deletions src/app/vault/groupings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import { GroupingsComponent as BaseGroupingsComponent } from 'jslib/angular/comp
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
import { CollectionView } from 'jslib/models/view/collectionView';

import { CipherType } from 'jslib/enums/cipherType';
import { ServiceUtils } from 'jslib/misc/serviceUtils';
import { CipherView } from 'jslib/models/view';

const NestingDelimiter = '/';

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

hasNotes: boolean;
private prevSelection: any = new Object();
Expand Down Expand Up @@ -57,6 +63,10 @@ export class GroupingsComponent extends BaseGroupingsComponent {
return (c.type === 2 && !c.isDeleted);
});
this.hasNotes = (noteIndex > -1) ;
// Cozy customization, Add typeCounts to conditionnaly remove Profiles section
// /*
await this.getCounts();
// */
// run super
super.load(setLoaded);
}
Expand Down Expand Up @@ -188,6 +198,28 @@ export class GroupingsComponent extends BaseGroupingsComponent {

// */

// Cozy customization, Add typeCounts to conditionnaly remove Profiles section
// /*
async getCounts() {
const typeCounts = new Map<CipherType, number>();

const ciphers = await this.cipherService.getAllDecrypted();
ciphers.forEach(c => {
if (c.isDeleted) {
return;
}

if (typeCounts.has(c.type)) {
typeCounts.set(c.type, typeCounts.get(c.type) + 1);
} else {
typeCounts.set(c.type, 1);
}
});

this.typeCounts = typeCounts;
}
// */

protected isOrgWithNoKey(collection: CollectionView) {
// in loadCollections() we set collection.id = collection.organization.id for organizations with no key
return collection.id === collection.organizationId;
Expand Down
4 changes: 4 additions & 0 deletions src/app/vault/vault.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
(onAddFolder)="addFolder()" (onEditFolder)="editFolder($event.id)"
(onCollectionClicked)="filterCollection($event.id)" (onTrashClicked)="filterDeleted()" (onImportClicked)="startImport()">
</app-vault-groupings>
<!-- Cozy customization -->
<!-- Add type to allow disabling profiles creation -->
<app-vault-ciphers id="items" [hidden]="action === 'import'"
class="{{shouldDisplayCiphersList()}} items"
[type]="type"
[activeCipherId]="cipherId" (onCipherClicked)="viewCipher($event)"
(onCipherRightClicked)="viewCipherMenu($event)" (onAddCipher)="addCipher($event)"
(onAddCipherOptions)="addCipherOptions()" (onDeletedCipher)="deletedCipher($event)"
[collectionId]="collectionId">
</app-vault-ciphers>
<!---->
<app-vault-view id="details" class="details" *ngIf="cipherId && action === 'view'" [cipherId]="cipherId"
(onCloneCipher)="cloneCipher($event)" (onEditCipher)="editCipher($event)"
(onViewCipherPasswordHistory)="viewCipherPasswordHistory($event)" (onRestoredCipher)="restoredCipher($event)"
Expand Down
5 changes: 4 additions & 1 deletion src/app/vault/view.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,11 @@
<i class="fa fa-pencil fa-fw fa-lg" aria-hidden="true"></i>
<span>{{'edit' | i18n}}</span>
</button>
<!-- Cozy customization -->
<!-- Prevent to restore deleted Profiles as they will be replaced by Cozy Contacts -->
<button appBlurClick class="primary" (click)="restore()" appA11yTitle="{{'restore' | i18n}}"
*ngIf="cipher.isDeleted">
*ngIf="cipher.isDeleted && cipher.type !== cipherType.Identity">
<!---->
<i class="fa fa-undo fa-fw fa-lg" aria-hidden="true"></i>
<span>{{'restore' | i18n}}</span>
</button>
Expand Down
5 changes: 5 additions & 0 deletions src/app/vault/view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { StorageService } from 'jslib/abstractions/storage.service';
import { TokenService } from 'jslib/abstractions/token.service';
import { TotpService } from 'jslib/abstractions/totp.service';
import { UserService } from 'jslib/abstractions/user.service';
import { CipherType } from 'jslib/enums/cipherType';

import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';

Expand All @@ -38,6 +39,10 @@ export class ViewComponent extends BaseViewComponent implements OnChanges {
@Output() onViewCipherPasswordHistory = new EventEmitter<CipherView>();

isReadOnly = false;
// Cozy customization, Prevent to restore deleted Profiles as they will be replaced by Cozy Contacts
// /*
cipherType = CipherType;
// */

constructor(cipherService: CipherService, totpService: TotpService,
tokenService: TokenService, i18nService: I18nService,
Expand Down