mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 18:56:39 +00:00
Add support for registering config panels (#17296)
This commit is contained in:
parent
0ce93263e9
commit
d7e58a00ca
@ -4,11 +4,11 @@ import { HomeAssistant } from "../types";
|
|||||||
import { debounce } from "../common/util/debounce";
|
import { debounce } from "../common/util/debounce";
|
||||||
|
|
||||||
export const integrationsWithPanel = {
|
export const integrationsWithPanel = {
|
||||||
matter: "/config/matter",
|
matter: "config/matter",
|
||||||
mqtt: "/config/mqtt",
|
mqtt: "config/mqtt",
|
||||||
thread: "/config/thread",
|
thread: "config/thread",
|
||||||
zha: "/config/zha/dashboard",
|
zha: "config/zha/dashboard",
|
||||||
zwave_js: "/config/zwave_js/dashboard",
|
zwave_js: "config/zwave_js/dashboard",
|
||||||
};
|
};
|
||||||
|
|
||||||
export type IntegrationType =
|
export type IntegrationType =
|
||||||
|
@ -135,6 +135,13 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
|||||||
window.location.hash.substring(1)
|
window.location.hash.substring(1)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private _configPanel = memoizeOne(
|
||||||
|
(domain: string, panels: HomeAssistant["panels"]): string | undefined =>
|
||||||
|
Object.values(panels).find(
|
||||||
|
(panel) => panel.config_panel_domain === domain
|
||||||
|
)?.url_path || integrationsWithPanel[domain]
|
||||||
|
);
|
||||||
|
|
||||||
private _domainConfigEntries = memoizeOne(
|
private _domainConfigEntries = memoizeOne(
|
||||||
(domain: string, configEntries?: ConfigEntry[]): ConfigEntry[] =>
|
(domain: string, configEntries?: ConfigEntry[]): ConfigEntry[] =>
|
||||||
configEntries
|
configEntries
|
||||||
@ -638,6 +645,8 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const configPanel = this._configPanel(item.domain, this.hass.panels);
|
||||||
|
|
||||||
return html`<ha-list-item
|
return html`<ha-list-item
|
||||||
hasMeta
|
hasMeta
|
||||||
class="config_entry ${classMap({
|
class="config_entry ${classMap({
|
||||||
@ -669,13 +678,11 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
|||||||
? html`<mwc-button unelevated slot="meta" @click=${this._handleEnable}>
|
? html`<mwc-button unelevated slot="meta" @click=${this._handleEnable}>
|
||||||
${this.hass.localize("ui.common.enable")}
|
${this.hass.localize("ui.common.enable")}
|
||||||
</mwc-button>`
|
</mwc-button>`
|
||||||
: item.domain in integrationsWithPanel &&
|
: configPanel &&
|
||||||
(item.domain !== "matter" || isDevVersion(this.hass.config.version))
|
(item.domain !== "matter" || isDevVersion(this.hass.config.version))
|
||||||
? html`<a
|
? html`<a
|
||||||
slot="meta"
|
slot="meta"
|
||||||
href=${`${integrationsWithPanel[item.domain]}?config_entry=${
|
href=${`/${configPanel}?config_entry=${item.entry_id}`}
|
||||||
item.entry_id
|
|
||||||
}`}
|
|
||||||
><mwc-button>
|
><mwc-button>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.integrations.config_entry.configure"
|
"ui.panel.config.integrations.config_entry.configure"
|
||||||
|
@ -120,6 +120,7 @@ export interface PanelInfo<T = Record<string, any> | null> {
|
|||||||
icon: string | null;
|
icon: string | null;
|
||||||
title: string | null;
|
title: string | null;
|
||||||
url_path: string;
|
url_path: string;
|
||||||
|
config_panel_domain?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Panels {
|
export interface Panels {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user