mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Disable dashboard resources in safe mode (#18382)
This commit is contained in:
parent
8350d71f6e
commit
eb35eb3de5
@ -309,7 +309,7 @@ export class HcMain extends HassElement {
|
||||
? await fetchResources(this.hass!.connection)
|
||||
: (this._lovelaceConfig as LegacyLovelaceConfig).resources;
|
||||
if (resources) {
|
||||
loadLovelaceResources(resources, this.hass!.auth.data.hassUrl);
|
||||
loadLovelaceResources(resources, this.hass!);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@
|
||||
"fuse.js": "6.6.2",
|
||||
"google-timezones-json": "1.2.0",
|
||||
"hls.js": "1.4.12",
|
||||
"home-assistant-js-websocket": "9.0.0",
|
||||
"home-assistant-js-websocket": "9.1.0",
|
||||
"idb-keyval": "6.2.1",
|
||||
"intl-messageformat": "10.5.4",
|
||||
"js-yaml": "4.1.0",
|
||||
|
@ -22,6 +22,7 @@ export const demoConfig: HassConfig = {
|
||||
allowlist_external_urls: [],
|
||||
config_source: "storage",
|
||||
recovery_mode: false,
|
||||
safe_mode: false,
|
||||
state: STATE_RUNNING,
|
||||
internal_url: "http://homeassistant.local:8123",
|
||||
external_url: null,
|
||||
|
@ -144,14 +144,14 @@ export class HaConfigLovelaceRescources extends LitElement {
|
||||
this._resources = this._resources!.concat(created).sort((res1, res2) =>
|
||||
stringCompare(res1.url, res2.url, this.hass!.locale.language)
|
||||
);
|
||||
loadLovelaceResources([created], this.hass!.auth.data.hassUrl);
|
||||
loadLovelaceResources([created], this.hass!);
|
||||
},
|
||||
updateResource: async (values) => {
|
||||
const updated = await updateResource(this.hass!, resource!.id, values);
|
||||
this._resources = this._resources!.map((res) =>
|
||||
res === resource ? updated : res
|
||||
);
|
||||
loadLovelaceResources([updated], this.hass!.auth.data.hassUrl);
|
||||
loadLovelaceResources([updated], this.hass!);
|
||||
},
|
||||
removeResource: async () => {
|
||||
if (
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { loadCSS, loadJS, loadModule } from "../../../common/dom/load_resource";
|
||||
import { LovelaceResource } from "../../../data/lovelace";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
|
||||
// CSS and JS should only be imported once. Modules and HTML are safe.
|
||||
const CSS_CACHE = {};
|
||||
@ -7,10 +8,17 @@ const JS_CACHE = {};
|
||||
|
||||
export const loadLovelaceResources = (
|
||||
resources: NonNullable<LovelaceResource[]>,
|
||||
hassUrl: string
|
||||
) =>
|
||||
hass: HomeAssistant
|
||||
) => {
|
||||
// Don't load ressources on safe mode
|
||||
if (hass.config.safe_mode) {
|
||||
return;
|
||||
}
|
||||
resources.forEach((resource) => {
|
||||
const normalizedUrl = new URL(resource.url, hassUrl).toString();
|
||||
const normalizedUrl = new URL(
|
||||
resource.url,
|
||||
hass.auth.data.hassUrl
|
||||
).toString();
|
||||
switch (resource.type) {
|
||||
case "css":
|
||||
if (normalizedUrl in CSS_CACHE) {
|
||||
@ -35,3 +43,4 @@ export const loadLovelaceResources = (
|
||||
console.warn(`Unknown resource type specified: ${resource.type}`);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -229,10 +229,9 @@ export class LovelacePanel extends LitElement {
|
||||
}
|
||||
if (!resourcesLoaded) {
|
||||
resourcesLoaded = true;
|
||||
(llWindow.llResProm || fetchResources(this.hass!.connection)).then(
|
||||
(resources) =>
|
||||
loadLovelaceResources(resources, this.hass!.auth.data.hassUrl)
|
||||
);
|
||||
const resources = await (llWindow.llResProm ||
|
||||
fetchResources(this.hass!.connection));
|
||||
loadLovelaceResources(resources, this.hass!);
|
||||
}
|
||||
|
||||
if (this.urlPath !== null || !confProm) {
|
||||
|
10
yarn.lock
10
yarn.lock
@ -9789,7 +9789,7 @@ __metadata:
|
||||
gulp-rename: 2.0.0
|
||||
gulp-zopfli-green: 6.0.1
|
||||
hls.js: 1.4.12
|
||||
home-assistant-js-websocket: 9.0.0
|
||||
home-assistant-js-websocket: 9.1.0
|
||||
html-minifier-terser: 7.2.0
|
||||
husky: 8.0.3
|
||||
idb-keyval: 6.2.1
|
||||
@ -9865,10 +9865,10 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"home-assistant-js-websocket@npm:9.0.0":
|
||||
version: 9.0.0
|
||||
resolution: "home-assistant-js-websocket@npm:9.0.0"
|
||||
checksum: c1543483f55c1d135400b9bd6dce084b5942f57dc8098f4c84c6ece7b8289c558dc6578c45c94eecde99fec134041d8c4f458492e2573875bfb706df70ffd902
|
||||
"home-assistant-js-websocket@npm:9.1.0":
|
||||
version: 9.1.0
|
||||
resolution: "home-assistant-js-websocket@npm:9.1.0"
|
||||
checksum: 4692b856b1e89c05ec772e7e3590d6b0cd0f6ef711eac9fa888d62c21fe4f9c669ab7ae8b7b5c52af58e4821c7cecb4167ec8a617426bff17b8095fd44a9c8e4
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user