Fix filters for entity/device from integrations dashboard (#20953)

This commit is contained in:
Brynley McDonald 2024-06-04 03:50:40 +12:00 committed by GitHub
parent 250f87cfd8
commit f2b2da9877
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 59 deletions

View File

@ -199,7 +199,9 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
}
private _setFiltersFromUrl() {
if (this._searchParms.has("domain")) {
const domain = this._searchParms.get("domain");
const configEntry = this._searchParms.get("config_entry");
this._filters = {
...this._filters,
"ha-filter-states": {
@ -210,27 +212,15 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
items: undefined,
},
"ha-filter-integrations": {
value: [this._searchParms.get("domain")!],
items: undefined,
},
};
}
if (this._searchParms.has("config_entry")) {
this._filters = {
...this._filters,
"ha-filter-states": {
value: [
...((this._filters["ha-filter-states"]?.value as string[]) || []),
"disabled",
],
value: domain ? [domain] : [],
items: undefined,
},
config_entry: {
value: [this._searchParms.get("config_entry")!],
value: configEntry ? [configEntry] : [],
items: undefined,
},
};
}
if (this._searchParms.has("label")) {
this._filterLabel();
}

View File

@ -943,6 +943,7 @@ ${
}
protected firstUpdated() {
this._setFiltersFromUrl();
if (Object.keys(this._filters).length) {
return;
}
@ -952,14 +953,15 @@ ${
items: undefined,
},
};
this._setFiltersFromUrl();
fetchEntitySourcesWithCache(this.hass).then((sources) => {
this._entitySources = sources;
});
}
private _setFiltersFromUrl() {
if (this._searchParms.has("domain")) {
const domain = this._searchParms.get("domain");
const configEntry = this._searchParms.get("config_entry");
this._filters = {
...this._filters,
"ha-filter-states": {
@ -967,24 +969,15 @@ ${
items: undefined,
},
"ha-filter-integrations": {
value: [this._searchParms.get("domain")!],
items: undefined,
},
};
}
if (this._searchParms.has("config_entry")) {
this._filters = {
...this._filters,
"ha-filter-states": {
value: [],
value: domain ? [domain] : [],
items: undefined,
},
config_entry: {
value: [this._searchParms.get("config_entry")!],
value: configEntry ? [configEntry] : [],
items: undefined,
},
};
}
if (this._searchParms.has("label")) {
this._filterLabel();
}