mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 17:56:46 +00:00
Add supervisor redirects to m keyboard shortcut (#12466)
This commit is contained in:
parent
307cd5ad8c
commit
4b644d8bc5
@ -15,7 +15,7 @@ import {
|
|||||||
} from "../../src/panels/my/ha-panel-my";
|
} from "../../src/panels/my/ha-panel-my";
|
||||||
import { HomeAssistant, Route } from "../../src/types";
|
import { HomeAssistant, Route } from "../../src/types";
|
||||||
|
|
||||||
const REDIRECTS: Redirects = {
|
export const REDIRECTS: Redirects = {
|
||||||
supervisor: {
|
supervisor: {
|
||||||
redirect: "/hassio/dashboard",
|
redirect: "/hassio/dashboard",
|
||||||
},
|
},
|
||||||
|
@ -63,22 +63,49 @@ export default <T extends Constructor<HassElement>>(superClass: T) =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async _createMyLink(e: KeyboardEvent) {
|
private async _createMyLink(e: KeyboardEvent) {
|
||||||
if (!this._canOverrideAlphanumericInput(e) || !this.hass) {
|
if (
|
||||||
|
!this.hass?.enableShortcuts ||
|
||||||
|
!this._canOverrideAlphanumericInput(e)
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetPath = mainWindow.location.pathname;
|
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");
|
const myPanel = await import("../panels/my/ha-panel-my");
|
||||||
|
|
||||||
for (const [slug, redirect] of Object.entries(
|
for (const [slug, redirect] of Object.entries(
|
||||||
myPanel.getMyRedirects(isComponentLoaded(this.hass, "hassio"))
|
myPanel.getMyRedirects(isHassio)
|
||||||
)) {
|
)) {
|
||||||
if (targetPath.startsWith(redirect.redirect)) {
|
if (targetPath.startsWith(redirect.redirect)) {
|
||||||
|
myParams.append("redirect", slug);
|
||||||
window.open(
|
window.open(
|
||||||
`https://my.home-assistant.io/create-link/?redirect=${slug}`,
|
`https://my.home-assistant.io/create-link/?${myParams.toString()}`,
|
||||||
"_blank"
|
"_blank"
|
||||||
);
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user