Hide download diagnostics if config entry is not loaded (#11383)

This commit is contained in:
Paulus Schoutsen 2022-01-21 09:41:02 -08:00 committed by GitHub
parent 197b581e8e
commit cf527e4bc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 19 deletions

View File

@ -210,25 +210,27 @@ export class HaConfigDevicePage extends LitElement {
}
return Promise.all(
this._integrations(device, this.entries).map(async (entry) => {
const info = await fetchDiagnosticHandler(this.hass, entry.domain);
this._integrations(device, this.entries)
.filter((entry) => entry.state === "loaded")
.map(async (entry) => {
const info = await fetchDiagnosticHandler(this.hass, entry.domain);
if (!info.handlers.device && !info.handlers.config_entry) {
return "";
}
const link = info.handlers.device
? getDeviceDiagnosticsDownloadUrl(entry.entry_id, this.deviceId)
: getConfigEntryDiagnosticsDownloadUrl(entry.entry_id);
return html`
<a href=${link} @click=${this._signUrl}>
<mwc-button>
${this.hass.localize(
`ui.panel.config.devices.download_diagnostics`
)}
</mwc-button>
</a>
`;
})
if (!info.handlers.device && !info.handlers.config_entry) {
return "";
}
const link = info.handlers.device
? getDeviceDiagnosticsDownloadUrl(entry.entry_id, this.deviceId)
: getConfigEntryDiagnosticsDownloadUrl(entry.entry_id);
return html`
<a href=${link} @click=${this._signUrl}>
<mwc-button>
${this.hass.localize(
`ui.panel.config.devices.download_diagnostics`
)}
</mwc-button>
</a>
`;
})
);
}

View File

@ -362,7 +362,7 @@ export class HaIntegrationCard extends LitElement {
)}
</mwc-list-item>`
: ""}
${this.supportsDiagnostics
${this.supportsDiagnostics && item.state === "loaded"
? html`<a
href=${getConfigEntryDiagnosticsDownloadUrl(item.entry_id)}
target="_blank"