Skip to content

Commit

Permalink
Show detailed config entry error inline (#20764)
Browse files Browse the repository at this point in the history
* Put config entry error inline

* Fixes (show configure button and don't make them interactive)
  • Loading branch information
silamon authored May 29, 2024
1 parent 97206ee commit b3e14d4
Showing 1 changed file with 52 additions and 51 deletions.
103 changes: 52 additions & 51 deletions src/panels/config/integrations/ha-config-integration-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ import { nextRender } from "../../../common/util/render-status";
import "../../../components/ha-button";
import "../../../components/ha-card";
import "../../../components/ha-list-item";
import "../../../components/ha-list-new";
import "../../../components/ha-list-item-new";
import "../../../components/ha-button-menu-new";
import {
deleteApplicationCredential,
fetchApplicationCredentialsConfigEntry,
Expand Down Expand Up @@ -419,27 +422,23 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
"ui.panel.config.integrations.discovered"
)}
</h1>
<mwc-list>
<ha-list-new>
${discoveryFlows.map(
(flow) =>
html`<ha-list-item
hasMeta
class="discovered"
noninteractive
>
html`<ha-list-item-new class="discovered">
${flow.localized_title}
<ha-button
slot="meta"
slot="end"
unelevated
.flow=${flow}
@click=${this._continueFlow}
.label=${this.hass.localize(
"ui.panel.config.integrations.configure"
)}
></ha-button>
</ha-list-item>`
</ha-list-item-new>`
)}
</mwc-list>
</ha-list-new>
</ha-card>`
: ""}
${attentionFlows.length || attentionEntries.length
Expand All @@ -449,27 +448,24 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
`ui.panel.config.integrations.integration_page.attention_entries`
)}
</h1>
<mwc-list>
<ha-list-new>
${attentionFlows.map((flow) => {
const attention = ATTENTION_SOURCES.includes(
flow.context.source
);
return html`<ha-list-item
hasMeta
return html`<ha-list-item-new
class="config_entry ${attention ? "attention" : ""}"
twoLine
noninteractive
>
${flow.localized_title}
<span slot="secondary"
<span slot="supporting-text"
>${this.hass.localize(
`ui.panel.config.integrations.${
attention ? "attention" : "discovered"
}`
)}</span
>
<ha-button
slot="meta"
slot="end"
unelevated
.flow=${flow}
@click=${this._continueFlow}
Expand All @@ -479,12 +475,12 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
}`
)}
></ha-button>
</ha-list-item>`;
</ha-list-item-new>`;
})}
${attentionEntries.map((item) =>
this._renderConfigEntry(item)
)}
</mwc-list>
</ha-list-new>
</ha-card>`
: ""}
Expand All @@ -505,9 +501,9 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
)}
</div>`
: nothing}
<mwc-list>
<ha-list-new>
${normalEntries.map((item) => this._renderConfigEntry(item))}
</mwc-list>
</ha-list-new>
<div class="card-actions">
<ha-button @click=${this._addIntegration}>
${this._manifest?.integration_type
Expand Down Expand Up @@ -671,41 +667,42 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {

const configPanel = this._configPanel(item.domain, this.hass.panels);

return html`<ha-list-item
hasMeta
class="config_entry ${classMap({
return html`<ha-list-item-new
class=${classMap({
config_entry: true,
"state-not-loaded": item!.state === "not_loaded",
"state-failed-unload": item!.state === "failed_unload",
"state-setup": item!.state === "setup_in_progress",
"state-error": ERROR_STATES.includes(item!.state),
})}"
})}
data-entry-id=${item.entry_id}
.disabled=${item.disabled_by}
.configEntry=${item}
twoline
noninteractive
>
${stateText
? html`
<div class="message" slot="meta">
<ha-svg-icon .path=${icon}></ha-svg-icon>
<div>${this.hass.localize(...stateText)}</div>
${stateTextExtra
? html`<simple-tooltip>${stateTextExtra}</simple-tooltip>`
: ""}
</div>
`
: ""}
${item.title || domainToName(this.hass.localize, item.domain)}
<span slot="secondary">${devicesLine}</span>
<div slot="supporting-text">
<div>${devicesLine}</div>
${stateText
? html`
<div class="message">
<ha-svg-icon .path=${icon}></ha-svg-icon>
<div>
${this.hass.localize(...stateText)}${stateTextExtra
? html`: ${stateTextExtra}`
: ""}
</div>
</div>
`
: ""}
</div>
${item.disabled_by === "user"
? html`<mwc-button unelevated slot="meta" @click=${this._handleEnable}>
? html`<mwc-button unelevated slot="end" @click=${this._handleEnable}>
${this.hass.localize("ui.common.enable")}
</mwc-button>`
: configPanel &&
(item.domain !== "matter" || isDevVersion(this.hass.config.version))
? html`<a
slot="meta"
slot="end"
href=${`/${configPanel}?config_entry=${item.entry_id}`}
><mwc-button>
${this.hass.localize(
Expand All @@ -715,14 +712,14 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
>`
: item.supports_options && !stateText
? html`
<mwc-button slot="meta" @click=${this._showOptions}>
<mwc-button slot="end" @click=${this._showOptions}>
${this.hass.localize(
"ui.panel.config.integrations.config_entry.configure"
)}
</mwc-button>
`
: ""}
<ha-button-menu slot="meta">
<ha-button-menu-new positioning="popover" slot="end">
<ha-icon-button
slot="trigger"
.label=${this.hass.localize("ui.common.menu")}
Expand Down Expand Up @@ -893,8 +890,8 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
></ha-svg-icon>
</ha-list-item>`
: ""}
</ha-button-menu>
</ha-list-item>`;
</ha-button-menu-new>
</ha-list-item-new>`;
}

private async _highlightEntry() {
Expand Down Expand Up @@ -1431,30 +1428,30 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
ha-alert:first-of-type {
margin-top: 16px;
}
ha-list-item.discovered {
ha-list-item-new.discovered {
--mdc-list-item-meta-size: auto;
--mdc-list-item-meta-display: flex;
height: 72px;
}
ha-list-item.config_entry {
ha-list-item-new.config_entry {
overflow: visible;
--mdc-list-item-meta-size: auto;
--mdc-list-item-meta-display: flex;
}
ha-button-menu ha-list-item {
ha-button-menu-new ha-list-item {
--mdc-list-item-meta-size: 24px;
}
ha-list-item.config_entry::after {
ha-list-item-new.config_entry::after {
position: absolute;
top: 0;
top: 8px;
right: 0;
bottom: 0;
bottom: 8px;
left: 0;
opacity: 0.12;
pointer-events: none;
content: "";
}
ha-button-menu {
ha-button-menu-new {
flex: 0;
}
a {
Expand Down Expand Up @@ -1513,6 +1510,10 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
overflow: hidden;
text-overflow: ellipsis;
}
ha-list-new {
margin-top: 8px;
margin-bottom: 8px;
}
`,
];
}
Expand Down

0 comments on commit b3e14d4

Please sign in to comment.