Restore energy config in quickbar (#11391)

This commit is contained in:
Paulus Schoutsen 2022-01-21 15:06:42 -08:00 committed by GitHub
parent 14e5b2a7a5
commit d4646bac01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 22 deletions

View File

@ -573,21 +573,27 @@ export class QuickBar extends LitElement {
for (const sectionKey of Object.keys(configSections)) {
for (const page of configSections[sectionKey]) {
if (canShowPage(this.hass, page)) {
if (page.component) {
const info = this._getNavigationInfoFromConfig(page);
// Add to list, but only if we do not already have an entry for the same path and component
if (
info &&
!items.some(
(e) => e.path === info.path && e.component === info.component
)
) {
items.push(info);
}
}
if (!canShowPage(this.hass, page)) {
continue;
}
if (!page.component) {
continue;
}
const info = this._getNavigationInfoFromConfig(page);
if (!info) {
continue;
}
// Add to list, but only if we do not already have an entry for the same path and component
if (
items.some(
(e) => e.path === info.path && e.component === info.component
)
) {
continue;
}
items.push(info);
}
}
@ -597,14 +603,15 @@ export class QuickBar extends LitElement {
private _getNavigationInfoFromConfig(
page: PageNavigation
): NavigationInfo | undefined {
if (page.component) {
const caption = this.hass.localize(
`ui.dialogs.quick-bar.commands.navigation.${page.component}`
);
if (!page.component) {
return undefined;
}
const caption = this.hass.localize(
`ui.dialogs.quick-bar.commands.navigation.${page.component}`
);
if (page.translationKey && caption) {
return { ...page, primaryText: caption };
}
if (page.translationKey && caption) {
return { ...page, primaryText: caption };
}
return undefined;

View File

@ -6,6 +6,7 @@ import {
mdiDevices,
mdiHomeAssistant,
mdiInformation,
mdiLightningBolt,
mdiMapMarkerRadius,
mdiMathLog,
mdiNfcVariant,
@ -192,6 +193,16 @@ export const configSections: { [name: string]: PageNavigation[] } = {
iconColor: "#616161",
},
],
// Not used as a tab, but this way it will stay in the quick bar
energy: [
{
component: "energy",
path: "/config/energy",
translationKey: "ui.panel.config.energy.caption",
iconPath: mdiLightningBolt,
iconColor: "#F1C447",
},
],
lovelace: [
{
component: "lovelace",

View File

@ -616,7 +616,7 @@
"person": "[%key:ui::panel::config::person::caption%]",
"devices": "[%key:ui::panel::config::devices::caption%]",
"entities": "[%key:ui::panel::config::entities::caption%]",
"energy": "[%key:ui::panel::config::energy::caption%]",
"energy": "Energy Configuration",
"lovelace": "[%key:ui::panel::config::lovelace::caption%]",
"core": "[%key:ui::panel::config::core::caption%]",
"zone": "[%key:ui::panel::config::zone::caption%]",