Skip to content

Commit

Permalink
Restore lovelace config name
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya committed Nov 14, 2023
1 parent f36e054 commit 4bb6504
Show file tree
Hide file tree
Showing 39 changed files with 148 additions and 154 deletions.
2 changes: 1 addition & 1 deletion cast/src/launcher/layout/hc-cast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions cast/src/receiver/demo/cast-demo-lovelace.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions cast/src/receiver/layout/hc-demo.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions cast/src/receiver/layout/hc-lovelace.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions cast/src/receiver/layout/hc-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;

Expand Down Expand Up @@ -347,7 +347,7 @@ export class HcMain extends HassElement {
);
}

private _handleNewLovelaceConfig(lovelaceConfig: LovelaceDashboardConfig) {
private _handleNewLovelaceConfig(lovelaceConfig: LovelaceConfig) {
castContext.setApplicationState(lovelaceConfig.title || "");
this._lovelaceConfig = lovelaceConfig;
}
Expand Down
4 changes: 2 additions & 2 deletions demo/src/configs/types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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 {
index?: number;
name: string;
authorName: string;
authorUrl: string;
lovelace: (localize: LocalizeFunc) => LovelaceDashboardConfig;
lovelace: (localize: LocalizeFunc) => LovelaceConfig;
entities: (localize: LocalizeFunc) => Entity[];
theme: () => Record<string, string> | null;
}
2 changes: 1 addition & 1 deletion src/components/ha-navigation-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/data/lovelace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand All @@ -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;
}
Expand All @@ -35,7 +35,7 @@ export const fetchConfig = (
conn: Connection,
urlPath: string | null,
force: boolean
): Promise<LovelaceDashboardRawConfig> =>
): Promise<LovelaceRawConfig> =>
conn.sendMessagePromise({
type: "lovelace/config",
url_path: urlPath,
Expand All @@ -45,7 +45,7 @@ export const fetchConfig = (
export const saveConfig = (
hass: HomeAssistant,
urlPath: string | null,
config: LovelaceDashboardRawConfig
config: LovelaceRawConfig
): Promise<void> =>
hass.callWS({
type: "lovelace/config/save",
Expand Down
4 changes: 2 additions & 2 deletions src/data/preloads.ts
Original file line number Diff line number Diff line change
@@ -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<LovelaceDashboardRawConfig>;
llConfProm?: Promise<LovelaceRawConfig>;
llResProm?: Promise<LovelaceResource[]>;
recorderInfoProm?: Promise<RecorderInfo>;
}
2 changes: 1 addition & 1 deletion src/entrypoints/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions src/panels/energy/ha-panel-energy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
8 changes: 3 additions & 5 deletions src/panels/lovelace/common/compute-unused-entities.ts
Original file line number Diff line number Diff line change
@@ -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"];
Expand Down Expand Up @@ -66,9 +66,7 @@ const addEntities = (entities: Set<string>, obj) => {
}
};

export const computeUsedEntities = (
config: LovelaceDashboardConfig
): Set<string> => {
export const computeUsedEntities = (config: LovelaceConfig): Set<string> => {
const entities = new Set<string>();
config.views.forEach((view) => addEntities(entities, view));
return entities;
Expand All @@ -94,7 +92,7 @@ export const calcUnusedEntities = (

export const computeUnusedEntities = (
hass: HomeAssistant,
config: LovelaceDashboardConfig
config: LovelaceConfig
): Set<string> => {
const usedEntities = computeUsedEntities(config);
const unusedEntities = calcUnusedEntities(hass, usedEntities);
Expand Down
2 changes: 1 addition & 1 deletion src/panels/lovelace/components/hui-card-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 4 additions & 6 deletions src/panels/lovelace/editor/add-entities-to-view.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -93,7 +93,7 @@ export const addEntitiesToLovelaceView = async (
showSuggestCardDialog(element, {
cardTitle,
lovelaceConfig: lovelaceConfig!,
saveConfig: async (newConfig: LovelaceDashboardConfig): Promise<void> => {
saveConfig: async (newConfig: LovelaceConfig): Promise<void> => {
try {
await saveConfig(hass!, null, newConfig);
} catch (err: any) {
Expand All @@ -116,9 +116,7 @@ export const addEntitiesToLovelaceView = async (
showSuggestCardDialog(element, {
cardTitle,
lovelaceConfig: selectedDashConfig,
saveConfig: async (
newConfig: LovelaceDashboardConfig
): Promise<void> => {
saveConfig: async (newConfig: LovelaceConfig): Promise<void> => {
try {
await saveConfig(hass!, newUrlPath, newConfig);
} catch {
Expand Down
4 changes: 2 additions & 2 deletions src/panels/lovelace/editor/card-editor/hui-card-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -56,7 +56,7 @@ export class HuiCardPicker extends LitElement {

@state() private _cards: CardElement[] = [];

public lovelace?: LovelaceDashboardConfig;
public lovelace?: LovelaceConfig;

public cardPicked?: (cardConf: LovelaceCardConfig) => void;

Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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",
Expand Down
Loading

0 comments on commit 4bb6504

Please sign in to comment.