mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 16:56:35 +00:00
Merge pull request #13357 from steverep/fix-some-card-keys
This commit is contained in:
commit
e241b20378
@ -59,9 +59,9 @@ export const getCloudTtsSupportedGenders = (
|
||||
if (curLang === language) {
|
||||
genders.push([
|
||||
gender,
|
||||
localize(`ui.panel.media-browser.tts.gender_${gender}`) ||
|
||||
localize(`ui.panel.config.cloud.account.tts.${gender}`) ||
|
||||
gender,
|
||||
gender === "male" || gender === "female"
|
||||
? localize(`ui.panel.config.cloud.account.tts.${gender}`)
|
||||
: gender,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ import type {
|
||||
} from "home-assistant-js-websocket";
|
||||
import { supportsFeature } from "../common/entity/supports-feature";
|
||||
import { MediaPlayerItemId } from "../components/media-player/ha-media-player-browse";
|
||||
import type { HomeAssistant } from "../types";
|
||||
import type { HomeAssistant, TranslationDict } from "../types";
|
||||
import { UNAVAILABLE_STATES } from "./entity";
|
||||
import { isTTSMediaSource } from "./tts";
|
||||
|
||||
@ -170,14 +170,14 @@ export interface MediaPlayerThumbnail {
|
||||
export interface ControlButton {
|
||||
icon: string;
|
||||
// Used as key for action as well as tooltip and aria-label translation key
|
||||
action: string;
|
||||
action: keyof TranslationDict["ui"]["card"]["media_player"];
|
||||
}
|
||||
|
||||
export interface MediaPlayerItem {
|
||||
title: string;
|
||||
media_content_type: string;
|
||||
media_content_id: string;
|
||||
media_class: string;
|
||||
media_class: keyof TranslationDict["ui"]["components"]["media-browser"]["class"];
|
||||
children_media_class?: string;
|
||||
can_play: boolean;
|
||||
can_expand: boolean;
|
||||
|
@ -246,7 +246,7 @@ export class HuiEnergyUsageGraphCard
|
||||
: "",
|
||||
totalReturned
|
||||
? this.hass.localize(
|
||||
"ui.panel.lovelace.cards.energyenergy_usage_graph.total_returned",
|
||||
"ui.panel.lovelace.cards.energy.energy_usage_graph.total_returned",
|
||||
{ num: formatNumber(totalReturned, locale) }
|
||||
)
|
||||
: "",
|
||||
|
@ -85,7 +85,7 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
|
||||
}
|
||||
|
||||
const defaults = {
|
||||
states: ["arm_away", "arm_home"],
|
||||
states: ["arm_away", "arm_home"] as const,
|
||||
};
|
||||
|
||||
this._config = { ...defaults, ...config };
|
||||
@ -166,7 +166,7 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
|
||||
<div id="armActions" class="actions">
|
||||
${(stateObj.state === "disarmed"
|
||||
? this._config.states!
|
||||
: ["disarm"]
|
||||
: (["disarm"] as const)
|
||||
).map(
|
||||
(stateAction) => html`
|
||||
<mwc-button
|
||||
@ -221,7 +221,9 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
|
||||
`;
|
||||
}
|
||||
|
||||
private _actionDisplay(entityState: string): string {
|
||||
private _actionDisplay(
|
||||
entityState: NonNullable<AlarmPanelCardConfig["states"]>[number]
|
||||
): string {
|
||||
return this.hass!.localize(`ui.card.alarm_control_panel.${entityState}`);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { StatisticType } from "../../../data/history";
|
||||
import { ActionConfig, LovelaceCardConfig } from "../../../data/lovelace";
|
||||
import { FullCalendarView } from "../../../types";
|
||||
import { FullCalendarView, TranslationDict } from "../../../types";
|
||||
import { Condition } from "../common/validate-condition";
|
||||
import { HuiImage } from "../components/hui-image";
|
||||
import { LovelaceElementConfig } from "../elements/types";
|
||||
@ -14,7 +14,7 @@ import { LovelaceHeaderFooterConfig } from "../header-footer/types";
|
||||
export interface AlarmPanelCardConfig extends LovelaceCardConfig {
|
||||
entity: string;
|
||||
name?: string;
|
||||
states?: string[];
|
||||
states?: readonly (keyof TranslationDict["ui"]["card"]["alarm_control_panel"])[];
|
||||
theme?: string;
|
||||
}
|
||||
|
||||
@ -411,7 +411,7 @@ export interface WeatherForecastCardConfig extends LovelaceCardConfig {
|
||||
name?: string;
|
||||
show_current?: boolean;
|
||||
show_forecast?: boolean;
|
||||
secondary_info_attribute?: string;
|
||||
secondary_info_attribute?: keyof TranslationDict["ui"]["card"]["weather"]["attributes"];
|
||||
theme?: string;
|
||||
tap_action?: ActionConfig;
|
||||
hold_action?: ActionConfig;
|
||||
|
@ -39,6 +39,7 @@ import {
|
||||
cleanupMediaTitle,
|
||||
computeMediaControls,
|
||||
computeMediaDescription,
|
||||
ControlButton,
|
||||
formatMediaTime,
|
||||
getCurrentProgress,
|
||||
handleMediaControlClick,
|
||||
@ -179,7 +180,7 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
||||
return this._renderChoosePlayer(stateObj);
|
||||
}
|
||||
|
||||
const controls = !this.narrow
|
||||
const controls: ControlButton[] | undefined = !this.narrow
|
||||
? computeMediaControls(stateObj, true)
|
||||
: (stateObj.state === "playing" &&
|
||||
(supportsFeature(stateObj, SUPPORT_PAUSE) ||
|
||||
@ -207,7 +208,7 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
||||
: "media_stop",
|
||||
},
|
||||
]
|
||||
: [{}];
|
||||
: undefined;
|
||||
const mediaDescription = computeMediaDescription(stateObj);
|
||||
const mediaDuration = formatMediaTime(stateObj.attributes.media_duration);
|
||||
const mediaTitleClean = cleanupMediaTitle(
|
||||
|
Loading…
x
Reference in New Issue
Block a user