From 06111330652b205c6d89f367b0ca63ae845c279c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Tue, 30 Nov 2021 17:03:10 +0100 Subject: [PATCH] Move companion app config from sidebar to configuration dashboard (#10733) * Move companion app config from sidebar to configuration dashboard * Remove translation refrence --- src/components/ha-sidebar.ts | 49 ----------------- .../config/dashboard/ha-config-dashboard.ts | 55 ++++++++++++++++++- src/translations/en.json | 1 - 3 files changed, 52 insertions(+), 53 deletions(-) diff --git a/src/components/ha-sidebar.ts b/src/components/ha-sidebar.ts index 6fe026809c..fa2ce7c2a5 100644 --- a/src/components/ha-sidebar.ts +++ b/src/components/ha-sidebar.ts @@ -3,7 +3,6 @@ import { mdiBell, mdiCalendar, mdiCart, - mdiCellphoneCog, mdiChartBox, mdiClose, mdiCog, @@ -45,10 +44,6 @@ import { PersistentNotification, subscribeNotifications, } from "../data/persistent_notification"; -import { - ExternalConfig, - getExternalConfig, -} from "../external_app/external_config"; import { actionHandler } from "../panels/lovelace/common/directives/action-handler-directive"; import { haStyleScrollbar } from "../resources/styles"; import type { HomeAssistant, PanelInfo, Route } from "../types"; @@ -195,8 +190,6 @@ class HaSidebar extends LitElement { @property({ type: Boolean }) public editMode = false; - @state() private _externalConfig?: ExternalConfig; - @state() private _notifications?: PersistentNotification[]; @state() private _renderEmptySortable = false; @@ -243,7 +236,6 @@ class HaSidebar extends LitElement { changedProps.has("expanded") || changedProps.has("narrow") || changedProps.has("alwaysExpand") || - changedProps.has("_externalConfig") || changedProps.has("_notifications") || changedProps.has("editMode") || changedProps.has("_renderEmptySortable") || @@ -274,11 +266,6 @@ class HaSidebar extends LitElement { protected firstUpdated(changedProps: PropertyValues) { super.firstUpdated(changedProps); - if (this.hass && this.hass.auth.external) { - getExternalConfig(this.hass.auth.external).then((conf) => { - this._externalConfig = conf; - }); - } subscribeNotifications(this.hass.connection, (notifications) => { this._notifications = notifications; }); @@ -376,7 +363,6 @@ class HaSidebar extends LitElement { : this._renderPanels(beforeSpacer)} ${this._renderSpacer()} ${this._renderPanels(afterSpacer)} - ${this._renderExternalConfiguration()} `; } @@ -561,34 +547,6 @@ class HaSidebar extends LitElement { `; } - private _renderExternalConfiguration() { - return html`${this._externalConfig && this._externalConfig.hasSettingsScreen - ? html` - - - - - ${this.hass.localize("ui.sidebar.external_app_configuration")} - - - - ` - : ""}`; - } - private get _tooltip() { return this.shadowRoot!.querySelector(".tooltip")! as HTMLDivElement; } @@ -760,13 +718,6 @@ class HaSidebar extends LitElement { fireEvent(this, "hass-show-notifications"); } - private _handleExternalAppConfiguration(ev: Event) { - ev.preventDefault(); - this.hass.auth.external!.fireMessage({ - type: "config_screen/show", - }); - } - private _toggleSidebar(ev: CustomEvent) { if (ev.detail.action !== "tap") { return; diff --git a/src/panels/config/dashboard/ha-config-dashboard.ts b/src/panels/config/dashboard/ha-config-dashboard.ts index eebd88c05a..69763fd558 100644 --- a/src/panels/config/dashboard/ha-config-dashboard.ts +++ b/src/panels/config/dashboard/ha-config-dashboard.ts @@ -1,14 +1,25 @@ -import { mdiCloudLock } from "@mdi/js"; +import { mdiCellphoneCog, mdiCloudLock } from "@mdi/js"; import "@polymer/app-layout/app-header/app-header"; import "@polymer/app-layout/app-toolbar/app-toolbar"; -import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; -import { customElement, property } from "lit/decorators"; +import { + css, + CSSResultGroup, + html, + LitElement, + PropertyValues, + TemplateResult, +} from "lit"; +import { customElement, property, state } from "lit/decorators"; import { isComponentLoaded } from "../../../common/config/is_component_loaded"; import "../../../components/ha-card"; import "../../../components/ha-icon-next"; import "../../../components/ha-menu-button"; import { CloudStatus } from "../../../data/cloud"; import { SupervisorAvailableUpdates } from "../../../data/supervisor/supervisor"; +import { + ExternalConfig, + getExternalConfig, +} from "../../../external_app/external_config"; import "../../../layouts/ha-app-layout"; import { haStyle } from "../../../resources/styles"; import { HomeAssistant } from "../../../types"; @@ -32,6 +43,18 @@ class HaConfigDashboard extends LitElement { @property() public showAdvanced!: boolean; + @state() private _externalConfig?: ExternalConfig; + + protected firstUpdated(changedProps: PropertyValues) { + super.firstUpdated(changedProps); + + if (this.hass && this.hass.auth.external) { + getExternalConfig(this.hass.auth.external).then((conf) => { + this._externalConfig = conf; + }); + } + } + protected render(): TemplateResult { return html` @@ -86,6 +109,25 @@ class HaConfigDashboard extends LitElement { > ` : ""} + ${this._externalConfig?.hasSettingsScreen + ? html` + + ` + : ""}