mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-17 22:36:35 +00:00
Fix yaml editor lovelace (#18664)
This commit is contained in:
parent
ba8849ed4d
commit
e1dc73e992
@ -343,26 +343,25 @@ export class LovelacePanel extends LitElement {
|
||||
this._panelState = "yaml-editor";
|
||||
},
|
||||
setEditMode: (editMode: boolean) => {
|
||||
// If the dashboard is generated (default dashboard)
|
||||
// Propose to take control of it
|
||||
if (this.lovelace!.mode === "generated" && editMode) {
|
||||
showSaveDialog(this, {
|
||||
lovelace: this.lovelace!,
|
||||
mode: this.panel!.config.mode,
|
||||
narrow: this.narrow!,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// If we use a strategy for dashboard, we cannot show the edit UI
|
||||
// So go straight to the YAML editor
|
||||
if (
|
||||
this.lovelace!.rawConfig &&
|
||||
this.lovelace!.rawConfig !== this.lovelace!.config
|
||||
) {
|
||||
if (isStrategyDashboard(this.lovelace!.rawConfig) && editMode) {
|
||||
this.lovelace!.enableFullEditMode();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!editMode || this.lovelace!.mode !== "generated") {
|
||||
this._updateLovelace({ editMode });
|
||||
return;
|
||||
}
|
||||
|
||||
showSaveDialog(this, {
|
||||
lovelace: this.lovelace!,
|
||||
mode: this.panel!.config.mode,
|
||||
narrow: this.narrow!,
|
||||
});
|
||||
this._updateLovelace({ editMode });
|
||||
},
|
||||
saveConfig: async (newConfig: LovelaceRawConfig): Promise<void> => {
|
||||
const {
|
||||
|
@ -558,19 +558,26 @@ class HUIRoot extends LitElement {
|
||||
view.visible.some((show) => show.user === this.hass!.user?.id))
|
||||
);
|
||||
|
||||
private _clearParam(param: string) {
|
||||
window.history.replaceState(
|
||||
null,
|
||||
"",
|
||||
constructUrlCurrentPath(removeSearchParam(param))
|
||||
);
|
||||
}
|
||||
|
||||
protected firstUpdated(changedProps: PropertyValues) {
|
||||
super.firstUpdated(changedProps);
|
||||
// Check for requested edit mode
|
||||
const searchParams = extractSearchParamsObject();
|
||||
if (searchParams.edit === "1" && this.hass!.user?.is_admin) {
|
||||
this.lovelace!.setEditMode(true);
|
||||
if (searchParams.edit === "1") {
|
||||
this._clearParam("edit");
|
||||
if (this.hass!.user?.is_admin) {
|
||||
this.lovelace!.setEditMode(true);
|
||||
}
|
||||
} else if (searchParams.conversation === "1") {
|
||||
this._clearParam("conversation");
|
||||
this._showVoiceCommandDialog();
|
||||
window.history.replaceState(
|
||||
null,
|
||||
"",
|
||||
constructUrlCurrentPath(removeSearchParam("conversation"))
|
||||
);
|
||||
}
|
||||
window.addEventListener("scroll", this._handleWindowScroll, {
|
||||
passive: true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user