Skip to content

Commit

Permalink
feat(currentRefinements): support multiple indices (#4012)
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour authored and Haroenv committed Oct 23, 2019
1 parent b4b5454 commit e997728
Show file tree
Hide file tree
Showing 13 changed files with 392 additions and 133 deletions.
5 changes: 4 additions & 1 deletion src/components/CurrentRefinements/CurrentRefinements.tsx
Expand Up @@ -37,7 +37,10 @@ const CurrentRefinements = ({ items, cssClasses }: CurrentRefinementsProps) => (
<div className={cssClasses.root}>
<ul className={cssClasses.list}>
{items.map((item, index) => (
<li key={`${item.attribute}-${index}`} className={cssClasses.item}>
<li
key={`${item.indexName}-${item.attribute}-${index}`}
className={cssClasses.item}
>
<span className={cssClasses.label}>{capitalize(item.label)}:</span>

{item.refinements.map(refinement => (
Expand Down
Expand Up @@ -19,6 +19,7 @@ describe('CurrentRefinements', () => {
cssClasses,
items: [
{
indexName: 'indexName',
attribute: 'facet',
label: 'facet',
refine: () => {},
Expand All @@ -38,6 +39,7 @@ describe('CurrentRefinements', () => {
],
},
{
indexName: 'indexName',
attribute: 'facetExclude',
label: 'facetExclude',
refine: () => {},
Expand All @@ -52,6 +54,7 @@ describe('CurrentRefinements', () => {
],
},
{
indexName: 'indexName',
attribute: 'disjunctive',
label: 'disjunctive',
refine: () => {},
Expand All @@ -65,6 +68,7 @@ describe('CurrentRefinements', () => {
],
},
{
indexName: 'indexName',
attribute: 'hierarchical',
label: 'hierarchical',
refine: () => {},
Expand All @@ -78,6 +82,7 @@ describe('CurrentRefinements', () => {
],
},
{
indexName: 'indexName',
attribute: 'numeric',
label: 'numeric',
refine: () => {},
Expand All @@ -92,6 +97,7 @@ describe('CurrentRefinements', () => {
],
},
{
indexName: 'indexName',
attribute: 'tag',
label: 'tag',
refine: () => {},
Expand All @@ -118,6 +124,7 @@ describe('CurrentRefinements', () => {
cssClasses,
items: [
{
indexName: 'indexName',
attribute: 'customFacet',
label: 'customFacet',
refine: () => {},
Expand All @@ -143,6 +150,7 @@ describe('CurrentRefinements', () => {
cssClasses,
items: [
{
indexName: 'indexName',
attribute: 'customExcludeFacet',
label: 'customExcludeFacet',
refine: () => {},
Expand All @@ -169,6 +177,7 @@ describe('CurrentRefinements', () => {
cssClasses,
items: [
{
indexName: 'indexName',
attribute: 'customDisjunctiveFacet',
label: 'customDisjunctiveFacet',
refine: () => {},
Expand All @@ -194,6 +203,7 @@ describe('CurrentRefinements', () => {
cssClasses,
items: [
{
indexName: 'indexName',
attribute: 'customHierarchicalFacet',
label: 'customHierarchicalFacet',
refine: () => {},
Expand All @@ -219,6 +229,7 @@ describe('CurrentRefinements', () => {
cssClasses,
items: [
{
indexName: 'indexName',
attribute: 'customNumericFilter',
label: 'customNumericFilter',
refine: () => {},
Expand All @@ -233,6 +244,7 @@ describe('CurrentRefinements', () => {
],
},
{
indexName: 'indexName',
attribute: 'customNumericFilter',
label: 'customNumericFilter',
refine: () => {},
Expand All @@ -247,6 +259,7 @@ describe('CurrentRefinements', () => {
],
},
{
indexName: 'indexName',
attribute: 'customNumericFilter',
label: 'customNumericFilter',
refine: () => {},
Expand All @@ -273,6 +286,7 @@ describe('CurrentRefinements', () => {
cssClasses,
items: [
{
indexName: 'indexName',
attribute: '_tags',
label: '_tags',
refine: () => {},
Expand All @@ -298,6 +312,7 @@ describe('CurrentRefinements', () => {
cssClasses,
items: [
{
indexName: 'indexName',
attribute: 'query',
label: 'query',
refine: () => {},
Expand Down
Expand Up @@ -9,7 +9,7 @@ exports[`CurrentRefinements options.refinements can be used with a disjunctive f
>
<li
className="item"
key="customDisjunctiveFacet-0"
key="indexName-customDisjunctiveFacet-0"
>
<span
className="label"
Expand Down Expand Up @@ -47,7 +47,7 @@ exports[`CurrentRefinements options.refinements can be used with a facet 1`] = `
>
<li
className="item"
key="customFacet-0"
key="indexName-customFacet-0"
>
<span
className="label"
Expand Down Expand Up @@ -85,7 +85,7 @@ exports[`CurrentRefinements options.refinements can be used with a hierarchical
>
<li
className="item"
key="customHierarchicalFacet-0"
key="indexName-customHierarchicalFacet-0"
>
<span
className="label"
Expand Down Expand Up @@ -123,7 +123,7 @@ exports[`CurrentRefinements options.refinements can be used with a query 1`] = `
>
<li
className="item"
key="query-0"
key="indexName-query-0"
>
<span
className="label"
Expand Down Expand Up @@ -163,7 +163,7 @@ exports[`CurrentRefinements options.refinements can be used with a tag 1`] = `
>
<li
className="item"
key="_tags-0"
key="indexName-_tags-0"
>
<span
className="label"
Expand Down Expand Up @@ -201,7 +201,7 @@ exports[`CurrentRefinements options.refinements can be used with an exclude 1`]
>
<li
className="item"
key="customExcludeFacet-0"
key="indexName-customExcludeFacet-0"
>
<span
className="label"
Expand Down Expand Up @@ -239,7 +239,7 @@ exports[`CurrentRefinements options.refinements can be used with numeric filters
>
<li
className="item"
key="customNumericFilter-0"
key="indexName-customNumericFilter-0"
>
<span
className="label"
Expand All @@ -266,7 +266,7 @@ exports[`CurrentRefinements options.refinements can be used with numeric filters
</li>
<li
className="item"
key="customNumericFilter-1"
key="indexName-customNumericFilter-1"
>
<span
className="label"
Expand All @@ -293,7 +293,7 @@ exports[`CurrentRefinements options.refinements can be used with numeric filters
</li>
<li
className="item"
key="customNumericFilter-2"
key="indexName-customNumericFilter-2"
>
<span
className="label"
Expand Down Expand Up @@ -331,7 +331,7 @@ exports[`CurrentRefinements renders 1`] = `
>
<li
className="item"
key="facet-0"
key="indexName-facet-0"
>
<span
className="label"
Expand Down Expand Up @@ -374,7 +374,7 @@ exports[`CurrentRefinements renders 1`] = `
</li>
<li
className="item"
key="facetExclude-1"
key="indexName-facetExclude-1"
>
<span
className="label"
Expand All @@ -401,7 +401,7 @@ exports[`CurrentRefinements renders 1`] = `
</li>
<li
className="item"
key="disjunctive-2"
key="indexName-disjunctive-2"
>
<span
className="label"
Expand All @@ -428,7 +428,7 @@ exports[`CurrentRefinements renders 1`] = `
</li>
<li
className="item"
key="hierarchical-3"
key="indexName-hierarchical-3"
>
<span
className="label"
Expand All @@ -455,7 +455,7 @@ exports[`CurrentRefinements renders 1`] = `
</li>
<li
className="item"
key="numeric-4"
key="indexName-numeric-4"
>
<span
className="label"
Expand All @@ -482,7 +482,7 @@ exports[`CurrentRefinements renders 1`] = `
</li>
<li
className="item"
key="tag-5"
key="indexName-tag-5"
>
<span
className="label"
Expand Down
Expand Up @@ -166,6 +166,7 @@ search.addWidgets([
hits: firstIndexHits,
}),
]),
helper,
},
{
indexId: 'index1',
Expand All @@ -175,6 +176,7 @@ search.addWidgets([
hits: secondIndexHits,
}),
]),
helper,
},
];

Expand Down Expand Up @@ -255,6 +257,7 @@ search.addWidgets([
results: new SearchResults(helper.state, [
createSingleSearchResponse({ hits }),
]),
helper,
},
],
state: helper.state,
Expand Down Expand Up @@ -297,6 +300,7 @@ search.addWidgets([
results: new SearchResults(helper.state, [
createSingleSearchResponse({ hits }),
]),
helper,
},
],
state: helper.state,
Expand Down

0 comments on commit e997728

Please sign in to comment.