Add shortcut from energy dashboard to energy settings (#18596)

This commit is contained in:
karwosts 2023-11-19 04:31:55 -08:00 committed by GitHub
parent 860ab7a3ba
commit 5ebe1e0369
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 1 deletions

View File

@ -7,8 +7,10 @@ import {
html, html,
nothing, nothing,
} from "lit"; } from "lit";
import { mdiPencil } from "@mdi/js";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import "../../components/ha-menu-button"; import "../../components/ha-menu-button";
import "../../components/ha-list-item";
import "../../components/ha-top-app-bar-fixed"; import "../../components/ha-top-app-bar-fixed";
import { LovelaceConfig } from "../../data/lovelace/config/types"; import { LovelaceConfig } from "../../data/lovelace/config/types";
import { haStyle } from "../../resources/styles"; import { haStyle } from "../../resources/styles";
@ -16,6 +18,7 @@ import { HomeAssistant } from "../../types";
import "../lovelace/components/hui-energy-period-selector"; import "../lovelace/components/hui-energy-period-selector";
import { Lovelace } from "../lovelace/types"; import { Lovelace } from "../lovelace/types";
import "../lovelace/views/hui-view"; import "../lovelace/views/hui-view";
import { navigate } from "../../common/navigate";
const ENERGY_LOVELACE_CONFIG: LovelaceConfig = { const ENERGY_LOVELACE_CONFIG: LovelaceConfig = {
views: [ views: [
@ -71,7 +74,21 @@ class PanelEnergy extends LitElement {
<hui-energy-period-selector <hui-energy-period-selector
.hass=${this.hass} .hass=${this.hass}
collectionKey="energy_dashboard" collectionKey="energy_dashboard"
></hui-energy-period-selector> >
${this.hass.user?.is_admin
? html`
<ha-list-item
slot="overflow-menu"
graphic="icon"
@request-selected=${this._navigateConfig}
>
<ha-svg-icon slot="graphic" .path=${mdiPencil}>
</ha-svg-icon>
${this.hass!.localize("ui.panel.energy.configure")}
</ha-list-item>
`
: nothing}
</hui-energy-period-selector>
</div> </div>
</div> </div>
<hui-view <hui-view
@ -100,6 +117,11 @@ class PanelEnergy extends LitElement {
}; };
} }
private _navigateConfig(ev) {
ev.stopPropagation();
navigate("/config/energy?historyBack=1");
}
private _reloadView() { private _reloadView() {
// Force strategy to be re-run by make a copy of the view // Force strategy to be re-run by make a copy of the view
const config = this._lovelace!.config; const config = this._lovelace!.config;

View File

@ -278,6 +278,7 @@ export class HuiEnergyPeriodSelector extends SubscribeMixin(LitElement) {
"ui.panel.lovelace.components.energy_period_selector.compare" "ui.panel.lovelace.components.energy_period_selector.compare"
)} )}
</ha-check-list-item> </ha-check-list-item>
<slot name="overflow-menu"></slot>
</ha-button-menu> </ha-button-menu>
</div> </div>
`; `;

View File

@ -6069,6 +6069,7 @@
} }
}, },
"energy": { "energy": {
"configure": "[%key:ui::dialogs::quick-bar::commands::navigation::energy%]",
"compare": { "compare": {
"info": "You are comparing the period {start} with the period {end}" "info": "You are comparing the period {start} with the period {end}"
}, },