Frontend indicate require admin (#22272)
* Allow panels to indicate they are meant for admins * Panels to indicate when they require admin access * Do not return admin-only panels to non-admin users * Fix flake8
This commit is contained in:
1 parent
b57d809dad
commit
f1a0ad9e4a
9 files changed
+90
-14
No files matched your search
@@ -12,6 +12,7 @@ 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(
|
||||
@@ -19,6 +20,7 @@ CONFIG_SCHEMA = vol.Schema({
|
||||
# pylint: disable=no-value-for-parameter
|
||||
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,
|
||||
@@ -34,6 +36,7 @@ async def async_setup(hass, config):
|
||||
for url_path, info in config[DOMAIN].items():
|
||||
await hass.components.frontend.async_register_built_in_panel(
|
||||
'iframe', info.get(CONF_TITLE), info.get(CONF_ICON),
|
||||
url_path, {'url': info[CONF_URL]})
|
||||
url_path, {'url': info[CONF_URL]},
|
||||
require_admin=info[CONF_REQUIRE_ADMIN])
|
||||
|
||||
return True
|
||||
Reference in new issue
Block a user