Skip to content

Commit

Permalink
Update and add backup my links (#23556)
Browse files Browse the repository at this point in the history
* Update and add backup my links
  • Loading branch information
bramkragten authored Jan 2, 2025
1 parent 2945a7b commit 052744e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
30 changes: 18 additions & 12 deletions src/panels/my/ha-panel-my.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import "../../layouts/hass-error-screen";
import type { HomeAssistant, Route } from "../../types";
import { documentationUrl } from "../../util/documentation-url";

export const getMyRedirects = (hasSupervisor: boolean): Redirects => ({
export const getMyRedirects = (): Redirects => ({
application_credentials: {
redirect: "/config/application_credentials",
},
Expand Down Expand Up @@ -244,16 +244,24 @@ export const getMyRedirects = (hasSupervisor: boolean): Redirects => ({
redirect: "/media-browser",
},
backup: {
component: hasSupervisor ? "hassio" : "backup",
redirect: hasSupervisor ? "/hassio/backups" : "/config/backup",
component: "backup",
redirect: "/config/backup",
},
backup_list: {
component: "backup",
redirect: "/config/backup/backups",
},
backup_config: {
component: "backup",
redirect: "/config/backup/settings",
},
supervisor_snapshots: {
component: hasSupervisor ? "hassio" : "backup",
redirect: hasSupervisor ? "/hassio/backups" : "/config/backup",
component: "backup",
redirect: "/config/backup",
},
supervisor_backups: {
component: hasSupervisor ? "hassio" : "backup",
redirect: hasSupervisor ? "/hassio/backups" : "/config/backup",
component: "backup",
redirect: "/config/backup",
},
supervisor_system: {
// Moved from Supervisor panel in 2022.5
Expand All @@ -278,10 +286,8 @@ export const getMyRedirects = (hasSupervisor: boolean): Redirects => ({
},
});

const getRedirect = (
path: string,
hasSupervisor: boolean
): Redirect | undefined => getMyRedirects(hasSupervisor)?.[path];
const getRedirect = (path: string): Redirect | undefined =>
getMyRedirects()?.[path];

export type ParamType = "url" | "string" | "string?";

Expand Down Expand Up @@ -314,7 +320,7 @@ class HaPanelMy extends LitElement {
const path = this.route.path.substring(1);
const hasSupervisor = isComponentLoaded(this.hass, "hassio");

this._redirect = getRedirect(path, hasSupervisor);
this._redirect = getRedirect(path);

if (path.startsWith("supervisor") && this._redirect === undefined) {
if (!hasSupervisor) {
Expand Down
4 changes: 1 addition & 3 deletions src/state/quick-bar-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ export default <T extends Constructor<HassElement>>(superClass: T) =>

const myPanel = await import("../panels/my/ha-panel-my");

for (const [slug, redirect] of Object.entries(
myPanel.getMyRedirects(isHassio)
)) {
for (const [slug, redirect] of Object.entries(myPanel.getMyRedirects())) {
if (targetPath.startsWith(redirect.redirect)) {
myParams.append("redirect", slug);
if (redirect.params) {
Expand Down

0 comments on commit 052744e

Please sign in to comment.