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

View File

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