mirror of
https://github.com/bitwarden/browser.git
synced 2025-03-10 13:09:37 +01:00
filter out linked option for notes (#10162)
This commit is contained in:
parent
f75c1ab02d
commit
bf66cd1550
@ -2,7 +2,7 @@ import { DIALOG_DATA } from "@angular/cdk/dialog";
|
||||
import { ComponentFixture, TestBed } from "@angular/core/testing";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { FieldType } from "@bitwarden/common/vault/enums";
|
||||
import { CipherType, FieldType } from "@bitwarden/common/vault/enums";
|
||||
|
||||
import {
|
||||
AddEditCustomFieldDialogComponent,
|
||||
@ -20,6 +20,7 @@ describe("AddEditCustomFieldDialogComponent", () => {
|
||||
addField,
|
||||
updateLabel,
|
||||
removeField,
|
||||
cipherType: CipherType.Login,
|
||||
} as AddEditCustomFieldDialogData;
|
||||
|
||||
beforeEach(async () => {
|
||||
@ -69,4 +70,15 @@ describe("AddEditCustomFieldDialogComponent", () => {
|
||||
|
||||
expect(removeField).toHaveBeenCalledWith(2);
|
||||
});
|
||||
|
||||
it('filters out "Linked" field type for SecureNote cipher type', () => {
|
||||
dialogData.cipherType = CipherType.SecureNote;
|
||||
|
||||
fixture = TestBed.createComponent(AddEditCustomFieldDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
expect(component.fieldTypeOptions).not.toContainEqual(
|
||||
expect.objectContaining({ value: FieldType.Linked }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -5,7 +5,7 @@ import { FormBuilder, ReactiveFormsModule, Validators } from "@angular/forms";
|
||||
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { FieldType } from "@bitwarden/common/vault/enums";
|
||||
import { CipherType, FieldType } from "@bitwarden/common/vault/enums";
|
||||
import {
|
||||
AsyncActionsModule,
|
||||
ButtonModule,
|
||||
@ -19,6 +19,8 @@ export type AddEditCustomFieldDialogData = {
|
||||
addField: (type: FieldType, label: string) => void;
|
||||
updateLabel: (index: number, label: string) => void;
|
||||
removeField: (index: number) => void;
|
||||
/** Type of cipher */
|
||||
cipherType: CipherType;
|
||||
/** When provided, dialog will display edit label variants */
|
||||
editLabelConfig?: { index: number; label: string };
|
||||
};
|
||||
@ -63,6 +65,15 @@ export class AddEditCustomFieldDialogComponent {
|
||||
) {
|
||||
this.variant = data.editLabelConfig ? "edit" : "add";
|
||||
|
||||
this.fieldTypeOptions = this.fieldTypeOptions.filter((option) => {
|
||||
// Filter out the Linked field type for Secure Notes
|
||||
if (this.data.cipherType === CipherType.SecureNote) {
|
||||
return option.value !== FieldType.Linked;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
if (this.variant === "edit") {
|
||||
this.customFieldForm.controls.label.setValue(data.editLabelConfig.label);
|
||||
this.customFieldForm.controls.type.disable();
|
||||
|
@ -201,6 +201,7 @@ export class CustomFieldsComponent implements OnInit, AfterViewInit {
|
||||
addField: this.addField.bind(this),
|
||||
updateLabel: this.updateLabel.bind(this),
|
||||
removeField: this.removeField.bind(this),
|
||||
cipherType: this.cipherFormContainer.config.cipherType,
|
||||
editLabelConfig,
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user