Add button to MQTT options flow (#6217)

This commit is contained in:
Bram Kragten 2020-06-23 18:51:08 +02:00 committed by GitHub
parent 46bf5cf830
commit e21efc0a5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 4 deletions

View File

@ -15,6 +15,8 @@ import { haStyle } from "../../../../../resources/styles";
import { HomeAssistant } from "../../../../../types"; import { HomeAssistant } from "../../../../../types";
import "./mqtt-subscribe-card"; import "./mqtt-subscribe-card";
import "../../../../../layouts/hass-subpage"; import "../../../../../layouts/hass-subpage";
import { showOptionsFlowDialog } from "../../../../../dialogs/config-flow/show-dialog-options-flow";
import { getConfigEntries } from "../../../../../data/config_entries";
@customElement("mqtt-config-panel") @customElement("mqtt-config-panel")
class HaPanelDevMqtt extends LitElement { class HaPanelDevMqtt extends LitElement {
@ -40,6 +42,13 @@ class HaPanelDevMqtt extends LitElement {
return html` return html`
<hass-subpage> <hass-subpage>
<div class="content"> <div class="content">
<ha-card header="MQTT settings">
<div class="card-actions">
<mwc-button @click=${this._openOptionFlow}
>Re-configure MQTT</mwc-button
>
</div>
</ha-card>
<ha-card <ha-card
header="${this.hass.localize( header="${this.hass.localize(
"ui.panel.config.mqtt.description_publish" "ui.panel.config.mqtt.description_publish"
@ -100,6 +109,19 @@ class HaPanelDevMqtt extends LitElement {
}); });
} }
private async _openOptionFlow() {
const searchParams = new URLSearchParams(window.location.search);
if (!searchParams.has("config_entry")) {
return;
}
const configEntryId = searchParams.get("config_entry") as string;
const configEntries = await getConfigEntries(this.hass);
const configEntry = configEntries.find(
(entry) => entry.entry_id === configEntryId
);
showOptionsFlowDialog(this, configEntry!);
}
static get styles(): CSSResultArray { static get styles(): CSSResultArray {
return [ return [
haStyle, haStyle,
@ -116,7 +138,9 @@ class HaPanelDevMqtt extends LitElement {
margin: 0 auto; margin: 0 auto;
direction: ltr; direction: ltr;
} }
ha-card:first-child {
margin-bottom: 16px;
}
mqtt-subscribe-card { mqtt-subscribe-card {
display: block; display: block;
margin: 16px auto; margin: 16px auto;

View File

@ -56,19 +56,27 @@ class ZHAConfigDashboard extends LitElement {
> >
<ha-card header="Zigbee Network"> <ha-card header="Zigbee Network">
<div class="card-content"> <div class="card-content">
Network info/settings for specific config entry In the future you can change network settings for ZHA here.
</div> </div>
${this.configEntryId ${this.configEntryId
? html`<div class="card-actions"> ? html`<div class="card-actions">
<a <a
href="${`/config/devices/dashboard?historyBack=1&config_entry=${this.configEntryId}`}" href="${`/config/devices/dashboard?historyBack=1&config_entry=${this.configEntryId}`}"
> >
<mwc-button>Devices</mwc-button> <mwc-button
>${this.hass.localize(
"ui.panel.config.devices.caption"
)}</mwc-button
>
</a> </a>
<a <a
href="${`/config/entities/dashboard?historyBack=1&config_entry=${this.configEntryId}`}" href="${`/config/entities/dashboard?historyBack=1&config_entry=${this.configEntryId}`}"
> >
<mwc-button>Entities</mwc-button> <mwc-button
>${this.hass.localize(
"ui.panel.config.entities.caption"
)}</mwc-button
>
</a> </a>
</div>` </div>`
: ""} : ""}