Add attention required for config flows in progress (#6808)

This commit is contained in:
Bram Kragten 2020-09-07 09:09:42 +02:00 committed by GitHub
parent c73330a466
commit 979b7ae651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 78 additions and 45 deletions

View File

@ -13,6 +13,8 @@ export const DISCOVERY_SOURCES = [
"discovery", "discovery",
]; ];
export const ATTENTION_SOURCES = ["reauth"];
export const createConfigFlow = (hass: HomeAssistant, handler: string) => export const createConfigFlow = (hass: HomeAssistant, handler: string) =>
hass.callApi<DataEntryFlowStep>("POST", "config/config_entries/flow", { hass.callApi<DataEntryFlowStep>("POST", "config/config_entries/flow", {
handler, handler,

View File

@ -10,12 +10,13 @@ import {
CSSResult, CSSResult,
customElement, customElement,
html, html,
internalProperty,
LitElement, LitElement,
property, property,
internalProperty,
PropertyValues, PropertyValues,
TemplateResult, TemplateResult,
} from "lit-element"; } from "lit-element";
import { classMap } from "lit-html/directives/class-map";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { HASSDomEvent } from "../../../common/dom/fire_event"; import { HASSDomEvent } from "../../../common/dom/fire_event";
import "../../../common/search/search-input"; import "../../../common/search/search-input";
@ -32,6 +33,7 @@ import {
getConfigEntries, getConfigEntries,
} from "../../../data/config_entries"; } from "../../../data/config_entries";
import { import {
ATTENTION_SOURCES,
DISCOVERY_SOURCES, DISCOVERY_SOURCES,
getConfigFlowInProgressCollection, getConfigFlowInProgressCollection,
ignoreConfigFlow, ignoreConfigFlow,
@ -355,52 +357,67 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
: ""} : ""}
${configEntriesInProgress.length ${configEntriesInProgress.length
? configEntriesInProgress.map( ? configEntriesInProgress.map(
(flow: DataEntryFlowProgressExtended) => html` (flow: DataEntryFlowProgressExtended) => {
<ha-card outlined class="discovered"> const attention = ATTENTION_SOURCES.includes(
<div class="header"> flow.context.source
${this.hass.localize( );
"ui.panel.config.integrations.discovered" return html`
)} <ha-card
</div> outlined
<div class="card-content"> class=${classMap({
<div class="image"> discovered: !attention,
<img attention: attention,
src="https://brands.home-assistant.io/${flow.handler}/logo.png" })}
referrerpolicy="no-referrer" >
@error=${this._onImageError} <div class="header">
@load=${this._onImageLoad} ${this.hass.localize(
/> `ui.panel.config.integrations.${
attention ? "attention" : "discovered"
}`
)}
</div> </div>
<h2> <div class="card-content">
${flow.localized_title} <div class="image">
</h2> <img
<div> src="https://brands.home-assistant.io/${flow.handler}/logo.png"
<mwc-button referrerpolicy="no-referrer"
unelevated @error=${this._onImageError}
@click=${this._continueFlow} @load=${this._onImageLoad}
.flowId=${flow.flow_id} />
> </div>
${this.hass.localize( <h2>
"ui.panel.config.integrations.configure" ${flow.localized_title}
)} </h2>
</mwc-button> <div>
${DISCOVERY_SOURCES.includes(flow.context.source) && <mwc-button
flow.context.unique_id unelevated
? html` @click=${this._continueFlow}
<mwc-button .flowId=${flow.flow_id}
@click=${this._ignoreFlow} >
.flow=${flow} ${this.hass.localize(
> `ui.panel.config.integrations.${
${this.hass.localize( attention ? "reconfigure" : "configure"
"ui.panel.config.integrations.ignore.ignore" }`
)} )}
</mwc-button> </mwc-button>
` ${DISCOVERY_SOURCES.includes(flow.context.source) &&
: ""} flow.context.unique_id
? html`
<mwc-button
@click=${this._ignoreFlow}
.flow=${flow}
>
${this.hass.localize(
"ui.panel.config.integrations.ignore.ignore"
)}
</mwc-button>
`
: ""}
</div>
</div> </div>
</div> </ha-card>
</ha-card> `;
` }
) )
: ""} : ""}
${groupedConfigEntries.size ${groupedConfigEntries.size
@ -639,6 +656,18 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
flex-direction: column; flex-direction: column;
justify-content: space-between; justify-content: space-between;
} }
.attention {
--ha-card-border-color: var(--error-color);
}
.attention .header {
background: var(--error-color);
color: var(--text-primary-color);
padding: 8px;
text-align: center;
}
.attention mwc-button {
--mdc-theme-primary: var(--error-color);
}
.discovered { .discovered {
--ha-card-border-color: var(--primary-color); --ha-card-border-color: var(--primary-color);
} }

View File

@ -1610,6 +1610,7 @@
"description": "Manage integrations", "description": "Manage integrations",
"integration": "integration", "integration": "integration",
"discovered": "Discovered", "discovered": "Discovered",
"attention": "Attention required",
"configured": "Configured", "configured": "Configured",
"new": "Set up a new integration", "new": "Set up a new integration",
"add_integration": "Add integration", "add_integration": "Add integration",
@ -1618,6 +1619,7 @@
"note_about_website_reference": "More are available on the ", "note_about_website_reference": "More are available on the ",
"home_assistant_website": "Home Assistant website", "home_assistant_website": "Home Assistant website",
"configure": "Configure", "configure": "Configure",
"reconfigure": "Reconfigure",
"none": "Nothing configured yet", "none": "Nothing configured yet",
"none_found": "No integrations found", "none_found": "No integrations found",
"none_found_detail": "Adjust your search criteria.", "none_found_detail": "Adjust your search criteria.",