mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +00:00
Ensure we pickup all the reloadable domains (#6861)
This commit is contained in:
parent
4d0d1ed2a1
commit
869b7c85ca
9
src/common/config/components_with_service.ts
Normal file
9
src/common/config/components_with_service.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { HomeAssistant } from "../../types";
|
||||
|
||||
/** Return an array of domains with the service. */
|
||||
export const componentsWithService = (
|
||||
hass: HomeAssistant,
|
||||
service: string
|
||||
): Array<string> =>
|
||||
hass &&
|
||||
Object.keys(hass.services).filter((key) => service in hass.services[key]);
|
@ -12,7 +12,7 @@ import {
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { isServiceLoaded } from "../../../common/config/is_service_loaded";
|
||||
import { componentsWithService } from "../../../common/config/components_with_service";
|
||||
import "../../../components/buttons/ha-call-service-button";
|
||||
import "../../../components/ha-card";
|
||||
import { checkCoreConfig } from "../../../data/core";
|
||||
@ -23,8 +23,6 @@ import { HomeAssistant, Route } from "../../../types";
|
||||
import "../ha-config-section";
|
||||
import { configSections } from "../ha-panel-config";
|
||||
|
||||
const platformsWithReload = ["template"];
|
||||
|
||||
@customElement("ha-config-server-control")
|
||||
export class HaConfigServerControl extends LitElement {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
@ -51,13 +49,10 @@ export class HaConfigServerControl extends LitElement {
|
||||
changedProperties.has("hass") &&
|
||||
(!oldHass || oldHass.config.components !== this.hass.config.components)
|
||||
) {
|
||||
this._reloadableDomains = this.hass.config.components
|
||||
.concat(platformsWithReload)
|
||||
.filter(
|
||||
(component) =>
|
||||
!component.includes(".") &&
|
||||
isServiceLoaded(this.hass, component, "reload")
|
||||
);
|
||||
this._reloadableDomains = componentsWithService(
|
||||
this.hass,
|
||||
"reload"
|
||||
).sort();
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,24 +202,23 @@ export class HaConfigServerControl extends LitElement {
|
||||
)}
|
||||
</ha-call-service-button>
|
||||
</div>
|
||||
${this._reloadableDomains.map((domain) =>
|
||||
isServiceLoaded(this.hass, domain, "reload")
|
||||
? html`<div class="card-actions">
|
||||
<ha-call-service-button
|
||||
.hass=${this.hass}
|
||||
.domain=${domain}
|
||||
service="reload"
|
||||
>${this.hass.localize(
|
||||
`ui.panel.config.server_control.section.reloading.${domain}`
|
||||
) ||
|
||||
this.hass.localize(
|
||||
"ui.panel.config.server_control.section.reloading.reload",
|
||||
"domain",
|
||||
domainToName(this.hass.localize, domain)
|
||||
)}
|
||||
</ha-call-service-button>
|
||||
</div>`
|
||||
: ""
|
||||
${this._reloadableDomains.map(
|
||||
(domain) =>
|
||||
html`<div class="card-actions">
|
||||
<ha-call-service-button
|
||||
.hass=${this.hass}
|
||||
.domain=${domain}
|
||||
service="reload"
|
||||
>${this.hass.localize(
|
||||
`ui.panel.config.server_control.section.reloading.${domain}`
|
||||
) ||
|
||||
this.hass.localize(
|
||||
"ui.panel.config.server_control.section.reloading.reload",
|
||||
"domain",
|
||||
domainToName(this.hass.localize, domain)
|
||||
)}
|
||||
</ha-call-service-button>
|
||||
</div>`
|
||||
)}
|
||||
</ha-card>
|
||||
`
|
||||
|
Loading…
x
Reference in New Issue
Block a user