diff --git a/build-scripts/gulp/locale-data.js b/build-scripts/gulp/locale-data.js index 14ce9bc06a3c..4cf91711d495 100755 --- a/build-scripts/gulp/locale-data.js +++ b/build-scripts/gulp/locale-data.js @@ -9,7 +9,6 @@ const outDir = join(paths.build_dir, "locale-data"); const INTL_POLYFILLS = { "intl-datetimeformat": "DateTimeFormat", - "intl-durationFormat": "DurationFormat", "intl-displaynames": "DisplayNames", "intl-listformat": "ListFormat", "intl-numberformat": "NumberFormat", diff --git a/pyproject.toml b/pyproject.toml index 5a79bd0d75d3..d373f50e27d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "home-assistant-frontend" -version = "20241127.0" +version = "20241127.1" license = {text = "Apache-2.0"} description = "The Home Assistant frontend" readme = "README.md" diff --git a/src/common/datetime/format_duration.ts b/src/common/datetime/format_duration.ts index a67d5f82ca9e..e20f7e18af25 100644 --- a/src/common/datetime/format_duration.ts +++ b/src/common/datetime/format_duration.ts @@ -1,4 +1,3 @@ -import { DurationFormat } from "@formatjs/intl-durationformat"; import type { DurationInput } from "@formatjs/intl-durationformat/src/types"; import memoizeOne from "memoize-one"; import type { HaDurationData } from "../../components/ha-duration-input"; @@ -49,7 +48,7 @@ export const formatNumericDuration = ( const formatDurationLongMem = memoizeOne( (locale: FrontendLocaleData) => - new DurationFormat(locale.language, { + new Intl.DurationFormat(locale.language, { style: "long", }) ); @@ -61,7 +60,7 @@ export const formatDurationLong = ( const formatDigitalDurationMem = memoizeOne( (locale: FrontendLocaleData) => - new DurationFormat(locale.language, { + new Intl.DurationFormat(locale.language, { style: "digital", hoursDisplay: "auto", }) @@ -72,13 +71,13 @@ export const formatDurationDigital = ( duration: HaDurationData ) => formatDigitalDurationMem(locale).format(duration); -export const DURATION_UNITS = ["ms", "s", "min", "h", "d"] as const; +export const DURATION_UNITS = ["s", "min", "h", "d"] as const; type DurationUnit = (typeof DURATION_UNITS)[number]; const formatDurationDayMem = memoizeOne( (locale: FrontendLocaleData) => - new DurationFormat(locale.language, { + new Intl.DurationFormat(locale.language, { style: "narrow", daysDisplay: "always", }) @@ -86,7 +85,7 @@ const formatDurationDayMem = memoizeOne( const formatDurationHourMem = memoizeOne( (locale: FrontendLocaleData) => - new DurationFormat(locale.language, { + new Intl.DurationFormat(locale.language, { style: "narrow", hoursDisplay: "always", }) @@ -94,7 +93,7 @@ const formatDurationHourMem = memoizeOne( const formatDurationMinuteMem = memoizeOne( (locale: FrontendLocaleData) => - new DurationFormat(locale.language, { + new Intl.DurationFormat(locale.language, { style: "narrow", minutesDisplay: "always", }) @@ -102,20 +101,12 @@ const formatDurationMinuteMem = memoizeOne( const formatDurationSecondMem = memoizeOne( (locale: FrontendLocaleData) => - new DurationFormat(locale.language, { + new Intl.DurationFormat(locale.language, { style: "narrow", secondsDisplay: "always", }) ); -const formatDurationMillisecondMem = memoizeOne( - (locale: FrontendLocaleData) => - new DurationFormat(locale.language, { - style: "narrow", - millisecondsDisplay: "always", - }) -); - export const formatDuration = ( locale: FrontendLocaleData, duration: string, @@ -164,13 +155,6 @@ export const formatDuration = ( }; return formatDurationSecondMem(locale).format(input); } - case "ms": { - const milliseconds = Math.floor(value); - const input: DurationInput = { - milliseconds, - }; - return formatDurationMillisecondMem(locale).format(input); - } default: throw new Error("Invalid duration unit"); } diff --git a/src/data/integration.ts b/src/data/integration.ts index 846751e07c3f..c293dfc540b0 100644 --- a/src/data/integration.ts +++ b/src/data/integration.ts @@ -40,12 +40,13 @@ export interface IntegrationManifest { loggers?: string[]; quality_scale?: | "bronze" + | "silver" | "gold" - | "internal" | "platinum" - | "silver" - | "custom" - | "no_score"; + | "no_score" + | "internal" + | "legacy" + | "custom"; iot_class: | "assumed_state" | "cloud_polling" diff --git a/src/data/integration_quality_scale.ts b/src/data/integration_quality_scale.ts new file mode 100644 index 000000000000..e49bbc835dde --- /dev/null +++ b/src/data/integration_quality_scale.ts @@ -0,0 +1,39 @@ +import { mdiContentSave, mdiMedal, mdiTrophy } from "@mdi/js"; +import { mdiHomeAssistant } from "../resources/home-assistant-logo-svg"; +import type { LocalizeKeys } from "../common/translations/localize"; + +/** + * Map integration quality scale to icon and translation key. + */ +export const QUALITY_SCALE_MAP: Record< + string, + { icon: string; translationKey: LocalizeKeys } +> = { + bronze: { + icon: mdiMedal, + translationKey: "ui.panel.config.integrations.config_entry.bronze_quality", + }, + silver: { + icon: mdiMedal, + translationKey: "ui.panel.config.integrations.config_entry.silver_quality", + }, + gold: { + icon: mdiMedal, + translationKey: "ui.panel.config.integrations.config_entry.gold_quality", + }, + platinum: { + icon: mdiTrophy, + translationKey: + "ui.panel.config.integrations.config_entry.platinum_quality", + }, + internal: { + icon: mdiHomeAssistant, + translationKey: + "ui.panel.config.integrations.config_entry.internal_integration", + }, + legacy: { + icon: mdiContentSave, + translationKey: + "ui.panel.config.integrations.config_entry.legacy_integration", + }, +}; diff --git a/src/panels/config/integrations/ha-config-integration-page.ts b/src/panels/config/integrations/ha-config-integration-page.ts index 14a3282e92f3..f44a03b00fad 100644 --- a/src/panels/config/integrations/ha-config-integration-page.ts +++ b/src/panels/config/integrations/ha-config-integration-page.ts @@ -13,7 +13,6 @@ import { mdiDownload, mdiFileCodeOutline, mdiHandExtendedOutline, - mdiMedal, mdiOpenInNew, mdiPackageVariant, mdiPlayCircleOutline, @@ -23,7 +22,6 @@ import { mdiRenameBox, mdiShapeOutline, mdiStopCircleOutline, - mdiTrophy, mdiWeb, mdiWrench, } from "@mdi/js"; @@ -107,9 +105,7 @@ import { documentationUrl } from "../../../util/documentation-url"; import { fileDownload } from "../../../util/file_download"; import type { DataEntryFlowProgressExtended } from "./ha-config-integrations"; import { showAddIntegrationDialog } from "./show-add-integration-dialog"; - -type MedalColor = "gold" | "silver" | "bronze" | "platinum"; -const MEDAL_COLORS = ["bronze", "silver", "gold", "platinum"]; +import { QUALITY_SCALE_MAP } from "../../../data/integration_quality_scale"; export const renderConfigEntryError = ( hass: HomeAssistant, @@ -344,36 +340,30 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) { ? html`