mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-16 14:30:36 +00:00
Add alert for edit mode
This commit is contained in:
@@ -5,9 +5,10 @@ import { debounce } from "../../common/util/debounce";
|
|||||||
import { deepEqual } from "../../common/util/deep-equal";
|
import { deepEqual } from "../../common/util/deep-equal";
|
||||||
import type { LovelaceDashboardStrategyConfig } from "../../data/lovelace/config/types";
|
import type { LovelaceDashboardStrategyConfig } from "../../data/lovelace/config/types";
|
||||||
import type { HomeAssistant, PanelInfo, Route } from "../../types";
|
import type { HomeAssistant, PanelInfo, Route } from "../../types";
|
||||||
|
import "../lovelace/hui-root";
|
||||||
import { generateLovelaceDashboardStrategy } from "../lovelace/strategies/get-strategy";
|
import { generateLovelaceDashboardStrategy } from "../lovelace/strategies/get-strategy";
|
||||||
import type { Lovelace } from "../lovelace/types";
|
import type { Lovelace } from "../lovelace/types";
|
||||||
import "../lovelace/hui-root";
|
import { showAlertDialog } from "../lovelace/custom-card-helpers";
|
||||||
|
|
||||||
const HOME_LOVELACE_CONFIG: LovelaceDashboardStrategyConfig = {
|
const HOME_LOVELACE_CONFIG: LovelaceDashboardStrategyConfig = {
|
||||||
strategy: {
|
strategy: {
|
||||||
@@ -90,7 +91,6 @@ class PanelHome extends LitElement {
|
|||||||
.lovelace=${this._lovelace}
|
.lovelace=${this._lovelace}
|
||||||
.route=${this.route}
|
.route=${this.route}
|
||||||
.panel=${this.panel}
|
.panel=${this.panel}
|
||||||
no-edit
|
|
||||||
></hui-root>
|
></hui-root>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -101,15 +101,13 @@ class PanelHome extends LitElement {
|
|||||||
this.hass
|
this.hass
|
||||||
);
|
);
|
||||||
|
|
||||||
const rawConfig = HOME_LOVELACE_CONFIG;
|
|
||||||
|
|
||||||
if (deepEqual(config, this._lovelace?.config)) {
|
if (deepEqual(config, this._lovelace?.config)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._lovelace = {
|
this._lovelace = {
|
||||||
config: config,
|
config: config,
|
||||||
rawConfig: rawConfig,
|
rawConfig: config,
|
||||||
editMode: false,
|
editMode: false,
|
||||||
urlPath: "home",
|
urlPath: "home",
|
||||||
mode: "generated",
|
mode: "generated",
|
||||||
@@ -117,11 +115,21 @@ class PanelHome extends LitElement {
|
|||||||
enableFullEditMode: () => undefined,
|
enableFullEditMode: () => undefined,
|
||||||
saveConfig: async () => undefined,
|
saveConfig: async () => undefined,
|
||||||
deleteConfig: async () => undefined,
|
deleteConfig: async () => undefined,
|
||||||
setEditMode: () => undefined,
|
setEditMode: this._setEditMode,
|
||||||
showToast: () => undefined,
|
showToast: () => undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _setEditMode = () => {
|
||||||
|
// For now, we just show an alert that edit mode is not supported.
|
||||||
|
// This will be expanded in the future.
|
||||||
|
showAlertDialog(this, {
|
||||||
|
title: "Edit mode not available",
|
||||||
|
text: "The Home panel does not support edit mode.",
|
||||||
|
confirmText: this.hass.localize("ui.common.ok"),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
static readonly styles: CSSResultGroup = css`
|
static readonly styles: CSSResultGroup = css`
|
||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
|
|||||||
@@ -289,10 +289,7 @@ class HUIRoot extends LitElement {
|
|||||||
"yaml",
|
"yaml",
|
||||||
overflow: true,
|
overflow: true,
|
||||||
},
|
},
|
||||||
];
|
{
|
||||||
|
|
||||||
if (!this.noEdit) {
|
|
||||||
items.push({
|
|
||||||
icon: mdiPencil,
|
icon: mdiPencil,
|
||||||
key: "ui.panel.lovelace.menu.configure_ui",
|
key: "ui.panel.lovelace.menu.configure_ui",
|
||||||
overflowAction: this._handleEnableEditMode,
|
overflowAction: this._handleEnableEditMode,
|
||||||
@@ -303,8 +300,8 @@ class HUIRoot extends LitElement {
|
|||||||
!this.hass!.config.recovery_mode,
|
!this.hass!.config.recovery_mode,
|
||||||
overflow: true,
|
overflow: true,
|
||||||
overflow_can_promote: true,
|
overflow_can_promote: true,
|
||||||
});
|
},
|
||||||
}
|
];
|
||||||
|
|
||||||
const overflowItems = items.filter((i) => i.visible && i.overflow);
|
const overflowItems = items.filter((i) => i.visible && i.overflow);
|
||||||
const overflowCanPromote =
|
const overflowCanPromote =
|
||||||
|
|||||||
Reference in New Issue
Block a user