Allow configuration_url to point to an internal panel (#10395)

This commit is contained in:
Joakim Sørensen 2021-10-26 13:24:08 +02:00 committed by GitHub
parent 32ac04ea78
commit 63cd576d56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -195,6 +195,13 @@ export class HaConfigDevicePage extends LitElement {
: undefined; : undefined;
const area = this._computeArea(this.areas, device); const area = this._computeArea(this.areas, device);
const configurationUrlIsHomeAssistant =
device.configuration_url?.startsWith("homeassistant://") || false;
const configurationUrl = configurationUrlIsHomeAssistant
? device.configuration_url!.replace("homeassistant://", "/")
: device.configuration_url;
return html` return html`
<hass-tabs-subpage <hass-tabs-subpage
.hass=${this.hass} .hass=${this.hass}
@ -316,13 +323,15 @@ export class HaConfigDevicePage extends LitElement {
: html`` : html``
} }
${ ${
device.configuration_url configurationUrl
? html` ? html`
<div class="card-actions" slot="actions"> <div class="card-actions" slot="actions">
<a <a
href=${device.configuration_url} href=${configurationUrl}
target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
.target=${configurationUrlIsHomeAssistant
? "_self"
: "_blank"}
> >
<mwc-button> <mwc-button>
${this.hass.localize( ${this.hass.localize(