Open external device configuration url to a new tab/window (#13613)

* Open external device configuration url to a new tab/window

* Remove rel in action options
This commit is contained in:
Paul Bottein 2022-09-06 12:24:03 +02:00 committed by GitHub
parent 00bc315fc1
commit 66db8c999f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -80,6 +80,7 @@ export interface EntityRegistryStateEntry extends EntityRegistryEntry {
export interface DeviceAction { export interface DeviceAction {
href?: string; href?: string;
target?: string;
action?: (ev: any) => void; action?: (ev: any) => void;
label: string; label: string;
icon?: string; icon?: string;
@ -699,7 +700,15 @@ export class HaConfigDevicePage extends LitElement {
? html` ? html`
<div class="card-actions" slot="actions"> <div class="card-actions" slot="actions">
<div> <div>
<a href=${ifDefined(firstDeviceAction!.href)}> <a
href=${ifDefined(firstDeviceAction!.href)}
rel=${ifDefined(
firstDeviceAction!.target
? "noreferrer"
: undefined
)}
target=${ifDefined(firstDeviceAction!.target)}
>
<mwc-button <mwc-button
class=${ifDefined(firstDeviceAction!.classes)} class=${ifDefined(firstDeviceAction!.classes)}
.action=${firstDeviceAction!.action} .action=${firstDeviceAction!.action}
@ -742,7 +751,15 @@ export class HaConfigDevicePage extends LitElement {
></ha-icon-button> ></ha-icon-button>
${actions.map( ${actions.map(
(deviceAction) => html` (deviceAction) => html`
<a href=${ifDefined(deviceAction.href)}> <a
href=${ifDefined(deviceAction.href)}
target=${ifDefined(deviceAction.target)}
rel=${ifDefined(
deviceAction.target
? "noreferrer"
: undefined
)}
>
<mwc-list-item <mwc-list-item
class=${ifDefined( class=${ifDefined(
deviceAction.classes deviceAction.classes
@ -981,6 +998,7 @@ export class HaConfigDevicePage extends LitElement {
if (configurationUrl) { if (configurationUrl) {
deviceActions.push({ deviceActions.push({
href: configurationUrl, href: configurationUrl,
target: configurationUrlIsHomeAssistant ? undefined : "_blank",
icon: mdiCog, icon: mdiCog,
label: this.hass.localize( label: this.hass.localize(
"ui.panel.config.devices.open_configuration_url" "ui.panel.config.devices.open_configuration_url"