1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-04-02 08:33:31 +01:00

Menu item to reset light favorite colors (#30004)

reset-light-favorites
This commit is contained in:
karwosts
2026-03-05 11:46:44 -08:00
committed by GitHub
parent 59364d05ec
commit b3b35e4299
2 changed files with 54 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
import {
mdiBackupRestore,
mdiChartBoxOutline,
mdiClose,
mdiCodeBraces,
@@ -49,7 +50,10 @@ import type {
EntityRegistryEntry,
ExtEntityRegistryEntry,
} from "../../data/entity/entity_registry";
import { getExtendedEntityRegistryEntry } from "../../data/entity/entity_registry";
import {
getExtendedEntityRegistryEntry,
updateEntityRegistryEntry,
} from "../../data/entity/entity_registry";
import { lightSupportsFavoriteColors } from "../../data/light";
import type { ItemType } from "../../data/search";
import { SearchableDomains } from "../../data/search";
@@ -75,6 +79,7 @@ import "./ha-more-info-history-and-logbook";
import "./ha-more-info-info";
import "./ha-more-info-settings";
import "./more-info-content";
import { showConfirmationDialog } from "../generic/show-dialog-box";
export interface MoreInfoDialogParams {
entityId: string | null;
@@ -358,6 +363,9 @@ export class MoreInfoDialog extends ScrollableFadeMixin(LitElement) {
case "toggle_edit":
this._toggleInfoEditMode();
break;
case "reset_favorites":
this._resetFavorites();
break;
case "related":
this._goToRelated();
break;
@@ -373,6 +381,36 @@ export class MoreInfoDialog extends ScrollableFadeMixin(LitElement) {
}
}
private async _resetFavorites() {
if (
!(await showConfirmationDialog(this, {
title: this.hass!.localize(
"ui.dialogs.more_info_control.light.reset_favorites"
),
text: this.hass!.localize(
"ui.dialogs.more_info_control.light.reset_favorites_text"
),
dismissText: this.hass!.localize("ui.common.cancel"),
confirmText: this.hass!.localize("ui.common.reset"),
destructive: true,
}))
) {
return;
}
const result = await updateEntityRegistryEntry(
this.hass,
this._entry!.entity_id,
{
options_domain: "light",
options: {
favorite_colors: undefined,
},
}
);
this._entry = result.entity_entry;
}
private _showDetails(): void {
import("./ha-more-info-details");
this._childView = {
@@ -592,6 +630,19 @@ export class MoreInfoDialog extends ScrollableFadeMixin(LitElement) {
`ui.dialogs.more_info_control.${domain}.edit_mode`
)}
</ha-dropdown-item>
<ha-dropdown-item
value="reset_favorites"
.disabled=${!this._entry.options?.light
?.favorite_colors}
>
<ha-svg-icon
slot="icon"
.path=${mdiBackupRestore}
></ha-svg-icon>
${this.hass.localize(
`ui.dialogs.more_info_control.light.reset_favorites`
)}
</ha-dropdown-item>
`
: nothing}
<ha-dropdown-item value="related">

View File

@@ -1612,6 +1612,8 @@
},
"light": {
"edit_mode": "Edit favorite colors",
"reset_favorites": "Reset favorite colors",
"reset_favorites_text": "Do you want to reset all favorite colors for this light back to default?",
"toggle": "Toggle",
"color": "Color",
"color_temp": "Temperature",