Skip to content

Commit

Permalink
Merge branch 'dev' into markdown_show_empty_patch
Browse files Browse the repository at this point in the history
  • Loading branch information
illuzn authored Jul 15, 2024
2 parents 8096990 + 5ec257f commit 5dd82ca
Show file tree
Hide file tree
Showing 10 changed files with 342 additions and 496 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"license": "Apache-2.0",
"type": "module",
"dependencies": {
"@babel/runtime": "7.24.7",
"@babel/runtime": "7.24.8",
"@braintree/sanitize-url": "7.0.4",
"@codemirror/autocomplete": "6.17.0",
"@codemirror/commands": "6.6.0",
Expand Down Expand Up @@ -88,8 +88,8 @@
"@polymer/paper-tabs": "3.1.0",
"@polymer/polymer": "3.5.1",
"@thomasloven/round-slider": "0.6.0",
"@vaadin/combo-box": "24.4.1",
"@vaadin/vaadin-themable-mixin": "24.4.1",
"@vaadin/combo-box": "24.4.2",
"@vaadin/vaadin-themable-mixin": "24.4.2",
"@vibrant/color": "3.2.1-alpha.1",
"@vibrant/core": "3.2.1-alpha.1",
"@vibrant/quantizer-mmcq": "3.2.1-alpha.1",
Expand Down Expand Up @@ -149,11 +149,11 @@
"xss": "1.0.15"
},
"devDependencies": {
"@babel/core": "7.24.7",
"@babel/core": "7.24.8",
"@babel/helper-define-polyfill-provider": "0.6.2",
"@babel/plugin-proposal-decorators": "7.24.7",
"@babel/plugin-transform-runtime": "7.24.7",
"@babel/preset-env": "7.24.7",
"@babel/preset-env": "7.24.8",
"@babel/preset-typescript": "7.24.7",
"@bundle-stats/plugin-webpack-filter": "4.13.3",
"@koa/cors": "5.0.0",
Expand Down Expand Up @@ -200,16 +200,16 @@
"eslint-import-resolver-webpack": "0.13.8",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-lit": "1.14.0",
"eslint-plugin-lit-a11y": "4.1.3",
"eslint-plugin-lit-a11y": "4.1.4",
"eslint-plugin-unused-imports": "4.0.0",
"eslint-plugin-wc": "2.1.0",
"fancy-log": "2.0.0",
"fs-extra": "11.2.0",
"glob": "10.4.3",
"glob": "11.0.0",
"gulp": "5.0.0",
"gulp-json-transform": "0.5.0",
"gulp-rename": "2.0.0",
"gulp-zopfli-green": "6.0.1",
"gulp-zopfli-green": "6.0.2",
"html-minifier-terser": "7.2.0",
"husky": "9.0.11",
"instant-mocha": "1.5.2",
Expand Down Expand Up @@ -238,7 +238,7 @@
"transform-async-modules-webpack-plugin": "1.1.1",
"ts-lit-plugin": "2.0.2",
"typescript": "5.5.3",
"webpack": "5.92.1",
"webpack": "5.93.0",
"webpack-cli": "5.1.4",
"webpack-dev-server": "5.0.4",
"webpack-manifest-plugin": "5.0.0",
Expand Down
21 changes: 0 additions & 21 deletions src/data/group.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {
HassEntityAttributeBase,
HassEntityBase,
UnsubscribeFunc,
} from "home-assistant-js-websocket";
import { computeDomain } from "../common/entity/compute_domain";
import { HomeAssistant } from "../types";

interface GroupEntityAttributes extends HassEntityAttributeBase {
entity_id: string[];
Expand All @@ -17,11 +15,6 @@ export interface GroupEntity extends HassEntityBase {
attributes: GroupEntityAttributes;
}

export interface GroupPreview {
state: string;
attributes: Record<string, any>;
}

export const computeGroupDomain = (
stateObj: GroupEntity
): string | undefined => {
Expand All @@ -31,17 +24,3 @@ export const computeGroupDomain = (
];
return uniqueDomains.length === 1 ? uniqueDomains[0] : undefined;
};

export const subscribePreviewGroup = (
hass: HomeAssistant,
flow_id: string,
flow_type: "config_flow" | "options_flow",
user_input: Record<string, any>,
callback: (preview: GroupPreview) => void
): Promise<UnsubscribeFunc> =>
hass.connection.subscribeMessage(callback, {
type: "group/start_preview",
flow_id,
flow_type,
user_input,
});
14 changes: 10 additions & 4 deletions src/data/threshold.ts → src/data/preview.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
import { UnsubscribeFunc } from "home-assistant-js-websocket";
import { HomeAssistant } from "../types";

export interface ThresholdPreview {
const HAS_CUSTOM_PREVIEW = ["template"];

export interface GenericPreview {
state: string;
attributes: Record<string, any>;
}

export const subscribePreviewThreshold = (
export const subscribePreviewGeneric = (
hass: HomeAssistant,
domain: string,
flow_id: string,
flow_type: "config_flow" | "options_flow",
user_input: Record<string, any>,
callback: (preview: ThresholdPreview) => void
callback: (preview: GenericPreview) => void
): Promise<UnsubscribeFunc> =>
hass.connection.subscribeMessage(callback, {
type: "threshold/start_preview",
type: `${domain}/start_preview`,
flow_id,
flow_type,
user_input,
});

export const previewModule = (domain: string): string =>
HAS_CUSTOM_PREVIEW.includes(domain) ? domain : "generic";
21 changes: 0 additions & 21 deletions src/data/time_date.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ import { HassEntity, UnsubscribeFunc } from "home-assistant-js-websocket";
import { LitElement, html } from "lit";
import { customElement, property, state } from "lit/decorators";
import { FlowType } from "../../../data/data_entry_flow";
import {
ThresholdPreview,
subscribePreviewThreshold,
} from "../../../data/threshold";
import { GenericPreview, subscribePreviewGeneric } from "../../../data/preview";
import { HomeAssistant } from "../../../types";
import "./entity-preview-row";
import { debounce } from "../../../common/util/debounce";
import { fireEvent } from "../../../common/dom/fire_event";

@customElement("flow-preview-threshold")
class FlowPreviewThreshold extends LitElement {
@customElement("flow-preview-generic")
class FlowPreviewGeneric extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;

@property() public flowType!: FlowType;

public handler!: string;

@property() public domain!: string;

@property() public stepId!: string;

@property() public flowId!: string;
Expand Down Expand Up @@ -55,7 +54,7 @@ class FlowPreviewThreshold extends LitElement {
></entity-preview-row>`;
}

private _setPreview = (preview: ThresholdPreview) => {
private _setPreview = (preview: GenericPreview) => {
const now = new Date().toISOString();
this._preview = {
entity_id: `${this.stepId}.___flow_preview___`,
Expand All @@ -79,14 +78,14 @@ class FlowPreviewThreshold extends LitElement {
return;
}
try {
this._unsub = subscribePreviewThreshold(
this._unsub = subscribePreviewGeneric(
this.hass,
this.domain,
this.flowId,
this.flowType,
this.stepData,
this._setPreview
);
await this._unsub;
fireEvent(this, "set-flow-errors", { errors: {} });
} catch (err: any) {
if (typeof err.message === "string") {
Expand All @@ -103,6 +102,6 @@ class FlowPreviewThreshold extends LitElement {

declare global {
interface HTMLElementTagNameMap {
"flow-preview-threshold": FlowPreviewThreshold;
"flow-preview-generic": FlowPreviewGeneric;
}
}
90 changes: 0 additions & 90 deletions src/dialogs/config-flow/previews/flow-preview-group.ts

This file was deleted.

Loading

0 comments on commit 5dd82ca

Please sign in to comment.