mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 11:16:35 +00:00
Move get dialog logic entity registry (#4579)
This commit is contained in:
parent
8abe8d7615
commit
0c0e82a3ba
@ -60,6 +60,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
||||
@property() private _filter = "";
|
||||
@property() private _selectedEntities: string[] = [];
|
||||
@query("ha-data-table") private _dataTable!: HaDataTable;
|
||||
private getDialog?: () => DialogEntityRegistryDetail | undefined;
|
||||
|
||||
private _columns = memoize(
|
||||
(narrow, _language): DataTableColumnContainer => {
|
||||
@ -206,14 +207,14 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
||||
|
||||
public disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
const dialog = document
|
||||
.querySelector("home-assistant")!
|
||||
.shadowRoot!.querySelector("dialog-entity-registry-detail") as
|
||||
| DialogEntityRegistryDetail
|
||||
| undefined;
|
||||
if (dialog) {
|
||||
dialog.closeDialog();
|
||||
if (!this.getDialog) {
|
||||
return;
|
||||
}
|
||||
const dialog = this.getDialog();
|
||||
if (!dialog) {
|
||||
return;
|
||||
}
|
||||
dialog.closeDialog();
|
||||
}
|
||||
|
||||
protected render(): TemplateResult | void {
|
||||
@ -482,7 +483,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
||||
if (!entry) {
|
||||
return;
|
||||
}
|
||||
showEntityRegistryDetailDialog(this, {
|
||||
this.getDialog = showEntityRegistryDetailDialog(this, {
|
||||
entry,
|
||||
});
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import { EntityRegistryEntry } from "../../../data/entity_registry";
|
||||
import { DialogEntityRegistryDetail } from "./dialog-entity-registry-detail";
|
||||
|
||||
export interface EntityRegistryDetailDialogParams {
|
||||
entry: EntityRegistryEntry;
|
||||
@ -10,13 +11,22 @@ export const loadEntityRegistryDetailDialog = () =>
|
||||
/* webpackChunkName: "entity-registry-detail-dialog" */ "./dialog-entity-registry-detail"
|
||||
);
|
||||
|
||||
const getDialog = () => {
|
||||
return document
|
||||
.querySelector("home-assistant")!
|
||||
.shadowRoot!.querySelector("dialog-entity-registry-detail") as
|
||||
| DialogEntityRegistryDetail
|
||||
| undefined;
|
||||
};
|
||||
|
||||
export const showEntityRegistryDetailDialog = (
|
||||
element: HTMLElement,
|
||||
systemLogDetailParams: EntityRegistryDetailDialogParams
|
||||
): void => {
|
||||
): (() => DialogEntityRegistryDetail | undefined) => {
|
||||
fireEvent(element, "show-dialog", {
|
||||
dialogTag: "dialog-entity-registry-detail",
|
||||
dialogImport: loadEntityRegistryDetailDialog,
|
||||
dialogParams: systemLogDetailParams,
|
||||
});
|
||||
return getDialog;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user