fix: Confirmations should apply to all actions (#1959)

This also refactors how generic HA actions are handled, and improves
typing of actions.


[skip ci]
This commit is contained in:
Dermot Duffy
2025-03-15 14:32:48 -07:00
committed by GitHub
parent a79ffa6edc
commit 75ae7720d3
90 changed files with 1332 additions and 854 deletions
+8 -9
View File
@@ -3,17 +3,14 @@ import { orderBy } from 'lodash-es';
import { dispatchActionExecutionRequest } from '../card-controller/actions/utils/execution-request.js';
import { SubmenuInteraction } from '../components/submenu/types.js';
import {
ActionConfig,
MENU_PRIORITY_MAX,
type ActionType,
type ActionsConfig,
type MenuConfig,
type MenuItem,
} from '../config/types.js';
import { Interaction } from '../types.js';
import {
convertActionToCardCustomAction,
getActionConfigGivenAction,
} from '../utils/action';
import { getActionConfigGivenAction } from '../utils/action';
import { arrayify, isTruthy, setOrRemoveAttribute } from '../utils/basic.js';
export class MenuController {
@@ -114,7 +111,7 @@ export class MenuController {
let menuToggle = false;
const toggleLessActions = actions.filter(
(item) => isTruthy(item) && !this._isUnknownActionMenuToggleAction(item),
(item) => isTruthy(item) && !this._isMenuToggleAction(item),
);
if (toggleLessActions.length != actions.length) {
menuToggle = true;
@@ -171,8 +168,10 @@ export class MenuController {
return this._config?.style === 'hidden';
}
protected _isUnknownActionMenuToggleAction(action: ActionType): boolean {
const parsedAction = convertActionToCardCustomAction(action);
return !!parsedAction && parsedAction.advanced_camera_card_action == 'menu_toggle';
protected _isMenuToggleAction(action: ActionConfig): boolean {
return (
action.action === 'fire-dom-event' &&
action.advanced_camera_card_action === 'menu_toggle'
);
}
}