Warn on switching to automation UI mode with yaml errors (#22780)

This commit is contained in:
karwosts 2024-11-12 02:47:12 -08:00 committed by GitHub
parent 3f4351476f
commit de57b025e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View File

@ -756,7 +756,20 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
}
}
private _switchUiMode() {
private async _switchUiMode() {
if (this._yamlErrors) {
const result = await showConfirmationDialog(this, {
text: html`${this.hass.localize(
"ui.panel.config.automation.editor.switch_ui_yaml_error"
)}<br /><br />${this._yamlErrors}`,
confirmText: this.hass!.localize("ui.common.continue"),
destructive: true,
dismissText: this.hass!.localize("ui.common.cancel"),
});
if (!result) {
return;
}
}
this._yamlErrors = undefined;
this._mode = "gui";
}

View File

@ -2942,6 +2942,7 @@
"search_in": "Search · {group}",
"unknown_entity": "unknown entity",
"edit_unknown_device": "Editor not available for unknown device",
"switch_ui_yaml_error": "There are currently YAML errors in the automation, and it cannot be parsed. Switching to UI mode may cause pending changes to be lost. Press cancel to correct any errors before proceeding to prevent loss of pending changes, or continue if you are sure.",
"triggers": {
"name": "Triggers",
"header": "When",