Improve error messages

This commit is contained in:
Paul Bottein 2024-09-09 16:34:22 +02:00
parent 6d8b7f6995
commit 4f2652abd2
No known key found for this signature in database
2 changed files with 27 additions and 10 deletions

View File

@ -251,17 +251,30 @@ export abstract class HuiElementEditor<T, C = any> extends LitElement {
`}
${this._guiSupported === false && this.configElementType
? html`
<ha-alert alert-type="info">
${this.hass.localize("ui.errors.config.editor_not_available", {
type: this.configElementType,
})}
<ha-alert
alert-type="info"
.title=${this.hass.localize(
"ui.errors.config.editor_not_supported"
)}
>
${this.hass.localize(
"ui.errors.config.editor_not_supported_details",
{ type: this.configElementType }
)}
<br />
${this.hass.localize("ui.errors.config.edit_in_yaml_supported")}
</ha-alert>
`
: nothing}
${this.hasError
? html`
<ha-alert alert-type="error">
${this.hass.localize("ui.errors.config.error_detected")}:
<ha-alert
alert-type="error"
.title=${this.hass.localize(
"ui.errors.config.invalid_configuration"
)}
>
${this.hass.localize("ui.errors.config.error_details")}
<ul>
${this._errors!.map((error) => html`<li>${error}</li>`)}
</ul>
@ -272,12 +285,13 @@ export abstract class HuiElementEditor<T, C = any> extends LitElement {
? html`
<ha-alert
alert-type="warning"
.title="${this.hass.localize(
.title=${this.hass.localize(
"ui.errors.config.editor_not_supported"
)}:"
)}
>
${this._warnings!.length > 0 && this._warnings![0] !== undefined
? html`
${this.hass.localize("ui.errors.config.warning_details")}
<ul>
${this._warnings!.map(
(warning) => html`<li>${warning}</li>`

View File

@ -1797,9 +1797,12 @@
"errors": {
"config": {
"no_type_provided": "No type provided.",
"error_detected": "Configuration errors detected",
"invalid_configuration": "Invalid configuration",
"error_details": "The configuration contains the following errors:",
"editor_not_available": "No visual editor available for type ''{type}''.",
"editor_not_supported": "Visual editor is not supported for this configuration",
"editor_not_supported": "Visual editor not supported",
"editor_not_supported_details": "The visual editor is not supported for type ''{type}''.",
"warning_details": "The configuration contains the following warnings:",
"edit_in_yaml_supported": "You can still edit your config in YAML.",
"key_missing": "Required key ''{key}'' is missing.",
"key_not_expected": "Key ''{key}'' is not expected or not supported by the visual editor.",