Fix my link add integration: search for discovered items (#16315)

* fix my link add integration

* add confirm back

* Update dialog-add-integration.ts
This commit is contained in:
Bram Kragten 2023-04-26 12:02:50 +02:00 committed by GitHub
parent 10d476195d
commit 63de324224
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 20 deletions

View File

@ -92,14 +92,24 @@ class AddIntegrationDialog extends LitElement {
private _height?: number;
public showDialog(params?: AddIntegrationDialogParams): void {
this._load();
public async showDialog(params?: AddIntegrationDialogParams): Promise<void> {
const loadPromise = this._load();
this._open = true;
this._pickedBrand = params?.brand;
this._initialFilter = params?.initialFilter;
this._narrow = matchMedia(
"all and (max-width: 450px), all and (max-height: 500px)"
).matches;
if (params?.domain) {
this._createFlow(params.domain);
}
if (params?.brand) {
await loadPromise;
const brand = this._integrations?.[params.brand];
if (brand && "integrations" in brand && brand.integrations) {
this._fetchFlowsInProgress(Object.keys(brand.integrations));
}
}
}
public closeDialog() {
@ -543,7 +553,7 @@ class AddIntegrationDialog extends LitElement {
}
if (integration.config_flow) {
this._createFlow(integration);
this._createFlow(integration.domain);
return;
}
@ -563,25 +573,20 @@ class AddIntegrationDialog extends LitElement {
showYamlIntegrationDialog(this, { manifest });
}
private async _createFlow(integration: IntegrationListItem) {
const flowsInProgress = await this._fetchFlowsInProgress([
integration.domain,
]);
private async _createFlow(domain: string) {
const flowsInProgress = await this._fetchFlowsInProgress([domain]);
if (flowsInProgress?.length) {
this._pickedBrand = integration.domain;
this._pickedBrand = domain;
return;
}
const manifest = await fetchIntegrationManifest(
this.hass,
integration.domain
);
const manifest = await fetchIntegrationManifest(this.hass, domain);
this.closeDialog();
showConfigFlowDialog(this, {
startFlowHandler: integration.domain,
startFlowHandler: domain,
showAdvanced: this.hass.userData?.showAdvanced,
manifest,
});

View File

@ -731,13 +731,8 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
}),
})
) {
showConfigFlowDialog(this, {
dialogClosedCallback: () => {
this._handleFlowUpdated();
},
startFlowHandler: domain,
manifest: await fetchIntegrationManifest(this.hass, domain),
showAdvanced: this.hass.userData?.showAdvanced,
showAddIntegrationDialog(this, {
domain,
});
}
return;

View File

@ -3,6 +3,7 @@ import { IntegrationManifest } from "../../../data/integration";
export interface AddIntegrationDialogParams {
brand?: string;
domain?: string;
initialFilter?: string;
}