mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 16:26:43 +00:00
Show validation errors in UI (#7725)
This commit is contained in:
parent
10916fa82a
commit
5acee76c70
@ -25,6 +25,7 @@ export interface BlueprintImportResult {
|
|||||||
suggested_filename: string;
|
suggested_filename: string;
|
||||||
raw_data: string;
|
raw_data: string;
|
||||||
blueprint: Blueprint;
|
blueprint: Blueprint;
|
||||||
|
validation_errors: string[] | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fetchBlueprints = (hass: HomeAssistant, domain: string) =>
|
export const fetchBlueprints = (hass: HomeAssistant, domain: string) =>
|
||||||
|
@ -66,17 +66,32 @@ class DialogImportBlueprint extends LitElement {
|
|||||||
${this._error ? html` <div class="error">${this._error}</div> ` : ""}
|
${this._error ? html` <div class="error">${this._error}</div> ` : ""}
|
||||||
${this._result
|
${this._result
|
||||||
? html`${this.hass.localize(
|
? html`${this.hass.localize(
|
||||||
"ui.panel.config.blueprint.add.import",
|
"ui.panel.config.blueprint.add.import_header",
|
||||||
"name",
|
"name",
|
||||||
"domain",
|
|
||||||
html`<b>${this._result.blueprint.metadata.name}</b>`,
|
html`<b>${this._result.blueprint.metadata.name}</b>`,
|
||||||
|
"domain",
|
||||||
this._result.blueprint.metadata.domain
|
this._result.blueprint.metadata.domain
|
||||||
)}
|
)}
|
||||||
|
${this._result.validation_errors
|
||||||
|
? html`
|
||||||
|
<p class="error">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.blueprint.add.unsupported_blueprint"
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
<ul class="error">
|
||||||
|
${this._result.validation_errors.map(
|
||||||
|
(error) => html`<li>${error}</li>`
|
||||||
|
)}
|
||||||
|
</ul>
|
||||||
|
`
|
||||||
|
: html`
|
||||||
<paper-input
|
<paper-input
|
||||||
id="input"
|
id="input"
|
||||||
.value=${this._result.suggested_filename}
|
.value=${this._result.suggested_filename}
|
||||||
label="Filename"
|
label="Filename"
|
||||||
></paper-input>
|
></paper-input>
|
||||||
|
`}
|
||||||
<pre>${this._result.raw_data}</pre>`
|
<pre>${this._result.raw_data}</pre>`
|
||||||
: html`${this.hass.localize(
|
: html`${this.hass.localize(
|
||||||
"ui.panel.config.blueprint.add.import_introduction"
|
"ui.panel.config.blueprint.add.import_introduction"
|
||||||
@ -115,7 +130,7 @@ class DialogImportBlueprint extends LitElement {
|
|||||||
<mwc-button
|
<mwc-button
|
||||||
slot="primaryAction"
|
slot="primaryAction"
|
||||||
@click=${this._save}
|
@click=${this._save}
|
||||||
.disabled=${this._saving}
|
.disabled=${this._saving || this._result.validation_errors}
|
||||||
>
|
>
|
||||||
${this._saving
|
${this._saving
|
||||||
? html`<ha-circular-progress
|
? html`<ha-circular-progress
|
||||||
|
@ -1463,7 +1463,8 @@
|
|||||||
"import_btn": "Import blueprint",
|
"import_btn": "Import blueprint",
|
||||||
"saving": "Saving blueprint...",
|
"saving": "Saving blueprint...",
|
||||||
"save_btn": "Save blueprint",
|
"save_btn": "Save blueprint",
|
||||||
"error_no_url": "Please enter the URL of the blueprint."
|
"error_no_url": "Please enter the URL of the blueprint.",
|
||||||
|
"unsupported_blueprint": "This blueprint is not supported"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"script": {
|
"script": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user