mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 02:36:37 +00:00
Move data_entry_flow_progressed event subscriber (#7700)
This commit is contained in:
parent
af1518e924
commit
8fd1f35c59
@ -22,7 +22,10 @@ import {
|
|||||||
AreaRegistryEntry,
|
AreaRegistryEntry,
|
||||||
subscribeAreaRegistry,
|
subscribeAreaRegistry,
|
||||||
} from "../../data/area_registry";
|
} from "../../data/area_registry";
|
||||||
import type { DataEntryFlowStep } from "../../data/data_entry_flow";
|
import type {
|
||||||
|
DataEntryFlowProgressedEvent,
|
||||||
|
DataEntryFlowStep,
|
||||||
|
} from "../../data/data_entry_flow";
|
||||||
import {
|
import {
|
||||||
DeviceRegistryEntry,
|
DeviceRegistryEntry,
|
||||||
subscribeDeviceRegistry,
|
subscribeDeviceRegistry,
|
||||||
@ -224,6 +227,19 @@ class DataEntryFlowDialog extends LitElement {
|
|||||||
|
|
||||||
protected firstUpdated(changedProps: PropertyValues) {
|
protected firstUpdated(changedProps: PropertyValues) {
|
||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
|
this.hass.connection.subscribeEvents<DataEntryFlowProgressedEvent>(
|
||||||
|
async (ev) => {
|
||||||
|
if (ev.data.flow_id !== this._step?.flow_id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const step = await this._params!.flowConfig.fetchFlow(
|
||||||
|
this.hass,
|
||||||
|
this._step?.flow_id
|
||||||
|
);
|
||||||
|
this._processStep(step);
|
||||||
|
},
|
||||||
|
"data_entry_flow_progressed"
|
||||||
|
);
|
||||||
this.addEventListener("flow-update", (ev) => {
|
this.addEventListener("flow-update", (ev) => {
|
||||||
const { step, stepPromise } = (ev as any).detail;
|
const { step, stepPromise } = (ev as any).detail;
|
||||||
this._processStep(step || stepPromise);
|
this._processStep(step || stepPromise);
|
||||||
|
@ -8,11 +8,7 @@ import {
|
|||||||
property,
|
property,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { DataEntryFlowStepExternal } from "../../data/data_entry_flow";
|
||||||
import {
|
|
||||||
DataEntryFlowProgressedEvent,
|
|
||||||
DataEntryFlowStepExternal,
|
|
||||||
} from "../../data/data_entry_flow";
|
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import { FlowConfig } from "./show-dialog-data-entry-flow";
|
import { FlowConfig } from "./show-dialog-data-entry-flow";
|
||||||
import { configFlowContentStyles } from "./styles";
|
import { configFlowContentStyles } from "./styles";
|
||||||
@ -51,18 +47,6 @@ class StepFlowExternal extends LitElement {
|
|||||||
|
|
||||||
protected firstUpdated(changedProps) {
|
protected firstUpdated(changedProps) {
|
||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
this.hass.connection.subscribeEvents<DataEntryFlowProgressedEvent>(
|
|
||||||
async (ev) => {
|
|
||||||
if (ev.data.flow_id !== this.step.flow_id) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fireEvent(this, "flow-update", {
|
|
||||||
stepPromise: this.flowConfig.fetchFlow(this.hass, this.step.flow_id),
|
|
||||||
});
|
|
||||||
},
|
|
||||||
"data_entry_flow_progressed"
|
|
||||||
);
|
|
||||||
window.open(this.step.url);
|
window.open(this.step.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,12 +8,8 @@ import {
|
|||||||
property,
|
property,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
|
||||||
import "../../components/ha-circular-progress";
|
import "../../components/ha-circular-progress";
|
||||||
import {
|
import { DataEntryFlowStepProgress } from "../../data/data_entry_flow";
|
||||||
DataEntryFlowProgressedEvent,
|
|
||||||
DataEntryFlowStepProgress,
|
|
||||||
} from "../../data/data_entry_flow";
|
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import { FlowConfig } from "./show-dialog-data-entry-flow";
|
import { FlowConfig } from "./show-dialog-data-entry-flow";
|
||||||
import { configFlowContentStyles } from "./styles";
|
import { configFlowContentStyles } from "./styles";
|
||||||
@ -43,22 +39,6 @@ class StepFlowProgress extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected firstUpdated(changedProps) {
|
|
||||||
super.firstUpdated(changedProps);
|
|
||||||
this.hass.connection.subscribeEvents<DataEntryFlowProgressedEvent>(
|
|
||||||
async (ev) => {
|
|
||||||
if (ev.data.flow_id !== this.step.flow_id) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fireEvent(this, "flow-update", {
|
|
||||||
stepPromise: this.flowConfig.fetchFlow(this.hass, this.step.flow_id),
|
|
||||||
});
|
|
||||||
},
|
|
||||||
"data_entry_flow_progressed"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static get styles(): CSSResult[] {
|
static get styles(): CSSResult[] {
|
||||||
return [
|
return [
|
||||||
configFlowContentStyles,
|
configFlowContentStyles,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user