Import frontend (#64104)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-01-14 10:01:12 +01:00 committed by GitHub
parent 4bce92dd2d
commit 946238fb02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 31 additions and 29 deletions

View file

@ -9,7 +9,7 @@ from typing import cast, final
from aiohttp import web from aiohttp import web
from homeassistant.components import http from homeassistant.components import frontend, http
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -42,8 +42,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
hass.http.register_view(CalendarListView(component)) hass.http.register_view(CalendarListView(component))
hass.http.register_view(CalendarEventView(component)) hass.http.register_view(CalendarEventView(component))
hass.components.frontend.async_register_built_in_panel( frontend.async_register_built_in_panel(
"calendar", "calendar", "hass:calendar" hass, "calendar", "calendar", "hass:calendar"
) )
await component.async_setup(config) await component.async_setup(config)

View file

@ -6,6 +6,7 @@ import os
import voluptuous as vol import voluptuous as vol
from homeassistant.components import frontend
from homeassistant.components.http import HomeAssistantView from homeassistant.components.http import HomeAssistantView
from homeassistant.const import CONF_ID, EVENT_COMPONENT_LOADED from homeassistant.const import CONF_ID, EVENT_COMPONENT_LOADED
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
@ -35,8 +36,8 @@ ACTION_DELETE = "delete"
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the config component.""" """Set up the config component."""
hass.components.frontend.async_register_built_in_panel( frontend.async_register_built_in_panel(
"config", "config", "hass:cog", require_admin=True hass, "config", "config", "hass:cog", require_admin=True
) )
async def setup_panel(panel_name): async def setup_panel(panel_name):

View file

@ -5,6 +5,7 @@ import logging
from aiohttp import web from aiohttp import web
from homeassistant.components import frontend
from homeassistant.components.http import HomeAssistantView from homeassistant.components.http import HomeAssistantView
from homeassistant.const import ATTR_ICON from homeassistant.const import ATTR_ICON
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -62,7 +63,7 @@ class HassIOAddonPanel(HomeAssistantView):
async def delete(self, request, addon): async def delete(self, request, addon):
"""Handle remove add-on panel requests.""" """Handle remove add-on panel requests."""
self.hass.components.frontend.async_remove_panel(addon) frontend.async_remove_panel(self.hass, addon)
return web.Response() return web.Response()
async def get_panels(self): async def get_panels(self):

View file

@ -12,7 +12,7 @@ from aiohttp import web
from sqlalchemy import not_, or_ from sqlalchemy import not_, or_
import voluptuous as vol import voluptuous as vol
from homeassistant.components import websocket_api from homeassistant.components import frontend, websocket_api
from homeassistant.components.http import HomeAssistantView from homeassistant.components.http import HomeAssistantView
from homeassistant.components.recorder import history, models as history_models from homeassistant.components.recorder import history, models as history_models
from homeassistant.components.recorder.statistics import ( from homeassistant.components.recorder.statistics import (
@ -98,9 +98,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
use_include_order = conf.get(CONF_ORDER) use_include_order = conf.get(CONF_ORDER)
hass.http.register_view(HistoryPeriodView(filters, use_include_order)) hass.http.register_view(HistoryPeriodView(filters, use_include_order))
hass.components.frontend.async_register_built_in_panel( frontend.async_register_built_in_panel(hass, "history", "history", "hass:chart-box")
"history", "history", "hass:chart-box"
)
websocket_api.async_register_command(hass, ws_get_statistics_during_period) websocket_api.async_register_command(hass, ws_get_statistics_during_period)
websocket_api.async_register_command(hass, ws_get_list_statistic_ids) websocket_api.async_register_command(hass, ws_get_list_statistic_ids)

View file

@ -11,6 +11,7 @@ from sqlalchemy.orm import aliased
from sqlalchemy.sql.expression import literal from sqlalchemy.sql.expression import literal
import voluptuous as vol import voluptuous as vol
from homeassistant.components import frontend
from homeassistant.components.automation import EVENT_AUTOMATION_TRIGGERED from homeassistant.components.automation import EVENT_AUTOMATION_TRIGGERED
from homeassistant.components.history import sqlalchemy_filter_from_include_exclude_conf from homeassistant.components.history import sqlalchemy_filter_from_include_exclude_conf
from homeassistant.components.http import HomeAssistantView from homeassistant.components.http import HomeAssistantView
@ -154,8 +155,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
message = message.async_render(parse_result=False) message = message.async_render(parse_result=False)
async_log_entry(hass, name, message, domain, entity_id) async_log_entry(hass, name, message, domain, entity_id)
hass.components.frontend.async_register_built_in_panel( frontend.async_register_built_in_panel(
"logbook", "logbook", "hass:format-list-bulleted-type" hass, "logbook", "logbook", "hass:format-list-bulleted-type"
) )
if conf := config.get(DOMAIN, {}): if conf := config.get(DOMAIN, {}):

View file

@ -11,6 +11,7 @@ from aiohttp import web
from aiohttp.web_exceptions import HTTPNotFound from aiohttp.web_exceptions import HTTPNotFound
import async_timeout import async_timeout
from homeassistant.components import frontend
from homeassistant.components.http import HomeAssistantView from homeassistant.components.http import HomeAssistantView
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
@ -36,9 +37,7 @@ SCAN_INTERVAL = timedelta(seconds=30)
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Track states and offer events for mailboxes.""" """Track states and offer events for mailboxes."""
mailboxes: list[Mailbox] = [] mailboxes: list[Mailbox] = []
hass.components.frontend.async_register_built_in_panel( frontend.async_register_built_in_panel(hass, "mailbox", "mailbox", "mdi:mailbox")
"mailbox", "mailbox", "mdi:mailbox"
)
hass.http.register_view(MailboxPlatformsView(mailboxes)) hass.http.register_view(MailboxPlatformsView(mailboxes))
hass.http.register_view(MailboxMessageView(mailboxes)) hass.http.register_view(MailboxMessageView(mailboxes))
hass.http.register_view(MailboxMediaView(mailboxes)) hass.http.register_view(MailboxMediaView(mailboxes))

View file

@ -1,4 +1,5 @@
"""Support for showing device locations.""" """Support for showing device locations."""
from homeassistant.components import frontend
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -7,7 +8,5 @@ DOMAIN = "map"
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Register the built-in map panel.""" """Register the built-in map panel."""
hass.components.frontend.async_register_built_in_panel( frontend.async_register_built_in_panel(hass, "map", "map", "hass:tooltip-account")
"map", "map", "hass:tooltip-account"
)
return True return True

View file

@ -7,7 +7,7 @@ from urllib.parse import quote
import voluptuous as vol import voluptuous as vol
from homeassistant.components import websocket_api from homeassistant.components import frontend, websocket_api
from homeassistant.components.http.auth import async_sign_path from homeassistant.components.http.auth import async_sign_path
from homeassistant.components.media_player.const import ATTR_MEDIA_CONTENT_ID from homeassistant.components.media_player.const import ATTR_MEDIA_CONTENT_ID
from homeassistant.components.media_player.errors import BrowseError from homeassistant.components.media_player.errors import BrowseError
@ -44,8 +44,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
hass.data[DOMAIN] = {} hass.data[DOMAIN] = {}
websocket_api.async_register_command(hass, websocket_browse_media) websocket_api.async_register_command(hass, websocket_browse_media)
websocket_api.async_register_command(hass, websocket_resolve_media) websocket_api.async_register_command(hass, websocket_resolve_media)
hass.components.frontend.async_register_built_in_panel( frontend.async_register_built_in_panel(
"media-browser", "media_browser", "hass:play-box-multiple" hass, "media-browser", "media_browser", "hass:play-box-multiple"
) )
local_source.async_setup(hass) local_source.async_setup(hass)
await async_process_integration_platforms( await async_process_integration_platforms(

View file

@ -1,4 +1,5 @@
"""Support for my.home-assistant.io redirect service.""" """Support for my.home-assistant.io redirect service."""
from homeassistant.components import frontend
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -8,7 +9,5 @@ URL_PATH = "_my_redirect"
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Register hidden _my_redirect panel.""" """Register hidden _my_redirect panel."""
hass.components.frontend.async_register_built_in_panel( frontend.async_register_built_in_panel(hass, DOMAIN, frontend_url_path=URL_PATH)
DOMAIN, frontend_url_path=URL_PATH
)
return True return True

View file

@ -3,6 +3,7 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.components import frontend
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -116,7 +117,8 @@ async def async_register_panel(
config["_panel_custom"] = custom_panel_config config["_panel_custom"] = custom_panel_config
hass.components.frontend.async_register_built_in_panel( frontend.async_register_built_in_panel(
hass,
component_name="custom", component_name="custom",
sidebar_title=sidebar_title, sidebar_title=sidebar_title,
sidebar_icon=sidebar_icon, sidebar_icon=sidebar_icon,

View file

@ -1,6 +1,7 @@
"""Register an iFrame front end panel.""" """Register an iFrame front end panel."""
import voluptuous as vol import voluptuous as vol
from homeassistant.components import frontend
from homeassistant.const import CONF_ICON, CONF_URL from homeassistant.const import CONF_ICON, CONF_URL
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -40,7 +41,8 @@ CONFIG_SCHEMA = vol.Schema(
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the iFrame frontend panels.""" """Set up the iFrame frontend panels."""
for url_path, info in config[DOMAIN].items(): for url_path, info in config[DOMAIN].items():
hass.components.frontend.async_register_built_in_panel( frontend.async_register_built_in_panel(
hass,
"iframe", "iframe",
info.get(CONF_TITLE), info.get(CONF_TITLE),
info.get(CONF_ICON), info.get(CONF_ICON),

View file

@ -6,7 +6,7 @@ import uuid
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components import http, websocket_api from homeassistant.components import frontend, http, websocket_api
from homeassistant.components.http.data_validator import RequestDataValidator from homeassistant.components.http.data_validator import RequestDataValidator
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_NAME from homeassistant.const import ATTR_NAME
@ -162,8 +162,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
hass.http.register_view(UpdateShoppingListItemView) hass.http.register_view(UpdateShoppingListItemView)
hass.http.register_view(ClearCompletedItemsView) hass.http.register_view(ClearCompletedItemsView)
hass.components.frontend.async_register_built_in_panel( frontend.async_register_built_in_panel(
"shopping-list", "shopping_list", "mdi:cart" hass, "shopping-list", "shopping_list", "mdi:cart"
) )
websocket_api.async_register_command( websocket_api.async_register_command(