mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-18 23:06:40 +00:00
Make migration warning alert sticky at the top for views (#19970)
This commit is contained in:
parent
19d50b9c92
commit
70146a08c1
@ -57,8 +57,6 @@ import { EditViewDialogParams } from "./show-edit-view-dialog";
|
|||||||
export class HuiDialogEditView extends LitElement {
|
export class HuiDialogEditView extends LitElement {
|
||||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||||
|
|
||||||
@state() private _currentType?: string;
|
|
||||||
|
|
||||||
@state() private _params?: EditViewDialogParams;
|
@state() private _params?: EditViewDialogParams;
|
||||||
|
|
||||||
@state() private _config?: LovelaceViewConfig;
|
@state() private _config?: LovelaceViewConfig;
|
||||||
@ -113,7 +111,6 @@ export class HuiDialogEditView extends LitElement {
|
|||||||
this._badges = [];
|
this._badges = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._currentType = view.type;
|
|
||||||
const { badges, ...viewConfig } = view;
|
const { badges, ...viewConfig } = view;
|
||||||
this._config = viewConfig;
|
this._config = viewConfig;
|
||||||
this._badges = badges ? processEditorEntities(badges) : [];
|
this._badges = badges ? processEditorEntities(badges) : [];
|
||||||
@ -214,14 +211,12 @@ export class HuiDialogEditView extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const isEmpty =
|
|
||||||
!this._config?.cards?.length && !this._config?.sections?.length;
|
|
||||||
|
|
||||||
const isCompatibleViewType =
|
const isCompatibleViewType =
|
||||||
isEmpty ||
|
this._config?.type === SECTION_VIEW_LAYOUT
|
||||||
(this._currentType === SECTION_VIEW_LAYOUT
|
? this._config?.type === SECTION_VIEW_LAYOUT &&
|
||||||
? this._config?.type === SECTION_VIEW_LAYOUT
|
!this._config?.cards?.length
|
||||||
: this._config?.type !== SECTION_VIEW_LAYOUT);
|
: this._config?.type !== SECTION_VIEW_LAYOUT &&
|
||||||
|
!this._config?.sections?.length;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-dialog
|
<ha-dialog
|
||||||
@ -281,6 +276,19 @@ export class HuiDialogEditView extends LitElement {
|
|||||||
: ``}
|
: ``}
|
||||||
</mwc-list-item>
|
</mwc-list-item>
|
||||||
</ha-button-menu>
|
</ha-button-menu>
|
||||||
|
${!isCompatibleViewType
|
||||||
|
? html`
|
||||||
|
<ha-alert class="incompatible" alert-type="warning">
|
||||||
|
${this._config?.type === SECTION_VIEW_LAYOUT
|
||||||
|
? this.hass!.localize(
|
||||||
|
"ui.panel.lovelace.editor.edit_view.type_warning_sections"
|
||||||
|
)
|
||||||
|
: this.hass!.localize(
|
||||||
|
"ui.panel.lovelace.editor.edit_view.type_warning_others"
|
||||||
|
)}
|
||||||
|
</ha-alert>
|
||||||
|
`
|
||||||
|
: nothing}
|
||||||
${!this._yamlMode
|
${!this._yamlMode
|
||||||
? html`<paper-tabs
|
? html`<paper-tabs
|
||||||
scrollable
|
scrollable
|
||||||
@ -320,19 +328,6 @@ export class HuiDialogEditView extends LitElement {
|
|||||||
</mwc-button>
|
</mwc-button>
|
||||||
`
|
`
|
||||||
: nothing}
|
: nothing}
|
||||||
${!isCompatibleViewType
|
|
||||||
? html`
|
|
||||||
<ha-alert class="incompatible" alert-type="warning">
|
|
||||||
${this._config?.type === SECTION_VIEW_LAYOUT
|
|
||||||
? this.hass!.localize(
|
|
||||||
"ui.panel.lovelace.editor.edit_view.type_warning_sections"
|
|
||||||
)
|
|
||||||
: this.hass!.localize(
|
|
||||||
"ui.panel.lovelace.editor.edit_view.type_warning_others"
|
|
||||||
)}
|
|
||||||
</ha-alert>
|
|
||||||
`
|
|
||||||
: nothing}
|
|
||||||
<mwc-button
|
<mwc-button
|
||||||
slot="primaryAction"
|
slot="primaryAction"
|
||||||
?disabled=${!this._config ||
|
?disabled=${!this._config ||
|
||||||
@ -425,14 +420,13 @@ export class HuiDialogEditView extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._saving = true;
|
this._saving = true;
|
||||||
|
|
||||||
const viewConf: LovelaceViewConfig = {
|
const viewConf: LovelaceViewConfig = {
|
||||||
...this._config,
|
...this._config,
|
||||||
badges: this._badges,
|
badges: this._badges,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (viewConf.type === SECTION_VIEW_LAYOUT && !viewConf.sections?.length) {
|
if (viewConf.type === SECTION_VIEW_LAYOUT && !viewConf.sections?.length) {
|
||||||
viewConf.sections = [{ cards: [] }];
|
viewConf.sections = [{ type: "grid", cards: [] }];
|
||||||
} else if (!viewConf.cards?.length) {
|
} else if (!viewConf.cards?.length) {
|
||||||
viewConf.cards = [];
|
viewConf.cards = [];
|
||||||
}
|
}
|
||||||
@ -584,7 +578,6 @@ export class HuiDialogEditView extends LitElement {
|
|||||||
}
|
}
|
||||||
.incompatible {
|
.incompatible {
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media all and (min-width: 600px) {
|
@media all and (min-width: 600px) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user