mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Combine component/components PageNavigation keys (#19890)
* Combine component/components PageNavigation keys * Update src/panels/config/ha-panel-config.ts
This commit is contained in:
parent
841b9c0917
commit
3afc218adc
@ -9,13 +9,10 @@ export const canShowPage = (hass: HomeAssistant, page: PageNavigation) =>
|
|||||||
isNotLoadedIntegration(hass, page);
|
isNotLoadedIntegration(hass, page);
|
||||||
|
|
||||||
const isLoadedIntegration = (hass: HomeAssistant, page: PageNavigation) =>
|
const isLoadedIntegration = (hass: HomeAssistant, page: PageNavigation) =>
|
||||||
page.component
|
!page.component ||
|
||||||
? isComponentLoaded(hass, page.component)
|
ensureArray(page.component).some((integration) =>
|
||||||
: page.components
|
isComponentLoaded(hass, integration)
|
||||||
? page.components.some((integration) =>
|
);
|
||||||
isComponentLoaded(hass, integration)
|
|
||||||
)
|
|
||||||
: true;
|
|
||||||
|
|
||||||
const isNotLoadedIntegration = (hass: HomeAssistant, page: PageNavigation) =>
|
const isNotLoadedIntegration = (hass: HomeAssistant, page: PageNavigation) =>
|
||||||
!page.not_component ||
|
!page.not_component ||
|
||||||
|
@ -10,7 +10,6 @@ import {
|
|||||||
import { customElement, eventOptions, property, state } from "lit/decorators";
|
import { customElement, eventOptions, property, state } from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { isComponentLoaded } from "../common/config/is_component_loaded";
|
|
||||||
import { restoreScroll } from "../common/decorators/restore-scroll";
|
import { restoreScroll } from "../common/decorators/restore-scroll";
|
||||||
import { LocalizeFunc } from "../common/translations/localize";
|
import { LocalizeFunc } from "../common/translations/localize";
|
||||||
import "../components/ha-icon-button-arrow-prev";
|
import "../components/ha-icon-button-arrow-prev";
|
||||||
@ -19,12 +18,12 @@ import "../components/ha-svg-icon";
|
|||||||
import "../components/ha-tab";
|
import "../components/ha-tab";
|
||||||
import { HomeAssistant, Route } from "../types";
|
import { HomeAssistant, Route } from "../types";
|
||||||
import { haStyleScrollbar } from "../resources/styles";
|
import { haStyleScrollbar } from "../resources/styles";
|
||||||
|
import { canShowPage } from "../common/config/can_show_page";
|
||||||
|
|
||||||
export interface PageNavigation {
|
export interface PageNavigation {
|
||||||
path: string;
|
path: string;
|
||||||
translationKey?: string;
|
translationKey?: string;
|
||||||
component?: string;
|
component?: string | string[];
|
||||||
components?: string[];
|
|
||||||
name?: string;
|
name?: string;
|
||||||
not_component?: string | string[];
|
not_component?: string | string[];
|
||||||
core?: boolean;
|
core?: boolean;
|
||||||
@ -67,19 +66,12 @@ class HassTabsSubpage extends LitElement {
|
|||||||
(
|
(
|
||||||
tabs: PageNavigation[],
|
tabs: PageNavigation[],
|
||||||
activeTab: PageNavigation | undefined,
|
activeTab: PageNavigation | undefined,
|
||||||
showAdvanced: boolean | undefined,
|
|
||||||
_components,
|
_components,
|
||||||
_language,
|
_language,
|
||||||
_narrow,
|
_narrow,
|
||||||
localizeFunc
|
localizeFunc
|
||||||
) => {
|
) => {
|
||||||
const shownTabs = tabs.filter(
|
const shownTabs = tabs.filter((page) => canShowPage(this.hass, page));
|
||||||
(page) =>
|
|
||||||
(!page.component ||
|
|
||||||
page.core ||
|
|
||||||
isComponentLoaded(this.hass, page.component)) &&
|
|
||||||
(!page.advancedOnly || showAdvanced)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (shownTabs.length < 2) {
|
if (shownTabs.length < 2) {
|
||||||
if (shownTabs.length === 1) {
|
if (shownTabs.length === 1) {
|
||||||
@ -128,7 +120,6 @@ class HassTabsSubpage extends LitElement {
|
|||||||
const tabs = this._getTabs(
|
const tabs = this._getTabs(
|
||||||
this.tabs,
|
this.tabs,
|
||||||
this._activeTab,
|
this._activeTab,
|
||||||
this.hass.userData?.showAdvanced,
|
|
||||||
this.hass.config.components,
|
this.hass.config.components,
|
||||||
this.hass.language,
|
this.hass.language,
|
||||||
this.narrow,
|
this.narrow,
|
||||||
|
@ -74,7 +74,7 @@ export const configSections: { [name: string]: PageNavigation[] } = {
|
|||||||
translationKey: "areas",
|
translationKey: "areas",
|
||||||
iconPath: mdiSofa,
|
iconPath: mdiSofa,
|
||||||
iconColor: "#E48629",
|
iconColor: "#E48629",
|
||||||
components: ["zone"],
|
component: "zone",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/hassio",
|
path: "/hassio",
|
||||||
@ -108,7 +108,7 @@ export const configSections: { [name: string]: PageNavigation[] } = {
|
|||||||
translationKey: "people",
|
translationKey: "people",
|
||||||
iconPath: mdiAccount,
|
iconPath: mdiAccount,
|
||||||
iconColor: "#5A87FA",
|
iconColor: "#5A87FA",
|
||||||
components: ["person", "users"],
|
component: ["person", "users"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "#external-app-configuration",
|
path: "#external-app-configuration",
|
||||||
@ -342,7 +342,7 @@ export const configSections: { [name: string]: PageNavigation[] } = {
|
|||||||
translationKey: "hardware",
|
translationKey: "hardware",
|
||||||
iconPath: mdiMemory,
|
iconPath: mdiMemory,
|
||||||
iconColor: "#301A8E",
|
iconColor: "#301A8E",
|
||||||
components: ["hassio", "hardware"],
|
component: ["hassio", "hardware"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
about: [
|
about: [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user