Skip to content

Commit 2a8d935

Browse files
authored
Migrate dialog-device-registry-detail to ha-wa-dialog (#27668)
1 parent a6328fb commit 2a8d935

File tree

1 file changed

+35
-22
lines changed

1 file changed

+35
-22
lines changed

src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { fireEvent } from "../../../../common/dom/fire_event";
55
import { computeDeviceNameDisplay } from "../../../../common/entity/compute_device_name";
66
import "../../../../components/ha-alert";
77
import "../../../../components/ha-area-picker";
8-
import "../../../../components/ha-dialog";
8+
import "../../../../components/ha-wa-dialog";
9+
import "../../../../components/ha-dialog-footer";
910
import "../../../../components/ha-button";
1011
import "../../../../components/ha-labels-picker";
1112
import type { HaSwitch } from "../../../../components/ha-switch";
@@ -19,6 +20,8 @@ import type { DeviceRegistryDetailDialogParams } from "./show-dialog-device-regi
1920
class DialogDeviceRegistryDetail extends LitElement {
2021
@property({ attribute: false }) public hass!: HomeAssistant;
2122

23+
@state() private _open = false;
24+
2225
@state() private _nameByUser!: string;
2326

2427
@state() private _error?: string;
@@ -42,10 +45,15 @@ class DialogDeviceRegistryDetail extends LitElement {
4245
this._areaId = this._params.device.area_id || "";
4346
this._labels = this._params.device.labels || [];
4447
this._disabledBy = this._params.device.disabled_by;
48+
this._open = true;
4549
await this.updateComplete;
4650
}
4751

4852
public closeDialog(): void {
53+
this._open = false;
54+
}
55+
56+
private _dialogClosed(): void {
4957
this._error = "";
5058
this._params = undefined;
5159
fireEvent(this, "dialog-closed", { dialog: this.localName });
@@ -57,25 +65,27 @@ class DialogDeviceRegistryDetail extends LitElement {
5765
}
5866
const device = this._params.device;
5967
return html`
60-
<ha-dialog
61-
open
62-
@closed=${this.closeDialog}
63-
.heading=${computeDeviceNameDisplay(device, this.hass)}
68+
<ha-wa-dialog
69+
.hass=${this.hass}
70+
.open=${this._open}
71+
header-title=${computeDeviceNameDisplay(device, this.hass)}
72+
prevent-scrim-close
73+
@closed=${this._dialogClosed}
6474
>
6575
<div>
6676
${this._error
6777
? html`<ha-alert alert-type="error">${this._error}</ha-alert> `
6878
: ""}
6979
<div class="form">
7080
<ha-textfield
81+
autofocus
7182
.value=${this._nameByUser}
7283
@input=${this._nameChanged}
7384
.label=${this.hass.localize(
7485
"ui.dialogs.device-registry-detail.name"
7586
)}
7687
.placeholder=${device.name || ""}
7788
.disabled=${this._submitting}
78-
dialogInitialFocus
7989
></ha-textfield>
8090
<ha-area-picker
8191
.hass=${this.hass}
@@ -131,22 +141,25 @@ class DialogDeviceRegistryDetail extends LitElement {
131141
</div>
132142
</div>
133143
</div>
134-
<ha-button
135-
slot="secondaryAction"
136-
@click=${this.closeDialog}
137-
.disabled=${this._submitting}
138-
appearance="plain"
139-
>
140-
${this.hass.localize("ui.common.cancel")}
141-
</ha-button>
142-
<ha-button
143-
slot="primaryAction"
144-
@click=${this._updateEntry}
145-
.disabled=${this._submitting}
146-
>
147-
${this.hass.localize("ui.dialogs.device-registry-detail.update")}
148-
</ha-button>
149-
</ha-dialog>
144+
145+
<ha-dialog-footer slot="footer">
146+
<ha-button
147+
slot="secondaryAction"
148+
@click=${this.closeDialog}
149+
.disabled=${this._submitting}
150+
appearance="plain"
151+
>
152+
${this.hass.localize("ui.common.cancel")}
153+
</ha-button>
154+
<ha-button
155+
slot="primaryAction"
156+
@click=${this._updateEntry}
157+
.disabled=${this._submitting}
158+
>
159+
${this.hass.localize("ui.dialogs.device-registry-detail.update")}
160+
</ha-button>
161+
</ha-dialog-footer>
162+
</ha-wa-dialog>
150163
`;
151164
}
152165

0 commit comments

Comments
 (0)