Allow other fire-dom-event users (e.g. browser_mod)

This commit is contained in:
Dermot Duffy
2022-07-23 21:53:07 -07:00
parent 6c2409194b
commit 2f0e99a94e
3 changed files with 11 additions and 13 deletions
+8 -11
View File
@@ -331,22 +331,23 @@ export class FrigateCard extends LitElement {
for (const action of actions) {
// All frigate card actions will have action of 'fire-dom-event' and
// styling only applies to those.
if (!action || action.action !== 'fire-dom-event') {
if (!action || action.action !== 'fire-dom-event' || !('frigate_card_action' in action)) {
continue;
}
const frigateCardAction = action as FrigateCardCustomAction;
if (
FRIGATE_CARD_VIEWS_USER_SPECIFIED.some(
(view) =>
view === action?.frigate_card_action &&
this._view?.is(action.frigate_card_action),
view === frigateCardAction.frigate_card_action &&
this._view?.is(frigateCardAction.frigate_card_action),
) ||
(action?.frigate_card_action === 'default' &&
(frigateCardAction.frigate_card_action === 'default' &&
this._view?.is(this._getConfig().view.default)) ||
(action?.frigate_card_action === 'fullscreen' &&
(frigateCardAction.frigate_card_action === 'fullscreen' &&
screenfull.isEnabled &&
screenfull.isFullscreen) ||
(action?.frigate_card_action === 'camera_select' &&
this._view?.camera === action.camera)
(frigateCardAction.frigate_card_action === 'camera_select' &&
this._view?.camera === frigateCardAction.camera)
) {
return this._getEmphasizedStyle();
}
@@ -1304,10 +1305,6 @@ export class FrigateCard extends LitElement {
* @param ev The action requested.
*/
protected _cardActionHandler(ev: CustomEvent<ActionType>): void {
// These interactions should only be handled by the card, as nothing
// upstream has the user-provided configuration.
ev.stopPropagation();
const frigateCardAction = convertActionToFrigateCardCustomAction(ev.detail);
if (!frigateCardAction) {
return;
+2 -1
View File
@@ -167,7 +167,7 @@ const customActionSchema = schemaForType<
>()(
actionBaseSchema.extend({
action: z.literal('fire-dom-event'),
}),
}).passthrough(),
);
const noActionSchema = schemaForType<
NoActionConfig & ExtendedConfirmationRestrictionConfig
@@ -236,6 +236,7 @@ const actionSchema = z.union([
urlActionSchema,
moreInfoActionSchema,
noActionSchema,
customActionSchema,
frigateCardCustomActionSchema,
]);
export type ActionType = z.infer<typeof actionSchema>;