1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 02:38:53 +00:00

Restore navigation header for home, light, security and climate dashboards (#28552)

This commit is contained in:
Paul Bottein
2025-12-15 15:44:51 +01:00
committed by GitHub
parent 3bcf530200
commit 3005f12ef5
4 changed files with 73 additions and 51 deletions

View File

@@ -103,6 +103,10 @@ const processAreasForClimate = (
heading_style: "subtitle", heading_style: "subtitle",
type: "heading", type: "heading",
heading: area.name, heading: area.name,
tap_action: {
action: "navigate",
navigation_path: `/home/areas-${area.area_id}`,
},
}); });
cards.push(...areaCards); cards.push(...areaCards);
} }

View File

@@ -49,6 +49,10 @@ const processAreasForLight = (
heading_style: "subtitle", heading_style: "subtitle",
type: "heading", type: "heading",
heading: area.name, heading: area.name,
tap_action: {
action: "navigate",
navigation_path: `/home/areas-${area.area_id}`,
},
}); });
cards.push(...areaCards); cards.push(...areaCards);
} }

View File

@@ -8,7 +8,6 @@ import {
} from "../../../../common/entity/entity_filter"; } from "../../../../common/entity/entity_filter";
import { clamp } from "../../../../common/number/clamp"; import { clamp } from "../../../../common/number/clamp";
import type { LovelaceBadgeConfig } from "../../../../data/lovelace/config/badge"; import type { LovelaceBadgeConfig } from "../../../../data/lovelace/config/badge";
import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
import type { LovelaceSectionRawConfig } from "../../../../data/lovelace/config/section"; import type { LovelaceSectionRawConfig } from "../../../../data/lovelace/config/section";
import type { LovelaceViewConfig } from "../../../../data/lovelace/config/view"; import type { LovelaceViewConfig } from "../../../../data/lovelace/config/view";
import type { HomeAssistant } from "../../../../types"; import type { HomeAssistant } from "../../../../types";
@@ -27,25 +26,6 @@ export interface HomeAreaViewStrategyConfig {
area?: string; area?: string;
} }
const computeHeadingCard = (
heading: string,
icon: string,
navigation_path?: string
): LovelaceCardConfig =>
({
type: "heading",
heading: heading,
icon: icon,
tap_action: navigation_path
? {
action: "navigate",
navigation_path,
}
: {
action: "none",
},
}) satisfies HeadingCardConfig;
@customElement("home-area-view-strategy") @customElement("home-area-view-strategy")
export class HomeAreaViewStrategy extends ReactiveElement { export class HomeAreaViewStrategy extends ReactiveElement {
static async generate( static async generate(
@@ -114,11 +94,15 @@ export class HomeAreaViewStrategy extends ReactiveElement {
sections.push({ sections.push({
type: "grid", type: "grid",
cards: [ cards: [
computeHeadingCard( {
getSummaryLabel(hass.localize, "light"), type: "heading",
HOME_SUMMARIES_ICONS.light, heading: getSummaryLabel(hass.localize, "light"),
"/light?historyBack=1" icon: HOME_SUMMARIES_ICONS.light,
), tap_action: {
action: "navigate",
navigation_path: "/light?historyBack=1",
},
} satisfies HeadingCardConfig,
...light.map(computeTileCard), ...light.map(computeTileCard),
], ],
}); });
@@ -128,11 +112,15 @@ export class HomeAreaViewStrategy extends ReactiveElement {
sections.push({ sections.push({
type: "grid", type: "grid",
cards: [ cards: [
computeHeadingCard( {
getSummaryLabel(hass.localize, "climate"), type: "heading",
HOME_SUMMARIES_ICONS.climate, heading: getSummaryLabel(hass.localize, "climate"),
"/climate?historyBack=1" icon: HOME_SUMMARIES_ICONS.climate,
), tap_action: {
action: "navigate",
navigation_path: "/climate?historyBack=1",
},
} satisfies HeadingCardConfig,
...climate.map(computeTileCard), ...climate.map(computeTileCard),
], ],
}); });
@@ -142,11 +130,15 @@ export class HomeAreaViewStrategy extends ReactiveElement {
sections.push({ sections.push({
type: "grid", type: "grid",
cards: [ cards: [
computeHeadingCard( {
getSummaryLabel(hass.localize, "security"), type: "heading",
HOME_SUMMARIES_ICONS.security, heading: getSummaryLabel(hass.localize, "security"),
"/security?historyBack=1" icon: HOME_SUMMARIES_ICONS.security,
), tap_action: {
action: "navigate",
navigation_path: "/security?historyBack=1",
},
} satisfies HeadingCardConfig,
...security.map(computeTileCard), ...security.map(computeTileCard),
], ],
}); });
@@ -156,11 +148,15 @@ export class HomeAreaViewStrategy extends ReactiveElement {
sections.push({ sections.push({
type: "grid", type: "grid",
cards: [ cards: [
computeHeadingCard( {
getSummaryLabel(hass.localize, "media_players"), type: "heading",
HOME_SUMMARIES_ICONS.media_players, heading: getSummaryLabel(hass.localize, "media_players"),
"/media-players" icon: HOME_SUMMARIES_ICONS.media_players,
), tap_action: {
action: "navigate",
navigation_path: "media-players?historyBack=1",
},
} satisfies HeadingCardConfig,
...mediaPlayers.map(computeTileCard), ...mediaPlayers.map(computeTileCard),
], ],
}); });
@@ -181,11 +177,17 @@ export class HomeAreaViewStrategy extends ReactiveElement {
sections.push({ sections.push({
type: "grid", type: "grid",
cards: [ cards: [
computeHeadingCard( {
hass.localize("ui.panel.lovelace.strategy.home.scenes"), type: "heading",
"mdi:palette", heading: hass.localize("ui.panel.lovelace.strategy.home.scenes"),
hass.user?.is_admin ? "/config/scene/dashboard" : undefined icon: "mdi:palette",
), tap_action: hass.user?.is_admin
? {
action: "navigate",
navigation_path: "/config/scene/dashboard",
}
: undefined,
} satisfies HeadingCardConfig,
...scenes.map(computeTileCard), ...scenes.map(computeTileCard),
], ],
}); });
@@ -293,7 +295,7 @@ export class HomeAreaViewStrategy extends ReactiveElement {
action: "navigate", action: "navigate",
navigation_path: `/config/devices/device/${device.id}`, navigation_path: `/config/devices/device/${device.id}`,
} }
: { action: "none" }, : undefined,
badges: [ badges: [
...batteryEntities.slice(0, 1).map((e) => ({ ...batteryEntities.slice(0, 1).map((e) => ({
entity: e, entity: e,
@@ -334,11 +336,19 @@ export class HomeAreaViewStrategy extends ReactiveElement {
sections.push({ sections.push({
type: "grid", type: "grid",
cards: [ cards: [
computeHeadingCard( {
hass.localize("ui.panel.lovelace.strategy.home.automations"), type: "heading",
"mdi:robot", heading: hass.localize(
hass.user?.is_admin ? "/config/automation/dashboard" : undefined "ui.panel.lovelace.strategy.home.automations"
), ),
icon: "mdi:robot",
tap_action: hass.user?.is_admin
? {
action: "navigate",
navigation_path: "/config/automation/dashboard",
}
: undefined,
} satisfies HeadingCardConfig,
...automations.map(computeTileCard), ...automations.map(computeTileCard),
], ],
}); });

View File

@@ -91,6 +91,10 @@ const processAreasForSecurity = (
heading_style: "subtitle", heading_style: "subtitle",
type: "heading", type: "heading",
heading: area.name, heading: area.name,
tap_action: {
action: "navigate",
navigation_path: `/home/areas-${area.area_id}`,
},
}); });
cards.push(...areaCards); cards.push(...areaCards);
} }