diff --git a/src/components/ha-sidebar.ts b/src/components/ha-sidebar.ts index 62d0e7d333..6d19184f88 100644 --- a/src/components/ha-sidebar.ts +++ b/src/components/ha-sidebar.ts @@ -3,6 +3,7 @@ import { mdiBell, mdiCalendar, mdiCart, + mdiCellphoneCog, mdiChartBox, mdiClose, mdiCog, @@ -43,7 +44,10 @@ import { PersistentNotification, subscribeNotifications, } from "../data/persistent_notification"; -import { getExternalConfig } from "../external_app/external_config"; +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"; @@ -188,6 +192,8 @@ class HaSidebar extends LitElement { @property({ type: Boolean }) public editMode = false; + @state() private _externalConfig?: ExternalConfig; + @state() private _notifications?: PersistentNotification[]; @state() private _renderEmptySortable = false; @@ -234,6 +240,7 @@ 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") || @@ -264,14 +271,15 @@ 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; }); - - // Temporary workaround for a bug in Android. Can be removed in Home Assistant 2022.2 - if (this.hass.auth.external) { - getExternalConfig(this.hass.auth.external); - } } protected updated(changedProps) { @@ -364,6 +372,7 @@ class HaSidebar extends LitElement { : this._renderPanels(beforeSpacer)} ${this._renderSpacer()} ${this._renderPanels(afterSpacer)} + ${this._renderExternalConfiguration()} `; } @@ -548,6 +557,43 @@ class HaSidebar extends LitElement { `; } + private _renderExternalConfiguration() { + return html`${!this.hass.user?.is_admin && + this._externalConfig && + this._externalConfig.hasSettingsScreen + ? html` + + + + + ${this.hass.localize("ui.sidebar.external_app_configuration")} + + + + ` + : ""}`; + } + + private _handleExternalAppConfiguration(ev: Event) { + ev.preventDefault(); + this.hass.auth.external!.fireMessage({ + type: "config_screen/show", + }); + } + private get _tooltip() { return this.shadowRoot!.querySelector(".tooltip")! as HTMLDivElement; } diff --git a/src/translations/en.json b/src/translations/en.json index d8b350b504..0b8793f8c1 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -922,6 +922,7 @@ "dismiss": "Dismiss" }, "sidebar": { + "external_app_configuration": "App Configuration", "sidebar_toggle": "Sidebar Toggle", "done": "Done", "hide_panel": "Hide panel",