{"results":{"result":{"added-files":{"code-health":8.92162939139867,"old-code-health":0.0,"files":[{"file":"templates/UmbracoExtension/Client/src/api/client/client.gen.ts","loc":162,"code-health":10.0},{"file":"templates/UmbracoExtension/Client/src/api/client/utils.gen.ts","loc":358,"code-health":8.314864455744324},{"file":"templates/UmbracoExtension/Client/src/api/core/bodySerializer.gen.ts","loc":78,"code-health":10.0},{"file":"templates/UmbracoExtension/Client/src/api/core/params.gen.ts","loc":121,"code-health":7.989617941542713},{"file":"templates/UmbracoExtension/Client/src/api/core/pathSerializer.gen.ts","loc":160,"code-health":9.366543680976838}]},"external-review-url":"https://github.com/umbraco/Umbraco-CMS/pull/19825","old-code-health":9.603465296750686,"modified-files":{"code-health":9.603465296750686,"old-code-health":9.603465296750686,"files":[{"file":"templates/UmbracoExtension/Client/src/dashboards/dashboard.element.ts","loc":183,"old-loc":183,"code-health":9.603465296750686,"old-code-health":9.603465296750686}]},"removed-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-id":"19825","analysis-time":"2025-08-19T12:49:56Z","negative-impact-count":12,"suppressions":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"affected-hotspots":0,"commits":["6ac7ae79b56c7e98d2188130e7363bc01194d12a","b3e60becf8814d76ef01b041e52b77c996d5a1ce","c9e1345af074cda49dcb14930707ad31a0ec602f","fba8302ce1cafc6698616738dc262036e532f5fa","1237899e411070ce3844919bff36e83e6af10a37","f9ac34071c53d07b2acf2a5b410b74adaebf61ed","0acbf8287cc3281716e1fb3ed0dfed2a3f5ae1cb","dda547279f33146b419a678a4864b69dfb7c54ff","1e41a3fbe12cd4019d64c51434733916d5265521","6a5588e522fcc80852d5e68a7e6f8b5396f470b2","eeb341dd848535f062f0d78d91f017d5e356c11c","717a993c5670f81c199b74e1f98a51eda37fc285"],"is-negative-review":true,"negative-findings":{"number-of-types":4,"number-of-files-touched":3,"findings":[{"method":"defaultPathSerializer","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the TypeScript language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"templates/UmbracoExtension/Client/src/api/client/utils.gen.ts","refactoring-examples":[{"architectural-component-id":null,"author-name":"Niels Lyngsø","training-data":{"loc-added":"9","loc-deleted":"10","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"nsl@umbraco.dk","commit-full-message":"","commit-date":"2025-02-17T08:11:28Z","current-rev":"8bbe0533c3","filename":"Umbraco-CMS/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts","previous-rev":"5379fec2d3","commit-title":"Close active modal if its begin unregistered (#18285)","language":"TypeScript","id":"88aeef715fd9d2fa61f2042a7a9017a6bab23d00","model-score":0.6,"author-id":null,"project-id":33308,"delta-file-score":0.31179166,"diff":"diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\nindex 96d25919bf..aad4a291a0 100644\n--- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\n+++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\n@@ -1,2 +1,2 @@\n-import type { UmbContentTypeModel, UmbPropertyTypeContainerModel } from '../types.js';\n+import type { UmbContentTypeModel } from '../types.js';\n import type { UmbContentTypeStructureManager } from './content-type-structure-manager.class.js';\n@@ -12,3 +12,2 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t#structure?: UmbContentTypeStructureManager<T>;\n-\t#tabContainers?: Array<UmbPropertyTypeContainerModel>;\n \n@@ -20,12 +19,10 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \n-\t#observeContainers() {\n+\tasync #observeContainers() {\n \t\tif (!this.#structure) return;\n \n-\t\tthis.observe(\n+\t\tawait this.observe(\n \t\t\tthis.#structure.ownerContainersOf('Tab', null),\n \t\t\t(tabContainers) => {\n-\t\t\t\tconst old = this.#tabContainers;\n-\t\t\t\tthis.#tabContainers = tabContainers;\n-\t\t\t\t// If the amount of containers was 0 before and now becomes 1, we should move all root containers into this tab:\n-\t\t\t\tif (old?.length === 0 && tabContainers?.length === 1) {\n+\t\t\t\t// If the amount of containers now became 1, we should move all root containers into this tab:\n+\t\t\t\tif (tabContainers?.length === 1) {\n \t\t\t\t\tconst firstTabId = tabContainers[0].id;\n@@ -35,2 +32,3 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\t\t\t\t});\n+\t\t\t\t\tthis.destroy();\n \t\t\t\t}\n@@ -38,3 +36,5 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\t\t'_observeMainContainer',\n-\t\t);\n+\t\t).asPromise();\n+\n+\t\tthis.destroy();\n \t}\n@@ -44,3 +44,2 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\tthis.#structure = undefined;\n-\t\tthis.#tabContainers = undefined;\n \t}\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Niels Lyngsø","training-data":{"loc-added":"54","loc-deleted":"72","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"nsl@umbraco.dk","commit-full-message":"* improve sorting algorithm\n\n* fix block type input\n\n* make confirm modal localizable\n\n* rename method\n\n* clean up\n\n* clean up\n\n* improve code\n\n* Fix creating Block Types in Groups\n\n* remove #moveData\n\n* lint fixes\n\n* remove unused\n\n---------\n\nCo-authored-by: Mads Rasmussen <madsr@hey.com>","commit-date":"2025-01-20T08:10:50Z","current-rev":"6c1c851d8a","filename":"Umbraco-CMS/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts","previous-rev":"4353027655","commit-title":"Fix: Improve sorter placement algorithm (#18021)","language":"TypeScript","id":"1c09c6d9203e7223417b741738479d2b893aaab9","model-score":0.27,"author-id":null,"project-id":33308,"delta-file-score":0.31179166,"diff":"diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\nindex ae743a577d..9c3f2f9276 100644\n--- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\n+++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\n@@ -1,7 +1,5 @@\n-import type { UmbBlockTypeWithGroupKey, UmbInputBlockTypeElement } from '../../../block-type/index.js';\n-import '../../../block-type/components/input-block-type/index.js';\n-import {\n-\ttype UmbPropertyEditorUiElement,\n-\tUmbPropertyValueChangeEvent,\n-\ttype UmbPropertyEditorConfigCollection,\n+import type { UmbBlockTypeWithGroupKey, UmbInputBlockTypeElement } from '@umbraco-cms/backoffice/block-type';\n+import type {\n+\tUmbPropertyEditorUiElement,\n+\tUmbPropertyEditorConfigCollection,\n } from '@umbraco-cms/backoffice/property-editor';\n@@ -32,2 +30,4 @@ import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/rou\n import { UmbSorterController } from '@umbraco-cms/backoffice/sorter';\n+import { UmbChangeEvent } from '@umbraco-cms/backoffice/event';\n+import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';\n \n@@ -45,3 +45,2 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n {\n-\t#moveData?: Array<UmbBlockTypeWithGroupKey>;\n \t#sorter = new UmbSorterController<MappedGroupWithBlockTypes, HTMLElement>(this, {\n@@ -106,4 +105,10 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\tthis.#datasetContext = context;\n-\t\t\t//this.#observeBlocks();\n-\t\t\tthis.#observeBlockGroups();\n+\t\t\tthis.observe(\n+\t\t\t\tawait this.#datasetContext.propertyValueByAlias('blockGroups'),\n+\t\t\t\t(value) => {\n+\t\t\t\t\tthis.#blockGroups = (value as Array<UmbBlockGridTypeGroupType>) ?? [];\n+\t\t\t\t\tthis.#mapValuesToBlockGroups();\n+\t\t\t\t},\n+\t\t\t\t'_observeBlockGroups',\n+\t\t\t);\n \t\t});\n@@ -121,20 +126,2 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \n-\tasync #observeBlockGroups() {\n-\t\tif (!this.#datasetContext) return;\n-\t\tthis.observe(await this.#datasetContext.propertyValueByAlias('blockGroups'), (value) => {\n-\t\t\tthis.#blockGroups = (value as Array<UmbBlockGridTypeGroupType>) ?? [];\n-\t\t\tthis.#mapValuesToBlockGroups();\n-\t\t});\n-\t}\n-\t// TODO: No need for this, we just got the value via the value property.. [NL]\n-\t/*\n-\tasync #observeBlocks() {\n-\t\tif (!this.#datasetContext) return;\n-\t\tthis.observe(await this.#datasetContext.propertyValueByAlias('blocks'), (value) => {\n-\t\t\tthis.value = (value as Array<UmbBlockTypeWithGroupKey>) ?? [];\n-\t\t\tthis.#mapValuesToBlockGroups();\n-\t\t});\n-\t}\n-\t*/\n-\n \t#mapValuesToBlockGroups() {\n@@ -154,36 +141,30 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \n-\t#onDelete(e: CustomEvent, groupKey?: string) {\n-\t\tconst updatedValues = (e.target as UmbInputBlockTypeElement).value.map((value) => ({ ...value, groupKey }));\n-\t\tconst filteredValues = this.#value.filter((value) => value.groupKey !== groupKey);\n-\t\tthis.value = [...filteredValues, ...updatedValues];\n-\t\tthis.dispatchEvent(new UmbPropertyValueChangeEvent());\n-\t}\n-\n-\tasync #onChange(e: CustomEvent) {\n+\tasync #onChange(e: Event, groupKey?: string) {\n \t\te.stopPropagation();\n \t\tconst element = e.target as UmbInputBlockTypeElement;\n-\t\tconst value = element.value;\n-\n-\t\tif (!e.detail?.moveComplete) {\n-\t\t\t// Container change, store data of the new group...\n-\t\t\tconst newGroupKey = element.getAttribute('data-umb-group-key');\n-\t\t\tconst movedItem = e.detail?.item as UmbBlockTypeWithGroupKey;\n-\t\t\t// Check if item moved back to original group...\n-\t\t\tif (movedItem.groupKey === newGroupKey) {\n-\t\t\t\tthis.#moveData = undefined;\n-\t\t\t} else {\n-\t\t\t\tthis.#moveData = value.map((block) => ({ ...block, groupKey: newGroupKey }));\n-\t\t\t}\n-\t\t} else if (e.detail?.moveComplete) {\n-\t\t\t// Move complete, get the blocks that were in an untouched group\n-\t\t\tconst blocks = this.#value\n-\t\t\t\t.filter((block) => !value.find((value) => value.contentElementTypeKey === block.contentElementTypeKey))\n-\t\t\t\t.filter(\n-\t\t\t\t\t(block) => !this.#moveData?.find((value) => value.contentElementTypeKey === block.contentElementTypeKey),\n-\t\t\t\t);\n-\n-\t\t\tthis.value = this.#moveData ? [...blocks, ...value, ...this.#moveData] : [...blocks, ...value];\n-\t\t\tthis.dispatchEvent(new UmbPropertyValueChangeEvent());\n-\t\t\tthis.#moveData = undefined;\n+\t\tconst value = element.value.map((x) => ({ ...x, groupKey }));\n+\n+\t\tif (groupKey) {\n+\t\t\t// Update the specific group:\n+\t\t\tthis._groupsWithBlockTypes = this._groupsWithBlockTypes.map((group) => {\n+\t\t\t\tif (group.key === groupKey) {\n+\t\t\t\t\treturn { ...group, blocks: value };\n+\t\t\t\t}\n+\t\t\t\treturn group;\n+\t\t\t});\n+\t\t} else {\n+\t\t\t// Update the not grouped blocks:\n+\t\t\tthis._notGroupedBlockTypes = value;\n \t\t}\n+\n+\t\tthis.#updateValue();\n+\t}\n+\n+\t#updateValue() {\n+\t\tthis.value = [...this._notGroupedBlockTypes, ...this._groupsWithBlockTypes.flatMap((group) => group.blocks)];\n+\t\tthis.dispatchEvent(new UmbChangeEvent());\n+\t}\n+\n+\t#updateBlockGroupsValue(groups: Array<UmbBlockGridTypeGroupType>) {\n+\t\tthis.#datasetContext?.setPropertyValue('blockGroups', groups);\n \t}\n@@ -193,3 +174,3 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\tif (selectedElementType) {\n-\t\t\tthis.#blockTypeWorkspaceModalRegistration?.open({}, 'create/' + selectedElementType + '/' + (groupKey ?? null));\n+\t\t\tthis.#blockTypeWorkspaceModalRegistration?.open({}, 'create/' + selectedElementType + '/' + (groupKey ?? 'null'));\n \t\t}\n@@ -198,15 +179,18 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t// TODO: Implement confirm dialog [NL]\n-\t#deleteGroup(groupKey: string) {\n-\t\t// TODO: make one method for updating the blockGroupsDataSetValue: [NL]\n-\t\t// This one that deletes might require the ability to parse what to send as an argument to the method, then a filtering can occur before.\n-\t\tthis.#datasetContext?.setPropertyValue(\n-\t\t\t'blockGroups',\n-\t\t\tthis.#blockGroups?.filter((group) => group.key !== groupKey),\n-\t\t);\n-\n+\tasync #deleteGroup(groupKey: string) {\n+\t\tconst groupName = this.#blockGroups?.find((group) => group.key === groupKey)?.name ?? '';\n+\t\tawait umbConfirmModal(this, {\n+\t\t\theadline: '#blockEditor_confirmDeleteBlockGroupTitle',\n+\t\t\tcontent: this.localize.term('#blockEditor_confirmDeleteBlockGroupMessage', [groupName]),\n+\t\t\tcolor: 'danger',\n+\t\t\tconfirmLabel: '#general_delete',\n+\t\t});\n \t\t// If a group is deleted, Move the blocks to no group:\n \t\tthis.value = this.#value.map((block) => (block.groupKey === groupKey ? { ...block, groupKey: undefined } : block));\n+\t\tif (this.#blockGroups) {\n+\t\t\tthis.#updateBlockGroupsValue(this.#blockGroups.filter((group) => group.key !== groupKey));\n+\t\t}\n \t}\n \n-\t#changeGroupName(e: UUIInputEvent, groupKey: string) {\n+\t#onGroupNameChange(e: UUIInputEvent, groupKey: string) {\n \t\tconst groupName = e.target.value as string;\n@@ -226,5 +210,4 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t\t\t.workspacePath=${this._workspacePath}\n-\t\t\t\t\t\t@change=${this.#onChange}\n-\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, undefined)}\n-\t\t\t\t\t\t@delete=${(e: CustomEvent) => this.#onDelete(e, undefined)}></umb-input-block-type>`\n+\t\t\t\t\t\t@change=${(e: Event) => this.#onChange(e, undefined)}\n+\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, undefined)}></umb-input-block-type>`\n \t\t\t\t: ''}\n@@ -241,5 +224,4 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t\t\t\t.workspacePath=${this._workspacePath}\n-\t\t\t\t\t\t\t@change=${this.#onChange}\n-\t\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, group.key)}\n-\t\t\t\t\t\t\t@delete=${(e: CustomEvent) => this.#onDelete(e, group.key)}></umb-input-block-type>\n+\t\t\t\t\t\t\t@change=${(e: Event) => this.#onChange(e, group.key)}\n+\t\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, group.key)}></umb-input-block-type>\n \t\t\t\t\t</div>`,\n@@ -255,3 +237,3 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t.value=${groupName ?? ''}\n-\t\t\t\t@change=${(e: UUIInputEvent) => this.#changeGroupName(e, groupKey)}>\n+\t\t\t\t@change=${(e: UUIInputEvent) => this.#onGroupNameChange(e, groupKey)}>\n \t\t\t\t<uui-button compact slot=\"append\" label=\"delete\" @click=${() => this.#deleteGroup(groupKey)}>\n","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":27,"what-changed":"defaultPathSerializer has a cyclomatic complexity of 12, threshold = 9","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"introduced"},{"method":"querySerializer","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the TypeScript language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"templates/UmbracoExtension/Client/src/api/client/utils.gen.ts","refactoring-examples":[{"architectural-component-id":null,"author-name":"Niels Lyngsø","training-data":{"loc-added":"9","loc-deleted":"10","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"nsl@umbraco.dk","commit-full-message":"","commit-date":"2025-02-17T08:11:28Z","current-rev":"8bbe0533c3","filename":"Umbraco-CMS/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts","previous-rev":"5379fec2d3","commit-title":"Close active modal if its begin unregistered (#18285)","language":"TypeScript","id":"88aeef715fd9d2fa61f2042a7a9017a6bab23d00","model-score":0.6,"author-id":null,"project-id":33308,"delta-file-score":0.31179166,"diff":"diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\nindex 96d25919bf..aad4a291a0 100644\n--- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\n+++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\n@@ -1,2 +1,2 @@\n-import type { UmbContentTypeModel, UmbPropertyTypeContainerModel } from '../types.js';\n+import type { UmbContentTypeModel } from '../types.js';\n import type { UmbContentTypeStructureManager } from './content-type-structure-manager.class.js';\n@@ -12,3 +12,2 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t#structure?: UmbContentTypeStructureManager<T>;\n-\t#tabContainers?: Array<UmbPropertyTypeContainerModel>;\n \n@@ -20,12 +19,10 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \n-\t#observeContainers() {\n+\tasync #observeContainers() {\n \t\tif (!this.#structure) return;\n \n-\t\tthis.observe(\n+\t\tawait this.observe(\n \t\t\tthis.#structure.ownerContainersOf('Tab', null),\n \t\t\t(tabContainers) => {\n-\t\t\t\tconst old = this.#tabContainers;\n-\t\t\t\tthis.#tabContainers = tabContainers;\n-\t\t\t\t// If the amount of containers was 0 before and now becomes 1, we should move all root containers into this tab:\n-\t\t\t\tif (old?.length === 0 && tabContainers?.length === 1) {\n+\t\t\t\t// If the amount of containers now became 1, we should move all root containers into this tab:\n+\t\t\t\tif (tabContainers?.length === 1) {\n \t\t\t\t\tconst firstTabId = tabContainers[0].id;\n@@ -35,2 +32,3 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\t\t\t\t});\n+\t\t\t\t\tthis.destroy();\n \t\t\t\t}\n@@ -38,3 +36,5 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\t\t'_observeMainContainer',\n-\t\t);\n+\t\t).asPromise();\n+\n+\t\tthis.destroy();\n \t}\n@@ -44,3 +44,2 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\tthis.#structure = undefined;\n-\t\tthis.#tabContainers = undefined;\n \t}\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Niels Lyngsø","training-data":{"loc-added":"54","loc-deleted":"72","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"nsl@umbraco.dk","commit-full-message":"* improve sorting algorithm\n\n* fix block type input\n\n* make confirm modal localizable\n\n* rename method\n\n* clean up\n\n* clean up\n\n* improve code\n\n* Fix creating Block Types in Groups\n\n* remove #moveData\n\n* lint fixes\n\n* remove unused\n\n---------\n\nCo-authored-by: Mads Rasmussen <madsr@hey.com>","commit-date":"2025-01-20T08:10:50Z","current-rev":"6c1c851d8a","filename":"Umbraco-CMS/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts","previous-rev":"4353027655","commit-title":"Fix: Improve sorter placement algorithm (#18021)","language":"TypeScript","id":"1c09c6d9203e7223417b741738479d2b893aaab9","model-score":0.27,"author-id":null,"project-id":33308,"delta-file-score":0.31179166,"diff":"diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\nindex ae743a577d..9c3f2f9276 100644\n--- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\n+++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\n@@ -1,7 +1,5 @@\n-import type { UmbBlockTypeWithGroupKey, UmbInputBlockTypeElement } from '../../../block-type/index.js';\n-import '../../../block-type/components/input-block-type/index.js';\n-import {\n-\ttype UmbPropertyEditorUiElement,\n-\tUmbPropertyValueChangeEvent,\n-\ttype UmbPropertyEditorConfigCollection,\n+import type { UmbBlockTypeWithGroupKey, UmbInputBlockTypeElement } from '@umbraco-cms/backoffice/block-type';\n+import type {\n+\tUmbPropertyEditorUiElement,\n+\tUmbPropertyEditorConfigCollection,\n } from '@umbraco-cms/backoffice/property-editor';\n@@ -32,2 +30,4 @@ import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/rou\n import { UmbSorterController } from '@umbraco-cms/backoffice/sorter';\n+import { UmbChangeEvent } from '@umbraco-cms/backoffice/event';\n+import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';\n \n@@ -45,3 +45,2 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n {\n-\t#moveData?: Array<UmbBlockTypeWithGroupKey>;\n \t#sorter = new UmbSorterController<MappedGroupWithBlockTypes, HTMLElement>(this, {\n@@ -106,4 +105,10 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\tthis.#datasetContext = context;\n-\t\t\t//this.#observeBlocks();\n-\t\t\tthis.#observeBlockGroups();\n+\t\t\tthis.observe(\n+\t\t\t\tawait this.#datasetContext.propertyValueByAlias('blockGroups'),\n+\t\t\t\t(value) => {\n+\t\t\t\t\tthis.#blockGroups = (value as Array<UmbBlockGridTypeGroupType>) ?? [];\n+\t\t\t\t\tthis.#mapValuesToBlockGroups();\n+\t\t\t\t},\n+\t\t\t\t'_observeBlockGroups',\n+\t\t\t);\n \t\t});\n@@ -121,20 +126,2 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \n-\tasync #observeBlockGroups() {\n-\t\tif (!this.#datasetContext) return;\n-\t\tthis.observe(await this.#datasetContext.propertyValueByAlias('blockGroups'), (value) => {\n-\t\t\tthis.#blockGroups = (value as Array<UmbBlockGridTypeGroupType>) ?? [];\n-\t\t\tthis.#mapValuesToBlockGroups();\n-\t\t});\n-\t}\n-\t// TODO: No need for this, we just got the value via the value property.. [NL]\n-\t/*\n-\tasync #observeBlocks() {\n-\t\tif (!this.#datasetContext) return;\n-\t\tthis.observe(await this.#datasetContext.propertyValueByAlias('blocks'), (value) => {\n-\t\t\tthis.value = (value as Array<UmbBlockTypeWithGroupKey>) ?? [];\n-\t\t\tthis.#mapValuesToBlockGroups();\n-\t\t});\n-\t}\n-\t*/\n-\n \t#mapValuesToBlockGroups() {\n@@ -154,36 +141,30 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \n-\t#onDelete(e: CustomEvent, groupKey?: string) {\n-\t\tconst updatedValues = (e.target as UmbInputBlockTypeElement).value.map((value) => ({ ...value, groupKey }));\n-\t\tconst filteredValues = this.#value.filter((value) => value.groupKey !== groupKey);\n-\t\tthis.value = [...filteredValues, ...updatedValues];\n-\t\tthis.dispatchEvent(new UmbPropertyValueChangeEvent());\n-\t}\n-\n-\tasync #onChange(e: CustomEvent) {\n+\tasync #onChange(e: Event, groupKey?: string) {\n \t\te.stopPropagation();\n \t\tconst element = e.target as UmbInputBlockTypeElement;\n-\t\tconst value = element.value;\n-\n-\t\tif (!e.detail?.moveComplete) {\n-\t\t\t// Container change, store data of the new group...\n-\t\t\tconst newGroupKey = element.getAttribute('data-umb-group-key');\n-\t\t\tconst movedItem = e.detail?.item as UmbBlockTypeWithGroupKey;\n-\t\t\t// Check if item moved back to original group...\n-\t\t\tif (movedItem.groupKey === newGroupKey) {\n-\t\t\t\tthis.#moveData = undefined;\n-\t\t\t} else {\n-\t\t\t\tthis.#moveData = value.map((block) => ({ ...block, groupKey: newGroupKey }));\n-\t\t\t}\n-\t\t} else if (e.detail?.moveComplete) {\n-\t\t\t// Move complete, get the blocks that were in an untouched group\n-\t\t\tconst blocks = this.#value\n-\t\t\t\t.filter((block) => !value.find((value) => value.contentElementTypeKey === block.contentElementTypeKey))\n-\t\t\t\t.filter(\n-\t\t\t\t\t(block) => !this.#moveData?.find((value) => value.contentElementTypeKey === block.contentElementTypeKey),\n-\t\t\t\t);\n-\n-\t\t\tthis.value = this.#moveData ? [...blocks, ...value, ...this.#moveData] : [...blocks, ...value];\n-\t\t\tthis.dispatchEvent(new UmbPropertyValueChangeEvent());\n-\t\t\tthis.#moveData = undefined;\n+\t\tconst value = element.value.map((x) => ({ ...x, groupKey }));\n+\n+\t\tif (groupKey) {\n+\t\t\t// Update the specific group:\n+\t\t\tthis._groupsWithBlockTypes = this._groupsWithBlockTypes.map((group) => {\n+\t\t\t\tif (group.key === groupKey) {\n+\t\t\t\t\treturn { ...group, blocks: value };\n+\t\t\t\t}\n+\t\t\t\treturn group;\n+\t\t\t});\n+\t\t} else {\n+\t\t\t// Update the not grouped blocks:\n+\t\t\tthis._notGroupedBlockTypes = value;\n \t\t}\n+\n+\t\tthis.#updateValue();\n+\t}\n+\n+\t#updateValue() {\n+\t\tthis.value = [...this._notGroupedBlockTypes, ...this._groupsWithBlockTypes.flatMap((group) => group.blocks)];\n+\t\tthis.dispatchEvent(new UmbChangeEvent());\n+\t}\n+\n+\t#updateBlockGroupsValue(groups: Array<UmbBlockGridTypeGroupType>) {\n+\t\tthis.#datasetContext?.setPropertyValue('blockGroups', groups);\n \t}\n@@ -193,3 +174,3 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\tif (selectedElementType) {\n-\t\t\tthis.#blockTypeWorkspaceModalRegistration?.open({}, 'create/' + selectedElementType + '/' + (groupKey ?? null));\n+\t\t\tthis.#blockTypeWorkspaceModalRegistration?.open({}, 'create/' + selectedElementType + '/' + (groupKey ?? 'null'));\n \t\t}\n@@ -198,15 +179,18 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t// TODO: Implement confirm dialog [NL]\n-\t#deleteGroup(groupKey: string) {\n-\t\t// TODO: make one method for updating the blockGroupsDataSetValue: [NL]\n-\t\t// This one that deletes might require the ability to parse what to send as an argument to the method, then a filtering can occur before.\n-\t\tthis.#datasetContext?.setPropertyValue(\n-\t\t\t'blockGroups',\n-\t\t\tthis.#blockGroups?.filter((group) => group.key !== groupKey),\n-\t\t);\n-\n+\tasync #deleteGroup(groupKey: string) {\n+\t\tconst groupName = this.#blockGroups?.find((group) => group.key === groupKey)?.name ?? '';\n+\t\tawait umbConfirmModal(this, {\n+\t\t\theadline: '#blockEditor_confirmDeleteBlockGroupTitle',\n+\t\t\tcontent: this.localize.term('#blockEditor_confirmDeleteBlockGroupMessage', [groupName]),\n+\t\t\tcolor: 'danger',\n+\t\t\tconfirmLabel: '#general_delete',\n+\t\t});\n \t\t// If a group is deleted, Move the blocks to no group:\n \t\tthis.value = this.#value.map((block) => (block.groupKey === groupKey ? { ...block, groupKey: undefined } : block));\n+\t\tif (this.#blockGroups) {\n+\t\t\tthis.#updateBlockGroupsValue(this.#blockGroups.filter((group) => group.key !== groupKey));\n+\t\t}\n \t}\n \n-\t#changeGroupName(e: UUIInputEvent, groupKey: string) {\n+\t#onGroupNameChange(e: UUIInputEvent, groupKey: string) {\n \t\tconst groupName = e.target.value as string;\n@@ -226,5 +210,4 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t\t\t.workspacePath=${this._workspacePath}\n-\t\t\t\t\t\t@change=${this.#onChange}\n-\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, undefined)}\n-\t\t\t\t\t\t@delete=${(e: CustomEvent) => this.#onDelete(e, undefined)}></umb-input-block-type>`\n+\t\t\t\t\t\t@change=${(e: Event) => this.#onChange(e, undefined)}\n+\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, undefined)}></umb-input-block-type>`\n \t\t\t\t: ''}\n@@ -241,5 +224,4 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t\t\t\t.workspacePath=${this._workspacePath}\n-\t\t\t\t\t\t\t@change=${this.#onChange}\n-\t\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, group.key)}\n-\t\t\t\t\t\t\t@delete=${(e: CustomEvent) => this.#onDelete(e, group.key)}></umb-input-block-type>\n+\t\t\t\t\t\t\t@change=${(e: Event) => this.#onChange(e, group.key)}\n+\t\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, group.key)}></umb-input-block-type>\n \t\t\t\t\t</div>`,\n@@ -255,3 +237,3 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t.value=${groupName ?? ''}\n-\t\t\t\t@change=${(e: UUIInputEvent) => this.#changeGroupName(e, groupKey)}>\n+\t\t\t\t@change=${(e: UUIInputEvent) => this.#onGroupNameChange(e, groupKey)}>\n \t\t\t\t<uui-button compact slot=\"append\" label=\"delete\" @click=${() => this.#deleteGroup(groupKey)}>\n","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":102,"what-changed":"querySerializer has a cyclomatic complexity of 11, threshold = 9","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"introduced"},{"method":"getParseAs","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the TypeScript language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"templates/UmbracoExtension/Client/src/api/client/utils.gen.ts","refactoring-examples":[{"architectural-component-id":null,"author-name":"Niels Lyngsø","training-data":{"loc-added":"9","loc-deleted":"10","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"nsl@umbraco.dk","commit-full-message":"","commit-date":"2025-02-17T08:11:28Z","current-rev":"8bbe0533c3","filename":"Umbraco-CMS/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts","previous-rev":"5379fec2d3","commit-title":"Close active modal if its begin unregistered (#18285)","language":"TypeScript","id":"88aeef715fd9d2fa61f2042a7a9017a6bab23d00","model-score":0.6,"author-id":null,"project-id":33308,"delta-file-score":0.31179166,"diff":"diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\nindex 96d25919bf..aad4a291a0 100644\n--- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\n+++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\n@@ -1,2 +1,2 @@\n-import type { UmbContentTypeModel, UmbPropertyTypeContainerModel } from '../types.js';\n+import type { UmbContentTypeModel } from '../types.js';\n import type { UmbContentTypeStructureManager } from './content-type-structure-manager.class.js';\n@@ -12,3 +12,2 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t#structure?: UmbContentTypeStructureManager<T>;\n-\t#tabContainers?: Array<UmbPropertyTypeContainerModel>;\n \n@@ -20,12 +19,10 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \n-\t#observeContainers() {\n+\tasync #observeContainers() {\n \t\tif (!this.#structure) return;\n \n-\t\tthis.observe(\n+\t\tawait this.observe(\n \t\t\tthis.#structure.ownerContainersOf('Tab', null),\n \t\t\t(tabContainers) => {\n-\t\t\t\tconst old = this.#tabContainers;\n-\t\t\t\tthis.#tabContainers = tabContainers;\n-\t\t\t\t// If the amount of containers was 0 before and now becomes 1, we should move all root containers into this tab:\n-\t\t\t\tif (old?.length === 0 && tabContainers?.length === 1) {\n+\t\t\t\t// If the amount of containers now became 1, we should move all root containers into this tab:\n+\t\t\t\tif (tabContainers?.length === 1) {\n \t\t\t\t\tconst firstTabId = tabContainers[0].id;\n@@ -35,2 +32,3 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\t\t\t\t});\n+\t\t\t\t\tthis.destroy();\n \t\t\t\t}\n@@ -38,3 +36,5 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\t\t'_observeMainContainer',\n-\t\t);\n+\t\t).asPromise();\n+\n+\t\tthis.destroy();\n \t}\n@@ -44,3 +44,2 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\tthis.#structure = undefined;\n-\t\tthis.#tabContainers = undefined;\n \t}\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Niels Lyngsø","training-data":{"loc-added":"54","loc-deleted":"72","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"nsl@umbraco.dk","commit-full-message":"* improve sorting algorithm\n\n* fix block type input\n\n* make confirm modal localizable\n\n* rename method\n\n* clean up\n\n* clean up\n\n* improve code\n\n* Fix creating Block Types in Groups\n\n* remove #moveData\n\n* lint fixes\n\n* remove unused\n\n---------\n\nCo-authored-by: Mads Rasmussen <madsr@hey.com>","commit-date":"2025-01-20T08:10:50Z","current-rev":"6c1c851d8a","filename":"Umbraco-CMS/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts","previous-rev":"4353027655","commit-title":"Fix: Improve sorter placement algorithm (#18021)","language":"TypeScript","id":"1c09c6d9203e7223417b741738479d2b893aaab9","model-score":0.27,"author-id":null,"project-id":33308,"delta-file-score":0.31179166,"diff":"diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\nindex ae743a577d..9c3f2f9276 100644\n--- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\n+++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\n@@ -1,7 +1,5 @@\n-import type { UmbBlockTypeWithGroupKey, UmbInputBlockTypeElement } from '../../../block-type/index.js';\n-import '../../../block-type/components/input-block-type/index.js';\n-import {\n-\ttype UmbPropertyEditorUiElement,\n-\tUmbPropertyValueChangeEvent,\n-\ttype UmbPropertyEditorConfigCollection,\n+import type { UmbBlockTypeWithGroupKey, UmbInputBlockTypeElement } from '@umbraco-cms/backoffice/block-type';\n+import type {\n+\tUmbPropertyEditorUiElement,\n+\tUmbPropertyEditorConfigCollection,\n } from '@umbraco-cms/backoffice/property-editor';\n@@ -32,2 +30,4 @@ import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/rou\n import { UmbSorterController } from '@umbraco-cms/backoffice/sorter';\n+import { UmbChangeEvent } from '@umbraco-cms/backoffice/event';\n+import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';\n \n@@ -45,3 +45,2 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n {\n-\t#moveData?: Array<UmbBlockTypeWithGroupKey>;\n \t#sorter = new UmbSorterController<MappedGroupWithBlockTypes, HTMLElement>(this, {\n@@ -106,4 +105,10 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\tthis.#datasetContext = context;\n-\t\t\t//this.#observeBlocks();\n-\t\t\tthis.#observeBlockGroups();\n+\t\t\tthis.observe(\n+\t\t\t\tawait this.#datasetContext.propertyValueByAlias('blockGroups'),\n+\t\t\t\t(value) => {\n+\t\t\t\t\tthis.#blockGroups = (value as Array<UmbBlockGridTypeGroupType>) ?? [];\n+\t\t\t\t\tthis.#mapValuesToBlockGroups();\n+\t\t\t\t},\n+\t\t\t\t'_observeBlockGroups',\n+\t\t\t);\n \t\t});\n@@ -121,20 +126,2 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \n-\tasync #observeBlockGroups() {\n-\t\tif (!this.#datasetContext) return;\n-\t\tthis.observe(await this.#datasetContext.propertyValueByAlias('blockGroups'), (value) => {\n-\t\t\tthis.#blockGroups = (value as Array<UmbBlockGridTypeGroupType>) ?? [];\n-\t\t\tthis.#mapValuesToBlockGroups();\n-\t\t});\n-\t}\n-\t// TODO: No need for this, we just got the value via the value property.. [NL]\n-\t/*\n-\tasync #observeBlocks() {\n-\t\tif (!this.#datasetContext) return;\n-\t\tthis.observe(await this.#datasetContext.propertyValueByAlias('blocks'), (value) => {\n-\t\t\tthis.value = (value as Array<UmbBlockTypeWithGroupKey>) ?? [];\n-\t\t\tthis.#mapValuesToBlockGroups();\n-\t\t});\n-\t}\n-\t*/\n-\n \t#mapValuesToBlockGroups() {\n@@ -154,36 +141,30 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \n-\t#onDelete(e: CustomEvent, groupKey?: string) {\n-\t\tconst updatedValues = (e.target as UmbInputBlockTypeElement).value.map((value) => ({ ...value, groupKey }));\n-\t\tconst filteredValues = this.#value.filter((value) => value.groupKey !== groupKey);\n-\t\tthis.value = [...filteredValues, ...updatedValues];\n-\t\tthis.dispatchEvent(new UmbPropertyValueChangeEvent());\n-\t}\n-\n-\tasync #onChange(e: CustomEvent) {\n+\tasync #onChange(e: Event, groupKey?: string) {\n \t\te.stopPropagation();\n \t\tconst element = e.target as UmbInputBlockTypeElement;\n-\t\tconst value = element.value;\n-\n-\t\tif (!e.detail?.moveComplete) {\n-\t\t\t// Container change, store data of the new group...\n-\t\t\tconst newGroupKey = element.getAttribute('data-umb-group-key');\n-\t\t\tconst movedItem = e.detail?.item as UmbBlockTypeWithGroupKey;\n-\t\t\t// Check if item moved back to original group...\n-\t\t\tif (movedItem.groupKey === newGroupKey) {\n-\t\t\t\tthis.#moveData = undefined;\n-\t\t\t} else {\n-\t\t\t\tthis.#moveData = value.map((block) => ({ ...block, groupKey: newGroupKey }));\n-\t\t\t}\n-\t\t} else if (e.detail?.moveComplete) {\n-\t\t\t// Move complete, get the blocks that were in an untouched group\n-\t\t\tconst blocks = this.#value\n-\t\t\t\t.filter((block) => !value.find((value) => value.contentElementTypeKey === block.contentElementTypeKey))\n-\t\t\t\t.filter(\n-\t\t\t\t\t(block) => !this.#moveData?.find((value) => value.contentElementTypeKey === block.contentElementTypeKey),\n-\t\t\t\t);\n-\n-\t\t\tthis.value = this.#moveData ? [...blocks, ...value, ...this.#moveData] : [...blocks, ...value];\n-\t\t\tthis.dispatchEvent(new UmbPropertyValueChangeEvent());\n-\t\t\tthis.#moveData = undefined;\n+\t\tconst value = element.value.map((x) => ({ ...x, groupKey }));\n+\n+\t\tif (groupKey) {\n+\t\t\t// Update the specific group:\n+\t\t\tthis._groupsWithBlockTypes = this._groupsWithBlockTypes.map((group) => {\n+\t\t\t\tif (group.key === groupKey) {\n+\t\t\t\t\treturn { ...group, blocks: value };\n+\t\t\t\t}\n+\t\t\t\treturn group;\n+\t\t\t});\n+\t\t} else {\n+\t\t\t// Update the not grouped blocks:\n+\t\t\tthis._notGroupedBlockTypes = value;\n \t\t}\n+\n+\t\tthis.#updateValue();\n+\t}\n+\n+\t#updateValue() {\n+\t\tthis.value = [...this._notGroupedBlockTypes, ...this._groupsWithBlockTypes.flatMap((group) => group.blocks)];\n+\t\tthis.dispatchEvent(new UmbChangeEvent());\n+\t}\n+\n+\t#updateBlockGroupsValue(groups: Array<UmbBlockGridTypeGroupType>) {\n+\t\tthis.#datasetContext?.setPropertyValue('blockGroups', groups);\n \t}\n@@ -193,3 +174,3 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\tif (selectedElementType) {\n-\t\t\tthis.#blockTypeWorkspaceModalRegistration?.open({}, 'create/' + selectedElementType + '/' + (groupKey ?? null));\n+\t\t\tthis.#blockTypeWorkspaceModalRegistration?.open({}, 'create/' + selectedElementType + '/' + (groupKey ?? 'null'));\n \t\t}\n@@ -198,15 +179,18 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t// TODO: Implement confirm dialog [NL]\n-\t#deleteGroup(groupKey: string) {\n-\t\t// TODO: make one method for updating the blockGroupsDataSetValue: [NL]\n-\t\t// This one that deletes might require the ability to parse what to send as an argument to the method, then a filtering can occur before.\n-\t\tthis.#datasetContext?.setPropertyValue(\n-\t\t\t'blockGroups',\n-\t\t\tthis.#blockGroups?.filter((group) => group.key !== groupKey),\n-\t\t);\n-\n+\tasync #deleteGroup(groupKey: string) {\n+\t\tconst groupName = this.#blockGroups?.find((group) => group.key === groupKey)?.name ?? '';\n+\t\tawait umbConfirmModal(this, {\n+\t\t\theadline: '#blockEditor_confirmDeleteBlockGroupTitle',\n+\t\t\tcontent: this.localize.term('#blockEditor_confirmDeleteBlockGroupMessage', [groupName]),\n+\t\t\tcolor: 'danger',\n+\t\t\tconfirmLabel: '#general_delete',\n+\t\t});\n \t\t// If a group is deleted, Move the blocks to no group:\n \t\tthis.value = this.#value.map((block) => (block.groupKey === groupKey ? { ...block, groupKey: undefined } : block));\n+\t\tif (this.#blockGroups) {\n+\t\t\tthis.#updateBlockGroupsValue(this.#blockGroups.filter((group) => group.key !== groupKey));\n+\t\t}\n \t}\n \n-\t#changeGroupName(e: UUIInputEvent, groupKey: string) {\n+\t#onGroupNameChange(e: UUIInputEvent, groupKey: string) {\n \t\tconst groupName = e.target.value as string;\n@@ -226,5 +210,4 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t\t\t.workspacePath=${this._workspacePath}\n-\t\t\t\t\t\t@change=${this.#onChange}\n-\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, undefined)}\n-\t\t\t\t\t\t@delete=${(e: CustomEvent) => this.#onDelete(e, undefined)}></umb-input-block-type>`\n+\t\t\t\t\t\t@change=${(e: Event) => this.#onChange(e, undefined)}\n+\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, undefined)}></umb-input-block-type>`\n \t\t\t\t: ''}\n@@ -241,5 +224,4 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t\t\t\t.workspacePath=${this._workspacePath}\n-\t\t\t\t\t\t\t@change=${this.#onChange}\n-\t\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, group.key)}\n-\t\t\t\t\t\t\t@delete=${(e: CustomEvent) => this.#onDelete(e, group.key)}></umb-input-block-type>\n+\t\t\t\t\t\t\t@change=${(e: Event) => this.#onChange(e, group.key)}\n+\t\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, group.key)}></umb-input-block-type>\n \t\t\t\t\t</div>`,\n@@ -255,3 +237,3 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t.value=${groupName ?? ''}\n-\t\t\t\t@change=${(e: UUIInputEvent) => this.#changeGroupName(e, groupKey)}>\n+\t\t\t\t@change=${(e: UUIInputEvent) => this.#onGroupNameChange(e, groupKey)}>\n \t\t\t\t<uui-button compact slot=\"append\" label=\"delete\" @click=${() => this.#deleteGroup(groupKey)}>\n","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":150,"what-changed":"getParseAs has a cyclomatic complexity of 9, threshold = 9","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"introduced"},{"method":"querySerializer","why-it-occurs":"A Bumpy Road is a function that contains multiple chunks of nested conditional logic inside the same function. The deeper the nesting and the more bumps, the lower the code health.\n\nA bumpy code road represents a lack of encapsulation which becomes an obstacle to comprehension. In imperative languages there’s also an increased risk for feature entanglement, which leads to complex state management. CodeScene considers the following rules for the code health impact: 1) The deeper the nested conditional logic of each bump, the higher the tax on our working memory. 2) The more bumps inside a function, the more expensive it is to refactor as each bump represents a missing abstraction. 3) The larger each bump – that is, the more lines of code it spans – the harder it is to build up a mental model of the function. The nesting depth for what is considered a bump is  levels of conditionals.","name":"Bumpy Road Ahead","file":"templates/UmbracoExtension/Client/src/api/client/utils.gen.ts","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":102,"what-changed":"querySerializer has 4 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is one single, nested block per function","how-to-fix":"Bumpy Road implementations indicate a lack of encapsulation. Check out the detailed description of the [Bumpy Road code health issue](https://codescene.com/blog/bumpy-road-code-complexity-in-context/).\n\nA Bumpy Road often suggests that the function/method does too many things. The first refactoring step is to identify the different possible responsibilities of the function. Consider extracting those responsibilities into smaller, cohesive, and well-named functions. The [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring is the primary response.","change-type":"introduced"},{"method":"setAuthParams","why-it-occurs":"A Bumpy Road is a function that contains multiple chunks of nested conditional logic inside the same function. The deeper the nesting and the more bumps, the lower the code health.\n\nA bumpy code road represents a lack of encapsulation which becomes an obstacle to comprehension. In imperative languages there’s also an increased risk for feature entanglement, which leads to complex state management. CodeScene considers the following rules for the code health impact: 1) The deeper the nested conditional logic of each bump, the higher the tax on our working memory. 2) The more bumps inside a function, the more expensive it is to refactor as each bump represents a missing abstraction. 3) The larger each bump – that is, the more lines of code it spans – the harder it is to build up a mental model of the function. The nesting depth for what is considered a bump is  levels of conditionals.","name":"Bumpy Road Ahead","file":"templates/UmbracoExtension/Client/src/api/client/utils.gen.ts","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":191,"what-changed":"setAuthParams has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is one single, nested block per function","how-to-fix":"Bumpy Road implementations indicate a lack of encapsulation. Check out the detailed description of the [Bumpy Road code health issue](https://codescene.com/blog/bumpy-road-code-complexity-in-context/).\n\nA Bumpy Road often suggests that the function/method does too many things. The first refactoring step is to identify the different possible responsibilities of the function. Consider extracting those responsibilities into smaller, cohesive, and well-named functions. The [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring is the primary response.","change-type":"introduced"},{"method":"querySerializer","why-it-occurs":"Deep nested logic means that you have control structures like if-statements or loops inside other control structures. Deep nested logic increases the cognitive load on the programmer reading the code. The human working memory has a maximum capacity of 3-4 items; beyond that threshold, we struggle with keeping things in our head. Consequently, deep nested logic has a strong correlation to defects and accounts for roughly 20% of all programming mistakes.\n\nCodeScene measures the maximum nesting depth inside each function. The deeper the nesting, the lower the code health. The threshold for the TypeScript language is 4 levels of nesting.","name":"Deep, Nested Complexity","file":"templates/UmbracoExtension/Client/src/api/client/utils.gen.ts","refactoring-examples":[{"architectural-component-id":null,"author-name":"leekelleher","training-data":{"loc-added":"5","loc-deleted":"7","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"2.0","delta-n-functions":"0","current-file-score":"9.663736664415227"},"author-email":"leekelleher@gmail.com","commit-full-message":"The unit test doesn't register the manifests, so we'll need\nto hard code loading the \"Rich Text Essentials\" extension.","commit-date":"2025-02-19T10:22:48Z","current-rev":"28fb7ad67e","filename":"Umbraco-CMS/src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts","previous-rev":"effa40fabb","commit-title":"Refactors loading core Tipap extension","language":"TypeScript","id":"8312ef85dffade57f8d0318992ee5ef649ad8f27","model-score":0.64,"author-id":null,"project-id":33308,"delta-file-score":0.58988667,"diff":"diff --git a/src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts b/src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts\nindex 8ad7178036..387f511eb1 100644\n--- a/src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts\n+++ b/src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts\n@@ -68,11 +68,12 @@ export class UmbInputTiptapElement extends UmbFormControlMixin<string, typeof Um\n \tasync #loadExtensions() {\n-\t\tawait new Promise<void>((resolve) => {\n-\t\t\tthis.observe(umbExtensionsRegistry.byType('tiptapExtension'), async (manifests) => {\n-\t\t\t\tlet enabledExtensions = this.configuration?.getValueByAlias<string[]>('extensions') ?? [];\n+\t\tconst enabledExtensions = this.configuration?.getValueByAlias<string[]>('extensions') ?? [];\n \n-\t\t\t\t// Ensures that the \"Rich Text Essentials\" extension is always enabled. [LK]\n-\t\t\t\tif (!enabledExtensions.includes(TIPTAP_CORE_EXTENSION_ALIAS)) {\n-\t\t\t\t\tenabledExtensions = [TIPTAP_CORE_EXTENSION_ALIAS, ...enabledExtensions];\n-\t\t\t\t}\n+\t\t// Ensures that the \"Rich Text Essentials\" extension is always enabled. [LK]\n+\t\tif (!enabledExtensions.includes(TIPTAP_CORE_EXTENSION_ALIAS)) {\n+\t\t\tconst { api } = await import('../../extensions/core/rich-text-essentials.tiptap-api.js');\n+\t\t\tthis._extensions.push(new api(this));\n+\t\t}\n \n+\t\tawait new Promise<void>((resolve) => {\n+\t\t\tthis.observe(umbExtensionsRegistry.byTypeAndAliases('tiptapExtension', enabledExtensions), async (manifests) => {\n \t\t\t\tfor (const manifest of manifests) {\n@@ -81,6 +82,3 @@ export class UmbInputTiptapElement extends UmbFormControlMixin<string, typeof Um\n \t\t\t\t\t\tif (extension) {\n-\t\t\t\t\t\t\t// Check if the extension is enabled\n-\t\t\t\t\t\t\tif (enabledExtensions.includes(manifest.alias)) {\n-\t\t\t\t\t\t\t\tthis._extensions.push(new extension(this));\n-\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t\tthis._extensions.push(new extension(this));\n \t\t\t\t\t\t}\n","improvement-type":"Deep, Nested Complexity"}],"change-level":"warning","is-hotspot?":false,"line":102,"what-changed":"querySerializer has a nested complexity depth of 4, threshold = 4","how-to-fix":"Occassionally, it's possible to get rid of the nested logic by [Replacing Conditionals with Guard Clauses](https://refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html).\n\nAnother viable strategy is to identify smaller building blocks inside the nested chunks of logic and extract those responsibilities into smaller, cohesive, and well-named functions. The [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring explains the steps.","change-type":"introduced"},{"method":"buildClientParams","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the TypeScript language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"templates/UmbracoExtension/Client/src/api/core/params.gen.ts","refactoring-examples":[{"architectural-component-id":null,"author-name":"Niels Lyngsø","training-data":{"loc-added":"9","loc-deleted":"10","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"nsl@umbraco.dk","commit-full-message":"","commit-date":"2025-02-17T08:11:28Z","current-rev":"8bbe0533c3","filename":"Umbraco-CMS/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts","previous-rev":"5379fec2d3","commit-title":"Close active modal if its begin unregistered (#18285)","language":"TypeScript","id":"88aeef715fd9d2fa61f2042a7a9017a6bab23d00","model-score":0.6,"author-id":null,"project-id":33308,"delta-file-score":0.31179166,"diff":"diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\nindex 96d25919bf..aad4a291a0 100644\n--- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\n+++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\n@@ -1,2 +1,2 @@\n-import type { UmbContentTypeModel, UmbPropertyTypeContainerModel } from '../types.js';\n+import type { UmbContentTypeModel } from '../types.js';\n import type { UmbContentTypeStructureManager } from './content-type-structure-manager.class.js';\n@@ -12,3 +12,2 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t#structure?: UmbContentTypeStructureManager<T>;\n-\t#tabContainers?: Array<UmbPropertyTypeContainerModel>;\n \n@@ -20,12 +19,10 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \n-\t#observeContainers() {\n+\tasync #observeContainers() {\n \t\tif (!this.#structure) return;\n \n-\t\tthis.observe(\n+\t\tawait this.observe(\n \t\t\tthis.#structure.ownerContainersOf('Tab', null),\n \t\t\t(tabContainers) => {\n-\t\t\t\tconst old = this.#tabContainers;\n-\t\t\t\tthis.#tabContainers = tabContainers;\n-\t\t\t\t// If the amount of containers was 0 before and now becomes 1, we should move all root containers into this tab:\n-\t\t\t\tif (old?.length === 0 && tabContainers?.length === 1) {\n+\t\t\t\t// If the amount of containers now became 1, we should move all root containers into this tab:\n+\t\t\t\tif (tabContainers?.length === 1) {\n \t\t\t\t\tconst firstTabId = tabContainers[0].id;\n@@ -35,2 +32,3 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\t\t\t\t});\n+\t\t\t\t\tthis.destroy();\n \t\t\t\t}\n@@ -38,3 +36,5 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\t\t'_observeMainContainer',\n-\t\t);\n+\t\t).asPromise();\n+\n+\t\tthis.destroy();\n \t}\n@@ -44,3 +44,2 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\tthis.#structure = undefined;\n-\t\tthis.#tabContainers = undefined;\n \t}\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Niels Lyngsø","training-data":{"loc-added":"54","loc-deleted":"72","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"nsl@umbraco.dk","commit-full-message":"* improve sorting algorithm\n\n* fix block type input\n\n* make confirm modal localizable\n\n* rename method\n\n* clean up\n\n* clean up\n\n* improve code\n\n* Fix creating Block Types in Groups\n\n* remove #moveData\n\n* lint fixes\n\n* remove unused\n\n---------\n\nCo-authored-by: Mads Rasmussen <madsr@hey.com>","commit-date":"2025-01-20T08:10:50Z","current-rev":"6c1c851d8a","filename":"Umbraco-CMS/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts","previous-rev":"4353027655","commit-title":"Fix: Improve sorter placement algorithm (#18021)","language":"TypeScript","id":"1c09c6d9203e7223417b741738479d2b893aaab9","model-score":0.27,"author-id":null,"project-id":33308,"delta-file-score":0.31179166,"diff":"diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\nindex ae743a577d..9c3f2f9276 100644\n--- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\n+++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\n@@ -1,7 +1,5 @@\n-import type { UmbBlockTypeWithGroupKey, UmbInputBlockTypeElement } from '../../../block-type/index.js';\n-import '../../../block-type/components/input-block-type/index.js';\n-import {\n-\ttype UmbPropertyEditorUiElement,\n-\tUmbPropertyValueChangeEvent,\n-\ttype UmbPropertyEditorConfigCollection,\n+import type { UmbBlockTypeWithGroupKey, UmbInputBlockTypeElement } from '@umbraco-cms/backoffice/block-type';\n+import type {\n+\tUmbPropertyEditorUiElement,\n+\tUmbPropertyEditorConfigCollection,\n } from '@umbraco-cms/backoffice/property-editor';\n@@ -32,2 +30,4 @@ import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/rou\n import { UmbSorterController } from '@umbraco-cms/backoffice/sorter';\n+import { UmbChangeEvent } from '@umbraco-cms/backoffice/event';\n+import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';\n \n@@ -45,3 +45,2 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n {\n-\t#moveData?: Array<UmbBlockTypeWithGroupKey>;\n \t#sorter = new UmbSorterController<MappedGroupWithBlockTypes, HTMLElement>(this, {\n@@ -106,4 +105,10 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\tthis.#datasetContext = context;\n-\t\t\t//this.#observeBlocks();\n-\t\t\tthis.#observeBlockGroups();\n+\t\t\tthis.observe(\n+\t\t\t\tawait this.#datasetContext.propertyValueByAlias('blockGroups'),\n+\t\t\t\t(value) => {\n+\t\t\t\t\tthis.#blockGroups = (value as Array<UmbBlockGridTypeGroupType>) ?? [];\n+\t\t\t\t\tthis.#mapValuesToBlockGroups();\n+\t\t\t\t},\n+\t\t\t\t'_observeBlockGroups',\n+\t\t\t);\n \t\t});\n@@ -121,20 +126,2 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \n-\tasync #observeBlockGroups() {\n-\t\tif (!this.#datasetContext) return;\n-\t\tthis.observe(await this.#datasetContext.propertyValueByAlias('blockGroups'), (value) => {\n-\t\t\tthis.#blockGroups = (value as Array<UmbBlockGridTypeGroupType>) ?? [];\n-\t\t\tthis.#mapValuesToBlockGroups();\n-\t\t});\n-\t}\n-\t// TODO: No need for this, we just got the value via the value property.. [NL]\n-\t/*\n-\tasync #observeBlocks() {\n-\t\tif (!this.#datasetContext) return;\n-\t\tthis.observe(await this.#datasetContext.propertyValueByAlias('blocks'), (value) => {\n-\t\t\tthis.value = (value as Array<UmbBlockTypeWithGroupKey>) ?? [];\n-\t\t\tthis.#mapValuesToBlockGroups();\n-\t\t});\n-\t}\n-\t*/\n-\n \t#mapValuesToBlockGroups() {\n@@ -154,36 +141,30 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \n-\t#onDelete(e: CustomEvent, groupKey?: string) {\n-\t\tconst updatedValues = (e.target as UmbInputBlockTypeElement).value.map((value) => ({ ...value, groupKey }));\n-\t\tconst filteredValues = this.#value.filter((value) => value.groupKey !== groupKey);\n-\t\tthis.value = [...filteredValues, ...updatedValues];\n-\t\tthis.dispatchEvent(new UmbPropertyValueChangeEvent());\n-\t}\n-\n-\tasync #onChange(e: CustomEvent) {\n+\tasync #onChange(e: Event, groupKey?: string) {\n \t\te.stopPropagation();\n \t\tconst element = e.target as UmbInputBlockTypeElement;\n-\t\tconst value = element.value;\n-\n-\t\tif (!e.detail?.moveComplete) {\n-\t\t\t// Container change, store data of the new group...\n-\t\t\tconst newGroupKey = element.getAttribute('data-umb-group-key');\n-\t\t\tconst movedItem = e.detail?.item as UmbBlockTypeWithGroupKey;\n-\t\t\t// Check if item moved back to original group...\n-\t\t\tif (movedItem.groupKey === newGroupKey) {\n-\t\t\t\tthis.#moveData = undefined;\n-\t\t\t} else {\n-\t\t\t\tthis.#moveData = value.map((block) => ({ ...block, groupKey: newGroupKey }));\n-\t\t\t}\n-\t\t} else if (e.detail?.moveComplete) {\n-\t\t\t// Move complete, get the blocks that were in an untouched group\n-\t\t\tconst blocks = this.#value\n-\t\t\t\t.filter((block) => !value.find((value) => value.contentElementTypeKey === block.contentElementTypeKey))\n-\t\t\t\t.filter(\n-\t\t\t\t\t(block) => !this.#moveData?.find((value) => value.contentElementTypeKey === block.contentElementTypeKey),\n-\t\t\t\t);\n-\n-\t\t\tthis.value = this.#moveData ? [...blocks, ...value, ...this.#moveData] : [...blocks, ...value];\n-\t\t\tthis.dispatchEvent(new UmbPropertyValueChangeEvent());\n-\t\t\tthis.#moveData = undefined;\n+\t\tconst value = element.value.map((x) => ({ ...x, groupKey }));\n+\n+\t\tif (groupKey) {\n+\t\t\t// Update the specific group:\n+\t\t\tthis._groupsWithBlockTypes = this._groupsWithBlockTypes.map((group) => {\n+\t\t\t\tif (group.key === groupKey) {\n+\t\t\t\t\treturn { ...group, blocks: value };\n+\t\t\t\t}\n+\t\t\t\treturn group;\n+\t\t\t});\n+\t\t} else {\n+\t\t\t// Update the not grouped blocks:\n+\t\t\tthis._notGroupedBlockTypes = value;\n \t\t}\n+\n+\t\tthis.#updateValue();\n+\t}\n+\n+\t#updateValue() {\n+\t\tthis.value = [...this._notGroupedBlockTypes, ...this._groupsWithBlockTypes.flatMap((group) => group.blocks)];\n+\t\tthis.dispatchEvent(new UmbChangeEvent());\n+\t}\n+\n+\t#updateBlockGroupsValue(groups: Array<UmbBlockGridTypeGroupType>) {\n+\t\tthis.#datasetContext?.setPropertyValue('blockGroups', groups);\n \t}\n@@ -193,3 +174,3 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\tif (selectedElementType) {\n-\t\t\tthis.#blockTypeWorkspaceModalRegistration?.open({}, 'create/' + selectedElementType + '/' + (groupKey ?? null));\n+\t\t\tthis.#blockTypeWorkspaceModalRegistration?.open({}, 'create/' + selectedElementType + '/' + (groupKey ?? 'null'));\n \t\t}\n@@ -198,15 +179,18 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t// TODO: Implement confirm dialog [NL]\n-\t#deleteGroup(groupKey: string) {\n-\t\t// TODO: make one method for updating the blockGroupsDataSetValue: [NL]\n-\t\t// This one that deletes might require the ability to parse what to send as an argument to the method, then a filtering can occur before.\n-\t\tthis.#datasetContext?.setPropertyValue(\n-\t\t\t'blockGroups',\n-\t\t\tthis.#blockGroups?.filter((group) => group.key !== groupKey),\n-\t\t);\n-\n+\tasync #deleteGroup(groupKey: string) {\n+\t\tconst groupName = this.#blockGroups?.find((group) => group.key === groupKey)?.name ?? '';\n+\t\tawait umbConfirmModal(this, {\n+\t\t\theadline: '#blockEditor_confirmDeleteBlockGroupTitle',\n+\t\t\tcontent: this.localize.term('#blockEditor_confirmDeleteBlockGroupMessage', [groupName]),\n+\t\t\tcolor: 'danger',\n+\t\t\tconfirmLabel: '#general_delete',\n+\t\t});\n \t\t// If a group is deleted, Move the blocks to no group:\n \t\tthis.value = this.#value.map((block) => (block.groupKey === groupKey ? { ...block, groupKey: undefined } : block));\n+\t\tif (this.#blockGroups) {\n+\t\t\tthis.#updateBlockGroupsValue(this.#blockGroups.filter((group) => group.key !== groupKey));\n+\t\t}\n \t}\n \n-\t#changeGroupName(e: UUIInputEvent, groupKey: string) {\n+\t#onGroupNameChange(e: UUIInputEvent, groupKey: string) {\n \t\tconst groupName = e.target.value as string;\n@@ -226,5 +210,4 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t\t\t.workspacePath=${this._workspacePath}\n-\t\t\t\t\t\t@change=${this.#onChange}\n-\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, undefined)}\n-\t\t\t\t\t\t@delete=${(e: CustomEvent) => this.#onDelete(e, undefined)}></umb-input-block-type>`\n+\t\t\t\t\t\t@change=${(e: Event) => this.#onChange(e, undefined)}\n+\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, undefined)}></umb-input-block-type>`\n \t\t\t\t: ''}\n@@ -241,5 +224,4 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t\t\t\t.workspacePath=${this._workspacePath}\n-\t\t\t\t\t\t\t@change=${this.#onChange}\n-\t\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, group.key)}\n-\t\t\t\t\t\t\t@delete=${(e: CustomEvent) => this.#onDelete(e, group.key)}></umb-input-block-type>\n+\t\t\t\t\t\t\t@change=${(e: Event) => this.#onChange(e, group.key)}\n+\t\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, group.key)}></umb-input-block-type>\n \t\t\t\t\t</div>`,\n@@ -255,3 +237,3 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t.value=${groupName ?? ''}\n-\t\t\t\t@change=${(e: UUIInputEvent) => this.#changeGroupName(e, groupKey)}>\n+\t\t\t\t@change=${(e: UUIInputEvent) => this.#onGroupNameChange(e, groupKey)}>\n \t\t\t\t<uui-button compact slot=\"append\" label=\"delete\" @click=${() => this.#deleteGroup(groupKey)}>\n","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":86,"what-changed":"buildClientParams has a cyclomatic complexity of 13, threshold = 9","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"introduced"},{"method":"stripEmptySlots","why-it-occurs":"A complex conditional is an expression inside a branch such as an <code>if</code>-statmeent which consists of multiple, logical operations. Example: <code>if (x.started() && y.running())</code>.Complex conditionals make the code even harder to read, and contribute to the Complex Method code smell. Encapsulate them.","name":"Complex Conditional","file":"templates/UmbracoExtension/Client/src/api/core/params.gen.ts","refactoring-examples":[{"diff":"diff --git a/complex_conditional.js b/complex_conditional.js\nindex c43da09584..94259ce874 100644\n--- a/complex_conditional.js\n+++ b/complex_conditional.js\n@@ -1,16 +1,34 @@\n function messageReceived(message, timeReceived) {\n-   // Ignore all messages which aren't from known customers:\n-   if (!message.sender &&\n-       customers.getId(message.name) == null) {\n+   // Refactoring #1: encapsulate the business rule in a\n+   // function. A clear name replaces the need for the comment:\n+   if (!knownCustomer(message)) {\n      log('spam received -- ignoring');\n      return;\n    }\n \n-  // Provide an auto-reply when outside business hours:\n-  if ((timeReceived.getHours() > 17) ||\n-      (timeReceived.getHours() < 8)) {\n+  // Refactoring #2: encapsulate the business rule.\n+  // Again, note how a clear function name replaces the\n+  // need for a code comment:\n+  if (outsideBusinessHours(timeReceived)) {\n     return autoReplyTo(message);\n   }\n \n   pingAgentFor(message);\n+}\n+\n+function outsideBusinessHours(timeReceived) {\n+  // Refactoring #3: replace magic numbers with\n+  // symbols that communicate with the code reader:\n+  const closingHour = 17;\n+  const openingHour = 8;\n+\n+  const hours = timeReceived.getHours();\n+\n+  // Refactoring #4: simple conditional rules can\n+  // be further clarified by introducing a variable:\n+  const afterClosing = hours > closingHour;\n+  const beforeOpening = hours < openingHour;\n+\n+  // Yeah -- look how clear the business rule is now!\n+  return afterClosing || beforeOpening;\n }\n\\ No newline at end of file\n","language":"typescript","improvement-type":"Complex Conditional"}],"change-level":"warning","is-hotspot?":false,"line":80,"what-changed":"stripEmptySlots has 1 complex conditionals with 2 branches, threshold = 2","how-to-fix":"Apply the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring so that the complex conditional is encapsulated in a separate function with a good name that captures the business rule. Optionally, for simple expressions, introduce a new variable which holds the result of the complex conditional.","change-type":"introduced"},{"method":"buildClientParams","why-it-occurs":"A Bumpy Road is a function that contains multiple chunks of nested conditional logic inside the same function. The deeper the nesting and the more bumps, the lower the code health.\n\nA bumpy code road represents a lack of encapsulation which becomes an obstacle to comprehension. In imperative languages there’s also an increased risk for feature entanglement, which leads to complex state management. CodeScene considers the following rules for the code health impact: 1) The deeper the nested conditional logic of each bump, the higher the tax on our working memory. 2) The more bumps inside a function, the more expensive it is to refactor as each bump represents a missing abstraction. 3) The larger each bump – that is, the more lines of code it spans – the harder it is to build up a mental model of the function. The nesting depth for what is considered a bump is  levels of conditionals.","name":"Bumpy Road Ahead","file":"templates/UmbracoExtension/Client/src/api/core/params.gen.ts","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":86,"what-changed":"buildClientParams has 5 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is one single, nested block per function","how-to-fix":"Bumpy Road implementations indicate a lack of encapsulation. Check out the detailed description of the [Bumpy Road code health issue](https://codescene.com/blog/bumpy-road-code-complexity-in-context/).\n\nA Bumpy Road often suggests that the function/method does too many things. The first refactoring step is to identify the different possible responsibilities of the function. Consider extracting those responsibilities into smaller, cohesive, and well-named functions. The [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring is the primary response.","change-type":"introduced"},{"method":"buildClientParams","why-it-occurs":"Deep nested logic means that you have control structures like if-statements or loops inside other control structures. Deep nested logic increases the cognitive load on the programmer reading the code. The human working memory has a maximum capacity of 3-4 items; beyond that threshold, we struggle with keeping things in our head. Consequently, deep nested logic has a strong correlation to defects and accounts for roughly 20% of all programming mistakes.\n\nCodeScene measures the maximum nesting depth inside each function. The deeper the nesting, the lower the code health. The threshold for the TypeScript language is 7 levels of nesting.","name":"Deep, Nested Complexity","file":"templates/UmbracoExtension/Client/src/api/core/params.gen.ts","refactoring-examples":[{"architectural-component-id":null,"author-name":"leekelleher","training-data":{"loc-added":"5","loc-deleted":"7","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"2.0","delta-n-functions":"0","current-file-score":"9.663736664415227"},"author-email":"leekelleher@gmail.com","commit-full-message":"The unit test doesn't register the manifests, so we'll need\nto hard code loading the \"Rich Text Essentials\" extension.","commit-date":"2025-02-19T10:22:48Z","current-rev":"28fb7ad67e","filename":"Umbraco-CMS/src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts","previous-rev":"effa40fabb","commit-title":"Refactors loading core Tipap extension","language":"TypeScript","id":"8312ef85dffade57f8d0318992ee5ef649ad8f27","model-score":0.64,"author-id":null,"project-id":33308,"delta-file-score":0.58988667,"diff":"diff --git a/src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts b/src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts\nindex 8ad7178036..387f511eb1 100644\n--- a/src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts\n+++ b/src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts\n@@ -68,11 +68,12 @@ export class UmbInputTiptapElement extends UmbFormControlMixin<string, typeof Um\n \tasync #loadExtensions() {\n-\t\tawait new Promise<void>((resolve) => {\n-\t\t\tthis.observe(umbExtensionsRegistry.byType('tiptapExtension'), async (manifests) => {\n-\t\t\t\tlet enabledExtensions = this.configuration?.getValueByAlias<string[]>('extensions') ?? [];\n+\t\tconst enabledExtensions = this.configuration?.getValueByAlias<string[]>('extensions') ?? [];\n \n-\t\t\t\t// Ensures that the \"Rich Text Essentials\" extension is always enabled. [LK]\n-\t\t\t\tif (!enabledExtensions.includes(TIPTAP_CORE_EXTENSION_ALIAS)) {\n-\t\t\t\t\tenabledExtensions = [TIPTAP_CORE_EXTENSION_ALIAS, ...enabledExtensions];\n-\t\t\t\t}\n+\t\t// Ensures that the \"Rich Text Essentials\" extension is always enabled. [LK]\n+\t\tif (!enabledExtensions.includes(TIPTAP_CORE_EXTENSION_ALIAS)) {\n+\t\t\tconst { api } = await import('../../extensions/core/rich-text-essentials.tiptap-api.js');\n+\t\t\tthis._extensions.push(new api(this));\n+\t\t}\n \n+\t\tawait new Promise<void>((resolve) => {\n+\t\t\tthis.observe(umbExtensionsRegistry.byTypeAndAliases('tiptapExtension', enabledExtensions), async (manifests) => {\n \t\t\t\tfor (const manifest of manifests) {\n@@ -81,6 +82,3 @@ export class UmbInputTiptapElement extends UmbFormControlMixin<string, typeof Um\n \t\t\t\t\t\tif (extension) {\n-\t\t\t\t\t\t\t// Check if the extension is enabled\n-\t\t\t\t\t\t\tif (enabledExtensions.includes(manifest.alias)) {\n-\t\t\t\t\t\t\t\tthis._extensions.push(new extension(this));\n-\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t\tthis._extensions.push(new extension(this));\n \t\t\t\t\t\t}\n","improvement-type":"Deep, Nested Complexity"}],"change-level":"warning","is-hotspot?":false,"line":86,"what-changed":"buildClientParams has a nested complexity depth of 7, threshold = 4","how-to-fix":"Occassionally, it's possible to get rid of the nested logic by [Replacing Conditionals with Guard Clauses](https://refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html).\n\nAnother viable strategy is to identify smaller building blocks inside the nested chunks of logic and extract those responsibilities into smaller, cohesive, and well-named functions. The [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring explains the steps.","change-type":"introduced"},{"method":"serializeObjectParam","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the TypeScript language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"templates/UmbracoExtension/Client/src/api/core/pathSerializer.gen.ts","refactoring-examples":[{"architectural-component-id":null,"author-name":"Niels Lyngsø","training-data":{"loc-added":"9","loc-deleted":"10","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"nsl@umbraco.dk","commit-full-message":"","commit-date":"2025-02-17T08:11:28Z","current-rev":"8bbe0533c3","filename":"Umbraco-CMS/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts","previous-rev":"5379fec2d3","commit-title":"Close active modal if its begin unregistered (#18285)","language":"TypeScript","id":"88aeef715fd9d2fa61f2042a7a9017a6bab23d00","model-score":0.6,"author-id":null,"project-id":33308,"delta-file-score":0.31179166,"diff":"diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\nindex 96d25919bf..aad4a291a0 100644\n--- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\n+++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\n@@ -1,2 +1,2 @@\n-import type { UmbContentTypeModel, UmbPropertyTypeContainerModel } from '../types.js';\n+import type { UmbContentTypeModel } from '../types.js';\n import type { UmbContentTypeStructureManager } from './content-type-structure-manager.class.js';\n@@ -12,3 +12,2 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t#structure?: UmbContentTypeStructureManager<T>;\n-\t#tabContainers?: Array<UmbPropertyTypeContainerModel>;\n \n@@ -20,12 +19,10 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \n-\t#observeContainers() {\n+\tasync #observeContainers() {\n \t\tif (!this.#structure) return;\n \n-\t\tthis.observe(\n+\t\tawait this.observe(\n \t\t\tthis.#structure.ownerContainersOf('Tab', null),\n \t\t\t(tabContainers) => {\n-\t\t\t\tconst old = this.#tabContainers;\n-\t\t\t\tthis.#tabContainers = tabContainers;\n-\t\t\t\t// If the amount of containers was 0 before and now becomes 1, we should move all root containers into this tab:\n-\t\t\t\tif (old?.length === 0 && tabContainers?.length === 1) {\n+\t\t\t\t// If the amount of containers now became 1, we should move all root containers into this tab:\n+\t\t\t\tif (tabContainers?.length === 1) {\n \t\t\t\t\tconst firstTabId = tabContainers[0].id;\n@@ -35,2 +32,3 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\t\t\t\t});\n+\t\t\t\t\tthis.destroy();\n \t\t\t\t}\n@@ -38,3 +36,5 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\t\t'_observeMainContainer',\n-\t\t);\n+\t\t).asPromise();\n+\n+\t\tthis.destroy();\n \t}\n@@ -44,3 +44,2 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\tthis.#structure = undefined;\n-\t\tthis.#tabContainers = undefined;\n \t}\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Niels Lyngsø","training-data":{"loc-added":"54","loc-deleted":"72","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"nsl@umbraco.dk","commit-full-message":"* improve sorting algorithm\n\n* fix block type input\n\n* make confirm modal localizable\n\n* rename method\n\n* clean up\n\n* clean up\n\n* improve code\n\n* Fix creating Block Types in Groups\n\n* remove #moveData\n\n* lint fixes\n\n* remove unused\n\n---------\n\nCo-authored-by: Mads Rasmussen <madsr@hey.com>","commit-date":"2025-01-20T08:10:50Z","current-rev":"6c1c851d8a","filename":"Umbraco-CMS/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts","previous-rev":"4353027655","commit-title":"Fix: Improve sorter placement algorithm (#18021)","language":"TypeScript","id":"1c09c6d9203e7223417b741738479d2b893aaab9","model-score":0.27,"author-id":null,"project-id":33308,"delta-file-score":0.31179166,"diff":"diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\nindex ae743a577d..9c3f2f9276 100644\n--- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\n+++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\n@@ -1,7 +1,5 @@\n-import type { UmbBlockTypeWithGroupKey, UmbInputBlockTypeElement } from '../../../block-type/index.js';\n-import '../../../block-type/components/input-block-type/index.js';\n-import {\n-\ttype UmbPropertyEditorUiElement,\n-\tUmbPropertyValueChangeEvent,\n-\ttype UmbPropertyEditorConfigCollection,\n+import type { UmbBlockTypeWithGroupKey, UmbInputBlockTypeElement } from '@umbraco-cms/backoffice/block-type';\n+import type {\n+\tUmbPropertyEditorUiElement,\n+\tUmbPropertyEditorConfigCollection,\n } from '@umbraco-cms/backoffice/property-editor';\n@@ -32,2 +30,4 @@ import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/rou\n import { UmbSorterController } from '@umbraco-cms/backoffice/sorter';\n+import { UmbChangeEvent } from '@umbraco-cms/backoffice/event';\n+import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';\n \n@@ -45,3 +45,2 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n {\n-\t#moveData?: Array<UmbBlockTypeWithGroupKey>;\n \t#sorter = new UmbSorterController<MappedGroupWithBlockTypes, HTMLElement>(this, {\n@@ -106,4 +105,10 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\tthis.#datasetContext = context;\n-\t\t\t//this.#observeBlocks();\n-\t\t\tthis.#observeBlockGroups();\n+\t\t\tthis.observe(\n+\t\t\t\tawait this.#datasetContext.propertyValueByAlias('blockGroups'),\n+\t\t\t\t(value) => {\n+\t\t\t\t\tthis.#blockGroups = (value as Array<UmbBlockGridTypeGroupType>) ?? [];\n+\t\t\t\t\tthis.#mapValuesToBlockGroups();\n+\t\t\t\t},\n+\t\t\t\t'_observeBlockGroups',\n+\t\t\t);\n \t\t});\n@@ -121,20 +126,2 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \n-\tasync #observeBlockGroups() {\n-\t\tif (!this.#datasetContext) return;\n-\t\tthis.observe(await this.#datasetContext.propertyValueByAlias('blockGroups'), (value) => {\n-\t\t\tthis.#blockGroups = (value as Array<UmbBlockGridTypeGroupType>) ?? [];\n-\t\t\tthis.#mapValuesToBlockGroups();\n-\t\t});\n-\t}\n-\t// TODO: No need for this, we just got the value via the value property.. [NL]\n-\t/*\n-\tasync #observeBlocks() {\n-\t\tif (!this.#datasetContext) return;\n-\t\tthis.observe(await this.#datasetContext.propertyValueByAlias('blocks'), (value) => {\n-\t\t\tthis.value = (value as Array<UmbBlockTypeWithGroupKey>) ?? [];\n-\t\t\tthis.#mapValuesToBlockGroups();\n-\t\t});\n-\t}\n-\t*/\n-\n \t#mapValuesToBlockGroups() {\n@@ -154,36 +141,30 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \n-\t#onDelete(e: CustomEvent, groupKey?: string) {\n-\t\tconst updatedValues = (e.target as UmbInputBlockTypeElement).value.map((value) => ({ ...value, groupKey }));\n-\t\tconst filteredValues = this.#value.filter((value) => value.groupKey !== groupKey);\n-\t\tthis.value = [...filteredValues, ...updatedValues];\n-\t\tthis.dispatchEvent(new UmbPropertyValueChangeEvent());\n-\t}\n-\n-\tasync #onChange(e: CustomEvent) {\n+\tasync #onChange(e: Event, groupKey?: string) {\n \t\te.stopPropagation();\n \t\tconst element = e.target as UmbInputBlockTypeElement;\n-\t\tconst value = element.value;\n-\n-\t\tif (!e.detail?.moveComplete) {\n-\t\t\t// Container change, store data of the new group...\n-\t\t\tconst newGroupKey = element.getAttribute('data-umb-group-key');\n-\t\t\tconst movedItem = e.detail?.item as UmbBlockTypeWithGroupKey;\n-\t\t\t// Check if item moved back to original group...\n-\t\t\tif (movedItem.groupKey === newGroupKey) {\n-\t\t\t\tthis.#moveData = undefined;\n-\t\t\t} else {\n-\t\t\t\tthis.#moveData = value.map((block) => ({ ...block, groupKey: newGroupKey }));\n-\t\t\t}\n-\t\t} else if (e.detail?.moveComplete) {\n-\t\t\t// Move complete, get the blocks that were in an untouched group\n-\t\t\tconst blocks = this.#value\n-\t\t\t\t.filter((block) => !value.find((value) => value.contentElementTypeKey === block.contentElementTypeKey))\n-\t\t\t\t.filter(\n-\t\t\t\t\t(block) => !this.#moveData?.find((value) => value.contentElementTypeKey === block.contentElementTypeKey),\n-\t\t\t\t);\n-\n-\t\t\tthis.value = this.#moveData ? [...blocks, ...value, ...this.#moveData] : [...blocks, ...value];\n-\t\t\tthis.dispatchEvent(new UmbPropertyValueChangeEvent());\n-\t\t\tthis.#moveData = undefined;\n+\t\tconst value = element.value.map((x) => ({ ...x, groupKey }));\n+\n+\t\tif (groupKey) {\n+\t\t\t// Update the specific group:\n+\t\t\tthis._groupsWithBlockTypes = this._groupsWithBlockTypes.map((group) => {\n+\t\t\t\tif (group.key === groupKey) {\n+\t\t\t\t\treturn { ...group, blocks: value };\n+\t\t\t\t}\n+\t\t\t\treturn group;\n+\t\t\t});\n+\t\t} else {\n+\t\t\t// Update the not grouped blocks:\n+\t\t\tthis._notGroupedBlockTypes = value;\n \t\t}\n+\n+\t\tthis.#updateValue();\n+\t}\n+\n+\t#updateValue() {\n+\t\tthis.value = [...this._notGroupedBlockTypes, ...this._groupsWithBlockTypes.flatMap((group) => group.blocks)];\n+\t\tthis.dispatchEvent(new UmbChangeEvent());\n+\t}\n+\n+\t#updateBlockGroupsValue(groups: Array<UmbBlockGridTypeGroupType>) {\n+\t\tthis.#datasetContext?.setPropertyValue('blockGroups', groups);\n \t}\n@@ -193,3 +174,3 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\tif (selectedElementType) {\n-\t\t\tthis.#blockTypeWorkspaceModalRegistration?.open({}, 'create/' + selectedElementType + '/' + (groupKey ?? null));\n+\t\t\tthis.#blockTypeWorkspaceModalRegistration?.open({}, 'create/' + selectedElementType + '/' + (groupKey ?? 'null'));\n \t\t}\n@@ -198,15 +179,18 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t// TODO: Implement confirm dialog [NL]\n-\t#deleteGroup(groupKey: string) {\n-\t\t// TODO: make one method for updating the blockGroupsDataSetValue: [NL]\n-\t\t// This one that deletes might require the ability to parse what to send as an argument to the method, then a filtering can occur before.\n-\t\tthis.#datasetContext?.setPropertyValue(\n-\t\t\t'blockGroups',\n-\t\t\tthis.#blockGroups?.filter((group) => group.key !== groupKey),\n-\t\t);\n-\n+\tasync #deleteGroup(groupKey: string) {\n+\t\tconst groupName = this.#blockGroups?.find((group) => group.key === groupKey)?.name ?? '';\n+\t\tawait umbConfirmModal(this, {\n+\t\t\theadline: '#blockEditor_confirmDeleteBlockGroupTitle',\n+\t\t\tcontent: this.localize.term('#blockEditor_confirmDeleteBlockGroupMessage', [groupName]),\n+\t\t\tcolor: 'danger',\n+\t\t\tconfirmLabel: '#general_delete',\n+\t\t});\n \t\t// If a group is deleted, Move the blocks to no group:\n \t\tthis.value = this.#value.map((block) => (block.groupKey === groupKey ? { ...block, groupKey: undefined } : block));\n+\t\tif (this.#blockGroups) {\n+\t\t\tthis.#updateBlockGroupsValue(this.#blockGroups.filter((group) => group.key !== groupKey));\n+\t\t}\n \t}\n \n-\t#changeGroupName(e: UUIInputEvent, groupKey: string) {\n+\t#onGroupNameChange(e: UUIInputEvent, groupKey: string) {\n \t\tconst groupName = e.target.value as string;\n@@ -226,5 +210,4 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t\t\t.workspacePath=${this._workspacePath}\n-\t\t\t\t\t\t@change=${this.#onChange}\n-\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, undefined)}\n-\t\t\t\t\t\t@delete=${(e: CustomEvent) => this.#onDelete(e, undefined)}></umb-input-block-type>`\n+\t\t\t\t\t\t@change=${(e: Event) => this.#onChange(e, undefined)}\n+\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, undefined)}></umb-input-block-type>`\n \t\t\t\t: ''}\n@@ -241,5 +224,4 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t\t\t\t.workspacePath=${this._workspacePath}\n-\t\t\t\t\t\t\t@change=${this.#onChange}\n-\t\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, group.key)}\n-\t\t\t\t\t\t\t@delete=${(e: CustomEvent) => this.#onDelete(e, group.key)}></umb-input-block-type>\n+\t\t\t\t\t\t\t@change=${(e: Event) => this.#onChange(e, group.key)}\n+\t\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, group.key)}></umb-input-block-type>\n \t\t\t\t\t</div>`,\n@@ -255,3 +237,3 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t.value=${groupName ?? ''}\n-\t\t\t\t@change=${(e: UUIInputEvent) => this.#changeGroupName(e, groupKey)}>\n+\t\t\t\t@change=${(e: UUIInputEvent) => this.#onGroupNameChange(e, groupKey)}>\n \t\t\t\t<uui-button compact slot=\"append\" label=\"delete\" @click=${() => this.#deleteGroup(groupKey)}>\n","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":131,"what-changed":"serializeObjectParam has a cyclomatic complexity of 12, threshold = 9","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"introduced"},{"method":"serializeArrayParam","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the TypeScript language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"templates/UmbracoExtension/Client/src/api/core/pathSerializer.gen.ts","refactoring-examples":[{"architectural-component-id":null,"author-name":"Niels Lyngsø","training-data":{"loc-added":"9","loc-deleted":"10","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"nsl@umbraco.dk","commit-full-message":"","commit-date":"2025-02-17T08:11:28Z","current-rev":"8bbe0533c3","filename":"Umbraco-CMS/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts","previous-rev":"5379fec2d3","commit-title":"Close active modal if its begin unregistered (#18285)","language":"TypeScript","id":"88aeef715fd9d2fa61f2042a7a9017a6bab23d00","model-score":0.6,"author-id":null,"project-id":33308,"delta-file-score":0.31179166,"diff":"diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\nindex 96d25919bf..aad4a291a0 100644\n--- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\n+++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-move-root-containers-into-first-tab-helper.class.ts\n@@ -1,2 +1,2 @@\n-import type { UmbContentTypeModel, UmbPropertyTypeContainerModel } from '../types.js';\n+import type { UmbContentTypeModel } from '../types.js';\n import type { UmbContentTypeStructureManager } from './content-type-structure-manager.class.js';\n@@ -12,3 +12,2 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t#structure?: UmbContentTypeStructureManager<T>;\n-\t#tabContainers?: Array<UmbPropertyTypeContainerModel>;\n \n@@ -20,12 +19,10 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \n-\t#observeContainers() {\n+\tasync #observeContainers() {\n \t\tif (!this.#structure) return;\n \n-\t\tthis.observe(\n+\t\tawait this.observe(\n \t\t\tthis.#structure.ownerContainersOf('Tab', null),\n \t\t\t(tabContainers) => {\n-\t\t\t\tconst old = this.#tabContainers;\n-\t\t\t\tthis.#tabContainers = tabContainers;\n-\t\t\t\t// If the amount of containers was 0 before and now becomes 1, we should move all root containers into this tab:\n-\t\t\t\tif (old?.length === 0 && tabContainers?.length === 1) {\n+\t\t\t\t// If the amount of containers now became 1, we should move all root containers into this tab:\n+\t\t\t\tif (tabContainers?.length === 1) {\n \t\t\t\t\tconst firstTabId = tabContainers[0].id;\n@@ -35,2 +32,3 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\t\t\t\t});\n+\t\t\t\t\tthis.destroy();\n \t\t\t\t}\n@@ -38,3 +36,5 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\t\t'_observeMainContainer',\n-\t\t);\n+\t\t).asPromise();\n+\n+\t\tthis.destroy();\n \t}\n@@ -44,3 +44,2 @@ export class UmbContentTypeMoveRootGroupsIntoFirstTabHelper<T extends UmbContent\n \t\tthis.#structure = undefined;\n-\t\tthis.#tabContainers = undefined;\n \t}\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Niels Lyngsø","training-data":{"loc-added":"54","loc-deleted":"72","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"nsl@umbraco.dk","commit-full-message":"* improve sorting algorithm\n\n* fix block type input\n\n* make confirm modal localizable\n\n* rename method\n\n* clean up\n\n* clean up\n\n* improve code\n\n* Fix creating Block Types in Groups\n\n* remove #moveData\n\n* lint fixes\n\n* remove unused\n\n---------\n\nCo-authored-by: Mads Rasmussen <madsr@hey.com>","commit-date":"2025-01-20T08:10:50Z","current-rev":"6c1c851d8a","filename":"Umbraco-CMS/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts","previous-rev":"4353027655","commit-title":"Fix: Improve sorter placement algorithm (#18021)","language":"TypeScript","id":"1c09c6d9203e7223417b741738479d2b893aaab9","model-score":0.27,"author-id":null,"project-id":33308,"delta-file-score":0.31179166,"diff":"diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\nindex ae743a577d..9c3f2f9276 100644\n--- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\n+++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.ts\n@@ -1,7 +1,5 @@\n-import type { UmbBlockTypeWithGroupKey, UmbInputBlockTypeElement } from '../../../block-type/index.js';\n-import '../../../block-type/components/input-block-type/index.js';\n-import {\n-\ttype UmbPropertyEditorUiElement,\n-\tUmbPropertyValueChangeEvent,\n-\ttype UmbPropertyEditorConfigCollection,\n+import type { UmbBlockTypeWithGroupKey, UmbInputBlockTypeElement } from '@umbraco-cms/backoffice/block-type';\n+import type {\n+\tUmbPropertyEditorUiElement,\n+\tUmbPropertyEditorConfigCollection,\n } from '@umbraco-cms/backoffice/property-editor';\n@@ -32,2 +30,4 @@ import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/rou\n import { UmbSorterController } from '@umbraco-cms/backoffice/sorter';\n+import { UmbChangeEvent } from '@umbraco-cms/backoffice/event';\n+import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';\n \n@@ -45,3 +45,2 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n {\n-\t#moveData?: Array<UmbBlockTypeWithGroupKey>;\n \t#sorter = new UmbSorterController<MappedGroupWithBlockTypes, HTMLElement>(this, {\n@@ -106,4 +105,10 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\tthis.#datasetContext = context;\n-\t\t\t//this.#observeBlocks();\n-\t\t\tthis.#observeBlockGroups();\n+\t\t\tthis.observe(\n+\t\t\t\tawait this.#datasetContext.propertyValueByAlias('blockGroups'),\n+\t\t\t\t(value) => {\n+\t\t\t\t\tthis.#blockGroups = (value as Array<UmbBlockGridTypeGroupType>) ?? [];\n+\t\t\t\t\tthis.#mapValuesToBlockGroups();\n+\t\t\t\t},\n+\t\t\t\t'_observeBlockGroups',\n+\t\t\t);\n \t\t});\n@@ -121,20 +126,2 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \n-\tasync #observeBlockGroups() {\n-\t\tif (!this.#datasetContext) return;\n-\t\tthis.observe(await this.#datasetContext.propertyValueByAlias('blockGroups'), (value) => {\n-\t\t\tthis.#blockGroups = (value as Array<UmbBlockGridTypeGroupType>) ?? [];\n-\t\t\tthis.#mapValuesToBlockGroups();\n-\t\t});\n-\t}\n-\t// TODO: No need for this, we just got the value via the value property.. [NL]\n-\t/*\n-\tasync #observeBlocks() {\n-\t\tif (!this.#datasetContext) return;\n-\t\tthis.observe(await this.#datasetContext.propertyValueByAlias('blocks'), (value) => {\n-\t\t\tthis.value = (value as Array<UmbBlockTypeWithGroupKey>) ?? [];\n-\t\t\tthis.#mapValuesToBlockGroups();\n-\t\t});\n-\t}\n-\t*/\n-\n \t#mapValuesToBlockGroups() {\n@@ -154,36 +141,30 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \n-\t#onDelete(e: CustomEvent, groupKey?: string) {\n-\t\tconst updatedValues = (e.target as UmbInputBlockTypeElement).value.map((value) => ({ ...value, groupKey }));\n-\t\tconst filteredValues = this.#value.filter((value) => value.groupKey !== groupKey);\n-\t\tthis.value = [...filteredValues, ...updatedValues];\n-\t\tthis.dispatchEvent(new UmbPropertyValueChangeEvent());\n-\t}\n-\n-\tasync #onChange(e: CustomEvent) {\n+\tasync #onChange(e: Event, groupKey?: string) {\n \t\te.stopPropagation();\n \t\tconst element = e.target as UmbInputBlockTypeElement;\n-\t\tconst value = element.value;\n-\n-\t\tif (!e.detail?.moveComplete) {\n-\t\t\t// Container change, store data of the new group...\n-\t\t\tconst newGroupKey = element.getAttribute('data-umb-group-key');\n-\t\t\tconst movedItem = e.detail?.item as UmbBlockTypeWithGroupKey;\n-\t\t\t// Check if item moved back to original group...\n-\t\t\tif (movedItem.groupKey === newGroupKey) {\n-\t\t\t\tthis.#moveData = undefined;\n-\t\t\t} else {\n-\t\t\t\tthis.#moveData = value.map((block) => ({ ...block, groupKey: newGroupKey }));\n-\t\t\t}\n-\t\t} else if (e.detail?.moveComplete) {\n-\t\t\t// Move complete, get the blocks that were in an untouched group\n-\t\t\tconst blocks = this.#value\n-\t\t\t\t.filter((block) => !value.find((value) => value.contentElementTypeKey === block.contentElementTypeKey))\n-\t\t\t\t.filter(\n-\t\t\t\t\t(block) => !this.#moveData?.find((value) => value.contentElementTypeKey === block.contentElementTypeKey),\n-\t\t\t\t);\n-\n-\t\t\tthis.value = this.#moveData ? [...blocks, ...value, ...this.#moveData] : [...blocks, ...value];\n-\t\t\tthis.dispatchEvent(new UmbPropertyValueChangeEvent());\n-\t\t\tthis.#moveData = undefined;\n+\t\tconst value = element.value.map((x) => ({ ...x, groupKey }));\n+\n+\t\tif (groupKey) {\n+\t\t\t// Update the specific group:\n+\t\t\tthis._groupsWithBlockTypes = this._groupsWithBlockTypes.map((group) => {\n+\t\t\t\tif (group.key === groupKey) {\n+\t\t\t\t\treturn { ...group, blocks: value };\n+\t\t\t\t}\n+\t\t\t\treturn group;\n+\t\t\t});\n+\t\t} else {\n+\t\t\t// Update the not grouped blocks:\n+\t\t\tthis._notGroupedBlockTypes = value;\n \t\t}\n+\n+\t\tthis.#updateValue();\n+\t}\n+\n+\t#updateValue() {\n+\t\tthis.value = [...this._notGroupedBlockTypes, ...this._groupsWithBlockTypes.flatMap((group) => group.blocks)];\n+\t\tthis.dispatchEvent(new UmbChangeEvent());\n+\t}\n+\n+\t#updateBlockGroupsValue(groups: Array<UmbBlockGridTypeGroupType>) {\n+\t\tthis.#datasetContext?.setPropertyValue('blockGroups', groups);\n \t}\n@@ -193,3 +174,3 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\tif (selectedElementType) {\n-\t\t\tthis.#blockTypeWorkspaceModalRegistration?.open({}, 'create/' + selectedElementType + '/' + (groupKey ?? null));\n+\t\t\tthis.#blockTypeWorkspaceModalRegistration?.open({}, 'create/' + selectedElementType + '/' + (groupKey ?? 'null'));\n \t\t}\n@@ -198,15 +179,18 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t// TODO: Implement confirm dialog [NL]\n-\t#deleteGroup(groupKey: string) {\n-\t\t// TODO: make one method for updating the blockGroupsDataSetValue: [NL]\n-\t\t// This one that deletes might require the ability to parse what to send as an argument to the method, then a filtering can occur before.\n-\t\tthis.#datasetContext?.setPropertyValue(\n-\t\t\t'blockGroups',\n-\t\t\tthis.#blockGroups?.filter((group) => group.key !== groupKey),\n-\t\t);\n-\n+\tasync #deleteGroup(groupKey: string) {\n+\t\tconst groupName = this.#blockGroups?.find((group) => group.key === groupKey)?.name ?? '';\n+\t\tawait umbConfirmModal(this, {\n+\t\t\theadline: '#blockEditor_confirmDeleteBlockGroupTitle',\n+\t\t\tcontent: this.localize.term('#blockEditor_confirmDeleteBlockGroupMessage', [groupName]),\n+\t\t\tcolor: 'danger',\n+\t\t\tconfirmLabel: '#general_delete',\n+\t\t});\n \t\t// If a group is deleted, Move the blocks to no group:\n \t\tthis.value = this.#value.map((block) => (block.groupKey === groupKey ? { ...block, groupKey: undefined } : block));\n+\t\tif (this.#blockGroups) {\n+\t\t\tthis.#updateBlockGroupsValue(this.#blockGroups.filter((group) => group.key !== groupKey));\n+\t\t}\n \t}\n \n-\t#changeGroupName(e: UUIInputEvent, groupKey: string) {\n+\t#onGroupNameChange(e: UUIInputEvent, groupKey: string) {\n \t\tconst groupName = e.target.value as string;\n@@ -226,5 +210,4 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t\t\t.workspacePath=${this._workspacePath}\n-\t\t\t\t\t\t@change=${this.#onChange}\n-\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, undefined)}\n-\t\t\t\t\t\t@delete=${(e: CustomEvent) => this.#onDelete(e, undefined)}></umb-input-block-type>`\n+\t\t\t\t\t\t@change=${(e: Event) => this.#onChange(e, undefined)}\n+\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, undefined)}></umb-input-block-type>`\n \t\t\t\t: ''}\n@@ -241,5 +224,4 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t\t\t\t.workspacePath=${this._workspacePath}\n-\t\t\t\t\t\t\t@change=${this.#onChange}\n-\t\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, group.key)}\n-\t\t\t\t\t\t\t@delete=${(e: CustomEvent) => this.#onDelete(e, group.key)}></umb-input-block-type>\n+\t\t\t\t\t\t\t@change=${(e: Event) => this.#onChange(e, group.key)}\n+\t\t\t\t\t\t\t@create=${(e: CustomEvent) => this.#onCreate(e, group.key)}></umb-input-block-type>\n \t\t\t\t\t</div>`,\n@@ -255,3 +237,3 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement\n \t\t\t\t.value=${groupName ?? ''}\n-\t\t\t\t@change=${(e: UUIInputEvent) => this.#changeGroupName(e, groupKey)}>\n+\t\t\t\t@change=${(e: UUIInputEvent) => this.#onGroupNameChange(e, groupKey)}>\n \t\t\t\t<uui-button compact slot=\"append\" label=\"delete\" @click=${() => this.#deleteGroup(groupKey)}>\n","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":69,"what-changed":"serializeArrayParam has a cyclomatic complexity of 11, threshold = 9","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"introduced"}]},"positive-impact-count":0,"repo":"Umbraco-CMS","code-health":9.039120889213564,"version":"3.0","authors":["Warren Buckley"],"directives":{"added":[],"removed":[]},"positive-findings":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"notices":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"external-review-provider":"GitHub"},"analysistime":"2025-08-19T12:49:56.000Z","project-name":"Umbraco-CMS","repository":"https://github.com/umbraco/Umbraco-CMS.git"}}