Check if energy integration is enabled (#11458)

This commit is contained in:
Bram Kragten 2022-01-27 16:27:40 +01:00 committed by GitHub
parent 242bad0a29
commit f04b844223
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,7 @@ import "@polymer/paper-tooltip/paper-tooltip";
import { html, LitElement, PropertyValues, TemplateResult } from "lit"; import { html, LitElement, PropertyValues, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import memoize from "memoize-one"; import memoize from "memoize-one";
import { isComponentLoaded } from "../../../../common/config/is_component_loaded";
import { navigate } from "../../../../common/navigate"; import { navigate } from "../../../../common/navigate";
import { stringCompare } from "../../../../common/string/compare"; import { stringCompare } from "../../../../common/string/compare";
import { import {
@ -183,31 +184,34 @@ export class HaConfigLovelaceDashboards extends LitElement {
).mode; ).mode;
const defaultUrlPath = this.hass.defaultPanel; const defaultUrlPath = this.hass.defaultPanel;
const isDefault = defaultUrlPath === "lovelace"; const isDefault = defaultUrlPath === "lovelace";
return [ const result: Record<string, any>[] = [
{ {
icon: "hass:view-dashboard", icon: "hass:view-dashboard",
title: this.hass.localize("panel.states"), title: this.hass.localize("panel.states"),
default: isDefault, default: isDefault,
sidebar: isDefault, show_in_sidebar: isDefault,
require_admin: false, require_admin: false,
url_path: "lovelace", url_path: "lovelace",
mode: defaultMode, mode: defaultMode,
filename: defaultMode === "yaml" ? "ui-lovelace.yaml" : "", filename: defaultMode === "yaml" ? "ui-lovelace.yaml" : "",
}, },
{
icon: "hass:lightning-bolt",
title: this.hass.localize(`ui.panel.config.dashboard.energy.title`),
show_in_sidebar: true,
mode: "storage",
url_path: "energy",
filename: "",
},
...dashboards.map((dashboard) => ({ ...dashboards.map((dashboard) => ({
filename: "", filename: "",
...dashboard, ...dashboard,
default: defaultUrlPath === dashboard.url_path, default: defaultUrlPath === dashboard.url_path,
})), })),
]; ];
if (isComponentLoaded(this.hass, "energy")) {
result.push({
icon: "hass:lightning-bolt",
title: this.hass.localize(`ui.panel.config.dashboard.energy.title`),
show_in_sidebar: true,
mode: "storage",
url_path: "energy",
filename: "",
});
}
return result;
}); });
protected render(): TemplateResult { protected render(): TemplateResult {