diff --git a/hassio/src/hassio-my-redirect.ts b/hassio/src/hassio-my-redirect.ts index 777672870a..fc0e1c0808 100644 --- a/hassio/src/hassio-my-redirect.ts +++ b/hassio/src/hassio-my-redirect.ts @@ -15,7 +15,7 @@ import { } from "../../src/panels/my/ha-panel-my"; import { HomeAssistant, Route } from "../../src/types"; -const REDIRECTS: Redirects = { +export const REDIRECTS: Redirects = { supervisor: { redirect: "/hassio/dashboard", }, diff --git a/src/state/quick-bar-mixin.ts b/src/state/quick-bar-mixin.ts index 72b4902edf..532ffbe49e 100644 --- a/src/state/quick-bar-mixin.ts +++ b/src/state/quick-bar-mixin.ts @@ -63,22 +63,49 @@ export default >(superClass: T) => } private async _createMyLink(e: KeyboardEvent) { - if (!this._canOverrideAlphanumericInput(e) || !this.hass) { + if ( + !this.hass?.enableShortcuts || + !this._canOverrideAlphanumericInput(e) + ) { return; } const targetPath = mainWindow.location.pathname; + const isHassio = isComponentLoaded(this.hass, "hassio"); + const myParams = new URLSearchParams(); + + if (isHassio && targetPath.startsWith("/hassio")) { + const myPanelSupervisor = await import( + "../../hassio/src/hassio-my-redirect" + ); + for (const [slug, redirect] of Object.entries( + myPanelSupervisor.REDIRECTS + )) { + if (targetPath.startsWith(redirect.redirect)) { + myParams.append("redirect", slug); + if (redirect.redirect === "/hassio/addon") { + myParams.append("addon", targetPath.split("/")[3]); + } + window.open( + `https://my.home-assistant.io/create-link/?${myParams.toString()}`, + "_blank" + ); + return; + } + } + } + const myPanel = await import("../panels/my/ha-panel-my"); for (const [slug, redirect] of Object.entries( - myPanel.getMyRedirects(isComponentLoaded(this.hass, "hassio")) + myPanel.getMyRedirects(isHassio) )) { if (targetPath.startsWith(redirect.redirect)) { + myParams.append("redirect", slug); window.open( - `https://my.home-assistant.io/create-link/?redirect=${slug}`, + `https://my.home-assistant.io/create-link/?${myParams.toString()}`, "_blank" ); - return; } }