Add menu conditions.

This commit is contained in:
Dermot Duffy
2021-11-14 15:32:25 -08:00
parent 3ae908d4b7
commit c7506c9ee0
7 changed files with 481 additions and 302 deletions
+5 -1
View File
@@ -26,6 +26,7 @@ import {
} from '../common.js';
import menuStyle from '../scss/menu.scss';
import { ConditionState, evaluateCondition } from '../card-condition.js';
export const MENU_HEIGHT = 46;
export const FRIGATE_BUTTON_MENU_ICON = 'frigate';
@@ -53,6 +54,9 @@ export class FrigateCardMenu extends LitElement {
@property({ attribute: false })
public buttons: MenuButton[] = [];
@property({ attribute: false })
protected conditionState?: ConditionState;
/**
* Handle an action on a menu button.
* @param ev The action event.
@@ -196,7 +200,7 @@ export class FrigateCardMenu extends LitElement {
}
const mode = this._menuConfig.mode;
if (mode == 'none') {
if (mode == 'none' || !evaluateCondition(this._menuConfig.conditions, this.conditionState)) {
return;
}