Add my support for brands (#13909)

This commit is contained in:
Bram Kragten 2022-09-29 02:34:11 +02:00 committed by GitHub
parent c17e8ba65a
commit 8ccd0426dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 5 deletions

View File

@ -38,6 +38,7 @@ import type { HomeAssistant } from "../../../types";
import { documentationUrl } from "../../../util/documentation-url";
import "./ha-domain-integrations";
import "./ha-integration-list-item";
import { AddIntegrationDialogParams } from "./show-add-integration-dialog";
export interface IntegrationListItem {
name: string;
@ -78,8 +79,9 @@ class AddIntegrationDialog extends LitElement {
private _height?: number;
public showDialog(params): void {
public showDialog(params: AddIntegrationDialogParams): void {
this._open = true;
this._pickedBrand = params.brand;
this._initialFilter = params.initialFilter;
this._narrow = matchMedia(
"all and (max-width: 450px), all and (max-height: 500px)"

View File

@ -678,8 +678,16 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
}
private async _handleAdd(localizePromise: Promise<LocalizeFunc>) {
const brand = extractSearchParam("brand");
const domain = extractSearchParam("domain");
navigate("/config/integrations", { replace: true });
if (brand) {
showAddIntegrationDialog(this, {
brand,
});
return;
}
if (!domain) {
return;
}
@ -714,14 +722,14 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
// Supported brand exists, so we can just create a flow
if (Object.keys(supportedBrandsIntegrations).includes(domain)) {
const brand = supportedBrandsIntegrations[domain];
const slug = brand.supported_flows![0];
const supBrand = supportedBrandsIntegrations[domain];
const slug = supBrand.supported_flows![0];
showConfirmationDialog(this, {
text: this.hass.localize(
"ui.panel.config.integrations.config_flow.supported_brand_flow",
{
supported_brand: brand.name,
supported_brand: supBrand.name,
flow_domain_name: domainToName(this.hass.localize, slug),
}
),

View File

@ -1,8 +1,13 @@
import { fireEvent } from "../../../common/dom/fire_event";
export interface AddIntegrationDialogParams {
brand?: string;
initialFilter?: string;
}
export const showAddIntegrationDialog = (
element: HTMLElement,
dialogParams?: any
dialogParams?: AddIntegrationDialogParams
): void => {
fireEvent(element, "show-dialog", {
dialogTag: "dialog-add-integration",

View File

@ -53,6 +53,12 @@ export const getMyRedirects = (hasSupervisor: boolean): Redirects => ({
domain: "string",
},
},
brand: {
redirect: "/config/integrations/add",
params: {
brand: "string",
},
},
integrations: {
redirect: "/config/integrations",
},