From 5751fdbe5679f0378e18c75b55913b9e5eff610d Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 3 Apr 2024 15:18:40 +0200 Subject: [PATCH 1/6] Improve entity integration filter (#20372) --- .../config/entities/ha-config-entities.ts | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/panels/config/entities/ha-config-entities.ts b/src/panels/config/entities/ha-config-entities.ts index 910448ac3a..1ec59d4d14 100644 --- a/src/panels/config/entities/ha-config-entities.ts +++ b/src/panels/config/entities/ha-config-entities.ts @@ -88,6 +88,10 @@ 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"; +import { + EntitySources, + fetchEntitySourcesWithCache, +} from "../../../data/entity_sources"; export interface StateEntity extends Omit { @@ -141,6 +145,8 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { @state() _labels!: LabelRegistryEntry[]; + @state() private _entitySources?: EntitySources; + @query("hass-tabs-subpage-data-table", true) private _dataTable!: HaTabsSubpageDataTable; @@ -405,10 +411,12 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { const entryIds = entries .filter((entry) => filter.value!.includes(entry.domain)) .map((entry) => entry.entry_id); + filteredEntities = filteredEntities.filter( (entity) => - entity.config_entry_id && - entryIds.includes(entity.config_entry_id) + filter.value?.includes(entity.platform) || + (entity.config_entry_id && + entryIds.includes(entity.config_entry_id)) ); filter.value!.forEach((domain) => filteredDomains.add(domain)); } else if (key === "ha-filter-labels" && filter.value?.length) { @@ -807,6 +815,9 @@ ${ }, }; this._setFiltersFromUrl(); + fetchEntitySourcesWithCache(this.hass).then((sources) => { + this._entitySources = sources; + }); } private _setFiltersFromUrl() { @@ -865,14 +876,18 @@ ${ this._filters = {}; } - public willUpdate(changedProps: PropertyValues): void { + public willUpdate(changedProps: PropertyValues): void { super.willUpdate(changedProps); const oldHass = changedProps.get("hass"); let changed = false; if (!this.hass || !this._entities) { return; } - if (changedProps.has("hass") || changedProps.has("_entities")) { + if ( + changedProps.has("hass") || + changedProps.has("_entities") || + changedProps.has("_entitySources") + ) { const stateEntities: StateEntity[] = []; const regEntityIds = new Set( this._entities.map((entity) => entity.entity_id) @@ -883,6 +898,7 @@ ${ } if ( !oldHass || + changedProps.has("_entitySources") || this.hass.states[entityId] !== oldHass.states[entityId] ) { changed = true; @@ -890,7 +906,8 @@ ${ stateEntities.push({ name: computeStateName(this.hass.states[entityId]), entity_id: entityId, - platform: computeDomain(entityId), + platform: + this._entitySources?.[entityId]?.domain || computeDomain(entityId), disabled_by: null, hidden_by: null, area_id: null, From 92f6083e0bb639a5c18124e32144719dcd74231a Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 3 Apr 2024 15:19:05 +0200 Subject: [PATCH 2/6] Faulty helpers should not be selectable (#20373) --- src/panels/config/helpers/ha-config-helpers.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/panels/config/helpers/ha-config-helpers.ts b/src/panels/config/helpers/ha-config-helpers.ts index a63b0c2a01..745fb85572 100644 --- a/src/panels/config/helpers/ha-config-helpers.ts +++ b/src/panels/config/helpers/ha-config-helpers.ts @@ -375,6 +375,7 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) { type: configEntry.domain, configEntry, entity: undefined, + selectable: false, })); return [...states, ...entries] From d52afc3f7136e99c8f5424b7fcef3c871dfda560 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 3 Apr 2024 16:11:32 +0200 Subject: [PATCH 3/6] Add settings shortcut to scene and script table (#20375) --- src/panels/config/scene/ha-scene-dashboard.ts | 16 ++++++++++++++++ src/panels/config/script/ha-script-picker.ts | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/panels/config/scene/ha-scene-dashboard.ts b/src/panels/config/scene/ha-scene-dashboard.ts index 990ab42656..663d9dc720 100644 --- a/src/panels/config/scene/ha-scene-dashboard.ts +++ b/src/panels/config/scene/ha-scene-dashboard.ts @@ -2,6 +2,7 @@ import { consume } from "@lit-labs/context"; import "@lrnwebcomponents/simple-tooltip/simple-tooltip"; import { mdiChevronRight, + mdiCog, mdiContentDuplicate, mdiDelete, mdiDotsVertical, @@ -82,6 +83,7 @@ import { showAlertDialog, showConfirmationDialog, } from "../../../dialogs/generic/show-dialog-box"; +import { showMoreInfoDialog } from "../../../dialogs/more-info/show-ha-more-info-dialog"; import "../../../layouts/hass-tabs-subpage-data-table"; import { SubscribeMixin } from "../../../mixins/subscribe-mixin"; import { haStyle } from "../../../resources/styles"; @@ -283,6 +285,13 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) { ), action: () => this._showInfo(scene), }, + { + path: mdiCog, + label: this.hass.localize( + "ui.panel.config.automation.picker.show_settings" + ), + action: () => this._openSettings(scene), + }, { path: mdiPlay, label: this.hass.localize( @@ -815,6 +824,13 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) { fireEvent(this, "hass-more-info", { entityId: scene.entity_id }); } + private _openSettings(scene: SceneEntity) { + showMoreInfoDialog(this, { + entityId: scene.entity_id, + view: "settings", + }); + } + private _activateScene = async (scene: SceneEntity) => { await activateScene(this.hass, scene.entity_id); showToast(this, { diff --git a/src/panels/config/script/ha-script-picker.ts b/src/panels/config/script/ha-script-picker.ts index 4d0242e934..a548613d1a 100644 --- a/src/panels/config/script/ha-script-picker.ts +++ b/src/panels/config/script/ha-script-picker.ts @@ -1,6 +1,7 @@ import { consume } from "@lit-labs/context"; import { mdiChevronRight, + mdiCog, mdiContentDuplicate, mdiDelete, mdiDotsVertical, @@ -83,6 +84,7 @@ import { showAlertDialog, showConfirmationDialog, } from "../../../dialogs/generic/show-dialog-box"; +import { showMoreInfoDialog } from "../../../dialogs/more-info/show-ha-more-info-dialog"; import "../../../layouts/hass-tabs-subpage-data-table"; import { SubscribeMixin } from "../../../mixins/subscribe-mixin"; import { haStyle } from "../../../resources/styles"; @@ -294,6 +296,13 @@ class HaScriptPicker extends SubscribeMixin(LitElement) { ), action: () => this._showInfo(script), }, + { + path: mdiCog, + label: this.hass.localize( + "ui.panel.config.automation.picker.show_settings" + ), + action: () => this._openSettings(script), + }, { path: mdiTag, label: this.hass.localize( @@ -895,6 +904,13 @@ class HaScriptPicker extends SubscribeMixin(LitElement) { fireEvent(this, "hass-more-info", { entityId: script.entity_id }); } + private _openSettings(script: any) { + showMoreInfoDialog(this, { + entityId: script.entity_id, + view: "settings", + }); + } + private _showTrace(script: any) { const entry = this.entityRegistry.find( (e) => e.entity_id === script.entity_id From 712ddb531be0066c4733fa08f75d9ac42cf01a4c Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 3 Apr 2024 16:48:02 +0200 Subject: [PATCH 4/6] Make selection bar responsive (#20378) --- .../config/automation/ha-automation-picker.ts | 18 +++++++++++++---- .../config/helpers/ha-config-helpers.ts | 20 ++++++++++++++----- src/panels/config/scene/ha-scene-dashboard.ts | 16 ++++++++++++--- src/panels/config/script/ha-script-picker.ts | 16 ++++++++++++--- 4 files changed, 55 insertions(+), 15 deletions(-) diff --git a/src/panels/config/automation/ha-automation-picker.ts b/src/panels/config/automation/ha-automation-picker.ts index 28cd56dfc5..2da5c4ec56 100644 --- a/src/panels/config/automation/ha-automation-picker.ts +++ b/src/panels/config/automation/ha-automation-picker.ts @@ -1,4 +1,5 @@ import { consume } from "@lit-labs/context"; +import { ResizeController } from "@lit-labs/observers/resize-controller"; import "@lrnwebcomponents/simple-tooltip/simple-tooltip"; import "@material/web/divider/divider"; import { @@ -153,6 +154,10 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { @query("#overflow-menu") private _overflowMenu!: HaMenu; + private _sizeController = new ResizeController(this, { + callback: (entries) => entries[0]?.contentRect.width, + }); + private _automations = memoizeOne( ( automations: AutomationEntity[], @@ -414,7 +419,9 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { ${this.hass.localize("ui.panel.config.labels.add_label")} `; - + const labelsInOverflow = + (this._sizeController.value && this._sizeController.value < 700) || + (!this._sizeController.value && this.hass.dockedSidebar === "docked"); return html` ${categoryItems} - ${this.hass.dockedSidebar === "docked" + ${labelsInOverflow ? nothing : html` + this.narrow || labelsInOverflow + ? html`
${this.hass.localize( @@ -1146,6 +1153,9 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { return [ haStyle, css` + :host { + display: block; + } hass-tabs-subpage-data-table { --data-table-row-height: 60px; } diff --git a/src/panels/config/helpers/ha-config-helpers.ts b/src/panels/config/helpers/ha-config-helpers.ts index 745fb85572..fa89081415 100644 --- a/src/panels/config/helpers/ha-config-helpers.ts +++ b/src/panels/config/helpers/ha-config-helpers.ts @@ -1,4 +1,5 @@ import { consume } from "@lit-labs/context"; +import { ResizeController } from "@lit-labs/observers/resize-controller"; import "@lrnwebcomponents/simple-tooltip/simple-tooltip"; import { mdiAlertCircle, @@ -83,12 +84,12 @@ import { SubscribeMixin } from "../../../mixins/subscribe-mixin"; import { haStyle } from "../../../resources/styles"; import { HomeAssistant, Route } from "../../../types"; import { showAssignCategoryDialog } from "../category/show-dialog-assign-category"; +import { showCategoryRegistryDetailDialog } from "../category/show-dialog-category-registry-detail"; import { configSections } from "../ha-panel-config"; import "../integrations/ha-integration-overflow-menu"; +import { showLabelDetailDialog } from "../labels/show-dialog-label-detail"; import { isHelperDomain } from "./const"; import { showHelperDetailDialog } from "./show-dialog-helper-detail"; -import { showCategoryRegistryDetailDialog } from "../category/show-dialog-category-registry-detail"; -import { showLabelDetailDialog } from "../labels/show-dialog-label-detail"; type HelperItem = { id: string; @@ -163,6 +164,10 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) { @state() private _filteredStateItems?: string[] | null; + private _sizeController = new ResizeController(this, { + callback: (entries) => entries[0]?.contentRect.width, + }); + public hassSubscribe() { return [ subscribeConfigEntries( @@ -478,7 +483,9 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) { ${this.hass.localize("ui.panel.config.labels.add_label")}
`; - + const labelsInOverflow = + (this._sizeController.value && this._sizeController.value < 700) || + (!this._sizeController.value && this.hass.dockedSidebar === "docked"); return html` ${categoryItems}
- ${this.hass.dockedSidebar === "docked" + ${labelsInOverflow ? nothing : html` `}` : nothing} - ${this.narrow || this.hass.dockedSidebar === "docked" + ${this.narrow || labelsInOverflow ? html` ${ @@ -958,6 +965,9 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) { return [ haStyle, css` + :host { + display: block; + } hass-tabs-subpage-data-table { --data-table-row-height: 60px; } diff --git a/src/panels/config/scene/ha-scene-dashboard.ts b/src/panels/config/scene/ha-scene-dashboard.ts index 663d9dc720..ee79904c47 100644 --- a/src/panels/config/scene/ha-scene-dashboard.ts +++ b/src/panels/config/scene/ha-scene-dashboard.ts @@ -1,4 +1,5 @@ import { consume } from "@lit-labs/context"; +import { ResizeController } from "@lit-labs/observers/resize-controller"; import "@lrnwebcomponents/simple-tooltip/simple-tooltip"; import { mdiChevronRight, @@ -139,6 +140,10 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) { @consume({ context: fullEntitiesContext, subscribe: true }) _entityReg!: EntityRegistryEntry[]; + private _sizeController = new ResizeController(this, { + callback: (entries) => entries[0]?.contentRect.width, + }); + private _scenes = memoizeOne( ( scenes: SceneEntity[], @@ -417,7 +422,9 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) { ${this.hass.localize("ui.panel.config.labels.add_label")} `; - + const labelsInOverflow = + (this._sizeController.value && this._sizeController.value < 700) || + (!this._sizeController.value && this.hass.dockedSidebar === "docked"); return html` ${categoryItems} - ${this.hass.dockedSidebar === "docked" + ${labelsInOverflow ? nothing : html` `}` : nothing} - ${this.narrow || this.hass.dockedSidebar === "docked" + ${this.narrow || labelsInOverflow ? html` ${ @@ -912,6 +919,9 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) { return [ haStyle, css` + :host { + display: block; + } hass-tabs-subpage-data-table { --data-table-row-height: 60px; } diff --git a/src/panels/config/script/ha-script-picker.ts b/src/panels/config/script/ha-script-picker.ts index a548613d1a..8e9d5dd566 100644 --- a/src/panels/config/script/ha-script-picker.ts +++ b/src/panels/config/script/ha-script-picker.ts @@ -1,4 +1,5 @@ import { consume } from "@lit-labs/context"; +import { ResizeController } from "@lit-labs/observers/resize-controller"; import { mdiChevronRight, mdiCog, @@ -143,6 +144,10 @@ class HaScriptPicker extends SubscribeMixin(LitElement) { @consume({ context: fullEntitiesContext, subscribe: true }) _entityReg!: EntityRegistryEntry[]; + private _sizeController = new ResizeController(this, { + callback: (entries) => entries[0]?.contentRect.width, + }); + private _scripts = memoizeOne( ( scripts: ScriptEntity[], @@ -429,7 +434,9 @@ class HaScriptPicker extends SubscribeMixin(LitElement) { ${this.hass.localize("ui.panel.config.labels.add_label")} `; - + const labelsInOverflow = + (this._sizeController.value && this._sizeController.value < 700) || + (!this._sizeController.value && this.hass.dockedSidebar === "docked"); return html` ${categoryItems} - ${this.hass.dockedSidebar === "docked" + ${labelsInOverflow ? nothing : html` `}` : nothing} - ${this.narrow || this.hass.dockedSidebar === "docked" + ${this.narrow || labelsInOverflow ? html` ${ @@ -1028,6 +1035,9 @@ class HaScriptPicker extends SubscribeMixin(LitElement) { return [ haStyle, css` + :host { + display: block; + } hass-tabs-subpage-data-table { --data-table-row-height: 60px; } From 7704be12b1695b8a715391d786100f0625610178 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 3 Apr 2024 16:51:33 +0200 Subject: [PATCH 5/6] When creating a label or category with multi select, also assign it (#20379) * When creating a label or category with multi select, also assign it * correct scope * again --- .../config/automation/ha-automation-picker.ts | 33 +++++++++++++++---- .../devices/ha-config-devices-dashboard.ts | 14 ++++++-- .../config/entities/ha-config-entities.ts | 22 +++++++++---- .../config/helpers/ha-config-helpers.ts | 33 +++++++++++++++---- src/panels/config/scene/ha-scene-dashboard.ts | 33 +++++++++++++++---- src/panels/config/script/ha-script-picker.ts | 33 +++++++++++++++---- 6 files changed, 130 insertions(+), 38 deletions(-) diff --git a/src/panels/config/automation/ha-automation-picker.ts b/src/panels/config/automation/ha-automation-picker.ts index 2da5c4ec56..ecb40f5b71 100644 --- a/src/panels/config/automation/ha-automation-picker.ts +++ b/src/panels/config/automation/ha-automation-picker.ts @@ -378,7 +378,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { - +
${this.hass.localize("ui.panel.config.category.editor.add")}
@@ -414,7 +414,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
`; })} - +
${this.hass.localize("ui.panel.config.labels.add_label")}
[] = []; this._selected.forEach((entityId) => { promises.push( @@ -1103,6 +1107,10 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { private async _handleBulkLabel(ev) { const label = ev.currentTarget.value; const action = ev.currentTarget.action; + this._bulkLabel(label, action); + } + + private async _bulkLabel(label: string, action: "add" | "remove") { const promises: Promise[] = []; this._selected.forEach((entityId) => { promises.push( @@ -1135,17 +1143,28 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { await Promise.all(promises); } - private _createCategory() { + private async _bulkCreateCategory() { showCategoryRegistryDetailDialog(this, { scope: "automation", - createEntry: (values) => - createCategoryRegistryEntry(this.hass, "automation", values), + createEntry: async (values) => { + const category = await createCategoryRegistryEntry( + this.hass, + "automation", + values + ); + this._bulkAddCategory(category.category_id); + return category; + }, }); } - private _createLabel() { + private _bulkCreateLabel() { showLabelDetailDialog(this, { - createEntry: (values) => createLabelRegistryEntry(this.hass, values), + createEntry: async (values) => { + const label = await createLabelRegistryEntry(this.hass, values); + this._bulkLabel(label.label_id, "add"); + return label; + }, }); } diff --git a/src/panels/config/devices/ha-config-devices-dashboard.ts b/src/panels/config/devices/ha-config-devices-dashboard.ts index ba9630e2fa..f9f2fd16e6 100644 --- a/src/panels/config/devices/ha-config-devices-dashboard.ts +++ b/src/panels/config/devices/ha-config-devices-dashboard.ts @@ -575,7 +575,7 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
`; })} - +
${this.hass.localize("ui.panel.config.labels.add_label")}
[] = []; this._selected.forEach((deviceId) => { promises.push( @@ -817,9 +821,13 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) { await Promise.all(promises); } - private _createLabel() { + private _bulkCreateLabel() { showLabelDetailDialog(this, { - createEntry: (values) => createLabelRegistryEntry(this.hass, values), + createEntry: async (values) => { + const label = await createLabelRegistryEntry(this.hass, values); + this._bulkLabel(label.label_id, "add"); + return label; + }, }); } diff --git a/src/panels/config/entities/ha-config-entities.ts b/src/panels/config/entities/ha-config-entities.ts index 1ec59d4d14..5a7f5461aa 100644 --- a/src/panels/config/entities/ha-config-entities.ts +++ b/src/panels/config/entities/ha-config-entities.ts @@ -555,7 +555,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
`; })} - +
${this.hass.localize("ui.panel.config.labels.add_label")}
[] = []; this._selected.forEach((entityId) => { const entityReg = @@ -1064,6 +1068,16 @@ ${ await Promise.all(promises); } + private _bulkCreateLabel() { + showLabelDetailDialog(this, { + createEntry: async (values) => { + const label = await createLabelRegistryEntry(this.hass, values); + this._bulkLabel(label.label_id, "add"); + return label; + }, + }); + } + private _removeSelected() { const removeableEntities = this._selected.filter((entity) => { const stateObj = this.hass.states[entity]; @@ -1140,12 +1154,6 @@ ${ }); } - private _createLabel() { - showLabelDetailDialog(this, { - createEntry: (values) => createLabelRegistryEntry(this.hass, values), - }); - } - static get styles(): CSSResultGroup { return [ haStyle, diff --git a/src/panels/config/helpers/ha-config-helpers.ts b/src/panels/config/helpers/ha-config-helpers.ts index fa89081415..b32fa20750 100644 --- a/src/panels/config/helpers/ha-config-helpers.ts +++ b/src/panels/config/helpers/ha-config-helpers.ts @@ -443,7 +443,7 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
- +
${this.hass.localize("ui.panel.config.category.editor.add")}
@@ -478,7 +478,7 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
`; })} - +
${this.hass.localize("ui.panel.config.labels.add_label")}
@@ -779,6 +779,10 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) { private async _handleBulkCategory(ev) { const category = ev.currentTarget.value; + this._bulkAddCategory(category); + } + + private async _bulkAddCategory(category: string) { const promises: Promise[] = []; this._selected.forEach((entityId) => { promises.push( @@ -793,6 +797,10 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) { private async _handleBulkLabel(ev) { const label = ev.currentTarget.value; const action = ev.currentTarget.action; + this._bulkLabel(label, action); + } + + private async _bulkLabel(label: string, action: "add" | "remove") { const promises: Promise[] = []; this._selected.forEach((entityId) => { promises.push( @@ -947,17 +955,28 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) { showHelperDetailDialog(this, {}); } - private _createCategory() { + private async _bulkCreateCategory() { showCategoryRegistryDetailDialog(this, { scope: "helpers", - createEntry: (values) => - createCategoryRegistryEntry(this.hass, "helpers", values), + createEntry: async (values) => { + const category = await createCategoryRegistryEntry( + this.hass, + "helpers", + values + ); + this._bulkAddCategory(category.category_id); + return category; + }, }); } - private _createLabel() { + private _bulkCreateLabel() { showLabelDetailDialog(this, { - createEntry: (values) => createLabelRegistryEntry(this.hass, values), + createEntry: async (values) => { + const label = await createLabelRegistryEntry(this.hass, values); + this._bulkLabel(label.label_id, "add"); + return label; + }, }); } diff --git a/src/panels/config/scene/ha-scene-dashboard.ts b/src/panels/config/scene/ha-scene-dashboard.ts index ee79904c47..c07d31f7be 100644 --- a/src/panels/config/scene/ha-scene-dashboard.ts +++ b/src/panels/config/scene/ha-scene-dashboard.ts @@ -381,7 +381,7 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
- +
${this.hass.localize("ui.panel.config.category.editor.add")}
@@ -417,7 +417,7 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
`; })} - +
${this.hass.localize("ui.panel.config.labels.add_label")}
[] = []; this._selected.forEach((entityId) => { promises.push( @@ -790,6 +794,10 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) { private async _handleBulkLabel(ev) { const label = ev.currentTarget.value; const action = ev.currentTarget.action; + this._bulkLabel(label, action); + } + + private async _bulkLabel(label: string, action: "add" | "remove") { const promises: Promise[] = []; this._selected.forEach((entityId) => { promises.push( @@ -901,17 +909,28 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) { }); } - private _createCategory() { + private async _bulkCreateCategory() { showCategoryRegistryDetailDialog(this, { scope: "scene", - createEntry: (values) => - createCategoryRegistryEntry(this.hass, "scene", values), + createEntry: async (values) => { + const category = await createCategoryRegistryEntry( + this.hass, + "scene", + values + ); + this._bulkAddCategory(category.category_id); + return category; + }, }); } - private _createLabel() { + private _bulkCreateLabel() { showLabelDetailDialog(this, { - createEntry: (values) => createLabelRegistryEntry(this.hass, values), + createEntry: async (values) => { + const label = await createLabelRegistryEntry(this.hass, values); + this._bulkLabel(label.label_id, "add"); + return label; + }, }); } diff --git a/src/panels/config/script/ha-script-picker.ts b/src/panels/config/script/ha-script-picker.ts index 8e9d5dd566..2e769e8371 100644 --- a/src/panels/config/script/ha-script-picker.ts +++ b/src/panels/config/script/ha-script-picker.ts @@ -393,7 +393,7 @@ class HaScriptPicker extends SubscribeMixin(LitElement) { )}
- +
${this.hass.localize("ui.panel.config.category.editor.add")}
@@ -429,7 +429,7 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
`; })} - +
${this.hass.localize("ui.panel.config.labels.add_label")}
[] = []; this._selected.forEach((entityId) => { promises.push( @@ -859,6 +863,10 @@ class HaScriptPicker extends SubscribeMixin(LitElement) { private async _handleBulkLabel(ev) { const label = ev.currentTarget.value; const action = ev.currentTarget.action; + this._bulkLabel(label, action); + } + + private async _bulkLabel(label: string, action: "add" | "remove") { const promises: Promise[] = []; this._selected.forEach((entityId) => { promises.push( @@ -1017,17 +1025,28 @@ class HaScriptPicker extends SubscribeMixin(LitElement) { } } - private _createCategory() { + private async _bulkCreateCategory() { showCategoryRegistryDetailDialog(this, { scope: "script", - createEntry: (values) => - createCategoryRegistryEntry(this.hass, "script", values), + createEntry: async (values) => { + const category = await createCategoryRegistryEntry( + this.hass, + "script", + values + ); + this._bulkAddCategory(category.category_id); + return category; + }, }); } - private _createLabel() { + private _bulkCreateLabel() { showLabelDetailDialog(this, { - createEntry: (values) => createLabelRegistryEntry(this.hass, values), + createEntry: async (values) => { + const label = await createLabelRegistryEntry(this.hass, values); + this._bulkLabel(label.label_id, "add"); + return label; + }, }); } From 00837acdfcacea8732daf3cd125dfbc56081c95a Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 3 Apr 2024 16:52:23 +0200 Subject: [PATCH 6/6] Bumped version to 20240403.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7aa35c5c66..92bef3e682 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "home-assistant-frontend" -version = "20240403.0" +version = "20240403.1" license = {text = "Apache-2.0"} description = "The Home Assistant frontend" readme = "README.md"