mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 16:26:43 +00:00
Hide actions footer if no action links (#11388)
This commit is contained in:
parent
72bd5f84d6
commit
9cd23374f4
@ -3,7 +3,6 @@ import "@polymer/paper-tooltip/paper-tooltip";
|
|||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
import { until } from "lit/directives/until";
|
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
@ -90,9 +89,10 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
|
|
||||||
@state() private _related?: RelatedResult;
|
@state() private _related?: RelatedResult;
|
||||||
|
|
||||||
@state() private _diagnosticDownloadLinks?: Promise<
|
// If a number, it's the request ID so we make sure we don't show older info
|
||||||
(TemplateResult | string)[]
|
@state() private _diagnosticDownloadLinks?:
|
||||||
>;
|
| number
|
||||||
|
| (TemplateResult | string)[];
|
||||||
|
|
||||||
private _device = memoizeOne(
|
private _device = memoizeOne(
|
||||||
(
|
(
|
||||||
@ -196,20 +196,18 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._diagnosticDownloadLinks = this._renderDiagnosticButtons();
|
this._diagnosticDownloadLinks = Math.random();
|
||||||
|
this._renderDiagnosticButtons(this._diagnosticDownloadLinks);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _renderDiagnosticButtons(): Promise<
|
private async _renderDiagnosticButtons(requestId: number): Promise<void> {
|
||||||
(TemplateResult | string)[]
|
|
||||||
> {
|
|
||||||
const result: TemplateResult[] = [];
|
|
||||||
const device = this._device(this.deviceId, this.devices);
|
const device = this._device(this.deviceId, this.devices);
|
||||||
|
|
||||||
if (!device) {
|
if (!device) {
|
||||||
return result;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all(
|
let links = await Promise.all(
|
||||||
this._integrations(device, this.entries)
|
this._integrations(device, this.entries)
|
||||||
.filter((entry) => entry.state === "loaded")
|
.filter((entry) => entry.state === "loaded")
|
||||||
.map(async (entry) => {
|
.map(async (entry) => {
|
||||||
@ -232,6 +230,13 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
`;
|
`;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
if (this._diagnosticDownloadLinks !== requestId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
links = links.filter(Boolean);
|
||||||
|
if (links.length > 0) {
|
||||||
|
this._diagnosticDownloadLinks = links;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected firstUpdated(changedProps) {
|
protected firstUpdated(changedProps) {
|
||||||
@ -308,7 +313,7 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const deviceActions: TemplateResult[] = [];
|
const deviceActions: (TemplateResult | string)[] = [];
|
||||||
|
|
||||||
if (configurationUrl) {
|
if (configurationUrl) {
|
||||||
deviceActions.push(html`
|
deviceActions.push(html`
|
||||||
@ -339,8 +344,8 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
deviceActions
|
deviceActions
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this._diagnosticDownloadLinks) {
|
if (Array.isArray(this._diagnosticDownloadLinks)) {
|
||||||
deviceActions.push(html`${until(this._diagnosticDownloadLinks)}`);
|
deviceActions.push(...this._diagnosticDownloadLinks);
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
@ -739,7 +744,7 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
device,
|
device,
|
||||||
integrations: ConfigEntry[],
|
integrations: ConfigEntry[],
|
||||||
deviceInfo: TemplateResult[],
|
deviceInfo: TemplateResult[],
|
||||||
deviceActions: TemplateResult[]
|
deviceActions: (string | TemplateResult)[]
|
||||||
): TemplateResult[] {
|
): TemplateResult[] {
|
||||||
const domains = integrations.map((int) => int.domain);
|
const domains = integrations.map((int) => int.domain);
|
||||||
const templates: TemplateResult[] = [];
|
const templates: TemplateResult[] = [];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user