Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize reloadableDomains #6773

Merged
merged 2 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/panels/config/entities/dialog-entity-editor.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import "@material/mwc-tab-bar";
import "@material/mwc-tab";
import "@material/mwc-icon-button";
import "@material/mwc-tab";
import "@material/mwc-tab-bar";
import { mdiClose, mdiTune } from "@mdi/js";
import { HassEntity } from "home-assistant-js-websocket";
import {
css,
CSSResult,
customElement,
html,
internalProperty,
LitElement,
property,
internalProperty,
TemplateResult,
} from "lit-element";
import { cache } from "lit-html/directives/cache";
import { fireEvent } from "../../../common/dom/fire_event";
import { dynamicElement } from "../../../common/dom/dynamic-element-directive";
import { fireEvent } from "../../../common/dom/fire_event";
import { computeStateName } from "../../../common/entity/compute_state_name";
import "../../../components/ha-dialog";
import "../../../components/ha-header-bar";
import "../../../components/ha-svg-icon";
import "../../../components/ha-related-items";
import "../../../components/ha-svg-icon";
import {
EntityRegistryEntry,
ExtEntityRegistryEntry,
Expand All @@ -30,7 +31,6 @@ import type { HomeAssistant } from "../../../types";
import { PLATFORMS_WITH_SETTINGS_TAB } from "./const";
import "./entity-registry-settings";
import type { EntityRegistryDetailDialogParams } from "./show-dialog-entity-editor";
import { mdiClose, mdiTune } from "@mdi/js";

interface Tabs {
[key: string]: Tab;
Expand Down Expand Up @@ -252,7 +252,7 @@ export class DialogEntityEditor extends LitElement {

@media all and (min-width: 451px) and (min-height: 501px) {
.wrapper {
width: 400px;
min-width: 400px;
}
}

Expand Down
81 changes: 39 additions & 42 deletions src/panels/config/server_control/ha-config-server-control.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,27 @@
import "@material/mwc-button";
import "@polymer/app-layout/app-header/app-header";
import "@polymer/app-layout/app-toolbar/app-toolbar";
import "../../../layouts/hass-tabs-subpage";
import { configSections } from "../ha-panel-config";
import "@polymer/paper-input/paper-input";
import {
LitElement,
property,
internalProperty,
customElement,
html,
css,
CSSResult,
customElement,
html,
internalProperty,
LitElement,
property,
TemplateResult,
} from "lit-element";
import { HomeAssistant, Route } from "../../../types";

import "@material/mwc-button";
import "@polymer/paper-input/paper-input";
import { isServiceLoaded } from "../../../common/config/is_service_loaded";
import "../../../components/buttons/ha-call-service-button";
import "../../../components/ha-card";
import "../ha-config-section";
import { haStyle } from "../../../resources/styles";
import { checkCoreConfig } from "../../../data/core";

const reloadableDomains = [
"group",
"automation",
"script",
"scene",
"person",
"zone",
"input_boolean",
"input_text",
"input_number",
"input_datetime",
"input_select",
"template",
"universal",
"rest",
"command_line",
"filter",
"statistics",
"generic",
"generic_thermostat",
"homekit",
"min_max",
"history_stats",
"trend",
"ping",
"filesize",
];
import { domainToName } from "../../../data/integration";
import "../../../layouts/hass-tabs-subpage";
import { haStyle } from "../../../resources/styles";
import { HomeAssistant, Route } from "../../../types";
import "../ha-config-section";
import { configSections } from "../ha-panel-config";

@customElement("ha-config-server-control")
export class HaConfigServerControl extends LitElement {
Expand All @@ -65,10 +37,26 @@ export class HaConfigServerControl extends LitElement {

@internalProperty() private _validating = false;

@internalProperty() private _reloadableDomains: string[] = [];

private _validateLog = "";

private _isValid: boolean | null = null;

protected updated(changedProperties) {
const oldHass = changedProperties.get("hass");
if (
changedProperties.has("hass") &&
(!oldHass || oldHass.config.components !== this.hass.config.components)
) {
this._reloadableDomains = this.hass.config.components.filter(
(component) =>
!component.includes(".") &&
isServiceLoaded(this.hass, component, "reload")
);
}
}

protected render(): TemplateResult {
return html`
<hass-tabs-subpage
Expand Down Expand Up @@ -215,7 +203,7 @@ export class HaConfigServerControl extends LitElement {
)}
</ha-call-service-button>
</div>
${reloadableDomains.map((domain) =>
${this._reloadableDomains.map((domain) =>
isServiceLoaded(this.hass, domain, "reload")
? html`<div class="card-actions">
<ha-call-service-button
Expand All @@ -224,6 +212,11 @@ export class HaConfigServerControl extends LitElement {
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>`
Expand Down Expand Up @@ -282,6 +275,10 @@ export class HaConfigServerControl extends LitElement {
white-space: pre-wrap;
direction: ltr;
}

ha-config-section {
padding-bottom: 24px;
}
`,
];
}
Expand Down
1 change: 1 addition & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@
"reloading": {
"heading": "YAML configuration reloading",
"introduction": "Some parts of Home Assistant can reload without requiring a restart. Hitting reload will unload their current YAML configuration and load the new one.",
"reload": "Reload {domain}",
"core": "Reload location & customizations",
"group": "Reload groups",
"automation": "Reload automations",
Expand Down