mirror of
https://github.com/home-assistant/frontend.git
synced 2026-04-18 07:56:44 +01:00
Menu item to reset light favorite colors (#30004)
reset-light-favorites
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
mdiBackupRestore,
|
||||||
mdiChartBoxOutline,
|
mdiChartBoxOutline,
|
||||||
mdiClose,
|
mdiClose,
|
||||||
mdiCodeBraces,
|
mdiCodeBraces,
|
||||||
@@ -49,7 +50,10 @@ import type {
|
|||||||
EntityRegistryEntry,
|
EntityRegistryEntry,
|
||||||
ExtEntityRegistryEntry,
|
ExtEntityRegistryEntry,
|
||||||
} from "../../data/entity/entity_registry";
|
} 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 { lightSupportsFavoriteColors } from "../../data/light";
|
||||||
import type { ItemType } from "../../data/search";
|
import type { ItemType } from "../../data/search";
|
||||||
import { SearchableDomains } 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-info";
|
||||||
import "./ha-more-info-settings";
|
import "./ha-more-info-settings";
|
||||||
import "./more-info-content";
|
import "./more-info-content";
|
||||||
|
import { showConfirmationDialog } from "../generic/show-dialog-box";
|
||||||
|
|
||||||
export interface MoreInfoDialogParams {
|
export interface MoreInfoDialogParams {
|
||||||
entityId: string | null;
|
entityId: string | null;
|
||||||
@@ -358,6 +363,9 @@ export class MoreInfoDialog extends ScrollableFadeMixin(LitElement) {
|
|||||||
case "toggle_edit":
|
case "toggle_edit":
|
||||||
this._toggleInfoEditMode();
|
this._toggleInfoEditMode();
|
||||||
break;
|
break;
|
||||||
|
case "reset_favorites":
|
||||||
|
this._resetFavorites();
|
||||||
|
break;
|
||||||
case "related":
|
case "related":
|
||||||
this._goToRelated();
|
this._goToRelated();
|
||||||
break;
|
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 {
|
private _showDetails(): void {
|
||||||
import("./ha-more-info-details");
|
import("./ha-more-info-details");
|
||||||
this._childView = {
|
this._childView = {
|
||||||
@@ -592,6 +630,19 @@ export class MoreInfoDialog extends ScrollableFadeMixin(LitElement) {
|
|||||||
`ui.dialogs.more_info_control.${domain}.edit_mode`
|
`ui.dialogs.more_info_control.${domain}.edit_mode`
|
||||||
)}
|
)}
|
||||||
</ha-dropdown-item>
|
</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}
|
: nothing}
|
||||||
<ha-dropdown-item value="related">
|
<ha-dropdown-item value="related">
|
||||||
|
|||||||
@@ -1612,6 +1612,8 @@
|
|||||||
},
|
},
|
||||||
"light": {
|
"light": {
|
||||||
"edit_mode": "Edit favorite colors",
|
"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",
|
"toggle": "Toggle",
|
||||||
"color": "Color",
|
"color": "Color",
|
||||||
"color_temp": "Temperature",
|
"color_temp": "Temperature",
|
||||||
|
|||||||
Reference in New Issue
Block a user