mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-09 10:26:35 +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,
|
deleteAutomation,
|
||||||
duplicateAutomation,
|
duplicateAutomation,
|
||||||
fetchAutomationFileConfig,
|
fetchAutomationFileConfig,
|
||||||
|
getAutomationStateConfig,
|
||||||
|
showAutomationEditor,
|
||||||
triggerAutomationActions,
|
triggerAutomationActions,
|
||||||
} from "../../../data/automation";
|
} from "../../../data/automation";
|
||||||
import {
|
import {
|
||||||
@ -329,6 +331,14 @@ class HaAutomationPicker extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _showTrace(automation: any) {
|
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}`);
|
navigate(`/config/automation/trace/${automation.attributes.id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,17 +392,20 @@ class HaAutomationPicker extends LitElement {
|
|||||||
);
|
);
|
||||||
duplicateAutomation(config);
|
duplicateAutomation(config);
|
||||||
} catch (err: any) {
|
} 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, {
|
await showAlertDialog(this, {
|
||||||
text:
|
text: this.hass.localize(
|
||||||
err.status_code === 404
|
"ui.panel.config.automation.editor.load_error_unknown",
|
||||||
? this.hass.localize(
|
"err_no",
|
||||||
"ui.panel.config.automation.editor.load_error_not_duplicable"
|
err.status_code
|
||||||
)
|
),
|
||||||
: 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 {
|
import {
|
||||||
deleteScript,
|
deleteScript,
|
||||||
fetchScriptFileConfig,
|
fetchScriptFileConfig,
|
||||||
|
getScriptStateConfig,
|
||||||
showScriptEditor,
|
showScriptEditor,
|
||||||
triggerScript,
|
triggerScript,
|
||||||
} from "../../../data/script";
|
} from "../../../data/script";
|
||||||
@ -311,17 +312,20 @@ class HaScriptPicker extends LitElement {
|
|||||||
)})`,
|
)})`,
|
||||||
});
|
});
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
|
if (err.status_code === 404) {
|
||||||
|
const response = await getScriptStateConfig(
|
||||||
|
this.hass,
|
||||||
|
script.entity_id
|
||||||
|
);
|
||||||
|
showScriptEditor(response.config);
|
||||||
|
return;
|
||||||
|
}
|
||||||
await showAlertDialog(this, {
|
await showAlertDialog(this, {
|
||||||
text:
|
text: this.hass.localize(
|
||||||
err.status_code === 404
|
"ui.panel.config.script.editor.load_error_unknown",
|
||||||
? this.hass.localize(
|
"err_no",
|
||||||
"ui.panel.config.script.editor.load_error_not_duplicable"
|
err.status_code
|
||||||
)
|
),
|
||||||
: this.hass.localize(
|
|
||||||
"ui.panel.config.script.editor.load_error_unknown",
|
|
||||||
"err_no",
|
|
||||||
err.status_code
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1855,8 +1855,8 @@
|
|||||||
"show_info": "Information",
|
"show_info": "Information",
|
||||||
"default_name": "New Automation",
|
"default_name": "New Automation",
|
||||||
"missing_name": "Cannot save automation without a name",
|
"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_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_not_deletable": "Only automations in automations.yaml can be deleted.",
|
||||||
"load_error_unknown": "Error loading automation ({err_no}).",
|
"load_error_unknown": "Error loading automation ({err_no}).",
|
||||||
"save": "Save",
|
"save": "Save",
|
||||||
@ -2341,7 +2341,6 @@
|
|||||||
"parallel": "Max number of parallel runs"
|
"parallel": "Max number of parallel runs"
|
||||||
},
|
},
|
||||||
"load_error_not_editable": "Only scripts inside scripts.yaml are editable.",
|
"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_not_deletable": "Only scripts in scripts.yaml can be deleted.",
|
||||||
"load_error_unknown": "Error loading script ({err_no}).",
|
"load_error_unknown": "Error loading script ({err_no}).",
|
||||||
"delete_confirm_title": "Delete script?",
|
"delete_confirm_title": "Delete script?",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user