From 4bb6504d50ba600d40f03069b79c3f9786fae81c Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Tue, 14 Nov 2023 13:45:18 +0100 Subject: [PATCH] Restore lovelace config name --- cast/src/launcher/layout/hc-cast.ts | 2 +- cast/src/receiver/demo/cast-demo-lovelace.ts | 4 +- cast/src/receiver/layout/hc-demo.ts | 4 +- cast/src/receiver/layout/hc-lovelace.ts | 4 +- cast/src/receiver/layout/hc-main.ts | 8 ++-- demo/src/configs/types.ts | 4 +- src/components/ha-navigation-picker.ts | 2 +- src/data/lovelace.ts | 2 +- .../config/{dashboard.ts => types.ts} | 14 +++--- src/data/preloads.ts | 4 +- src/entrypoints/core.ts | 2 +- src/panels/energy/ha-panel-energy.ts | 4 +- .../common/compute-unused-entities.ts | 8 ++-- .../lovelace/components/hui-card-options.ts | 2 +- .../lovelace/editor/add-entities-to-view.ts | 10 ++-- .../editor/card-editor/hui-card-picker.ts | 4 +- .../card-editor/show-create-card-dialog.ts | 6 +-- .../card-editor/show-edit-card-dialog.ts | 6 +-- .../card-editor/show-suggest-card-dialog.ts | 6 +-- .../hui-conditional-card-editor.ts | 4 +- .../config-elements/hui-stack-card-editor.ts | 4 +- src/panels/lovelace/editor/config-util.ts | 48 +++++++++---------- .../hui-header-footer-editor.ts | 4 +- .../lovelace/editor/hui-dialog-save-config.ts | 4 +- .../lovelace/editor/hui-element-editor.ts | 4 +- .../hui-dialog-edit-lovelace.ts | 8 ++-- .../lovelace-editor/hui-lovelace-editor.ts | 6 +-- .../select-view/hui-dialog-select-view.ts | 8 ++-- .../select-view/show-select-view-dialog.ts | 6 +-- .../unused-entities/hui-unused-entities.ts | 4 +- src/panels/lovelace/ha-panel-lovelace.ts | 24 +++++----- src/panels/lovelace/hui-editor.ts | 6 +-- src/panels/lovelace/hui-root.ts | 4 +- .../lovelace/strategies/get-strategy.ts | 12 ++--- .../lovelace/strategies/legacy-strategy.ts | 12 ++--- .../original-states-dashboard-strategy.ts | 4 +- src/panels/lovelace/strategies/types.ts | 4 +- src/panels/lovelace/types.ts | 14 +++--- .../lovelace/editor/config-util.spec.ts | 26 +++++----- 39 files changed, 148 insertions(+), 154 deletions(-) rename src/data/lovelace/config/{dashboard.ts => types.ts} (79%) diff --git a/cast/src/launcher/layout/hc-cast.ts b/cast/src/launcher/layout/hc-cast.ts index fae464fe89fc..bdb15a3c9dd8 100644 --- a/cast/src/launcher/layout/hc-cast.ts +++ b/cast/src/launcher/layout/hc-cast.ts @@ -23,7 +23,7 @@ import { getLegacyLovelaceCollection, getLovelaceCollection, } from "../../../../src/data/lovelace"; -import { isStrategyDashboard } from "../../../../src/data/lovelace/config/dashboard"; +import { isStrategyDashboard } from "../../../../src/data/lovelace/config/types"; import { LovelaceViewConfig } from "../../../../src/data/lovelace/config/view"; import "../../../../src/layouts/hass-loading-screen"; import { generateDefaultViewConfig } from "../../../../src/panels/lovelace/common/generate-lovelace-config"; diff --git a/cast/src/receiver/demo/cast-demo-lovelace.ts b/cast/src/receiver/demo/cast-demo-lovelace.ts index 13642a230e0d..aa09f2b49b36 100644 --- a/cast/src/receiver/demo/cast-demo-lovelace.ts +++ b/cast/src/receiver/demo/cast-demo-lovelace.ts @@ -1,8 +1,8 @@ import { LovelaceCardConfig } from "../../../../src/data/lovelace/config/card"; -import { LovelaceDashboardConfig } from "../../../../src/data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../../../src/data/lovelace/config/types"; import { castContext } from "../cast_context"; -export const castDemoLovelace: () => LovelaceDashboardConfig = () => { +export const castDemoLovelace: () => LovelaceConfig = () => { const touchSupported = castContext.getDeviceCapabilities().touch_input_supported; return { diff --git a/cast/src/receiver/layout/hc-demo.ts b/cast/src/receiver/layout/hc-demo.ts index 128c9cea0786..8f53375bd080 100644 --- a/cast/src/receiver/layout/hc-demo.ts +++ b/cast/src/receiver/layout/hc-demo.ts @@ -1,7 +1,7 @@ import { html, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import { mockHistory } from "../../../../demo/src/stubs/history"; -import { LovelaceDashboardConfig } from "../../../../src/data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../../../src/data/lovelace/config/types"; import { MockHomeAssistant, provideHass, @@ -16,7 +16,7 @@ import "./hc-lovelace"; class HcDemo extends HassElement { @property({ attribute: false }) public lovelacePath!: string; - @state() private _lovelaceConfig?: LovelaceDashboardConfig; + @state() private _lovelaceConfig?: LovelaceConfig; protected render() { if (!this._lovelaceConfig) { diff --git a/cast/src/receiver/layout/hc-lovelace.ts b/cast/src/receiver/layout/hc-lovelace.ts index 7922d40a8caa..0de33aa69dd8 100644 --- a/cast/src/receiver/layout/hc-lovelace.ts +++ b/cast/src/receiver/layout/hc-lovelace.ts @@ -1,7 +1,7 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property, query } from "lit/decorators"; import { fireEvent } from "../../../../src/common/dom/fire_event"; -import { LovelaceDashboardConfig } from "../../../../src/data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../../../src/data/lovelace/config/types"; import { Lovelace } from "../../../../src/panels/lovelace/types"; import "../../../../src/panels/lovelace/views/hui-view"; import { HomeAssistant } from "../../../../src/types"; @@ -15,7 +15,7 @@ class HcLovelace extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) - public lovelaceConfig!: LovelaceDashboardConfig; + public lovelaceConfig!: LovelaceConfig; @property() public viewPath?: string | number; diff --git a/cast/src/receiver/layout/hc-main.ts b/cast/src/receiver/layout/hc-main.ts index a55e1eb8b165..876b68cda31d 100644 --- a/cast/src/receiver/layout/hc-main.ts +++ b/cast/src/receiver/layout/hc-main.ts @@ -27,9 +27,9 @@ import { import { isStrategyDashboard, LegacyLovelaceConfig, - LovelaceDashboardConfig, + LovelaceConfig, LovelaceDashboardStrategyConfig, -} from "../../../../src/data/lovelace/config/dashboard"; +} from "../../../../src/data/lovelace/config/types"; import { fetchResources } from "../../../../src/data/lovelace/resource"; import { loadLovelaceResources } from "../../../../src/panels/lovelace/common/load-resources"; import { HassElement } from "../../../../src/state/hass-element"; @@ -47,7 +47,7 @@ let resourcesLoaded = false; export class HcMain extends HassElement { @state() private _showDemo = false; - @state() private _lovelaceConfig?: LovelaceDashboardConfig; + @state() private _lovelaceConfig?: LovelaceConfig; @state() private _lovelacePath: string | number | null = null; @@ -347,7 +347,7 @@ export class HcMain extends HassElement { ); } - private _handleNewLovelaceConfig(lovelaceConfig: LovelaceDashboardConfig) { + private _handleNewLovelaceConfig(lovelaceConfig: LovelaceConfig) { castContext.setApplicationState(lovelaceConfig.title || ""); this._lovelaceConfig = lovelaceConfig; } diff --git a/demo/src/configs/types.ts b/demo/src/configs/types.ts index 55a1348ca9a9..abd677852788 100644 --- a/demo/src/configs/types.ts +++ b/demo/src/configs/types.ts @@ -1,5 +1,5 @@ import { LocalizeFunc } from "../../../src/common/translations/localize"; -import { LovelaceDashboardConfig } from "../../../src/data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../../src/data/lovelace/config/types"; import { Entity } from "../../../src/fake_data/entity"; export interface DemoConfig { @@ -7,7 +7,7 @@ export interface DemoConfig { name: string; authorName: string; authorUrl: string; - lovelace: (localize: LocalizeFunc) => LovelaceDashboardConfig; + lovelace: (localize: LocalizeFunc) => LovelaceConfig; entities: (localize: LocalizeFunc) => Entity[]; theme: () => Record | null; } diff --git a/src/components/ha-navigation-picker.ts b/src/components/ha-navigation-picker.ts index 907261b01249..7758ec9882e9 100644 --- a/src/components/ha-navigation-picker.ts +++ b/src/components/ha-navigation-picker.ts @@ -3,7 +3,7 @@ import { css, html, LitElement, PropertyValues, TemplateResult } from "lit"; import { customElement, property, query, state } from "lit/decorators"; import { fireEvent } from "../common/dom/fire_event"; import { titleCase } from "../common/string/title-case"; -import { fetchConfig } from "../data/lovelace/config/dashboard"; +import { fetchConfig } from "../data/lovelace/config/types"; import { LovelaceViewRawConfig } from "../data/lovelace/config/view"; import { HomeAssistant, PanelInfo, ValueChangedEvent } from "../types"; import "./ha-combo-box"; diff --git a/src/data/lovelace.ts b/src/data/lovelace.ts index 3fd9139f219c..1d6ba571ac5a 100644 --- a/src/data/lovelace.ts +++ b/src/data/lovelace.ts @@ -10,7 +10,7 @@ import { LovelaceCard, } from "../panels/lovelace/types"; import { HomeAssistant } from "../types"; -import { fetchConfig, LegacyLovelaceConfig } from "./lovelace/config/dashboard"; +import { fetchConfig, LegacyLovelaceConfig } from "./lovelace/config/types"; import { LovelaceViewConfig } from "./lovelace/config/view"; export interface LovelacePanelConfig { diff --git a/src/data/lovelace/config/dashboard.ts b/src/data/lovelace/config/types.ts similarity index 79% rename from src/data/lovelace/config/dashboard.ts rename to src/data/lovelace/config/types.ts index 869b12932204..b90725da5fd2 100644 --- a/src/data/lovelace/config/dashboard.ts +++ b/src/data/lovelace/config/types.ts @@ -6,7 +6,7 @@ import type { LovelaceViewRawConfig } from "./view"; export interface LovelaceDashboardBaseConfig {} -export interface LovelaceDashboardConfig extends LovelaceDashboardBaseConfig { +export interface LovelaceConfig extends LovelaceDashboardBaseConfig { title?: string; background?: string; views: LovelaceViewRawConfig[]; @@ -17,16 +17,16 @@ export interface LovelaceDashboardStrategyConfig strategy: LovelaceStrategyConfig; } -export interface LegacyLovelaceConfig extends LovelaceDashboardConfig { +export interface LegacyLovelaceConfig extends LovelaceConfig { resources?: LovelaceResource[]; } -export type LovelaceDashboardRawConfig = - | LovelaceDashboardConfig +export type LovelaceRawConfig = + | LovelaceConfig | LovelaceDashboardStrategyConfig; export function isStrategyDashboard( - view: LovelaceDashboardRawConfig + view: LovelaceRawConfig ): view is LovelaceDashboardStrategyConfig { return "strategy" in view; } @@ -35,7 +35,7 @@ export const fetchConfig = ( conn: Connection, urlPath: string | null, force: boolean -): Promise => +): Promise => conn.sendMessagePromise({ type: "lovelace/config", url_path: urlPath, @@ -45,7 +45,7 @@ export const fetchConfig = ( export const saveConfig = ( hass: HomeAssistant, urlPath: string | null, - config: LovelaceDashboardRawConfig + config: LovelaceRawConfig ): Promise => hass.callWS({ type: "lovelace/config/save", diff --git a/src/data/preloads.ts b/src/data/preloads.ts index 2dd6209538ac..ef2b99a3f31a 100644 --- a/src/data/preloads.ts +++ b/src/data/preloads.ts @@ -1,9 +1,9 @@ -import { LovelaceDashboardRawConfig } from "./lovelace/config/dashboard"; +import { LovelaceRawConfig } from "./lovelace/config/types"; import { LovelaceResource } from "./lovelace/resource"; import { RecorderInfo } from "./recorder"; export interface WindowWithPreloads extends Window { - llConfProm?: Promise; + llConfProm?: Promise; llResProm?: Promise; recorderInfoProm?: Promise; } diff --git a/src/entrypoints/core.ts b/src/entrypoints/core.ts index 0d0dce83a64d..a7b660afe607 100644 --- a/src/entrypoints/core.ts +++ b/src/entrypoints/core.ts @@ -15,7 +15,7 @@ import { hassUrl } from "../data/auth"; import { isExternal } from "../data/external"; import { getRecorderInfo } from "../data/recorder"; import { subscribeFrontendUserData } from "../data/frontend"; -import { fetchConfig } from "../data/lovelace/config/dashboard"; +import { fetchConfig } from "../data/lovelace/config/types"; import { fetchResources } from "../data/lovelace/resource"; import { subscribePanels } from "../data/ws-panels"; import { subscribeThemes } from "../data/ws-themes"; diff --git a/src/panels/energy/ha-panel-energy.ts b/src/panels/energy/ha-panel-energy.ts index b0be2baed428..bc76cf3f6d73 100644 --- a/src/panels/energy/ha-panel-energy.ts +++ b/src/panels/energy/ha-panel-energy.ts @@ -10,14 +10,14 @@ import { import { customElement, property, state } from "lit/decorators"; import "../../components/ha-menu-button"; import "../../components/ha-top-app-bar-fixed"; -import { LovelaceDashboardConfig } from "../../data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../data/lovelace/config/types"; import { haStyle } from "../../resources/styles"; import { HomeAssistant } from "../../types"; import "../lovelace/components/hui-energy-period-selector"; import { Lovelace } from "../lovelace/types"; import "../lovelace/views/hui-view"; -const ENERGY_LOVELACE_CONFIG: LovelaceDashboardConfig = { +const ENERGY_LOVELACE_CONFIG: LovelaceConfig = { views: [ { strategy: { diff --git a/src/panels/lovelace/common/compute-unused-entities.ts b/src/panels/lovelace/common/compute-unused-entities.ts index 5d86e337d9c3..d8abc9599483 100755 --- a/src/panels/lovelace/common/compute-unused-entities.ts +++ b/src/panels/lovelace/common/compute-unused-entities.ts @@ -1,5 +1,5 @@ import { ActionConfig } from "../../../data/lovelace/config/action"; -import { LovelaceDashboardConfig } from "../../../data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../../data/lovelace/config/types"; import { HomeAssistant } from "../../../types"; export const EXCLUDED_DOMAINS = ["zone", "persistent_notification"]; @@ -66,9 +66,7 @@ const addEntities = (entities: Set, obj) => { } }; -export const computeUsedEntities = ( - config: LovelaceDashboardConfig -): Set => { +export const computeUsedEntities = (config: LovelaceConfig): Set => { const entities = new Set(); config.views.forEach((view) => addEntities(entities, view)); return entities; @@ -94,7 +92,7 @@ export const calcUnusedEntities = ( export const computeUnusedEntities = ( hass: HomeAssistant, - config: LovelaceDashboardConfig + config: LovelaceConfig ): Set => { const usedEntities = computeUsedEntities(config); const unusedEntities = calcUnusedEntities(hass, usedEntities); diff --git a/src/panels/lovelace/components/hui-card-options.ts b/src/panels/lovelace/components/hui-card-options.ts index 063ba8250179..8236d900e38b 100644 --- a/src/panels/lovelace/components/hui-card-options.ts +++ b/src/panels/lovelace/components/hui-card-options.ts @@ -27,7 +27,7 @@ import "../../../components/ha-button-menu"; import "../../../components/ha-icon-button"; import "../../../components/ha-list-item"; import { LovelaceCardConfig } from "../../../data/lovelace/config/card"; -import { saveConfig } from "../../../data/lovelace/config/dashboard"; +import { saveConfig } from "../../../data/lovelace/config/types"; import { LovelaceViewConfig } from "../../../data/lovelace/config/view"; import { showAlertDialog, diff --git a/src/panels/lovelace/editor/add-entities-to-view.ts b/src/panels/lovelace/editor/add-entities-to-view.ts index ff484d8cac27..f28270a143ec 100644 --- a/src/panels/lovelace/editor/add-entities-to-view.ts +++ b/src/panels/lovelace/editor/add-entities-to-view.ts @@ -1,9 +1,9 @@ import { LovelacePanelConfig } from "../../../data/lovelace"; import { - LovelaceDashboardConfig, + LovelaceConfig, fetchConfig, saveConfig, -} from "../../../data/lovelace/config/dashboard"; +} from "../../../data/lovelace/config/types"; import { fetchDashboards } from "../../../data/lovelace/dashboard"; import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box"; import { HomeAssistant } from "../../../types"; @@ -93,7 +93,7 @@ export const addEntitiesToLovelaceView = async ( showSuggestCardDialog(element, { cardTitle, lovelaceConfig: lovelaceConfig!, - saveConfig: async (newConfig: LovelaceDashboardConfig): Promise => { + saveConfig: async (newConfig: LovelaceConfig): Promise => { try { await saveConfig(hass!, null, newConfig); } catch (err: any) { @@ -116,9 +116,7 @@ export const addEntitiesToLovelaceView = async ( showSuggestCardDialog(element, { cardTitle, lovelaceConfig: selectedDashConfig, - saveConfig: async ( - newConfig: LovelaceDashboardConfig - ): Promise => { + saveConfig: async (newConfig: LovelaceConfig): Promise => { try { await saveConfig(hass!, newUrlPath, newConfig); } catch { diff --git a/src/panels/lovelace/editor/card-editor/hui-card-picker.ts b/src/panels/lovelace/editor/card-editor/hui-card-picker.ts index f64ab31c0acb..d228aa60f658 100644 --- a/src/panels/lovelace/editor/card-editor/hui-card-picker.ts +++ b/src/panels/lovelace/editor/card-editor/hui-card-picker.ts @@ -19,7 +19,7 @@ import "../../../../components/ha-circular-progress"; import "../../../../components/search-input"; import { isUnavailableState } from "../../../../data/entity"; import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card"; -import type { LovelaceDashboardConfig } from "../../../../data/lovelace/config/dashboard"; +import type { LovelaceConfig } from "../../../../data/lovelace/config/types"; import { CUSTOM_TYPE_PREFIX, CustomCardEntry, @@ -56,7 +56,7 @@ export class HuiCardPicker extends LitElement { @state() private _cards: CardElement[] = []; - public lovelace?: LovelaceDashboardConfig; + public lovelace?: LovelaceConfig; public cardPicked?: (cardConf: LovelaceCardConfig) => void; diff --git a/src/panels/lovelace/editor/card-editor/show-create-card-dialog.ts b/src/panels/lovelace/editor/card-editor/show-create-card-dialog.ts index c75a225cd2cd..dedd6d1b6a25 100644 --- a/src/panels/lovelace/editor/card-editor/show-create-card-dialog.ts +++ b/src/panels/lovelace/editor/card-editor/show-create-card-dialog.ts @@ -1,9 +1,9 @@ import { fireEvent } from "../../../../common/dom/fire_event"; -import type { LovelaceDashboardConfig } from "../../../../data/lovelace/config/dashboard"; +import type { LovelaceConfig } from "../../../../data/lovelace/config/types"; export interface CreateCardDialogParams { - lovelaceConfig: LovelaceDashboardConfig; - saveConfig: (config: LovelaceDashboardConfig) => void; + lovelaceConfig: LovelaceConfig; + saveConfig: (config: LovelaceConfig) => void; path: [number] | [number, number]; entities?: string[]; // We can pass entity id's that will be added to the config when a card is picked } diff --git a/src/panels/lovelace/editor/card-editor/show-edit-card-dialog.ts b/src/panels/lovelace/editor/card-editor/show-edit-card-dialog.ts index 83823f368d61..f6b55e3b0e70 100644 --- a/src/panels/lovelace/editor/card-editor/show-edit-card-dialog.ts +++ b/src/panels/lovelace/editor/card-editor/show-edit-card-dialog.ts @@ -1,10 +1,10 @@ import { fireEvent } from "../../../../common/dom/fire_event"; import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card"; -import type { LovelaceDashboardConfig } from "../../../../data/lovelace/config/dashboard"; +import type { LovelaceConfig } from "../../../../data/lovelace/config/types"; export interface EditCardDialogParams { - lovelaceConfig: LovelaceDashboardConfig; - saveConfig: (config: LovelaceDashboardConfig) => void; + lovelaceConfig: LovelaceConfig; + saveConfig: (config: LovelaceConfig) => void; path: [number] | [number, number]; cardConfig?: LovelaceCardConfig; } diff --git a/src/panels/lovelace/editor/card-editor/show-suggest-card-dialog.ts b/src/panels/lovelace/editor/card-editor/show-suggest-card-dialog.ts index 2ea27131fa1b..781753e65e8b 100644 --- a/src/panels/lovelace/editor/card-editor/show-suggest-card-dialog.ts +++ b/src/panels/lovelace/editor/card-editor/show-suggest-card-dialog.ts @@ -1,12 +1,12 @@ import { fireEvent } from "../../../../common/dom/fire_event"; import { LovelaceCardConfig } from "../../../../data/lovelace/config/card"; -import { LovelaceDashboardConfig } from "../../../../data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../../../data/lovelace/config/types"; export interface SuggestCardDialogParams { cardTitle?: string; - lovelaceConfig?: LovelaceDashboardConfig; + lovelaceConfig?: LovelaceConfig; yaml?: boolean; - saveConfig?: (config: LovelaceDashboardConfig) => void; + saveConfig?: (config: LovelaceConfig) => void; path?: [number]; entities: string[]; // We can pass entity id's that will be added to the config when a card is picked cardConfig?: LovelaceCardConfig[]; // We can pass a suggested config diff --git a/src/panels/lovelace/editor/config-elements/hui-conditional-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-conditional-card-editor.ts index 30b1cb7fe79d..f875c3ed7e58 100644 --- a/src/panels/lovelace/editor/config-elements/hui-conditional-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-conditional-card-editor.ts @@ -12,7 +12,7 @@ import "../../../../components/ha-button"; import "../../../../components/ha-list-item"; import "../../../../components/ha-svg-icon"; import { LovelaceCardConfig } from "../../../../data/lovelace/config/card"; -import { LovelaceDashboardConfig } from "../../../../data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../../../data/lovelace/config/types"; import type { HomeAssistant } from "../../../../types"; import type { ConditionalCardConfig } from "../../cards/types"; import type { LovelaceCardEditor } from "../../types"; @@ -41,7 +41,7 @@ export class HuiConditionalCardEditor { @property({ attribute: false }) public hass?: HomeAssistant; - @property({ attribute: false }) public lovelace?: LovelaceDashboardConfig; + @property({ attribute: false }) public lovelace?: LovelaceConfig; @storage({ key: "lovelaceClipboard", diff --git a/src/panels/lovelace/editor/config-elements/hui-stack-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-stack-card-editor.ts index 258db8d1f1e9..b801108ff53c 100644 --- a/src/panels/lovelace/editor/config-elements/hui-stack-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-stack-card-editor.ts @@ -26,7 +26,7 @@ import { storage } from "../../../../common/decorators/storage"; import { HASSDomEvent, fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/ha-icon-button"; import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card"; -import type { LovelaceDashboardConfig } from "../../../../data/lovelace/config/dashboard"; +import type { LovelaceConfig } from "../../../../data/lovelace/config/types"; import { HomeAssistant } from "../../../../types"; import { StackCardConfig } from "../../cards/types"; import { LovelaceCardEditor } from "../../types"; @@ -53,7 +53,7 @@ export class HuiStackCardEditor { @property({ attribute: false }) public hass?: HomeAssistant; - @property({ attribute: false }) public lovelace?: LovelaceDashboardConfig; + @property({ attribute: false }) public lovelace?: LovelaceConfig; @storage({ key: "lovelaceClipboard", diff --git a/src/panels/lovelace/editor/config-util.ts b/src/panels/lovelace/editor/config-util.ts index f814bec9adcf..4200ac117a7a 100644 --- a/src/panels/lovelace/editor/config-util.ts +++ b/src/panels/lovelace/editor/config-util.ts @@ -1,5 +1,5 @@ import { LovelaceCardConfig } from "../../../data/lovelace/config/card"; -import { LovelaceDashboardConfig } from "../../../data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../../data/lovelace/config/types"; import { LovelaceViewConfig, isStrategyView, @@ -7,10 +7,10 @@ import { import type { HomeAssistant } from "../../../types"; export const addCard = ( - config: LovelaceDashboardConfig, + config: LovelaceConfig, path: [number], cardConfig: LovelaceCardConfig -): LovelaceDashboardConfig => { +): LovelaceConfig => { const [viewIndex] = path; const views: LovelaceViewConfig[] = []; @@ -41,10 +41,10 @@ export const addCard = ( }; export const addCards = ( - config: LovelaceDashboardConfig, + config: LovelaceConfig, path: [number], cardConfigs: LovelaceCardConfig[] -): LovelaceDashboardConfig => { +): LovelaceConfig => { const [viewIndex] = path; const views: LovelaceViewConfig[] = []; @@ -75,10 +75,10 @@ export const addCards = ( }; export const replaceCard = ( - config: LovelaceDashboardConfig, + config: LovelaceConfig, path: [number, number], cardConfig: LovelaceCardConfig -): LovelaceDashboardConfig => { +): LovelaceConfig => { const [viewIndex, cardIndex] = path; const views: LovelaceViewConfig[] = []; @@ -107,9 +107,9 @@ export const replaceCard = ( }; export const deleteCard = ( - config: LovelaceDashboardConfig, + config: LovelaceConfig, path: [number, number] -): LovelaceDashboardConfig => { +): LovelaceConfig => { const [viewIndex, cardIndex] = path; const views: LovelaceViewConfig[] = []; @@ -138,7 +138,7 @@ export const deleteCard = ( }; export const insertCard = ( - config: LovelaceDashboardConfig, + config: LovelaceConfig, path: [number, number], cardConfig: LovelaceCardConfig ) => { @@ -176,10 +176,10 @@ export const insertCard = ( }; export const swapCard = ( - config: LovelaceDashboardConfig, + config: LovelaceConfig, path1: [number, number], path2: [number, number] -): LovelaceDashboardConfig => { +): LovelaceConfig => { const origView1 = config.views[path1[0]]; const origView2 = config.views[path2[0]]; @@ -214,10 +214,10 @@ export const swapCard = ( }; export const moveCardToPosition = ( - config: LovelaceDashboardConfig, + config: LovelaceConfig, path: [number, number], position: number -): LovelaceDashboardConfig => { +): LovelaceConfig => { const view = config.views[path[0]]; if (isStrategyView(view)) { @@ -247,10 +247,10 @@ export const moveCardToPosition = ( }; export const moveCard = ( - config: LovelaceDashboardConfig, + config: LovelaceConfig, fromPath: [number, number], toPath: [number] -): LovelaceDashboardConfig => { +): LovelaceConfig => { if (fromPath[0] === toPath[0]) { throw new Error("You cannot move a card to the view it is in."); } @@ -295,9 +295,9 @@ export const moveCard = ( export const addView = ( hass: HomeAssistant, - config: LovelaceDashboardConfig, + config: LovelaceConfig, viewConfig: LovelaceViewConfig -): LovelaceDashboardConfig => { +): LovelaceConfig => { if (viewConfig.path && config.views.some((v) => v.path === viewConfig.path)) { throw new Error( hass.localize("ui.panel.lovelace.editor.edit_view.error_same_url") @@ -311,10 +311,10 @@ export const addView = ( export const replaceView = ( hass: HomeAssistant, - config: LovelaceDashboardConfig, + config: LovelaceConfig, viewIndex: number, viewConfig: LovelaceViewConfig -): LovelaceDashboardConfig => { +): LovelaceConfig => { if ( viewConfig.path && config.views.some( @@ -334,10 +334,10 @@ export const replaceView = ( }; export const swapView = ( - config: LovelaceDashboardConfig, + config: LovelaceConfig, path1: number, path2: number -): LovelaceDashboardConfig => { +): LovelaceConfig => { const view1 = config.views[path1]; const view2 = config.views[path2]; @@ -350,9 +350,9 @@ export const swapView = ( }; export const deleteView = ( - config: LovelaceDashboardConfig, + config: LovelaceConfig, viewIndex: number -): LovelaceDashboardConfig => ({ +): LovelaceConfig => ({ ...config, views: config.views.filter((_origView, index) => index !== viewIndex), }); diff --git a/src/panels/lovelace/editor/header-footer-editor/hui-header-footer-editor.ts b/src/panels/lovelace/editor/header-footer-editor/hui-header-footer-editor.ts index 2f2cd83612f2..1036e0437ec6 100644 --- a/src/panels/lovelace/editor/header-footer-editor/hui-header-footer-editor.ts +++ b/src/panels/lovelace/editor/header-footer-editor/hui-header-footer-editor.ts @@ -3,7 +3,7 @@ import { CSSResultGroup, LitElement, TemplateResult, css, html } from "lit"; import { customElement, property } from "lit/decorators"; import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/ha-icon-button"; -import type { LovelaceDashboardConfig } from "../../../../data/lovelace/config/dashboard"; +import type { LovelaceConfig } from "../../../../data/lovelace/config/types"; import type { HomeAssistant } from "../../../../types"; import type { LovelaceHeaderFooterConfig } from "../../header-footer/types"; import { showCreateHeaderFooterDialog } from "./show-create-headerfooter-dialog"; @@ -12,7 +12,7 @@ import { showCreateHeaderFooterDialog } from "./show-create-headerfooter-dialog" export class HuiHeaderFooterEditor extends LitElement { public hass!: HomeAssistant; - public lovelaceConfig!: LovelaceDashboardConfig; + public lovelaceConfig!: LovelaceConfig; @property({ attribute: false }) public config?: LovelaceHeaderFooterConfig; diff --git a/src/panels/lovelace/editor/hui-dialog-save-config.ts b/src/panels/lovelace/editor/hui-dialog-save-config.ts index 9a61c9389a1a..e66876d4a4c6 100644 --- a/src/panels/lovelace/editor/hui-dialog-save-config.ts +++ b/src/panels/lovelace/editor/hui-dialog-save-config.ts @@ -10,7 +10,7 @@ import "../../../components/ha-formfield"; import "../../../components/ha-icon-button"; import "../../../components/ha-switch"; import "../../../components/ha-yaml-editor"; -import { LovelaceDashboardConfig } from "../../../data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../../data/lovelace/config/types"; import type { HassDialog } from "../../../dialogs/make-dialog-manager"; import { haStyleDialog } from "../../../resources/styles"; import type { HomeAssistant } from "../../../types"; @@ -18,7 +18,7 @@ import { documentationUrl } from "../../../util/documentation-url"; import { expandLovelaceConfigStrategies } from "../strategies/get-strategy"; import type { SaveDialogParams } from "./show-save-config-dialog"; -const EMPTY_CONFIG: LovelaceDashboardConfig = { views: [{ title: "Home" }] }; +const EMPTY_CONFIG: LovelaceConfig = { views: [{ title: "Home" }] }; @customElement("hui-dialog-save-config") export class HuiSaveConfig extends LitElement implements HassDialog { diff --git a/src/panels/lovelace/editor/hui-element-editor.ts b/src/panels/lovelace/editor/hui-element-editor.ts index 104df575f1b5..56486d66ec79 100644 --- a/src/panels/lovelace/editor/hui-element-editor.ts +++ b/src/panels/lovelace/editor/hui-element-editor.ts @@ -17,7 +17,7 @@ import "../../../components/ha-circular-progress"; import "../../../components/ha-code-editor"; import type { HaCodeEditor } from "../../../components/ha-code-editor"; import type { LovelaceCardConfig } from "../../../data/lovelace/config/card"; -import type { LovelaceDashboardConfig } from "../../../data/lovelace/config/dashboard"; +import type { LovelaceConfig } from "../../../data/lovelace/config/types"; import type { HomeAssistant } from "../../../types"; import type { LovelaceRowConfig } from "../entity-rows/types"; import { LovelaceHeaderFooterConfig } from "../header-footer/types"; @@ -62,7 +62,7 @@ export interface UIConfigChangedEvent extends Event { export abstract class HuiElementEditor extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; - @property({ attribute: false }) public lovelace?: LovelaceDashboardConfig; + @property({ attribute: false }) public lovelace?: LovelaceConfig; @property({ attribute: false }) public context?: C; diff --git a/src/panels/lovelace/editor/lovelace-editor/hui-dialog-edit-lovelace.ts b/src/panels/lovelace/editor/lovelace-editor/hui-dialog-edit-lovelace.ts index 896910dcfb44..2ba47bdaf88d 100644 --- a/src/panels/lovelace/editor/lovelace-editor/hui-dialog-edit-lovelace.ts +++ b/src/panels/lovelace/editor/lovelace-editor/hui-dialog-edit-lovelace.ts @@ -8,7 +8,7 @@ import { haStyleDialog } from "../../../../resources/styles"; import type { HomeAssistant } from "../../../../types"; import type { Lovelace } from "../../types"; import "./hui-lovelace-editor"; -import { LovelaceDashboardConfig } from "../../../../data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../../../data/lovelace/config/types"; @customElement("hui-dialog-edit-lovelace") export class HuiDialogEditLovelace extends LitElement { @@ -16,14 +16,14 @@ export class HuiDialogEditLovelace extends LitElement { @state() private _lovelace?: Lovelace; - @state() private _config?: LovelaceDashboardConfig; + @state() private _config?: LovelaceConfig; private _saving = false; public showDialog(lovelace: Lovelace): void { this._lovelace = lovelace; const { views, ...lovelaceConfig } = this._lovelace!.config; - this._config = lovelaceConfig as LovelaceDashboardConfig; + this._config = lovelaceConfig as LovelaceConfig; } public closeDialog(): void { @@ -86,7 +86,7 @@ export class HuiDialogEditLovelace extends LitElement { this._saving = true; const lovelace = this._lovelace!; - const config: LovelaceDashboardConfig = { + const config: LovelaceConfig = { ...lovelace.config, ...this._config, }; diff --git a/src/panels/lovelace/editor/lovelace-editor/hui-lovelace-editor.ts b/src/panels/lovelace/editor/lovelace-editor/hui-lovelace-editor.ts index 3d92547d826c..e3805d93f586 100644 --- a/src/panels/lovelace/editor/lovelace-editor/hui-lovelace-editor.ts +++ b/src/panels/lovelace/editor/lovelace-editor/hui-lovelace-editor.ts @@ -2,14 +2,14 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property } from "lit/decorators"; import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/ha-textfield"; -import type { LovelaceDashboardConfig } from "../../../../data/lovelace/config/dashboard"; +import type { LovelaceConfig } from "../../../../data/lovelace/config/types"; import { HomeAssistant } from "../../../../types"; import { EditorTarget } from "../types"; declare global { interface HASSDomEvents { "lovelace-config-changed": { - config: LovelaceDashboardConfig; + config: LovelaceConfig; }; } } @@ -18,7 +18,7 @@ declare global { export class HuiLovelaceEditor extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; - @property() public config?: LovelaceDashboardConfig; + @property() public config?: LovelaceConfig; get _title(): string { if (!this.config) { 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 8f501f37692b..6a9c8eb04fdc 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 @@ -10,8 +10,8 @@ import "../../../../components/ha-icon"; import "../../../../components/ha-select"; import { fetchConfig, - LovelaceDashboardConfig, -} from "../../../../data/lovelace/config/dashboard"; + LovelaceConfig, +} from "../../../../data/lovelace/config/types"; import { fetchDashboards, LovelaceDashboard, @@ -38,7 +38,7 @@ export class HuiDialogSelectView extends LitElement { @state() private _urlPath?: string | null; - @state() private _config?: LovelaceDashboardConfig; + @state() private _config?: LovelaceConfig; @state() private _selectedViewIdx = 0; @@ -161,7 +161,7 @@ export class HuiDialogSelectView extends LitElement { this.hass.connection, urlPath, false - )) as LovelaceDashboardConfig; + )) as LovelaceConfig; } catch (err: any) { this._config = undefined; } 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 184978f64896..d53715c9b411 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 @@ -1,9 +1,9 @@ import { fireEvent } from "../../../../common/dom/fire_event"; -import { LovelaceDashboardConfig } from "../../../../data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../../../data/lovelace/config/types"; import { LovelaceDashboard } from "../../../../data/lovelace/dashboard"; export interface SelectViewDialogParams { - lovelaceConfig: LovelaceDashboardConfig; + lovelaceConfig: LovelaceConfig; allowDashboardChange: boolean; dashboards?: LovelaceDashboard[]; urlPath?: string | null; @@ -11,7 +11,7 @@ export interface SelectViewDialogParams { actionLabel?: string; viewSelectedCallback: ( urlPath: string | null, - config: LovelaceDashboardConfig, + config: LovelaceConfig, view: number ) => void; } diff --git a/src/panels/lovelace/editor/unused-entities/hui-unused-entities.ts b/src/panels/lovelace/editor/unused-entities/hui-unused-entities.ts index 845c9d2aaf75..e633861493cb 100644 --- a/src/panels/lovelace/editor/unused-entities/hui-unused-entities.ts +++ b/src/panels/lovelace/editor/unused-entities/hui-unused-entities.ts @@ -21,7 +21,7 @@ import type { Lovelace } from "../../types"; import "../card-editor/hui-entity-picker-table"; import { showSuggestCardDialog } from "../card-editor/show-suggest-card-dialog"; import { showSelectViewDialog } from "../select-view/show-select-view-dialog"; -import { LovelaceDashboardConfig } from "../../../../data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../../../data/lovelace/config/types"; @customElement("hui-unused-entities") export class HuiUnusedEntities extends LitElement { @@ -35,7 +35,7 @@ export class HuiUnusedEntities extends LitElement { @state() private _selectedEntities: string[] = []; - private get _config(): LovelaceDashboardConfig { + private get _config(): LovelaceConfig { return this.lovelace.config; } diff --git a/src/panels/lovelace/ha-panel-lovelace.ts b/src/panels/lovelace/ha-panel-lovelace.ts index e874c6355d17..32032d1d58f9 100644 --- a/src/panels/lovelace/ha-panel-lovelace.ts +++ b/src/panels/lovelace/ha-panel-lovelace.ts @@ -23,11 +23,11 @@ import { deleteConfig, fetchConfig, isStrategyDashboard, - LovelaceDashboardConfig, - LovelaceDashboardRawConfig, + LovelaceConfig, + LovelaceRawConfig, LovelaceDashboardStrategyConfig, saveConfig, -} from "../../data/lovelace/config/dashboard"; +} from "../../data/lovelace/config/types"; import { fetchResources } from "../../data/lovelace/resource"; import { isStrategyView, @@ -225,10 +225,10 @@ export class LovelacePanel extends LitElement { } private async _fetchConfig(forceDiskRefresh: boolean) { - let conf: LovelaceDashboardConfig; - let rawConf: LovelaceDashboardRawConfig | undefined; + let conf: LovelaceConfig; + let rawConf: LovelaceRawConfig | undefined; let confMode: Lovelace["mode"] = this.panel!.config.mode; - let confProm: Promise | undefined; + let confProm: Promise | undefined; const preloadWindow = window as WindowWithPreloads; // On first load, we speed up loading page by having LL promise ready @@ -298,7 +298,7 @@ export class LovelacePanel extends LitElement { this._setLovelaceConfig(conf, rawConf, confMode); } - private _checkLovelaceConfig(config: LovelaceDashboardRawConfig) { + private _checkLovelaceConfig(config: LovelaceRawConfig) { // Somehow there can be badges with value null, we remove those if (isStrategyDashboard(config)) { return config; @@ -322,8 +322,8 @@ export class LovelacePanel extends LitElement { } private _setLovelaceConfig( - config: LovelaceDashboardConfig, - rawConfig: LovelaceDashboardRawConfig, + config: LovelaceConfig, + rawConfig: LovelaceRawConfig, mode: Lovelace["mode"] ) { config = this._checkLovelaceConfig(config); @@ -364,16 +364,14 @@ export class LovelacePanel extends LitElement { narrow: this.narrow!, }); }, - saveConfig: async ( - newConfig: LovelaceDashboardRawConfig - ): Promise => { + saveConfig: async (newConfig: LovelaceRawConfig): Promise => { const { config: previousConfig, rawConfig: previousRawConfig, mode: previousMode, } = this.lovelace!; newConfig = this._checkLovelaceConfig(newConfig); - let conf: LovelaceDashboardConfig; + let conf: LovelaceConfig; // If strategy defined, apply it here. if (isStrategyDashboard(newConfig)) { conf = await generateLovelaceDashboardStrategy( diff --git a/src/panels/lovelace/hui-editor.ts b/src/panels/lovelace/hui-editor.ts index 343aeb20c64d..983dfa130bbf 100644 --- a/src/panels/lovelace/hui-editor.ts +++ b/src/panels/lovelace/hui-editor.ts @@ -27,7 +27,7 @@ import type { HomeAssistant } from "../../types"; import { showToast } from "../../util/toast"; import type { Lovelace } from "./types"; import "../../components/ha-top-app-bar-fixed"; -import { LovelaceDashboardRawConfig } from "../../data/lovelace/config/dashboard"; +import { LovelaceRawConfig } from "../../data/lovelace/config/types"; const lovelaceStruct = type({ title: optional(string()), @@ -247,9 +247,9 @@ class LovelaceFullConfigEditor extends LitElement { } } - let config: LovelaceDashboardRawConfig; + let config: LovelaceRawConfig; try { - config = load(value) as LovelaceDashboardRawConfig; + config = load(value) as LovelaceRawConfig; } catch (err: any) { showAlertDialog(this, { text: this.hass.localize( diff --git a/src/panels/lovelace/hui-root.ts b/src/panels/lovelace/hui-root.ts index e8a60549af6f..f2dc50d40067 100644 --- a/src/panels/lovelace/hui-root.ts +++ b/src/panels/lovelace/hui-root.ts @@ -68,7 +68,7 @@ import type { Lovelace } from "./types"; import "./views/hui-view"; import type { HUIView } from "./views/hui-view"; import { LovelaceViewConfig } from "../../data/lovelace/config/view"; -import { LovelaceDashboardConfig } from "../../data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../data/lovelace/config/types"; @customElement("hui-root") class HUIRoot extends LitElement { @@ -669,7 +669,7 @@ class HUIRoot extends LitElement { } } - private get config(): LovelaceDashboardConfig { + private get config(): LovelaceConfig { return this.lovelace!.config; } diff --git a/src/panels/lovelace/strategies/get-strategy.ts b/src/panels/lovelace/strategies/get-strategy.ts index 67c938bd1841..cf507c78ac94 100644 --- a/src/panels/lovelace/strategies/get-strategy.ts +++ b/src/panels/lovelace/strategies/get-strategy.ts @@ -1,8 +1,8 @@ import { - LovelaceDashboardConfig, - LovelaceDashboardRawConfig, + LovelaceConfig, + LovelaceRawConfig, isStrategyDashboard, -} from "../../../data/lovelace/config/dashboard"; +} from "../../../data/lovelace/config/types"; import { LovelaceStrategyConfig } from "../../../data/lovelace/config/strategy"; import { LovelaceViewConfig, @@ -130,7 +130,7 @@ const generateStrategy = async ( export const generateLovelaceDashboardStrategy = async ( strategyConfig: LovelaceStrategyConfig, hass: HomeAssistant -): Promise => +): Promise => generateStrategy( "dashboard", (err) => ({ @@ -172,9 +172,9 @@ export const generateLovelaceViewStrategy = async ( * Find all references to strategies and replaces them with the generated output */ export const expandLovelaceConfigStrategies = async ( - config: LovelaceDashboardRawConfig, + config: LovelaceRawConfig, hass: HomeAssistant -): Promise => { +): Promise => { const newConfig = isStrategyDashboard(config) ? await generateLovelaceDashboardStrategy(config.strategy, hass) : { ...config }; diff --git a/src/panels/lovelace/strategies/legacy-strategy.ts b/src/panels/lovelace/strategies/legacy-strategy.ts index 200d5cf99f8b..7ce729f0cd8b 100644 --- a/src/panels/lovelace/strategies/legacy-strategy.ts +++ b/src/panels/lovelace/strategies/legacy-strategy.ts @@ -1,7 +1,7 @@ import { - LovelaceDashboardConfig, - LovelaceDashboardRawConfig, -} from "../../../data/lovelace/config/dashboard"; + LovelaceConfig, + LovelaceRawConfig, +} from "../../../data/lovelace/config/types"; import { LovelaceViewConfig, LovelaceViewRawConfig, @@ -15,15 +15,15 @@ export const isLegacyStrategy = ( export interface LovelaceDashboardStrategy { generateDashboard(info: { - config?: LovelaceDashboardRawConfig; + config?: LovelaceRawConfig; hass: HomeAssistant; - }): Promise; + }): Promise; } export interface LovelaceViewStrategy { generateView(info: { view: LovelaceViewRawConfig; - config: LovelaceDashboardConfig; + config: LovelaceConfig; hass: HomeAssistant; }): Promise; } diff --git a/src/panels/lovelace/strategies/original-states-dashboard-strategy.ts b/src/panels/lovelace/strategies/original-states-dashboard-strategy.ts index 3a62a3d46310..7dfaec41a819 100644 --- a/src/panels/lovelace/strategies/original-states-dashboard-strategy.ts +++ b/src/panels/lovelace/strategies/original-states-dashboard-strategy.ts @@ -2,14 +2,14 @@ import { ReactiveElement } from "lit"; import { customElement } from "lit/decorators"; import { HomeAssistant } from "../../../types"; import { LovelaceStrategyConfig } from "../../../data/lovelace/config/strategy"; -import { LovelaceDashboardConfig } from "../../../data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../../data/lovelace/config/types"; @customElement("original-states-dashboard-strategy") export class OriginalStatesDashboardStrategy extends ReactiveElement { static async generate( _config: LovelaceStrategyConfig, hass: HomeAssistant - ): Promise { + ): Promise { return { title: hass.config.location_name, views: [ diff --git a/src/panels/lovelace/strategies/types.ts b/src/panels/lovelace/strategies/types.ts index 75cbab7ebb48..ea4946a8006e 100644 --- a/src/panels/lovelace/strategies/types.ts +++ b/src/panels/lovelace/strategies/types.ts @@ -1,4 +1,4 @@ -import { LovelaceDashboardConfig } from "../../../data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../../data/lovelace/config/types"; import { LovelaceStrategyConfig } from "../../../data/lovelace/config/strategy"; import { LovelaceViewConfig } from "../../../data/lovelace/config/view"; import { HomeAssistant } from "../../../types"; @@ -8,7 +8,7 @@ export type LovelaceStrategy = { }; export interface LovelaceDashboardStrategy - extends LovelaceStrategy {} + extends LovelaceStrategy {} export interface LovelaceViewStrategy extends LovelaceStrategy {} diff --git a/src/panels/lovelace/types.ts b/src/panels/lovelace/types.ts index 46667f9ab4ff..03f3c12d10fb 100644 --- a/src/panels/lovelace/types.ts +++ b/src/panels/lovelace/types.ts @@ -4,9 +4,9 @@ import { HaFormSchema } from "../../components/ha-form/types"; import { LovelaceBadgeConfig } from "../../data/lovelace/config/badge"; import { LovelaceCardConfig } from "../../data/lovelace/config/card"; import { - LovelaceDashboardConfig, - LovelaceDashboardRawConfig, -} from "../../data/lovelace/config/dashboard"; + LovelaceConfig, + LovelaceRawConfig, +} from "../../data/lovelace/config/types"; import { FrontendLocaleData } from "../../data/translation"; import { Constructor, HomeAssistant } from "../../types"; import { LovelaceRow, LovelaceRowConfig } from "./entity-rows/types"; @@ -22,15 +22,15 @@ declare global { } export interface Lovelace { - config: LovelaceDashboardConfig; - rawConfig: LovelaceDashboardRawConfig; + config: LovelaceConfig; + rawConfig: LovelaceRawConfig; editMode: boolean; urlPath: string | null; mode: "generated" | "yaml" | "storage"; locale: FrontendLocaleData; enableFullEditMode: () => void; setEditMode: (editMode: boolean) => void; - saveConfig: (newConfig: LovelaceDashboardRawConfig) => Promise; + saveConfig: (newConfig: LovelaceRawConfig) => Promise; deleteConfig: () => Promise; } @@ -106,7 +106,7 @@ export interface LovelaceRowEditor extends LovelaceGenericElementEditor { export interface LovelaceGenericElementEditor extends HTMLElement { hass?: HomeAssistant; - lovelace?: LovelaceDashboardConfig; + lovelace?: LovelaceConfig; context?: C; setConfig(config: any): void; focusYamlEditor?: () => void; diff --git a/test/panels/lovelace/editor/config-util.spec.ts b/test/panels/lovelace/editor/config-util.spec.ts index b6a2de3673f6..a437b28cfab1 100644 --- a/test/panels/lovelace/editor/config-util.spec.ts +++ b/test/panels/lovelace/editor/config-util.spec.ts @@ -5,11 +5,11 @@ import { moveCard, swapView, } from "../../../../src/panels/lovelace/editor/config-util"; -import { LovelaceDashboardConfig } from "../../../../src/data/lovelace/config/dashboard"; +import { LovelaceConfig } from "../../../../src/data/lovelace/config/types"; describe("swapCard", () => { it("swaps 2 cards in same view", () => { - const config: LovelaceDashboardConfig = { + const config: LovelaceConfig = { views: [ {}, { @@ -31,7 +31,7 @@ describe("swapCard", () => { }); it("swaps 2 cards in different views", () => { - const config: LovelaceDashboardConfig = { + const config: LovelaceConfig = { views: [ { cards: [{ type: "v1-c1" }, { type: "v1-c2" }], @@ -43,7 +43,7 @@ describe("swapCard", () => { }; const result = swapCard(config, [0, 0], [1, 1]); - const expected: LovelaceDashboardConfig = { + const expected: LovelaceConfig = { views: [ { cards: [{ type: "v2-c2" }, { type: "v1-c2" }], @@ -59,7 +59,7 @@ describe("swapCard", () => { describe("moveCard", () => { it("move a card to an empty view", () => { - const config: LovelaceDashboardConfig = { + const config: LovelaceConfig = { views: [ {}, { @@ -69,7 +69,7 @@ describe("moveCard", () => { }; const result = moveCard(config, [1, 0], [0]); - const expected: LovelaceDashboardConfig = { + const expected: LovelaceConfig = { views: [ { cards: [{ type: "card1" }], @@ -83,7 +83,7 @@ describe("moveCard", () => { }); it("move a card to different view", () => { - const config: LovelaceDashboardConfig = { + const config: LovelaceConfig = { views: [ { cards: [{ type: "v1-c1" }, { type: "v1-c2" }], @@ -95,7 +95,7 @@ describe("moveCard", () => { }; const result = moveCard(config, [1, 0], [0]); - const expected: LovelaceDashboardConfig = { + const expected: LovelaceConfig = { views: [ { cards: [{ type: "v1-c1" }, { type: "v1-c2" }, { type: "v2-c1" }], @@ -109,7 +109,7 @@ describe("moveCard", () => { }); it("move a card to the same view", () => { - const config: LovelaceDashboardConfig = { + const config: LovelaceConfig = { views: [ { cards: [{ type: "v1-c1" }, { type: "v1-c2" }], @@ -133,7 +133,7 @@ describe("moveCard", () => { describe("swapView", () => { it("swaps 2 view", () => { - const config: LovelaceDashboardConfig = { + const config: LovelaceConfig = { views: [ { title: "view1", @@ -147,7 +147,7 @@ describe("swapView", () => { }; const result = swapView(config, 1, 0); - const expected: LovelaceDashboardConfig = { + const expected: LovelaceConfig = { views: [ { title: "view2", @@ -163,7 +163,7 @@ describe("swapView", () => { }); it("swaps the same views", () => { - const config: LovelaceDashboardConfig = { + const config: LovelaceConfig = { views: [ { title: "view1", @@ -177,7 +177,7 @@ describe("swapView", () => { }; const result = swapView(config, 0, 0); - const expected: LovelaceDashboardConfig = { + const expected: LovelaceConfig = { views: [ { title: "view1",