mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Revert "Transform helper to warning for edit view type"
This reverts commit 3abdffda9cb06fb3757d6e03601b7f15c1c4b99c.
This commit is contained in:
parent
3abdffda9c
commit
c05824c641
@ -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,15 +211,6 @@ export class HuiDialogEditView extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const isEmpty =
|
|
||||||
!this._config?.cards?.length && !this._config?.sections?.length;
|
|
||||||
|
|
||||||
const isCompatibleViewType =
|
|
||||||
isEmpty ||
|
|
||||||
(this._currentType === SECTION_VIEW_LAYOUT
|
|
||||||
? this._config?.type === SECTION_VIEW_LAYOUT
|
|
||||||
: this._config?.type !== SECTION_VIEW_LAYOUT);
|
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-dialog
|
<ha-dialog
|
||||||
open
|
open
|
||||||
@ -320,25 +308,9 @@ 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 || this._saving || !this._dirty}
|
||||||
this._saving ||
|
|
||||||
!this._dirty ||
|
|
||||||
!isCompatibleViewType}
|
|
||||||
@click=${this._save}
|
@click=${this._save}
|
||||||
>
|
>
|
||||||
${this._saving
|
${this._saving
|
||||||
@ -582,10 +554,6 @@ export class HuiDialogEditView extends LitElement {
|
|||||||
margin: 12px 16px;
|
margin: 12px 16px;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
.incompatible {
|
|
||||||
display: block;
|
|
||||||
margin-top: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media all and (min-width: 600px) {
|
@media all and (min-width: 600px) {
|
||||||
ha-dialog {
|
ha-dialog {
|
||||||
|
@ -37,7 +37,7 @@ export class HuiViewEditor extends LitElement {
|
|||||||
private _suggestedPath = false;
|
private _suggestedPath = false;
|
||||||
|
|
||||||
private _schema = memoizeOne(
|
private _schema = memoizeOne(
|
||||||
(localize: LocalizeFunc) =>
|
(localize: LocalizeFunc, currentType: string, isNew: boolean) =>
|
||||||
[
|
[
|
||||||
{ name: "title", selector: { text: {} } },
|
{ name: "title", selector: { text: {} } },
|
||||||
{
|
{
|
||||||
@ -64,6 +64,11 @@ export class HuiViewEditor extends LitElement {
|
|||||||
label: localize(
|
label: localize(
|
||||||
`ui.panel.lovelace.editor.edit_view.types.${type}`
|
`ui.panel.lovelace.editor.edit_view.types.${type}`
|
||||||
),
|
),
|
||||||
|
disabled:
|
||||||
|
!isNew &&
|
||||||
|
(currentType === SECTION_VIEW_LAYOUT
|
||||||
|
? type !== SECTION_VIEW_LAYOUT
|
||||||
|
: type === SECTION_VIEW_LAYOUT),
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -90,12 +95,16 @@ export class HuiViewEditor extends LitElement {
|
|||||||
: this._config.type || DEFAULT_VIEW_LAYOUT;
|
: this._config.type || DEFAULT_VIEW_LAYOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private get _isEmpty(): boolean {
|
||||||
|
return !this._config.sections?.length && !this._config.cards?.length;
|
||||||
|
}
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
const schema = this._schema(this.hass.localize);
|
const schema = this._schema(this.hass.localize, this._type, this._isEmpty);
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
...this._config,
|
...this._config,
|
||||||
@ -159,6 +168,15 @@ export class HuiViewEditor extends LitElement {
|
|||||||
return this.hass.localize(
|
return this.hass.localize(
|
||||||
"ui.panel.lovelace.editor.edit_view.subview_helper"
|
"ui.panel.lovelace.editor.edit_view.subview_helper"
|
||||||
);
|
);
|
||||||
|
case "type":
|
||||||
|
if (this._isEmpty) return undefined;
|
||||||
|
return this._type === "sections"
|
||||||
|
? this.hass.localize(
|
||||||
|
"ui.panel.lovelace.editor.edit_view.type_helper_others"
|
||||||
|
)
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.lovelace.editor.edit_view.type_helper_sections"
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
@ -5135,8 +5135,8 @@
|
|||||||
"select_users": "Select which users should see this view in the navigation"
|
"select_users": "Select which users should see this view in the navigation"
|
||||||
},
|
},
|
||||||
"type": "View type",
|
"type": "View type",
|
||||||
"type_warning_sections": "You can not change your view to use the 'sections' view type because migration is not supported yet. Start from scratch with a new view if you want to experiment with the 'sections' view.",
|
"type_helper_sections": "You can not change your view to use the 'sections' view type because migration is not supported yet. Start from scratch with a new view if you want to experiment with the 'sections' view.",
|
||||||
"type_warning_others": "You can not change your view to an other type because migration is not supported yet. Start from scratch with a new view if you want to use another view type.",
|
"type_helper_others": "You can not change your view to an other type because migration is not supported yet. Start from scratch with a new view if you want to use another view type.",
|
||||||
|
|
||||||
"types": {
|
"types": {
|
||||||
"masonry": "Masonry (default)",
|
"masonry": "Masonry (default)",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user