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,
nothing,
} from "lit";
import { mdiPencil } from "@mdi/js";
import { customElement, property, state } from "lit/decorators";
import "../../components/ha-menu-button";
import "../../components/ha-list-item";
import "../../components/ha-top-app-bar-fixed";
import { LovelaceConfig } from "../../data/lovelace/config/types";
import { haStyle } from "../../resources/styles";
@ -16,6 +18,7 @@ import { HomeAssistant } from "../../types";
import "../lovelace/components/hui-energy-period-selector";
import { Lovelace } from "../lovelace/types";
import "../lovelace/views/hui-view";
import { navigate } from "../../common/navigate";
const ENERGY_LOVELACE_CONFIG: LovelaceConfig = {
views: [
@ -71,7 +74,21 @@ class PanelEnergy extends LitElement {
<hui-energy-period-selector
.hass=${this.hass}
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>
<hui-view
@ -100,6 +117,11 @@ class PanelEnergy extends LitElement {
};
}
private _navigateConfig(ev) {
ev.stopPropagation();
navigate("/config/energy?historyBack=1");
}
private _reloadView() {
// Force strategy to be re-run by make a copy of the view
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"
)}
</ha-check-list-item>
<slot name="overflow-menu"></slot>
</ha-button-menu>
</div>
`;

View File

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