diff --git a/src/panels/lovelace/components/hui-card-options.ts b/src/panels/lovelace/components/hui-card-options.ts index ec444bb9544f..d5c00ec686a3 100644 --- a/src/panels/lovelace/components/hui-card-options.ts +++ b/src/panels/lovelace/components/hui-card-options.ts @@ -28,6 +28,7 @@ import "../../../components/ha-icon-button"; import "../../../components/ha-list-item"; import { LovelaceCardConfig } from "../../../data/lovelace/config/card"; import { saveConfig } from "../../../data/lovelace/config/types"; +import { isStrategyView } from "../../../data/lovelace/config/view"; import { showAlertDialog, showPromptDialog, @@ -51,6 +52,7 @@ import { } from "../editor/lovelace-path"; import { showSelectViewDialog } from "../editor/select-view/show-select-view-dialog"; import { Lovelace, LovelaceCard } from "../types"; +import { SECTION_VIEW_LAYOUT } from "../views/const"; @customElement("hui-card-options") export class HuiCardOptions extends LitElement { @@ -351,6 +353,21 @@ export class HuiCardOptions extends LitElement { allowDashboardChange: true, header: this.hass!.localize("ui.panel.lovelace.editor.move_card.header"), viewSelectedCallback: async (urlPath, selectedDashConfig, viewIndex) => { + const view = this.lovelace!.config.views[viewIndex]; + + if (!isStrategyView(view) && view.type === SECTION_VIEW_LAYOUT) { + showAlertDialog(this, { + title: this.hass!.localize( + "ui.panel.lovelace.editor.move_card.error_title" + ), + text: this.hass!.localize( + "ui.panel.lovelace.editor.move_card.error_text_section" + ), + warning: true, + }); + return; + } + if (urlPath === this.lovelace!.urlPath) { this.lovelace!.saveConfig( moveCardToContainer(this.lovelace!.config, this.path!, [viewIndex]) diff --git a/src/panels/lovelace/editor/select-view/hui-dialog-select-view.ts b/src/panels/lovelace/editor/select-view/hui-dialog-select-view.ts index 2524ef0ab995..16449f0b3651 100644 --- a/src/panels/lovelace/editor/select-view/hui-dialog-select-view.ts +++ b/src/panels/lovelace/editor/select-view/hui-dialog-select-view.ts @@ -21,6 +21,7 @@ import { import { haStyleDialog } from "../../../../resources/styles"; import { HomeAssistant } from "../../../../types"; import type { SelectViewDialogParams } from "./show-select-view-dialog"; +import { isStrategyView } from "../../../../data/lovelace/config/view"; declare global { interface HASSDomEvents { @@ -117,8 +118,10 @@ export class HuiDialogSelectView extends LitElement { : this._config.views.length > 1 ? html` - ${this._config.views.map( - (view, idx) => html` + ${this._config.views.map((view, idx) => { + const isStrategy = isStrategyView(view); + + return html` icon) ? "icon" @@ -126,12 +129,19 @@ export class HuiDialogSelectView extends LitElement { @click=${this._viewChanged} .value=${idx.toString()} .selected=${this._selectedViewIdx === idx} + .disabled=${isStrategy && + !this._params?.includeStrategyViews} > - ${view.title} + + ${view.title}${isStrategy + ? ` (${this.hass.localize("ui.panel.lovelace.editor.select_view.strategy_type")})` + : nothing} + + - ` - )} + `; + })} ` : ""} diff --git a/src/panels/lovelace/editor/select-view/show-select-view-dialog.ts b/src/panels/lovelace/editor/select-view/show-select-view-dialog.ts index d53715c9b411..a93d75d24064 100644 --- a/src/panels/lovelace/editor/select-view/show-select-view-dialog.ts +++ b/src/panels/lovelace/editor/select-view/show-select-view-dialog.ts @@ -5,6 +5,7 @@ import { LovelaceDashboard } from "../../../../data/lovelace/dashboard"; export interface SelectViewDialogParams { lovelaceConfig: LovelaceConfig; allowDashboardChange: boolean; + includeStrategyViews?: boolean; dashboards?: LovelaceDashboard[]; urlPath?: string | null; header?: string; diff --git a/src/translations/en.json b/src/translations/en.json index 4802c539ea8a..0259e08976bd 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -5160,7 +5160,9 @@ "search_cards": "Search cards" }, "move_card": { - "header": "Choose a view to move the card to" + "header": "Choose a view to move the card to", + "error_title": "Impossible to move the card", + "error_text_section": "Moving a card to a section view is not supported yet. Use copy/cut/paste instead." }, "change_position": { "title": "Change card position", @@ -5171,7 +5173,8 @@ "dashboard_label": "Dashboard", "views_label": "View", "no_config": "No config found.", - "no_views": "No views in this dashboard." + "no_views": "No views in this dashboard.", + "strategy_type": "strategy" }, "section": { "unnamed_section": "Unnamed section",