1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-10 05:30:01 +00:00

React to Metadata Changes

This commit is contained in:
Justin Baur
2025-03-20 16:09:29 -04:00
parent ec69b7c165
commit 6311e8b566
4 changed files with 16 additions and 15 deletions

View File

@@ -370,8 +370,8 @@ export class FilterBuilderComponent implements OnInit {
}
}),
fields: customMap(
metadata.fieldNames,
(f, i) => ({ value: f, label: f }) satisfies ChipSelectOption<string>,
metadata.customFields,
(f, i) => ({ value: f.name, label: f.name }) satisfies ChipSelectOption<string>,
),
anyHaveAttachment: metadata.attachmentCount !== 0,
} satisfies FilterData;
@@ -442,7 +442,6 @@ export class FilterBuilderComponent implements OnInit {
}
protected saveFilter() {
// TODO: Handle advanced mode and just emit the raw text
const currentFilter = this.convertFilter(this.form.value);
this.saveFilterEvent.emit(currentFilter.raw);
}
@@ -457,6 +456,7 @@ export class FilterBuilderComponent implements OnInit {
} else {
if (!this.trySetBasicFilterElements(this.form.controls.text.value)) {
console.log("Could not set filter back to basic, button should have been disabled.");
this.mode = "advanced";
return;
}
}

View File

@@ -2,8 +2,9 @@ import { Meta, moduleMetadata, StoryObj } from "@storybook/angular";
import { map, of } from "rxjs";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherType, FieldType } from "@bitwarden/common/vault/enums";
import {
CustomFieldMetadata,
VaultFilterMetadata,
VaultFilterMetadataService,
} from "@bitwarden/common/vault/filtering/vault-filter-metadata.service";
@@ -58,10 +59,10 @@ export default {
[CipherType.SecureNote, 1],
[CipherType.SshKey, 1],
]),
fieldNames: new Map([
["one", 1],
["two", 1],
["three", 1],
customFields: new Map<CustomFieldMetadata, number>([
[{ name: "one", type: FieldType.Boolean, linkedType: null }, 1],
[{ name: "one", type: FieldType.Boolean, linkedType: null }, 1],
[{ name: "one", type: FieldType.Boolean, linkedType: null }, 1],
]),
attachmentCount: 1,
} satisfies VaultFilterMetadata;
@@ -90,7 +91,6 @@ export const Default: Story = {
props: args,
template: /*html*/ `
<app-filter-builder [ciphers]="ciphers" (searchFilterEvent)="searchFilterEvent($event)" (saveFilterEvent)="saveFilterEvent($event)"></app-filter-builder>
`,
}),
args: {

View File

@@ -2,8 +2,9 @@ import { Meta, moduleMetadata, StoryObj } from "@storybook/angular";
import { map, of } from "rxjs";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherType, FieldType } from "@bitwarden/common/vault/enums";
import {
CustomFieldMetadata,
VaultFilterMetadata,
VaultFilterMetadataService,
} from "@bitwarden/common/vault/filtering/vault-filter-metadata.service";
@@ -56,10 +57,10 @@ export default {
[CipherType.SecureNote, 1],
[CipherType.SshKey, 1],
]),
fieldNames: new Map([
["one", 1],
["two", 1],
["three", 1],
customFields: new Map<CustomFieldMetadata, number>([
[{ name: "one", type: FieldType.Boolean, linkedType: null }, 1],
[{ name: "one", type: FieldType.Boolean, linkedType: null }, 1],
[{ name: "one", type: FieldType.Boolean, linkedType: null }, 1],
]),
attachmentCount: 1,
} satisfies VaultFilterMetadata;

View File

@@ -12,7 +12,7 @@ export type VaultFilterMetadata = {
attachmentCount: number;
};
type CustomFieldMetadata = {
export type CustomFieldMetadata = {
name: string;
type: FieldType;
linkedType: LinkedIdType | null;