Warn that only automations in automations.yaml are editable (#3200)

This commit is contained in:
Paulus Schoutsen 2019-05-23 12:28:17 -07:00 committed by GitHub
parent 9309c5a1b6
commit fe80c7fe0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 10 deletions

View File

@ -147,7 +147,8 @@ class HaAutomationEditor extends LitElement {
"GET", "GET",
`config/automation/config/${this.automation.attributes.id}` `config/automation/config/${this.automation.attributes.id}`
) )
.then((config) => { .then(
(config) => {
// Normalize data: ensure trigger, action and condition are lists // Normalize data: ensure trigger, action and condition are lists
// Happens when people copy paste their automations into the config // Happens when people copy paste their automations into the config
for (const key of ["trigger", "condition", "action"]) { for (const key of ["trigger", "condition", "action"]) {
@ -158,7 +159,22 @@ class HaAutomationEditor extends LitElement {
} }
this._dirty = false; this._dirty = false;
this._config = config; this._config = config;
}); },
(resp) => {
alert(
resp.status_code === 404
? this.hass.localize(
"ui.panel.config.automation.editor.load_error_not_editable"
)
: this.hass.localize(
"ui.panel.config.automation.editor.load_error_unknown",
"err_no",
resp.status_code
)
);
history.back();
}
);
} }
if (changedProps.has("creatingNew") && this.creatingNew && this.hass) { if (changedProps.has("creatingNew") && this.creatingNew && this.hass) {

View File

@ -642,6 +642,8 @@
"editor": { "editor": {
"introduction": "Use automations to bring your home alive", "introduction": "Use automations to bring your home alive",
"default_name": "New Automation", "default_name": "New Automation",
"load_error_not_editable": "Only automations in automations.yaml are editable.",
"load_error_unknown": "Error loading automation ({err_no}).",
"save": "Save", "save": "Save",
"unsaved_confirm": "You have unsaved changes. Are you sure you want to leave?", "unsaved_confirm": "You have unsaved changes. Are you sure you want to leave?",
"alias": "Name", "alias": "Name",