Update and add backup my links (#23556)

* Update and add backup my links
This commit is contained in:
Bram Kragten 2025-01-02 17:18:34 +01:00 committed by GitHub
parent 2945a7b701
commit 052744e3d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 15 deletions

View File

@ -16,7 +16,7 @@ import "../../layouts/hass-error-screen";
import type { HomeAssistant, Route } from "../../types"; import type { HomeAssistant, Route } from "../../types";
import { documentationUrl } from "../../util/documentation-url"; import { documentationUrl } from "../../util/documentation-url";
export const getMyRedirects = (hasSupervisor: boolean): Redirects => ({ export const getMyRedirects = (): Redirects => ({
application_credentials: { application_credentials: {
redirect: "/config/application_credentials", redirect: "/config/application_credentials",
}, },
@ -244,16 +244,24 @@ export const getMyRedirects = (hasSupervisor: boolean): Redirects => ({
redirect: "/media-browser", redirect: "/media-browser",
}, },
backup: { backup: {
component: hasSupervisor ? "hassio" : "backup", component: "backup",
redirect: hasSupervisor ? "/hassio/backups" : "/config/backup", redirect: "/config/backup",
},
backup_list: {
component: "backup",
redirect: "/config/backup/backups",
},
backup_config: {
component: "backup",
redirect: "/config/backup/settings",
}, },
supervisor_snapshots: { supervisor_snapshots: {
component: hasSupervisor ? "hassio" : "backup", component: "backup",
redirect: hasSupervisor ? "/hassio/backups" : "/config/backup", redirect: "/config/backup",
}, },
supervisor_backups: { supervisor_backups: {
component: hasSupervisor ? "hassio" : "backup", component: "backup",
redirect: hasSupervisor ? "/hassio/backups" : "/config/backup", redirect: "/config/backup",
}, },
supervisor_system: { supervisor_system: {
// Moved from Supervisor panel in 2022.5 // Moved from Supervisor panel in 2022.5
@ -278,10 +286,8 @@ export const getMyRedirects = (hasSupervisor: boolean): Redirects => ({
}, },
}); });
const getRedirect = ( const getRedirect = (path: string): Redirect | undefined =>
path: string, getMyRedirects()?.[path];
hasSupervisor: boolean
): Redirect | undefined => getMyRedirects(hasSupervisor)?.[path];
export type ParamType = "url" | "string" | "string?"; export type ParamType = "url" | "string" | "string?";
@ -314,7 +320,7 @@ class HaPanelMy extends LitElement {
const path = this.route.path.substring(1); const path = this.route.path.substring(1);
const hasSupervisor = isComponentLoaded(this.hass, "hassio"); const hasSupervisor = isComponentLoaded(this.hass, "hassio");
this._redirect = getRedirect(path, hasSupervisor); this._redirect = getRedirect(path);
if (path.startsWith("supervisor") && this._redirect === undefined) { if (path.startsWith("supervisor") && this._redirect === undefined) {
if (!hasSupervisor) { if (!hasSupervisor) {

View File

@ -150,9 +150,7 @@ export default <T extends Constructor<HassElement>>(superClass: T) =>
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())) {
myPanel.getMyRedirects(isHassio)
)) {
if (targetPath.startsWith(redirect.redirect)) { if (targetPath.startsWith(redirect.redirect)) {
myParams.append("redirect", slug); myParams.append("redirect", slug);
if (redirect.params) { if (redirect.params) {