Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import type { UmbBlockManagerContext, UmbBlockWorkspaceOriginData } from '../index.js';
import type { UmbBlockLayoutBaseModel, UmbBlockDataModel, UmbBlockDataType, UmbBlockExposeModel } from '../types.js';
import type {
UmbBlockLayoutBaseModel,
UmbBlockDataModel,
UmbBlockDataType,
UmbBlockExposeModel,
UmbBlockDataValueModel,
} from '../types.js';
import type { UmbBlockEntriesContext } from './block-entries.context.js';
import type { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
import { UmbContextBase } from '@umbraco-cms/backoffice/class-api';
Expand Down Expand Up @@ -238,17 +244,7 @@
if (!this.#contentValuesObservable) {
this.#contentValuesObservable = mergeObservables(
[this._contentValueArray, this.#contentStructure!.contentTypeProperties, this._variantId],
([propertyValues, properties, variantId]) => {
if (!propertyValues || !properties || !variantId) return;

return properties.reduce((acc, property) => {
const propertyVariantId = this.#createPropertyVariantId(property, variantId);
acc[property.alias] = propertyValues.find(
(x) => x.alias === property.alias && propertyVariantId.compare(x),
)?.value;
return acc;
}, {} as UmbBlockDataType);
},
this.#propertyValuesToObjectCallback,

Check notice on line 247 in src/Umbraco.Web.UI.Client/src/packages/block/block/context/block-entry.context.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

✅ No longer an issue: Complex Conditional

UmbBlockEntryContext.contentValues no longer has a complex conditional. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
);
}
return this.#contentValuesObservable;
Expand All @@ -274,21 +270,28 @@
if (!this.#settingsValuesObservable) {
this.#settingsValuesObservable = mergeObservables(
[this._settingsValueArray, this.#settingsStructure!.contentTypeProperties, this._variantId],
([propertyValues, properties, variantId]) => {
if (!propertyValues || !properties || !variantId) return;

return properties.reduce((acc, property) => {
acc[property.alias] = propertyValues.find((x) =>
this.#createPropertyVariantId(property, variantId).compare(x),
)?.value;
return acc;
}, {} as UmbBlockDataType);
},
this.#propertyValuesToObjectCallback,

Check notice on line 273 in src/Umbraco.Web.UI.Client/src/packages/block/block/context/block-entry.context.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

✅ No longer an issue: Complex Conditional

UmbBlockEntryContext.settingsValues no longer has a complex conditional. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
);
}
return this.#settingsValuesObservable;
}

#propertyValuesToObjectCallback = ([propertyValues, properties, variantId]: [
UmbBlockDataValueModel<unknown>[] | undefined,
UmbPropertyTypeModel[],
UmbVariantId | undefined,
]) => {
if (!propertyValues || !properties || !variantId) return;

return properties.reduce((acc, property) => {
const propertyVariantId = this.#createPropertyVariantId(property, variantId);
acc[property.alias] = propertyValues.find(
(x) => x.alias === property.alias && propertyVariantId.compare(x),
)?.value;
return acc;
}, {} as UmbBlockDataType);
};

/**
* Get the settings of the block.
* @returns {UmbBlockDataModel | undefined} - the settings of the block.
Expand Down
Loading