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

Fix some errors #182

Merged
merged 3 commits into from
Apr 20, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions apps/browser/src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2423,5 +2423,20 @@
},
"encryptedInfoDismiss": {
"message": "I understand"
},
"home": {
"message": "Home"
},
"work": {
"message": "Work"
},
"cell": {
"message": "Cell"
},
"voice": {
"message": "Voice"
},
"fax": {
"message": "Fax"
}
}
15 changes: 15 additions & 0 deletions apps/browser/src/_locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2471,5 +2471,20 @@
},
"encryptedInfoDismiss": {
"message": "J'ai compris"
},
"home": {
"message": "Perso"
},
"work": {
"message": "Pro"
},
"cell": {
"message": "Mobile"
},
"voice": {
"message": "Fixe"
},
"fax": {
"message": "Fax"
}
}
2 changes: 0 additions & 2 deletions apps/browser/src/cozy/realtime/RealtimeNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ export class RealTimeNotifications {
this.cipherService,
this.i18nService,
hydratedData,
null,
{
noteIllustrationUrl,
}
Expand All @@ -125,7 +124,6 @@ export class RealTimeNotifications {
this.cipherService,
this.i18nService,
hydratedData,
null,
{
baseUrl,
}
Expand Down
2 changes: 2 additions & 0 deletions apps/browser/src/popup/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import { FlagConditionalComponent } from "../cozy/components/flag-conditional/fl
import { IfFlagDirective } from "../cozy/components/flag-conditional/if-flag.directive";
import { AddGenericComponent } from "../cozy/components/add-generic/add-generic.component";
import { ViewExpirationDateComponent } from "../vault/popup/components/vault/view-expiration-date.component";
import { ViewLabelComponent } from "../vault/popup/components/vault/view-label.component";
import { ContactAvatarComponent } from "../vault/popup/components/vault/contact-avatar.component";
import { ProfilesMigrationComponent } from "../cozy/components/profiles-migration/profiles-migration.component";
import { EncryptedInfoComponent } from "../cozy/components/encrypted-info/encrypted-info.component";
Expand Down Expand Up @@ -170,6 +171,7 @@ import { EncryptedInfoComponent } from "../cozy/components/encrypted-info/encryp
IfFlagDirective,
AddGenericComponent,
ViewExpirationDateComponent,
ViewLabelComponent,
ContactAvatarComponent,
ProfilesMigrationComponent,
EncryptedInfoComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ <h2 class="box-header">
(dragstart)="setTextDataOnDrag($event, field.value)"
>
{{ field.name }}
<span *ngIf="field.label" aria-hidden="true"> · </span>
<span *ngIf="field.label">
{{ field.label.type }}
</span>
<app-vault-view-label *ngIf="field.label" [label]="field.label"></app-vault-view-label>
</span>
<!-- Cozy customization end -->
<span *ngIf="field.type === fieldType.Linked" class="row-label">{{ field.name }}</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<span aria-hidden="true"> · </span>
<span>{{ this.stringifiedLabel }}</span>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Component, Input, OnInit } from "@angular/core";

import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LabelData } from "@bitwarden/common/vault/models/data/label.data";

@Component({
selector: "app-vault-view-label",
templateUrl: "./view-label.component.html",
})
export class ViewLabelComponent implements OnInit {
@Input() label: LabelData;
stringifiedLabel: string;

constructor(private i18nService: I18nService) {}

ngOnInit(): void {
if (this.label.type && !this.label.label) {
const type = this.getTranslatedType(this.label.type);

this.stringifiedLabel = type;
} else if (!this.label.type && this.label.label) {
const label = this.getTranslatedLabel(this.label.label);

this.stringifiedLabel = label;
} else if (this.label.type && this.label.label) {
const type = this.getTranslatedType(this.label.type);
const label = this.getTranslatedLabel(this.label.label);

this.stringifiedLabel = `${type} (${label.toLowerCase()})`;
}
}

getTranslatedType(type: string) {
return ["cell", "voice", "fax"].includes(type) ? this.i18nService.translate(type) : type;
}

getTranslatedLabel(label: string) {
return this.i18nService.translate(label);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,13 @@ export class ViewComponent extends BaseViewComponent {
if (this.cipher.type === CipherType.Paper) {
await favoritePaperCipher(
this.cipherService,
this.cryptoService,
this.i18nService,
this.cipher,
this.cozyClientService
);
} else if (this.cipher.type === CipherType.Contact) {
await favoriteContactCipher(
this.cipherService,
this.cryptoService,
this.i18nService,
this.cipher,
this.cozyClientService
Expand Down
2 changes: 1 addition & 1 deletion libs/common/src/vault/models/data/label.data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Cozy customization
export type LabelData = {
type: string;
type?: string;
label?: "home" | "work";
};
// Cozy customization end
2 changes: 1 addition & 1 deletion libs/cozy/contact.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const convertContactToCipherResponse = async (
cipherService: any,
i18nService: any,
contact: any,
key: SymmetricCryptoKey
key?: SymmetricCryptoKey
): Promise<CipherResponse> => {
const cipherView = new CipherView();
cipherView.id = contact.id ?? contact._id;
Expand Down
22 changes: 12 additions & 10 deletions libs/cozy/contactCipher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ const convertContactsAsCiphers = async (
const key = await cryptoService.getKeyForUserEncryption();

for (const contact of contacts) {
const cipherResponse = await convertContactToCipherResponse(
cipherService,
i18nService,
contact,
key
);

contactsCiphers.push(cipherResponse);
try {
const cipherResponse = await convertContactToCipherResponse(
cipherService,
i18nService,
contact,
key
);

contactsCiphers.push(cipherResponse);
} catch (e) {
console.log(`Error during conversion of contact ${contact.id}`, contact, e);
}
}

return contactsCiphers;
Expand Down Expand Up @@ -66,7 +70,6 @@ export const fetchContactsAndConvertAsCiphers = async (

export const favoriteContactCipher = async (
cipherService: CipherService,
cryptoService: CryptoService,
i18nService: I18nService,
cipher: CipherView,
cozyClientService: any
Expand All @@ -85,7 +88,6 @@ export const favoriteContactCipher = async (

const cipherResponse = await convertContactToCipherResponse(
cipherService,
cryptoService,
i18nService,
updatedContact
);
Expand Down
2 changes: 1 addition & 1 deletion libs/cozy/fields.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const buildContactField = ({

const fieldOptions: FieldOptions = {};

if (type) {
if (type || label) {
fieldOptions.label = {
type,
label,
Expand Down
4 changes: 2 additions & 2 deletions libs/cozy/note.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export const convertNoteToCipherResponse = async (
cipherService: any,
i18nService: any,
paper: any,
key: SymmetricCryptoKey,
options: NoteConversionOptions
options: NoteConversionOptions,
key?: SymmetricCryptoKey
): Promise<CipherResponse> => {
const { noteIllustrationUrl } = options;

Expand Down
4 changes: 2 additions & 2 deletions libs/cozy/paper.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export const convertPaperToCipherResponse = async (
cipherService: any,
i18nService: any,
paper: any,
key: SymmetricCryptoKey,
options: PaperConversionOptions
options: PaperConversionOptions,
key?: SymmetricCryptoKey
): Promise<CipherResponse> => {
const { baseUrl } = options;

Expand Down
37 changes: 26 additions & 11 deletions libs/cozy/paperCipher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,33 @@ export const convertPapersAsCiphers = async (

for (const paper of papers) {
let cipherResponse: CipherResponse;
if (isNote(paper)) {
cipherResponse = await convertNoteToCipherResponse(cipherService, i18nService, paper, key, {
noteIllustrationUrl,
});
} else {
cipherResponse = await convertPaperToCipherResponse(cipherService, i18nService, paper, key, {
baseUrl,
});
try {
if (isNote(paper)) {
cipherResponse = await convertNoteToCipherResponse(
cipherService,
i18nService,
paper,
{
noteIllustrationUrl,
},
key
);
} else {
cipherResponse = await convertPaperToCipherResponse(
cipherService,
i18nService,
paper,
{
baseUrl,
},
key
);
}

papersCiphers.push(cipherResponse);
} catch (e) {
console.log(`Error during conversion of paper ${paper.id}`, paper, e);
}
papersCiphers.push(cipherResponse);
}

return papersCiphers;
Expand Down Expand Up @@ -78,7 +95,6 @@ export const fetchPapersAndConvertAsCiphers = async (

export const favoritePaperCipher = async (
cipherService: CipherService,
cryptoService: CryptoService,
i18nService: I18nService,
cipher: CipherView,
cozyClientService: any
Expand All @@ -99,7 +115,6 @@ export const favoritePaperCipher = async (

const cipherResponse = await convertPaperToCipherResponse(
cipherService,
cryptoService,
i18nService,
updatePaperWithContacts,
{
Expand Down
Loading