mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +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";
|
||||
|
||||
export const integrationsWithPanel = {
|
||||
matter: "/config/matter",
|
||||
mqtt: "/config/mqtt",
|
||||
thread: "/config/thread",
|
||||
zha: "/config/zha/dashboard",
|
||||
zwave_js: "/config/zwave_js/dashboard",
|
||||
matter: "config/matter",
|
||||
mqtt: "config/mqtt",
|
||||
thread: "config/thread",
|
||||
zha: "config/zha/dashboard",
|
||||
zwave_js: "config/zwave_js/dashboard",
|
||||
};
|
||||
|
||||
export type IntegrationType =
|
||||
|
@ -135,6 +135,13 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
||||
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(
|
||||
(domain: string, configEntries?: ConfigEntry[]): ConfigEntry[] =>
|
||||
configEntries
|
||||
@ -638,6 +645,8 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
||||
}
|
||||
}
|
||||
|
||||
const configPanel = this._configPanel(item.domain, this.hass.panels);
|
||||
|
||||
return html`<ha-list-item
|
||||
hasMeta
|
||||
class="config_entry ${classMap({
|
||||
@ -669,13 +678,11 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
||||
? html`<mwc-button unelevated slot="meta" @click=${this._handleEnable}>
|
||||
${this.hass.localize("ui.common.enable")}
|
||||
</mwc-button>`
|
||||
: item.domain in integrationsWithPanel &&
|
||||
: configPanel &&
|
||||
(item.domain !== "matter" || isDevVersion(this.hass.config.version))
|
||||
? html`<a
|
||||
slot="meta"
|
||||
href=${`${integrationsWithPanel[item.domain]}?config_entry=${
|
||||
item.entry_id
|
||||
}`}
|
||||
href=${`/${configPanel}?config_entry=${item.entry_id}`}
|
||||
><mwc-button>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.integrations.config_entry.configure"
|
||||
|
@ -120,6 +120,7 @@ export interface PanelInfo<T = Record<string, any> | null> {
|
||||
icon: string | null;
|
||||
title: string | null;
|
||||
url_path: string;
|
||||
config_panel_domain?: string;
|
||||
}
|
||||
|
||||
export interface Panels {
|
||||
|
Loading…
x
Reference in New Issue
Block a user