Do not require all title popup options be specified.
This commit is contained in:
@@ -64,7 +64,14 @@ export class FrigateCardTitleControl extends LitElement {
|
|||||||
protected _toastRef: Ref<PaperToast> = createRef();
|
protected _toastRef: Ref<PaperToast> = createRef();
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
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``;
|
return html``;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -723,14 +723,16 @@ export type NextPreviousControlConfig = z.infer<typeof nextPreviousControlConfig
|
|||||||
// *************************************************************************
|
// *************************************************************************
|
||||||
|
|
||||||
const titleControlConfigSchema = z.object({
|
const titleControlConfigSchema = z.object({
|
||||||
mode: z.enum([
|
mode: z
|
||||||
|
.enum([
|
||||||
'none',
|
'none',
|
||||||
'popup-top-right',
|
'popup-top-right',
|
||||||
'popup-top-left',
|
'popup-top-left',
|
||||||
'popup-bottom-right',
|
'popup-bottom-right',
|
||||||
'popup-bottom-left',
|
'popup-bottom-left',
|
||||||
]),
|
])
|
||||||
duration_seconds: z.number().min(0).max(60),
|
.optional(),
|
||||||
|
duration_seconds: z.number().min(0).max(60).optional(),
|
||||||
});
|
});
|
||||||
export type TitleControlConfig = z.infer<typeof titleControlConfigSchema>;
|
export type TitleControlConfig = z.infer<typeof titleControlConfigSchema>;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
customSchema,
|
customSchema,
|
||||||
dimensionsConfigSchema,
|
dimensionsConfigSchema,
|
||||||
frigateCardCustomActionsBaseSchema,
|
frigateCardCustomActionsBaseSchema,
|
||||||
frigateCardPTZSchema
|
frigateCardPTZSchema,
|
||||||
} from '../../src/config/types';
|
} from '../../src/config/types';
|
||||||
import { createConfig } from '../test-utils';
|
import { createConfig } from '../test-utils';
|
||||||
|
|
||||||
@@ -419,3 +419,19 @@ describe('should handle custom frigate elements', () => {
|
|||||||
expect(result.success).toBeTruthy();
|
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();
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user