mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-14 04:46:34 +00:00
Add my
support for brands (#13909)
This commit is contained in:
parent
c17e8ba65a
commit
8ccd0426dd
@ -38,6 +38,7 @@ import type { HomeAssistant } from "../../../types";
|
|||||||
import { documentationUrl } from "../../../util/documentation-url";
|
import { documentationUrl } from "../../../util/documentation-url";
|
||||||
import "./ha-domain-integrations";
|
import "./ha-domain-integrations";
|
||||||
import "./ha-integration-list-item";
|
import "./ha-integration-list-item";
|
||||||
|
import { AddIntegrationDialogParams } from "./show-add-integration-dialog";
|
||||||
|
|
||||||
export interface IntegrationListItem {
|
export interface IntegrationListItem {
|
||||||
name: string;
|
name: string;
|
||||||
@ -78,8 +79,9 @@ class AddIntegrationDialog extends LitElement {
|
|||||||
|
|
||||||
private _height?: number;
|
private _height?: number;
|
||||||
|
|
||||||
public showDialog(params): void {
|
public showDialog(params: AddIntegrationDialogParams): void {
|
||||||
this._open = true;
|
this._open = true;
|
||||||
|
this._pickedBrand = params.brand;
|
||||||
this._initialFilter = params.initialFilter;
|
this._initialFilter = params.initialFilter;
|
||||||
this._narrow = matchMedia(
|
this._narrow = matchMedia(
|
||||||
"all and (max-width: 450px), all and (max-height: 500px)"
|
"all and (max-width: 450px), all and (max-height: 500px)"
|
||||||
|
@ -678,8 +678,16 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async _handleAdd(localizePromise: Promise<LocalizeFunc>) {
|
private async _handleAdd(localizePromise: Promise<LocalizeFunc>) {
|
||||||
|
const brand = extractSearchParam("brand");
|
||||||
const domain = extractSearchParam("domain");
|
const domain = extractSearchParam("domain");
|
||||||
navigate("/config/integrations", { replace: true });
|
navigate("/config/integrations", { replace: true });
|
||||||
|
|
||||||
|
if (brand) {
|
||||||
|
showAddIntegrationDialog(this, {
|
||||||
|
brand,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!domain) {
|
if (!domain) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -714,14 +722,14 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
// Supported brand exists, so we can just create a flow
|
// Supported brand exists, so we can just create a flow
|
||||||
if (Object.keys(supportedBrandsIntegrations).includes(domain)) {
|
if (Object.keys(supportedBrandsIntegrations).includes(domain)) {
|
||||||
const brand = supportedBrandsIntegrations[domain];
|
const supBrand = supportedBrandsIntegrations[domain];
|
||||||
const slug = brand.supported_flows![0];
|
const slug = supBrand.supported_flows![0];
|
||||||
|
|
||||||
showConfirmationDialog(this, {
|
showConfirmationDialog(this, {
|
||||||
text: this.hass.localize(
|
text: this.hass.localize(
|
||||||
"ui.panel.config.integrations.config_flow.supported_brand_flow",
|
"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),
|
flow_domain_name: domainToName(this.hass.localize, slug),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
|
|
||||||
|
export interface AddIntegrationDialogParams {
|
||||||
|
brand?: string;
|
||||||
|
initialFilter?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export const showAddIntegrationDialog = (
|
export const showAddIntegrationDialog = (
|
||||||
element: HTMLElement,
|
element: HTMLElement,
|
||||||
dialogParams?: any
|
dialogParams?: AddIntegrationDialogParams
|
||||||
): void => {
|
): void => {
|
||||||
fireEvent(element, "show-dialog", {
|
fireEvent(element, "show-dialog", {
|
||||||
dialogTag: "dialog-add-integration",
|
dialogTag: "dialog-add-integration",
|
||||||
|
@ -53,6 +53,12 @@ export const getMyRedirects = (hasSupervisor: boolean): Redirects => ({
|
|||||||
domain: "string",
|
domain: "string",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
brand: {
|
||||||
|
redirect: "/config/integrations/add",
|
||||||
|
params: {
|
||||||
|
brand: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
integrations: {
|
integrations: {
|
||||||
redirect: "/config/integrations",
|
redirect: "/config/integrations",
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user