Skip to content

Commit

Permalink
Fix translations (#1904)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Feb 13, 2021
1 parent c682bd6 commit 9305db8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 47 deletions.
4 changes: 2 additions & 2 deletions custom_components/hacs/manifest.json
Expand Up @@ -19,8 +19,8 @@
"aiogithubapi>=21.2.0",
"awesomeversion>=21.2.2",
"backoff>=1.10.0",
"hacs_frontend==20210207162610",
"hacs_frontend==20210213120600",
"queueman==0.5"
],
"version": "0.0.0"
}
}
46 changes: 3 additions & 43 deletions custom_components/hacs/operational/setup_actions/frontend.py
Expand Up @@ -29,7 +29,9 @@ async def async_setup_frontend():
hass.http.register_view(HacsFrontendDev())
else:
#
hass.http.register_static_path(f"{URL_BASE}/frontend", locate_dir())
hass.http.register_static_path(
f"{URL_BASE}/frontend", locate_dir(), cache_headers=False
)

# Custom iconset
hass.http.register_static_path(
Expand Down Expand Up @@ -66,45 +68,3 @@ async def async_setup_frontend():
},
require_admin=True,
)


async def async_serve_frontend(requested_file):
hacs = get_hacs()
requested = requested_file.split("/")[-1]
servefile = None
dev = False

if hacs.configuration.frontend_repo_url or hacs.configuration.frontend_repo:
dev = True

if hacs.configuration.frontend_repo_url:
_LOGGER.debug("Serving REMOTE DEVELOPMENT frontend")
try:
request = await hacs.session.get(
f"{hacs.configuration.frontend_repo_url}/{requested}"
)
if request.status == 200:
result = await request.read()
response = web.Response(body=result)
response.headers["Content-Type"] = "application/javascript"

return response
except (Exception, BaseException) as exception:
_LOGGER.error(exception)

elif hacs.configuration.frontend_repo:
_LOGGER.debug("Serving LOCAL DEVELOPMENT frontend")
servefile = f"{hacs.configuration.frontend_repo}/hacs_frontend/{requested}"
else:
servefile = f"{locate_dir()}/{requested}"

if servefile is None or not await async_path_exsist(servefile):
return web.Response(status=404)

response = web.FileResponse(servefile)
response.headers["Content-Type"] = "application/javascript"

if dev:
response.headers["Cache-Control"] = "no-store, max-age=0"
response.headers["Pragma"] = "no-store"
return response
2 changes: 1 addition & 1 deletion requirements.txt
Expand Up @@ -8,7 +8,7 @@ awesomeversion>=21.2.2
backoff>=1.10.0
bellybutton==0.3.1
colorlog==4.7.2
hacs_frontend==20210207162610
hacs_frontend==20210213120600
pre-commit==2.10.1
PyGithub==1.54.1
pytest==6.2.2
Expand Down
8 changes: 7 additions & 1 deletion tests/common.py
Expand Up @@ -11,6 +11,8 @@
from homeassistant.auth import auth_store
from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE
from homeassistant.helpers import storage
from homeassistant.helpers.device_registry import DeviceRegistry
from homeassistant.helpers.entity_registry import EntityRegistry
from homeassistant.util.unit_system import METRIC_SYSTEM

from custom_components.hacs.helpers.classes.repository import HacsRepository
Expand Down Expand Up @@ -118,7 +120,11 @@ def async_create_task(coroutine):
hass.config.time_zone = date_util.get_time_zone("US/Pacific")
hass.config.units = METRIC_SYSTEM
hass.config.skip_pip = True
hass.data = {"custom_components": {}}
hass.data = {
"custom_components": {},
"device_registry": DeviceRegistry(hass),
"entity_registry": EntityRegistry(hass),
}

hass.config_entries = config_entries.ConfigEntries(hass, {})
hass.config_entries._entries = []
Expand Down

0 comments on commit 9305db8

Please sign in to comment.