Fix localize key errors for URL error and system log (#14909)

* Use literal type for system log level

* Fix typo in URL error title key

* Remove localize key exceptions
This commit is contained in:
Steve Repsher 2023-01-21 23:29:17 -05:00 committed by GitHub
parent 3e14d825e3
commit f101bd1a54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 13 deletions

View File

@ -29,11 +29,9 @@ export type LocalizeKeys =
| `ui.panel.config.devices.${string}`
| `ui.panel.config.energy.${string}`
| `ui.panel.config.info.${string}`
| `ui.panel.config.logs.${string}`
| `ui.panel.config.lovelace.${string}`
| `ui.panel.config.network.${string}`
| `ui.panel.config.scene.${string}`
| `ui.panel.config.url.${string}`
| `ui.panel.config.zha.${string}`
| `ui.panel.config.zwave_js.${string}`
| `ui.panel.lovelace.card.${string}`

View File

@ -1,9 +1,9 @@
import { HomeAssistant } from "../types";
import { HomeAssistant, TranslationDict } from "../types";
export interface LoggedError {
name: string;
message: [string];
level: string;
level: keyof TranslationDict["ui"]["panel"]["config"]["logs"]["level"];
source: [string, number];
// unix timestamp in seconds
timestamp: number;
@ -13,8 +13,13 @@ export interface LoggedError {
first_occurred: number;
}
export const fetchSystemLog = (hass: HomeAssistant) =>
hass.callWS<LoggedError[]>({ type: "system_log/list" });
export const fetchSystemLog = async (hass: HomeAssistant) => {
const log = await hass.callWS<LoggedError[]>({ type: "system_log/list" });
for (const error of log) {
error.level = error.level.toLowerCase() as LoggedError["level"];
}
return log;
};
export const getLoggedErrorIntegration = (item: LoggedError) => {
// Try to derive from logger name

View File

@ -72,10 +72,8 @@ class DialogSystemLogDetail extends LitElement {
const title = this.hass.localize(
"ui.panel.config.logs.details",
"level",
html`<span class=${item.level.toLowerCase()}
>${this.hass.localize(
`ui.panel.config.logs.level.${item.level.toLowerCase()}`
)}</span
html`<span class=${item.level}
>${this.hass.localize(`ui.panel.config.logs.level.${item.level}`)}</span
>`
);

View File

@ -104,9 +104,9 @@ export class SystemLogCard extends LitElement {
<div class="row">${item.message[0]}</div>
<div class="row-secondary" secondary>
${this._timestamp(item)}
${html`(<span class=${item.level.toLowerCase()}
${html`(<span class=${item.level}
>${this.hass.localize(
`ui.panel.config.logs.level.${item.level.toLowerCase()}`
`ui.panel.config.logs.level.${item.level}`
)}</span
>) `}
${integrations[idx]

View File

@ -229,7 +229,7 @@ class ConfigUrlForm extends LitElement {
? "info"
: "warning"}
.title=${this.hass.localize(
"ui.panel.config.url.intenral_url_https_error_title"
"ui.panel.config.url.internal_url_https_error_title"
)}
>
${this.hass.localize(