diff --git a/src/panels/config/automation/ha-automation-picker.ts b/src/panels/config/automation/ha-automation-picker.ts index 20b976375035..62900a279877 100644 --- a/src/panels/config/automation/ha-automation-picker.ts +++ b/src/panels/config/automation/ha-automation-picker.ts @@ -73,6 +73,7 @@ import { } from "../../../data/automation"; import { CategoryRegistryEntry, + createCategoryRegistryEntry, subscribeCategoryRegistry, } from "../../../data/category_registry"; import { fullEntitiesContext } from "../../../data/context"; @@ -84,6 +85,7 @@ import { } from "../../../data/entity_registry"; import { LabelRegistryEntry, + createLabelRegistryEntry, subscribeLabelRegistry, } from "../../../data/label_registry"; import { findRelated } from "../../../data/search"; @@ -98,7 +100,9 @@ import { HomeAssistant, Route, ServiceCallResponse } from "../../../types"; import { documentationUrl } from "../../../util/documentation-url"; import { turnOnOffEntity } from "../../lovelace/common/entity/turn-on-off-entity"; import { showAssignCategoryDialog } from "../category/show-dialog-assign-category"; +import { showCategoryRegistryDetailDialog } from "../category/show-dialog-category-registry-detail"; import { configSections } from "../ha-panel-config"; +import { showLabelDetailDialog } from "../labels/show-dialog-label-detail"; import { showNewAutomationDialog } from "./show-dialog-new-automation"; type AutomationItem = AutomationEntity & { @@ -367,21 +371,32 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { "ui.panel.config.automation.picker.bulk_actions.no_category" )} + + + +
+ ${this.hass.localize("ui.panel.config.category.editor.add")} +
`; const labelItems = html` ${this._labels?.map((label) => { - const color = label.color ? computeCssColor(label.color) : undefined; - return html` - - ${label.icon - ? html`` - : nothing} - ${label.name} - + const color = label.color ? computeCssColor(label.color) : undefined; + return html` + + ${label.icon + ? html`` + : nothing} + ${label.name} + + `; + })} + +
+ ${this.hass.localize("ui.panel.config.labels.add_label")} +
`; - })}`; return html` + createCategoryRegistryEntry(this.hass, "automation", values), + }); + } + + private _createLabel() { + showLabelDetailDialog(this, { + createEntry: (values) => createLabelRegistryEntry(this.hass, values), + }); + } + static get styles(): CSSResultGroup { return [ haStyle, diff --git a/src/panels/config/devices/ha-config-devices-dashboard.ts b/src/panels/config/devices/ha-config-devices-dashboard.ts index 76e086cba941..e47b567e3e5b 100644 --- a/src/panels/config/devices/ha-config-devices-dashboard.ts +++ b/src/panels/config/devices/ha-config-devices-dashboard.ts @@ -57,6 +57,7 @@ import { import { IntegrationManifest } from "../../../data/integration"; import { LabelRegistryEntry, + createLabelRegistryEntry, subscribeLabelRegistry, } from "../../../data/label_registry"; import "../../../layouts/hass-tabs-subpage-data-table"; @@ -67,6 +68,7 @@ import { brandsUrl } from "../../../util/brands-url"; import { configSections } from "../ha-panel-config"; import "../integrations/ha-integration-overflow-menu"; import { showAddIntegrationDialog } from "../integrations/show-add-integration-dialog"; +import { showLabelDetailDialog } from "../labels/show-dialog-label-detail"; interface DeviceRowData extends DeviceRegistryEntry { device?: DeviceRowData; @@ -542,20 +544,25 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) { this._labels ); - const labelItems = html` ${this._labels?.map((label) => { - const color = label.color ? computeCssColor(label.color) : undefined; - return html` - - ${label.icon - ? html`` - : nothing} - ${label.name} - + const labelItems = html`${this._labels?.map((label) => { + const color = label.color ? computeCssColor(label.color) : undefined; + return html` + + ${label.icon + ? html`` + : nothing} + ${label.name} + + `; + })} + +
+ ${this.hass.localize("ui.panel.config.labels.add_label")} +
`; - })}`; return html` createLabelRegistryEntry(this.hass, values), + }); + } + static get styles(): CSSResultGroup { return [ css` diff --git a/src/panels/config/entities/ha-config-entities.ts b/src/panels/config/entities/ha-config-entities.ts index 80adf624d587..b4ae8573b97a 100644 --- a/src/panels/config/entities/ha-config-entities.ts +++ b/src/panels/config/entities/ha-config-entities.ts @@ -70,6 +70,7 @@ import { import { entryIcon } from "../../../data/icons"; import { LabelRegistryEntry, + createLabelRegistryEntry, subscribeLabelRegistry, } from "../../../data/label_registry"; import { @@ -86,6 +87,7 @@ import type { HomeAssistant, Route } from "../../../types"; import { configSections } from "../ha-panel-config"; import "../integrations/ha-integration-overflow-menu"; import { showAddIntegrationDialog } from "../integrations/show-add-integration-dialog"; +import { showLabelDetailDialog } from "../labels/show-dialog-label-detail"; export interface StateEntity extends Omit { @@ -515,19 +517,24 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { ); const labelItems = html` ${this._labels?.map((label) => { - const color = label.color ? computeCssColor(label.color) : undefined; - return html` - - ${label.icon - ? html`` - : nothing} - ${label.name} - + const color = label.color ? computeCssColor(label.color) : undefined; + return html` + + ${label.icon + ? html`` + : nothing} + ${label.name} + + `; + })} + +
+ ${this.hass.localize("ui.panel.config.labels.add_label")} +
`; - })}`; return html` createLabelRegistryEntry(this.hass, values), + }); + } + static get styles(): CSSResultGroup { return [ haStyle, diff --git a/src/panels/config/scene/ha-scene-dashboard.ts b/src/panels/config/scene/ha-scene-dashboard.ts index 11a0d92dccc9..e88f76d1e88e 100644 --- a/src/panels/config/scene/ha-scene-dashboard.ts +++ b/src/panels/config/scene/ha-scene-dashboard.ts @@ -27,6 +27,7 @@ import { } from "lit"; import { customElement, property, state } from "lit/decorators"; import memoizeOne from "memoize-one"; +import { computeCssColor } from "../../../common/color/compute-color"; import { formatShortDateTime } from "../../../common/datetime/format_date_time"; import { relativeTime } from "../../../common/datetime/relative_time"; import { HASSDomEvent, fireEvent } from "../../../common/dom/fire_event"; @@ -48,12 +49,13 @@ import "../../../components/ha-filter-floor-areas"; import "../../../components/ha-filter-labels"; import "../../../components/ha-icon-button"; import "../../../components/ha-icon-overflow-menu"; -import "../../../components/ha-state-icon"; -import "../../../components/ha-svg-icon"; import "../../../components/ha-menu-item"; +import "../../../components/ha-state-icon"; import "../../../components/ha-sub-menu"; +import "../../../components/ha-svg-icon"; import { CategoryRegistryEntry, + createCategoryRegistryEntry, subscribeCategoryRegistry, } from "../../../data/category_registry"; import { fullEntitiesContext } from "../../../data/context"; @@ -66,6 +68,7 @@ import { import { forwardHaptic } from "../../../data/haptics"; import { LabelRegistryEntry, + createLabelRegistryEntry, subscribeLabelRegistry, } from "../../../data/label_registry"; import { @@ -86,8 +89,9 @@ import { HomeAssistant, Route } from "../../../types"; import { documentationUrl } from "../../../util/documentation-url"; import { showToast } from "../../../util/toast"; import { showAssignCategoryDialog } from "../category/show-dialog-assign-category"; +import { showCategoryRegistryDetailDialog } from "../category/show-dialog-category-registry-detail"; import { configSections } from "../ha-panel-config"; -import { computeCssColor } from "../../../common/color/compute-color"; +import { showLabelDetailDialog } from "../labels/show-dialog-label-detail"; type SceneItem = SceneEntity & { name: string; @@ -361,21 +365,32 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) { "ui.panel.config.automation.picker.bulk_actions.no_category" )} +
+ + +
+ ${this.hass.localize("ui.panel.config.category.editor.add")} +
`; const labelItems = html` ${this._labels?.map((label) => { - const color = label.color ? computeCssColor(label.color) : undefined; - return html` - - ${label.icon - ? html`` - : nothing} - ${label.name} - + const color = label.color ? computeCssColor(label.color) : undefined; + return html` + + ${label.icon + ? html`` + : nothing} + ${label.name} + + `; + })} + +
+ ${this.hass.localize("ui.panel.config.labels.add_label")} +
`; - })}`; return html` + createCategoryRegistryEntry(this.hass, "scene", values), + }); + } + + private _createLabel() { + showLabelDetailDialog(this, { + createEntry: (values) => createLabelRegistryEntry(this.hass, values), + }); + } + static get styles(): CSSResultGroup { return [ haStyle, diff --git a/src/panels/config/script/ha-script-picker.ts b/src/panels/config/script/ha-script-picker.ts index 5e1e764b478d..c4be1b4e000e 100644 --- a/src/panels/config/script/ha-script-picker.ts +++ b/src/panels/config/script/ha-script-picker.ts @@ -27,6 +27,7 @@ import { import { customElement, property, state } from "lit/decorators"; import { styleMap } from "lit/directives/style-map"; import memoizeOne from "memoize-one"; +import { computeCssColor } from "../../../common/color/compute-color"; import { isComponentLoaded } from "../../../common/config/is_component_loaded"; import { formatShortDateTime } from "../../../common/datetime/format_date_time"; import { relativeTime } from "../../../common/datetime/relative_time"; @@ -49,11 +50,12 @@ import "../../../components/ha-filter-floor-areas"; import "../../../components/ha-filter-labels"; import "../../../components/ha-icon-button"; import "../../../components/ha-icon-overflow-menu"; -import "../../../components/ha-svg-icon"; import "../../../components/ha-menu-item"; import "../../../components/ha-sub-menu"; +import "../../../components/ha-svg-icon"; import { CategoryRegistryEntry, + createCategoryRegistryEntry, subscribeCategoryRegistry, } from "../../../data/category_registry"; import { fullEntitiesContext } from "../../../data/context"; @@ -65,6 +67,7 @@ import { } from "../../../data/entity_registry"; import { LabelRegistryEntry, + createLabelRegistryEntry, subscribeLabelRegistry, } from "../../../data/label_registry"; import { @@ -88,8 +91,9 @@ import { documentationUrl } from "../../../util/documentation-url"; import { showToast } from "../../../util/toast"; import { showNewAutomationDialog } from "../automation/show-dialog-new-automation"; import { showAssignCategoryDialog } from "../category/show-dialog-assign-category"; +import { showCategoryRegistryDetailDialog } from "../category/show-dialog-category-registry-detail"; import { configSections } from "../ha-panel-config"; -import { computeCssColor } from "../../../common/color/compute-color"; +import { showLabelDetailDialog } from "../labels/show-dialog-label-detail"; type ScriptItem = ScriptEntity & { name: string; @@ -373,22 +377,32 @@ class HaScriptPicker extends SubscribeMixin(LitElement) { ${this.hass.localize( "ui.panel.config.automation.picker.bulk_actions.no_category" )} +
+ +
+ ${this.hass.localize("ui.panel.config.category.editor.add")}
`; const labelItems = html` ${this._labels?.map((label) => { - const color = label.color ? computeCssColor(label.color) : undefined; - return html` - - ${label.icon - ? html`` - : nothing} - ${label.name} - + const color = label.color ? computeCssColor(label.color) : undefined; + return html` + + ${label.icon + ? html`` + : nothing} + ${label.name} + + `; + })} + +
+ ${this.hass.localize("ui.panel.config.labels.add_label")} +
`; - })}`; return html` + createCategoryRegistryEntry(this.hass, "script", values), + }); + } + + private _createLabel() { + showLabelDetailDialog(this, { + createEntry: (values) => createLabelRegistryEntry(this.hass, values), + }); + } + static get styles(): CSSResultGroup { return [ haStyle,