mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-08 18:06:36 +00:00
Make duplicate script/automation work in picker for yaml (#13952)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
176d8567f4
commit
dd695545d3
@ -35,6 +35,8 @@ import {
|
||||
deleteAutomation,
|
||||
duplicateAutomation,
|
||||
fetchAutomationFileConfig,
|
||||
getAutomationStateConfig,
|
||||
showAutomationEditor,
|
||||
triggerAutomationActions,
|
||||
} from "../../../data/automation";
|
||||
import {
|
||||
@ -329,6 +331,14 @@ class HaAutomationPicker extends LitElement {
|
||||
}
|
||||
|
||||
private _showTrace(automation: any) {
|
||||
if (!automation.attributes.id) {
|
||||
showAlertDialog(this, {
|
||||
text: this.hass.localize(
|
||||
"ui.panel.config.automation.picker.traces_not_available"
|
||||
),
|
||||
});
|
||||
return;
|
||||
}
|
||||
navigate(`/config/automation/trace/${automation.attributes.id}`);
|
||||
}
|
||||
|
||||
@ -382,13 +392,16 @@ class HaAutomationPicker extends LitElement {
|
||||
);
|
||||
duplicateAutomation(config);
|
||||
} catch (err: any) {
|
||||
if (err.status_code === 404) {
|
||||
const response = await getAutomationStateConfig(
|
||||
this.hass,
|
||||
automation.entity_id
|
||||
);
|
||||
showAutomationEditor({ ...response.config, id: undefined });
|
||||
return;
|
||||
}
|
||||
await showAlertDialog(this, {
|
||||
text:
|
||||
err.status_code === 404
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.automation.editor.load_error_not_duplicable"
|
||||
)
|
||||
: this.hass.localize(
|
||||
text: this.hass.localize(
|
||||
"ui.panel.config.automation.editor.load_error_unknown",
|
||||
"err_no",
|
||||
err.status_code
|
||||
|
@ -28,6 +28,7 @@ import "../../../components/ha-svg-icon";
|
||||
import {
|
||||
deleteScript,
|
||||
fetchScriptFileConfig,
|
||||
getScriptStateConfig,
|
||||
showScriptEditor,
|
||||
triggerScript,
|
||||
} from "../../../data/script";
|
||||
@ -311,13 +312,16 @@ class HaScriptPicker extends LitElement {
|
||||
)})`,
|
||||
});
|
||||
} catch (err: any) {
|
||||
if (err.status_code === 404) {
|
||||
const response = await getScriptStateConfig(
|
||||
this.hass,
|
||||
script.entity_id
|
||||
);
|
||||
showScriptEditor(response.config);
|
||||
return;
|
||||
}
|
||||
await showAlertDialog(this, {
|
||||
text:
|
||||
err.status_code === 404
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.script.editor.load_error_not_duplicable"
|
||||
)
|
||||
: this.hass.localize(
|
||||
text: this.hass.localize(
|
||||
"ui.panel.config.script.editor.load_error_unknown",
|
||||
"err_no",
|
||||
err.status_code
|
||||
|
@ -1855,8 +1855,8 @@
|
||||
"show_info": "Information",
|
||||
"default_name": "New Automation",
|
||||
"missing_name": "Cannot save automation without a name",
|
||||
"traces_not_available": "Automations need an ID for history to be tracked. Add an ID to your automation to make it available in traces.",
|
||||
"load_error_not_editable": "Only automations in automations.yaml are editable.",
|
||||
"load_error_not_duplicable": "Only automations in automations.yaml can be duplicated.",
|
||||
"load_error_not_deletable": "Only automations in automations.yaml can be deleted.",
|
||||
"load_error_unknown": "Error loading automation ({err_no}).",
|
||||
"save": "Save",
|
||||
@ -2341,7 +2341,6 @@
|
||||
"parallel": "Max number of parallel runs"
|
||||
},
|
||||
"load_error_not_editable": "Only scripts inside scripts.yaml are editable.",
|
||||
"load_error_not_duplicable": "Only scripts in scripts.yaml can be duplicated.",
|
||||
"load_error_not_deletable": "Only scripts in scripts.yaml can be deleted.",
|
||||
"load_error_unknown": "Error loading script ({err_no}).",
|
||||
"delete_confirm_title": "Delete script?",
|
||||
|
Loading…
x
Reference in New Issue
Block a user