Remove deprecated panel_iframe integration (#128532)

This commit is contained in:
Jan-Philipp Benecke
2024-10-16 21:34:43 +02:00
committed by GitHub
parent f4dfe7868b
commit 4964470e9c
8 changed files with 0 additions and 277 deletions

View File

@ -1090,8 +1090,6 @@ build.json @home-assistant/supervisor
/tests/components/p1_monitor/ @klaasnicolaas
/homeassistant/components/panel_custom/ @home-assistant/frontend
/tests/components/panel_custom/ @home-assistant/frontend
/homeassistant/components/panel_iframe/ @home-assistant/frontend
/tests/components/panel_iframe/ @home-assistant/frontend
/homeassistant/components/peco/ @IceBotYT
/tests/components/peco/ @IceBotYT
/homeassistant/components/pegel_online/ @mib1185

View File

@ -1,98 +0,0 @@
"""Register an iFrame front end panel."""
import voluptuous as vol
from homeassistant.components import lovelace
from homeassistant.components.lovelace import dashboard
from homeassistant.const import CONF_ICON, CONF_URL
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
from homeassistant.helpers.storage import Store
from homeassistant.helpers.typing import ConfigType
DOMAIN = "panel_iframe"
CONF_TITLE = "title"
CONF_RELATIVE_URL_ERROR_MSG = "Invalid relative URL. Absolute path required."
CONF_RELATIVE_URL_REGEX = r"\A/"
CONF_REQUIRE_ADMIN = "require_admin"
CONFIG_SCHEMA = vol.Schema(
{
DOMAIN: cv.schema_with_slug_keys(
vol.Schema(
{
vol.Optional(CONF_TITLE): cv.string,
vol.Optional(CONF_ICON): cv.icon,
vol.Optional(CONF_REQUIRE_ADMIN, default=False): cv.boolean,
vol.Required(CONF_URL): vol.Any(
vol.Match(
CONF_RELATIVE_URL_REGEX, msg=CONF_RELATIVE_URL_ERROR_MSG
),
vol.Url(),
),
}
)
)
},
extra=vol.ALLOW_EXTRA,
)
STORAGE_KEY = DOMAIN
STORAGE_VERSION_MAJOR = 1
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the iFrame frontend panels."""
async_create_issue(
hass,
DOMAIN,
"deprecated_yaml",
breaks_in_ha_version="2024.10.0",
is_fixable=False,
is_persistent=False,
issue_domain=DOMAIN,
severity=IssueSeverity.WARNING,
translation_key="deprecated_yaml",
translation_placeholders={
"domain": DOMAIN,
"integration_title": "iframe Panel",
},
)
store: Store[dict[str, bool]] = Store(
hass,
STORAGE_VERSION_MAJOR,
STORAGE_KEY,
)
data = await store.async_load()
if data:
return True
dashboards_collection: dashboard.DashboardsCollection = hass.data[lovelace.DOMAIN][
"dashboards_collection"
]
for url_path, info in config[DOMAIN].items():
dashboard_create_data = {
lovelace.CONF_ALLOW_SINGLE_WORD: True,
lovelace.CONF_URL_PATH: url_path,
}
for key in (CONF_ICON, CONF_REQUIRE_ADMIN, CONF_TITLE):
if key in info:
dashboard_create_data[key] = info[key]
await dashboards_collection.async_create_item(dashboard_create_data)
dashboard_store: dashboard.LovelaceStorage = hass.data[lovelace.DOMAIN][
"dashboards"
][url_path]
await dashboard_store.async_save(
{"strategy": {"type": "iframe", "url": info[CONF_URL]}}
)
await store.async_save({"migrated": True})
return True

View File

@ -1,8 +0,0 @@
{
"domain": "panel_iframe",
"name": "iframe Panel",
"codeowners": ["@home-assistant/frontend"],
"dependencies": ["frontend", "lovelace"],
"documentation": "https://www.home-assistant.io/integrations/panel_iframe",
"quality_scale": "internal"
}

View File

@ -1,8 +0,0 @@
{
"issues": {
"deprecated_yaml": {
"title": "The {integration_title} YAML configuration is being removed",
"description": "Configuring {integration_title} using YAML is being removed.\n\nYour existing YAML configuration has been imported into the UI automatically as a regular dashboard.\n\nRemove the `{domain}` configuration from your configuration.yaml file and restart Home Assistant to fix this issue."
}
}
}

View File

@ -4555,11 +4555,6 @@
"config_flow": false,
"iot_class": "local_polling"
},
"panel_iframe": {
"name": "iframe Panel",
"integration_type": "hub",
"config_flow": false
},
"pcs_lighting": {
"name": "PCS Lighting",
"integration_type": "virtual",

View File

@ -92,7 +92,6 @@ NO_IOT_CLASS = [
"my",
"onboarding",
"panel_custom",
"panel_iframe",
"plant",
"profiler",
"proxy",

View File

@ -1 +0,0 @@
"""Tests for the panel_iframe component."""

View File

@ -1,154 +0,0 @@
"""The tests for the panel_iframe component."""
from typing import Any
import pytest
from homeassistant.components.panel_iframe import DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.helpers import issue_registry as ir
from homeassistant.setup import async_setup_component
from tests.typing import WebSocketGenerator
TEST_CONFIG = {
"router": {
"icon": "mdi:network-wireless",
"title": "Router",
"url": "http://192.168.1.1",
"require_admin": True,
},
"weather": {
"icon": "mdi:weather",
"title": "Weather",
"url": "https://www.wunderground.com/us/ca/san-diego",
"require_admin": True,
},
"api": {"icon": "mdi:weather", "title": "Api", "url": "/api"},
"ftp": {
"icon": "mdi:weather",
"title": "FTP",
"url": "ftp://some/ftp",
},
}
@pytest.mark.parametrize(
"config_to_try",
[
{"invalid space": {"url": "https://home-assistant.io"}},
{"router": {"url": "not-a-url"}},
],
)
async def test_wrong_config(hass: HomeAssistant, config_to_try) -> None:
"""Test setup with wrong configuration."""
assert not await async_setup_component(
hass, "panel_iframe", {"panel_iframe": config_to_try}
)
async def test_import_config(
hass: HomeAssistant,
hass_storage: dict[str, Any],
hass_ws_client: WebSocketGenerator,
) -> None:
"""Test import config."""
client = await hass_ws_client(hass)
assert await async_setup_component(
hass,
"panel_iframe",
{"panel_iframe": TEST_CONFIG},
)
# List dashboards
await client.send_json_auto_id({"type": "lovelace/dashboards/list"})
response = await client.receive_json()
assert response["success"]
assert response["result"] == [
{
"icon": "mdi:network-wireless",
"id": "router",
"mode": "storage",
"require_admin": True,
"show_in_sidebar": True,
"title": "Router",
"url_path": "router",
},
{
"icon": "mdi:weather",
"id": "weather",
"mode": "storage",
"require_admin": True,
"show_in_sidebar": True,
"title": "Weather",
"url_path": "weather",
},
{
"icon": "mdi:weather",
"id": "api",
"mode": "storage",
"require_admin": False,
"show_in_sidebar": True,
"title": "Api",
"url_path": "api",
},
{
"icon": "mdi:weather",
"id": "ftp",
"mode": "storage",
"require_admin": False,
"show_in_sidebar": True,
"title": "FTP",
"url_path": "ftp",
},
]
for url_path in ("api", "ftp", "router", "weather"):
await client.send_json_auto_id(
{"type": "lovelace/config", "url_path": url_path}
)
response = await client.receive_json()
assert response["success"]
assert response["result"] == {
"strategy": {"type": "iframe", "url": TEST_CONFIG[url_path]["url"]}
}
assert hass_storage[DOMAIN]["data"] == {"migrated": True}
async def test_import_config_once(
hass: HomeAssistant,
hass_storage: dict[str, Any],
hass_ws_client: WebSocketGenerator,
) -> None:
"""Test import config only happens once."""
client = await hass_ws_client(hass)
hass_storage[DOMAIN] = {
"version": 1,
"minor_version": 1,
"key": "map",
"data": {"migrated": True},
}
assert await async_setup_component(
hass,
"panel_iframe",
{"panel_iframe": TEST_CONFIG},
)
# List dashboards
await client.send_json_auto_id({"type": "lovelace/dashboards/list"})
response = await client.receive_json()
assert response["success"]
assert response["result"] == []
async def test_create_issue_when_manually_configured(
hass: HomeAssistant, issue_registry: ir.IssueRegistry
) -> None:
"""Test creating issue registry issues."""
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
assert issue_registry.async_get_issue(DOMAIN, "deprecated_yaml")