Add automation/editor/show command to external bus (#19524)

This commit is contained in:
Bram Kragten 2024-01-25 00:01:10 +01:00 committed by GitHub
parent 2925ef3db0
commit b224ec50e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View File

@ -7,6 +7,7 @@ This is the entry point for providing external app stuff from app entrypoint.
import { fireEvent } from "../common/dom/fire_event"; import { fireEvent } from "../common/dom/fire_event";
import { mainWindow } from "../common/dom/get_main_window"; import { mainWindow } from "../common/dom/get_main_window";
import { showAutomationEditor } from "../data/automation";
import { HomeAssistantMain } from "../layouts/home-assistant-main"; import { HomeAssistantMain } from "../layouts/home-assistant-main";
import type { EMIncomingMessageCommands } from "./external_messaging"; import type { EMIncomingMessageCommands } from "./external_messaging";
@ -79,6 +80,14 @@ const handleExternalMessage = (
success: true, success: true,
result: null, result: null,
}); });
} else if (msg.command === "automation/editor/show") {
showAutomationEditor(msg.payload?.config);
bus.fireMessage({
id: msg.id,
type: "result",
success: true,
result: null,
});
} else { } else {
return false; return false;
} }

View File

@ -1,3 +1,5 @@
import { AutomationConfig } from "../data/automation";
const CALLBACK_EXTERNAL_BUS = "externalBus"; const CALLBACK_EXTERNAL_BUS = "externalBus";
interface CommandInFlight { interface CommandInFlight {
@ -147,11 +149,21 @@ interface EMIncomingMessageShowSidebar {
command: "sidebar/show"; command: "sidebar/show";
} }
interface EMIncomingMessageShowAutomationEditor {
id: number;
type: "command";
command: "automation/editor/show";
payload?: {
config?: Partial<AutomationConfig>;
};
}
export type EMIncomingMessageCommands = export type EMIncomingMessageCommands =
| EMIncomingMessageRestart | EMIncomingMessageRestart
| EMIncomingMessageShowNotifications | EMIncomingMessageShowNotifications
| EMIncomingMessageToggleSidebar | EMIncomingMessageToggleSidebar
| EMIncomingMessageShowSidebar; | EMIncomingMessageShowSidebar
| EMIncomingMessageShowAutomationEditor;
type EMIncomingMessage = type EMIncomingMessage =
| EMMessageResultSuccess | EMMessageResultSuccess