From 913355ad1d77b79f801a86dee6226ac714480dec Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Tue, 3 Oct 2023 19:53:02 -0700 Subject: [PATCH] Do not require all title popup options be specified. --- src/components/title-control.ts | 9 ++++++++- src/config/types.ts | 20 +++++++++++--------- tests/config/types.test.ts | 18 +++++++++++++++++- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/components/title-control.ts b/src/components/title-control.ts index 1a3cdd84..e93a1c6c 100644 --- a/src/components/title-control.ts +++ b/src/components/title-control.ts @@ -64,7 +64,14 @@ export class FrigateCardTitleControl extends LitElement { protected _toastRef: Ref = createRef(); protected render(): TemplateResult { - if (!this.text || !this.config || this.config.mode == 'none' || !this.fitInto) { + if ( + !this.text || + !this.config || + !this.config.mode || + this.config.duration_seconds === undefined || + this.config.mode === 'none' || + !this.fitInto + ) { return html``; } diff --git a/src/config/types.ts b/src/config/types.ts index 621a649e..88574ce7 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -390,7 +390,7 @@ export const conditionalSchema = z.object({ export const customSchema = z .object({ // Insist that Frigate card custom elements are handled by other schemas. - type: z.string().superRefine((val, ctx) => { + type: z.string().superRefine((val, ctx) => { if (!val.match(/^custom:(?!frigate-card).+/)) { ctx.addIssue({ code: z.ZodIssueCode.custom, @@ -723,14 +723,16 @@ export type NextPreviousControlConfig = z.infer; diff --git a/tests/config/types.test.ts b/tests/config/types.test.ts index 7882536f..4f49e905 100644 --- a/tests/config/types.test.ts +++ b/tests/config/types.test.ts @@ -4,7 +4,7 @@ import { customSchema, dimensionsConfigSchema, frigateCardCustomActionsBaseSchema, - frigateCardPTZSchema + frigateCardPTZSchema, } from '../../src/config/types'; import { createConfig } from '../test-utils'; @@ -419,3 +419,19 @@ describe('should handle custom frigate elements', () => { expect(result.success).toBeTruthy(); }); }); + +// https://github.com/dermotduffy/frigate-hass-card/issues/1280 +it('should not require title controls to specify all options', () => { + expect( + createConfig({ + cameras: [], + live: { + controls: { + title: { + mode: 'popup-top-left', + }, + }, + }, + }), + ).toBeTruthy(); +});