mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Handle reconnect while in raw edit (#8500)
This commit is contained in:
parent
1642c68493
commit
5ff757ad65
@ -257,7 +257,7 @@ class LovelacePanel extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
this._state = "loaded";
|
||||
this._state = this._state === "yaml-editor" ? this._state : "loaded";
|
||||
this._setLovelaceConfig(conf, confMode);
|
||||
}
|
||||
|
||||
|
@ -11,11 +11,13 @@ import {
|
||||
internalProperty,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { classMap } from "lit-html/directives/class-map";
|
||||
import { array, assert, object, optional, string, type } from "superstruct";
|
||||
import { computeRTL } from "../../common/util/compute_rtl";
|
||||
import { deepEqual } from "../../common/util/deep-equal";
|
||||
import "../../components/ha-circular-progress";
|
||||
import "../../components/ha-code-editor";
|
||||
import type { HaCodeEditor } from "../../components/ha-code-editor";
|
||||
@ -29,6 +31,7 @@ import {
|
||||
import "../../layouts/ha-app-layout";
|
||||
import { haStyle } from "../../resources/styles";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import { showToast } from "../../util/toast";
|
||||
import type { Lovelace } from "./types";
|
||||
|
||||
const lovelaceStruct = type({
|
||||
@ -101,10 +104,37 @@ class LovelaceFullConfigEditor extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
protected firstUpdated() {
|
||||
protected firstUpdated(changedProps: PropertyValues) {
|
||||
super.firstUpdated(changedProps);
|
||||
this.yamlEditor.value = safeDump(this.lovelace!.config);
|
||||
}
|
||||
|
||||
protected updated(changedProps: PropertyValues) {
|
||||
const oldLovelace = changedProps.get("lovelace") as Lovelace | undefined;
|
||||
if (
|
||||
oldLovelace &&
|
||||
this.lovelace &&
|
||||
oldLovelace.config !== this.lovelace.config &&
|
||||
!deepEqual(oldLovelace.config, this.lovelace.config)
|
||||
) {
|
||||
showToast(this, {
|
||||
message: this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.raw_editor.lovelace_changed"
|
||||
),
|
||||
action: {
|
||||
action: () => {
|
||||
this.yamlEditor.value = safeDump(this.lovelace!.config);
|
||||
},
|
||||
text: this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.raw_editor.reload"
|
||||
),
|
||||
},
|
||||
duration: 0,
|
||||
dismissable: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static get styles(): CSSResult[] {
|
||||
return [
|
||||
haStyle,
|
||||
|
@ -2654,6 +2654,8 @@
|
||||
"save": "Save",
|
||||
"unsaved_changes": "Unsaved changes",
|
||||
"saved": "Saved",
|
||||
"reload": "Reload",
|
||||
"lovelace_changed": "The Lovelace config was updated, do you want to load the updated config in the editor and lose your current changes?",
|
||||
"confirm_remove_config_title": "Are you sure you want to remove your Lovelace UI configuration?",
|
||||
"confirm_remove_config_text": "We will automatically generate your Lovelace UI views with your areas and devices if you remove your Lovelace UI configuration.",
|
||||
"confirm_unsaved_changes": "You have unsaved changes, are you sure you want to exit?",
|
||||
|
Loading…
x
Reference in New Issue
Block a user