Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(headless, atomic, quantic)!: remove deprecated functions/properties #4350

Merged
merged 17 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
Expand Up @@ -305,7 +305,7 @@ export class AtomicCategoryFacet implements InitializableComponent {
this.bindings.store.registerFacet('categoryFacets', facetInfo);
initializePopover(this.host, {
...facetInfo,
hasValues: () => !!this.facet.state.values.length,
hasValues: () => !!this.facet.state.valuesAsTrees.length,
numberOfActiveValues: () => (this.facetState.hasActiveValues ? 1 : 0),
});
this.initializeDependenciesManager();
Expand Down Expand Up @@ -344,7 +344,8 @@ export class AtomicCategoryFacet implements InitializableComponent {
return (
this.searchStatusState.hasError ||
!this.facet.state.enabled ||
(!this.facet.state.values.length && !this.facet.state.parents.length)
(!this.facet.state.selectedValueAncestry.length &&
!this.facet.state.valuesAsTrees.length)
);
}

Expand Down Expand Up @@ -381,7 +382,7 @@ export class AtomicCategoryFacet implements InitializableComponent {
}

private get hasParents() {
return !!this.facetState.parents.length;
return !!this.facetState.selectedValueAncestry.length;
}

private initializeDependenciesManager() {
Expand Down Expand Up @@ -447,7 +448,10 @@ export class AtomicCategoryFacet implements InitializableComponent {
);
}

private renderValuesTree(parents: CategoryFacetValue[], isRoot: boolean) {
private renderValuesTree(
valuesAsTrees: CategoryFacetValue[],
isRoot: boolean
) {
if (!this.hasParents) {
return this.renderChildren();
}
Expand All @@ -463,14 +467,14 @@ export class AtomicCategoryFacet implements InitializableComponent {
}}
/>
<CategoryFacetParentAsTreeContainer isTopLevel={false}>
{this.renderValuesTree(parents, false)}
{this.renderValuesTree(valuesAsTrees, false)}
</CategoryFacetParentAsTreeContainer>
</CategoryFacetTreeValueContainer>
);
}

if (parents.length > 1) {
const parentValue = parents[0];
if (valuesAsTrees.length > 1) {
const parentValue = valuesAsTrees[0];

return (
<CategoryFacetTreeValueContainer>
Expand All @@ -484,13 +488,13 @@ export class AtomicCategoryFacet implements InitializableComponent {
}}
/>
<CategoryFacetParentAsTreeContainer isTopLevel={false}>
{this.renderValuesTree(parents.slice(1), false)}
{this.renderValuesTree(valuesAsTrees.slice(1), false)}
</CategoryFacetParentAsTreeContainer>
</CategoryFacetTreeValueContainer>
);
}

const activeParent = parents[0];
const activeParent = valuesAsTrees[0];
const activeParentDisplayValue = getFieldValueCaption(
this.field,
activeParent.value,
Expand Down Expand Up @@ -551,11 +555,22 @@ export class AtomicCategoryFacet implements InitializableComponent {
}

private renderChildren() {
if (!this.facetState.values.length) {
if (!this.facetState.valuesAsTrees.length) {
return;
}
if (this.facetState.selectedValueAncestry.length > 0) {
return this.facetState.selectedValueAncestry
.find((value) => value.state === 'selected')
?.children.map((value, i) =>
this.renderChild(
value,
i === 0,
i === this.resultIndexToFocusOnShowMore
)
);
}

return this.facetState.values.map((value, i) =>
return this.facetState.valuesAsTrees.map((value, i) =>
this.renderChild(value, i === 0, i === this.resultIndexToFocusOnShowMore)
);
}
Expand Down Expand Up @@ -598,7 +613,8 @@ export class AtomicCategoryFacet implements InitializableComponent {
label={this.label}
i18n={this.bindings.i18n}
onShowMore={() => {
this.resultIndexToFocusOnShowMore = this.facetState.values.length;
this.resultIndexToFocusOnShowMore =
this.facetState.valuesAsTrees[0].children.length;
this.focusTargets.showMoreFocus.focusAfterSearch();
this.facet.showMoreValues();
}}
Expand Down Expand Up @@ -627,7 +643,7 @@ export class AtomicCategoryFacet implements InitializableComponent {
const {
bindings: {i18n},
label,
facetState: {facetSearch, enabled, valuesAsTrees, parents},
facetState: {facetSearch, enabled, valuesAsTrees, selectedValueAncestry},
searchStatusState: {hasError, firstSearchExecuted},
} = this;

Expand Down Expand Up @@ -666,7 +682,7 @@ export class AtomicCategoryFacet implements InitializableComponent {
isTopLevel={true}
className="mt-3"
>
{this.renderValuesTree(parents, true)}
{this.renderValuesTree(selectedValueAncestry, true)}
</CategoryFacetParentAsTreeContainer>
) : (
<CategoryFacetChildrenAsTreeContainer className="mt-3">
Expand Down
8 changes: 1 addition & 7 deletions packages/headless/src/app/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pino, {LevelWithSilent, LogEvent} from 'pino';
import pino, {LevelWithSilent} from 'pino';

export type LogLevel = LevelWithSilent;

Expand All @@ -12,12 +12,6 @@ export interface LoggerOptions {
* All arguments passed to the log method, except the message, will be pass to this function. By default it does not change the shape of the log object.
*/
logFormatter?: (object: {}) => {};
/**
* Function which will be called after writing the log message in the browser.
*
* @deprecated This option is deprecated and will be removed in a future version.
*/
browserPostLogHook?: (level: LogLevel, logEvent: LogEvent) => void;
}

export function buildLogger(options: LoggerOptions | undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,10 @@ describe('category facet', () => {
});

describe('when the search response is empty', () => {
it('#state.values is an empty array', () => {
expect(state.search.response.facets).toEqual([]);
expect(categoryFacet.state.values).toEqual([]);
it('#state.selectedValueAncestry is an empty array', () => {
expect(categoryFacet.state.selectedValueAncestry).toEqual([]);
});

it('#state.parents is an empty array', () => {
expect(categoryFacet.state.parents).toEqual([]);
});

it('#state.valuesAsTrees', () => {
it('#state.valuesAsTrees is an empty array', () => {
expect(categoryFacet.state.valuesAsTrees).toEqual([]);
});
});
Expand All @@ -174,10 +168,6 @@ describe('category facet', () => {
state.search.response.facets = [response];
});

it('#state.values contains the same values', () => {
expect(categoryFacet.state.values).toBe(values);
});

it('#state.valuesAsTrees contains the same values', () => {
expect(categoryFacet.state.valuesAsTrees).toBe(values);
});
Expand Down Expand Up @@ -212,18 +202,6 @@ describe('category facet', () => {
state.search.response.facets = [response];
});

it('#state.parents contains the outer and middle values', () => {
expect(categoryFacet.state.parents).toEqual([outerValue, middleValue]);
});

it('#state.values contains the innermost values', () => {
expect(categoryFacet.state.values).toBe(innerValues);
});

it('#state.parents contains the outer and middle values', () => {
expect(categoryFacet.state.parents).toEqual([outerValue, middleValue]);
});

it('#state.valueAsTree contains the outer value', () => {
expect(categoryFacet.state.valuesAsTrees).toEqual([outerValue]);
});
Expand Down Expand Up @@ -283,18 +261,14 @@ describe('category facet', () => {
state.search.response.facets = [response];
});

it('#state.parents contains the selected leaf value', () => {
expect(categoryFacet.state.parents).toEqual([selectedValue]);
});

it('#state.selectedValueAncestry contains the selected leaf value', () => {
expect(categoryFacet.state.selectedValueAncestry).toEqual([
selectedValue,
]);
});

it('#state.values is an empty array', () => {
expect(categoryFacet.state.values).toEqual([]);
it('#state.activeValue.children an empty array', () => {
expect(categoryFacet.state.activeValue?.children).toEqual([]);
});

it('#state.activeValue is the selected leaf value', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,6 @@ export interface CoreCategoryFacetState {
*/
isHierarchical: boolean;

/**
* The facet's parent values.
* @deprecated uses `valuesAsTrees` instead.
*
*/
parents: CategoryFacetValue[];

/**
* The facet's values.
* @deprecated use `selectedValueAncestry` instead.
*/
values: CategoryFacetValue[];

/**
* The selected facet values ancestry.
* The first element is the "root" of the selected value ancestry tree.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,10 @@ describe('category facet', () => {
});

describe('when the search response is empty', () => {
it('#state.values is an empty array', () => {
it('#state.valuesAsTrees and #state.selectedValueAncestry are empty arrays', () => {
expect(state.search.response.facets).toEqual([]);
expect(categoryFacet.state.values).toEqual([]);
});

it('#state.parents is an empty array', () => {
expect(categoryFacet.state.parents).toEqual([]);
expect(categoryFacet.state.valuesAsTrees).toEqual([]);
expect(categoryFacet.state.selectedValueAncestry).toEqual([]);
});
});

Expand All @@ -135,7 +132,7 @@ describe('category facet', () => {
const response = buildMockCategoryFacetResponse({facetId, values});

state.search.response.facets = [response];
expect(categoryFacet.state.values).toBe(values);
expect(categoryFacet.state.valuesAsTrees).toBe(values);
});

describe('when the search response has a category facet with nested values', () => {
Expand All @@ -160,16 +157,12 @@ describe('category facet', () => {
state.search.response.facets = [response];
});

it('#state.parents contains the outer and middle values', () => {
expect(categoryFacet.state.parents).toEqual([outerValue, middleValue]);
});

it('#state.values contains the innermost values', () => {
expect(categoryFacet.state.values).toBe(innerValues);
it('#state.valueAsTree contains the outer value', () => {
expect(categoryFacet.state.valuesAsTrees).toEqual([outerValue]);
});

it('#state.parents contains the outer and middle values', () => {
expect(categoryFacet.state.parents).toEqual([outerValue, middleValue]);
it('#state.isHierarchical should be true', () => {
expect(categoryFacet.state.isHierarchical).toBe(true);
});
});

Expand All @@ -188,12 +181,14 @@ describe('category facet', () => {
state.search.response.facets = [response];
});

it('#state.parents contains the selected leaf value', () => {
expect(categoryFacet.state.parents).toEqual([selectedValue]);
it('#state.valuesAsTrees contains the selected leaf value', () => {
expect(categoryFacet.state.valuesAsTrees).toEqual([selectedValue]);
});

it('#state.values is an empty array', () => {
expect(categoryFacet.state.values).toEqual([]);
it('#state.selectedValueAncestry contains the selected leaf value', () => {
expect(categoryFacet.state.selectedValueAncestry).toEqual([
selectedValue,
]);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ export interface QuickviewOptions {
* The maximum preview size to retrieve, in bytes. By default, the full preview is retrieved.
*/
maximumPreviewSize?: number;
/**
* Whether to only update the `contentURL` attribute when using `fetchResultContent` rather than updating `content`.
* Use this if you are using an iframe with `state.contentURL` as the source url.
* @deprecated This option is always set to `true` ad the Insight Quickview only supports `contentURL` mode.
*/
onlyContentURL?: boolean;
alexprudhomme marked this conversation as resolved.
Show resolved Hide resolved
}

export interface Quickview extends Controller {
Expand All @@ -49,14 +43,6 @@ export interface Quickview extends Controller {
}

export interface QuickviewState {
/**
* The result preview HTML content.
*
* @default ""
* @deprecated This value will always be empty as the InsightQuickview only supports usage of the `contentURL`.
*/
content: string;

/**
* `true` if the configured result has a preview, and `false` otherwise.
*/
Expand Down
alexprudhomme marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ describe('category facet', () => {
});

describe('when the product listing response is empty', () => {
it('#state.values is an empty array', () => {
it('#state.valuesAsTrees is an empty array', () => {
expect(state.productListing.facets.results).toEqual([]);
expect(categoryFacet.state.values).toEqual([]);
expect(categoryFacet.state.valuesAsTrees).toEqual([]);
});

it('#state.parents is an empty array', () => {
expect(categoryFacet.state.parents).toEqual([]);
it('#state.selectedValueAncestry is an empty array', () => {
expect(categoryFacet.state.selectedValueAncestry).toEqual([]);
});
});

Expand All @@ -82,16 +82,12 @@ describe('category facet', () => {
state.productListing.facets.results = [response];
});

it('#state.parents contains the outer and middle values', () => {
expect(categoryFacet.state.parents).toEqual([outerValue, middleValue]);
it('#state.valueAsTree contains the outer value', () => {
expect(categoryFacet.state.valuesAsTrees).toEqual([outerValue]);
});

it('#state.values contains the innermost values', () => {
expect(categoryFacet.state.values).toBe(innerValues);
});

it('#state.parents contains the outer and middle values', () => {
expect(categoryFacet.state.parents).toEqual([outerValue, middleValue]);
it('#state.isHierarchical should be true', () => {
expect(categoryFacet.state.isHierarchical).toBe(true);
});
});

Expand All @@ -110,12 +106,14 @@ describe('category facet', () => {
state.productListing.facets.results = [response];
});

it('#state.parents contains the selected leaf value', () => {
expect(categoryFacet.state.parents).toEqual([selectedValue]);
it('#state.valuesAsTrees contains the selected leaf value', () => {
expect(categoryFacet.state.valuesAsTrees).toEqual([selectedValue]);
});

it('#state.values is an empty array', () => {
expect(categoryFacet.state.values).toEqual([]);
it('#state.selectedValueAncestry contains the selected leaf value', () => {
expect(categoryFacet.state.selectedValueAncestry).toEqual([
selectedValue,
]);
});
});

Expand Down
Loading
Loading