Fix select options for add-on config (#10330)

This commit is contained in:
Joakim Sørensen 2021-10-19 22:54:07 +02:00 committed by GitHub
parent df53364d16
commit b1e6935df9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,6 +78,18 @@ class HassioAddonConfig extends LitElement {
this.addon.translations.en?.configuration?.[entry.name].name || this.addon.translations.en?.configuration?.[entry.name].name ||
entry.name; entry.name;
private _schema = memoizeOne((schema: HaFormSchema[]): HaFormSchema[] =>
// @ts-expect-error supervisor does not implement [string, string] for select.options[]
schema.map((entry) =>
entry.type === "select"
? {
...entry,
options: entry.options.map((option) => [option, option]),
}
: entry
)
);
private _filteredShchema = memoizeOne( private _filteredShchema = memoizeOne(
(options: Record<string, unknown>, schema: HaFormSchema[]) => (options: Record<string, unknown>, schema: HaFormSchema[]) =>
schema.filter((entry) => entry.name in options || entry.required) schema.filter((entry) => entry.name in options || entry.required)
@ -128,11 +140,13 @@ class HassioAddonConfig extends LitElement {
.data=${this._options!} .data=${this._options!}
@value-changed=${this._configChanged} @value-changed=${this._configChanged}
.computeLabel=${this.computeLabel} .computeLabel=${this.computeLabel}
.schema=${this._showOptional .schema=${this._schema(
this._showOptional
? this.addon.schema! ? this.addon.schema!
: this._filteredShchema( : this._filteredShchema(
this.addon.options, this.addon.options,
this.addon.schema! this.addon.schema!
)
)} )}
></ha-form>` ></ha-form>`
: html` <ha-yaml-editor : html` <ha-yaml-editor