Add overflow menu to discovered integration item (#11165)

Co-authored-by: Zack Barett <arnett.zackary@gmail.com>
This commit is contained in:
Franck Nijhof 2022-01-12 16:02:08 +01:00 committed by GitHub
parent 6ab497edf8
commit ba570f4004
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 11 deletions

View File

@ -1,6 +1,7 @@
import { css, html, LitElement, TemplateResult } from "lit"; import { css, html, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators"; import { customElement, property } from "lit/decorators";
import { classMap } from "lit/directives/class-map"; import { classMap } from "lit/directives/class-map";
import { mdiDotsVertical, mdiOpenInNew } from "@mdi/js";
import { fireEvent } from "../../../common/dom/fire_event"; import { fireEvent } from "../../../common/dom/fire_event";
import { import {
ATTENTION_SOURCES, ATTENTION_SOURCES,
@ -50,17 +51,62 @@ export class HaConfigFlowCard extends LitElement {
}` }`
)} )}
></mwc-button> ></mwc-button>
${DISCOVERY_SOURCES.includes(this.flow.context.source) && <ha-button-menu corner="BOTTOM_START">
this.flow.context.unique_id <ha-icon-button
? html` slot="trigger"
<mwc-button .label=${this.hass.localize("ui.common.menu")}
@click=${this._ignoreFlow} .path=${mdiDotsVertical}
.label=${this.hass.localize( ></ha-icon-button>
"ui.panel.config.integrations.ignore.ignore" ${this.flow.context.configuration_url
? html`<a
href=${this.flow.context.configuration_url.replace(
/^homeassistant:\/\//,
""
)} )}
></mwc-button> rel="noreferrer"
` target=${this.flow.context.configuration_url.startsWith(
: ""} "homeassistant://"
)
? "_self"
: "_blank"}
>
<mwc-list-item hasMeta>
${this.hass.localize(
"ui.panel.config.integrations.config_entry.open_configuration_url"
)}<ha-svg-icon
slot="meta"
.path=${mdiOpenInNew}
></ha-svg-icon>
</mwc-list-item>
</a>`
: ""}
${this.manifest
? html`<a
href=${this.manifest.documentation}
rel="noreferrer"
target="_blank"
>
<mwc-list-item hasMeta>
${this.hass.localize(
"ui.panel.config.integrations.config_entry.documentation"
)}<ha-svg-icon
slot="meta"
.path=${mdiOpenInNew}
></ha-svg-icon>
</mwc-list-item>
</a>`
: ""}
${DISCOVERY_SOURCES.includes(this.flow.context.source) &&
this.flow.context.unique_id
? html`
<mwc-list-item @click=${this._ignoreFlow}>
${this.hass.localize(
"ui.panel.config.integrations.ignore.ignore"
)}
</mwc-list-item>
`
: ""}
</ha-button-menu>
</ha-integration-action-card> </ha-integration-action-card>
`; `;
} }
@ -114,6 +160,10 @@ export class HaConfigFlowCard extends LitElement {
--state-color: var(--primary-color); --state-color: var(--primary-color);
--text-on-state-color: var(--text-primary-color); --text-on-state-color: var(--text-primary-color);
} }
a {
text-decoration: none;
color: var(--primary-color);
}
`; `;
} }

View File

@ -2478,7 +2478,8 @@
"setup_retry": "Retrying setup", "setup_retry": "Retrying setup",
"not_loaded": "Not loaded", "not_loaded": "Not loaded",
"failed_unload": "Failed to unload" "failed_unload": "Failed to unload"
} },
"open_configuration_url": "Visit device"
}, },
"config_flow": { "config_flow": {
"aborted": "Aborted", "aborted": "Aborted",