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

View File

@ -1797,9 +1797,12 @@
"errors": { "errors": {
"config": { "config": {
"no_type_provided": "No type provided.", "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_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.", "edit_in_yaml_supported": "You can still edit your config in YAML.",
"key_missing": "Required key ''{key}'' is missing.", "key_missing": "Required key ''{key}'' is missing.",
"key_not_expected": "Key ''{key}'' is not expected or not supported by the visual editor.", "key_not_expected": "Key ''{key}'' is not expected or not supported by the visual editor.",