diff --git a/src/dialogs/config-flow/dialog-data-entry-flow.ts b/src/dialogs/config-flow/dialog-data-entry-flow.ts index 415be7f833..7654a0b506 100644 --- a/src/dialogs/config-flow/dialog-data-entry-flow.ts +++ b/src/dialogs/config-flow/dialog-data-entry-flow.ts @@ -309,7 +309,7 @@ class DataEntryFlowDialog extends LitElement { : this._step.type === "abort" ? html` void; flowConfig: FlowConfig; showAdvanced?: boolean; + dialogParentElement?: HTMLElement; } export const loadDataEntryFlowDialog = () => import("./dialog-data-entry-flow"); @@ -146,6 +147,7 @@ export const showFlowDialog = ( dialogParams: { ...dialogParams, flowConfig, + dialogParentElement: element, }, }); }; diff --git a/src/dialogs/config-flow/step-flow-abort.ts b/src/dialogs/config-flow/step-flow-abort.ts index 79581e366a..e1909d0bfe 100644 --- a/src/dialogs/config-flow/step-flow-abort.ts +++ b/src/dialogs/config-flow/step-flow-abort.ts @@ -1,15 +1,25 @@ import "@material/mwc-button"; -import { CSSResultGroup, html, LitElement, TemplateResult } from "lit"; +import { + CSSResultGroup, + html, + LitElement, + TemplateResult, + PropertyValues, +} from "lit"; import { customElement, property } from "lit/decorators"; import { fireEvent } from "../../common/dom/fire_event"; import { DataEntryFlowStepAbort } from "../../data/data_entry_flow"; import { HomeAssistant } from "../../types"; -import { FlowConfig } from "./show-dialog-data-entry-flow"; +import { showAddApplicationCredentialDialog } from "../../panels/config/application_credentials/show-dialog-add-application-credential"; import { configFlowContentStyles } from "./styles"; +import { showConfirmationDialog } from "../generic/show-dialog-box"; +import { domainToName } from "../../data/integration"; +import { DataEntryFlowDialogParams } from "./show-dialog-data-entry-flow"; +import { showConfigFlowDialog } from "./show-dialog-config-flow"; @customElement("step-flow-abort") class StepFlowAbort extends LitElement { - @property({ attribute: false }) public flowConfig!: FlowConfig; + @property({ attribute: false }) public params!: DataEntryFlowDialogParams; @property({ attribute: false }) public hass!: HomeAssistant; @@ -17,11 +27,21 @@ class StepFlowAbort extends LitElement { @property({ attribute: false }) public domain!: string; + protected firstUpdated(changed: PropertyValues) { + super.firstUpdated(changed); + if (this.step.reason === "missing_credentials") { + this._handleMissingCreds(); + } + } + protected render(): TemplateResult { + if (this.step.reason === "missing_credentials") { + return html``; + } return html`

${this.hass.localize(`component.${this.domain}.title`)}

- ${this.flowConfig.renderAbortDescription(this.hass, this.step)} + ${this.params.flowConfig.renderAbortDescription(this.hass, this.step)}
{ + showConfigFlowDialog(this.params.dialogParentElement!, { + dialogClosedCallback: this.params.dialogClosedCallback, + startFlowHandler: this.domain, + showAdvanced: this.hass.userData?.showAdvanced, + }); + }, + }); + } + private _flowDone(): void { fireEvent(this, "flow-update", { step: undefined }); } diff --git a/src/panels/config/application_credentials/dialog-add-application-credential.ts b/src/panels/config/application_credentials/dialog-add-application-credential.ts index eccf71e4fe..9face54d7e 100644 --- a/src/panels/config/application_credentials/dialog-add-application-credential.ts +++ b/src/panels/config/application_credentials/dialog-add-application-credential.ts @@ -51,7 +51,8 @@ export class DialogAddApplicationCredential extends LitElement { public showDialog(params: AddApplicationCredentialDialogParams) { this._params = params; - this._domain = ""; + this._domain = + params.selectedDomain !== undefined ? params.selectedDomain : ""; this._name = ""; this._clientId = ""; this._clientSecret = ""; @@ -75,7 +76,7 @@ export class DialogAddApplicationCredential extends LitElement { return html` void; + dialogAbortedCallback?: () => void; + selectedDomain?: string; } export const loadAddApplicationCredentialDialog = () => diff --git a/src/translations/en.json b/src/translations/en.json index 08a5a407f8..63010bcb35 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -2825,7 +2825,8 @@ }, "error": "Error", "could_not_load": "Config flow could not be loaded", - "not_loaded": "The integration could not be loaded, try to restart Home Assistant." + "not_loaded": "The integration could not be loaded, try to restart Home Assistant.", + "missing_credentials": "Setting up {integration} requires configuring application credentials. Do you want to do that now?" } }, "users": {