Skip to content
This repository was archived by the owner on Dec 30, 2022. It is now read-only.

Commit 47d11bf

Browse files
shortcutsHaroenv
authored andcommitted
fix(RelevantSort): Rename SmartSort widget to RelevantSort (#3026)
1 parent fa815f9 commit 47d11bf

File tree

15 files changed

+109
-101
lines changed

15 files changed

+109
-101
lines changed

packages/react-instantsearch-core/src/connectors/__tests__/connectSmartSort.ts renamed to packages/react-instantsearch-core/src/connectors/__tests__/connectRelevantSort.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ConnectorDescription } from '../../core/createConnector';
2-
import connectReal from '../connectSmartSort';
2+
import connectReal from '../connectRelevantSort';
33

44
jest.mock(
55
'../../core/createConnector',
@@ -10,7 +10,7 @@ jest.mock(
1010
// @TODO: refactor these tests to work better with TS
1111
const connect: any = connectReal;
1212

13-
describe('connectSmartSort', () => {
13+
describe('connectRelevantSort', () => {
1414
describe('single index', () => {
1515
const contextValue = { mainTargetedIndex: 'index' };
1616

@@ -20,7 +20,7 @@ describe('connectSmartSort', () => {
2020
});
2121

2222
expect(props).toEqual({
23-
isSmartSorted: false,
23+
isRelevantSorted: false,
2424
isVirtualReplica: false,
2525
});
2626
});
@@ -36,7 +36,7 @@ describe('connectSmartSort', () => {
3636
});
3737

3838
expect(props).toEqual({
39-
isSmartSorted: true,
39+
isRelevantSorted: true,
4040
isVirtualReplica: true,
4141
});
4242
});
@@ -47,12 +47,12 @@ describe('connectSmartSort', () => {
4747
});
4848

4949
expect(props).toEqual({
50-
isSmartSorted: false,
50+
isRelevantSorted: false,
5151
isVirtualReplica: false,
5252
});
5353
});
5454

55-
it('decide isSmartSorted based on appliedRelevancyStrictness', () => {
55+
it('decide isRelevantSorted based on appliedRelevancyStrictness', () => {
5656
const props = connect.getProvidedProps({ contextValue }, null, {
5757
results: {
5858
hits: [],
@@ -61,7 +61,7 @@ describe('connectSmartSort', () => {
6161
});
6262

6363
expect(props).toEqual({
64-
isSmartSorted: false,
64+
isRelevantSorted: false,
6565
isVirtualReplica: true,
6666
});
6767
});
@@ -77,7 +77,7 @@ describe('connectSmartSort', () => {
7777
});
7878

7979
expect(props).toEqual({
80-
isSmartSorted: true,
80+
isRelevantSorted: true,
8181
isVirtualReplica: true,
8282
});
8383

@@ -96,7 +96,7 @@ describe('connectSmartSort', () => {
9696
});
9797

9898
expect(props).toEqual({
99-
isSmartSorted: false,
99+
isRelevantSorted: false,
100100
isVirtualReplica: true,
101101
});
102102
});
@@ -116,7 +116,7 @@ describe('connectSmartSort', () => {
116116
);
117117

118118
expect(props).toEqual({
119-
isSmartSorted: false,
119+
isRelevantSorted: false,
120120
isVirtualReplica: false,
121121
});
122122
});
@@ -138,7 +138,7 @@ describe('connectSmartSort', () => {
138138
);
139139

140140
expect(props).toEqual({
141-
isSmartSorted: true,
141+
isRelevantSorted: true,
142142
isVirtualReplica: true,
143143
});
144144
});
@@ -153,12 +153,12 @@ describe('connectSmartSort', () => {
153153
);
154154

155155
expect(props).toEqual({
156-
isSmartSorted: false,
156+
isRelevantSorted: false,
157157
isVirtualReplica: false,
158158
});
159159
});
160160

161-
it('decide isSmartSorted based on appliedRelevancyStrictness', () => {
161+
it('decide isRelevantSorted based on appliedRelevancyStrictness', () => {
162162
const props = connect.getProvidedProps(
163163
{ contextValue, indexContextValue },
164164
null,
@@ -173,7 +173,7 @@ describe('connectSmartSort', () => {
173173
);
174174

175175
expect(props).toEqual({
176-
isSmartSorted: false,
176+
isRelevantSorted: false,
177177
isVirtualReplica: true,
178178
});
179179
});
@@ -195,7 +195,7 @@ describe('connectSmartSort', () => {
195195
);
196196

197197
expect(props).toEqual({
198-
isSmartSorted: true,
198+
isRelevantSorted: true,
199199
isVirtualReplica: true,
200200
});
201201

@@ -220,7 +220,7 @@ describe('connectSmartSort', () => {
220220
);
221221

222222
expect(props).toEqual({
223-
isSmartSorted: false,
223+
isRelevantSorted: false,
224224
isVirtualReplica: true,
225225
});
226226
});

packages/react-instantsearch-core/src/connectors/__tests__/connectStats.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('connectStats', () => {
2424
processingTimeMS: 1,
2525
hits: [],
2626
nbSortedHits: undefined,
27-
isSmartSorted: false,
27+
isRelevantSorted: false,
2828
},
2929
});
3030
expect(props).toEqual({
@@ -57,7 +57,7 @@ describe('connectStats', () => {
5757
nbHits: 666,
5858
processingTimeMS: 1,
5959
nbSortedHits: undefined,
60-
isSmartSorted: false,
60+
isRelevantSorted: false,
6161
},
6262
},
6363
}

packages/react-instantsearch-core/src/connectors/connectSmartSort.ts renamed to packages/react-instantsearch-core/src/connectors/connectRelevantSort.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function getCurrentRefinement(
2626
}
2727

2828
export default createConnector({
29-
displayName: 'AlgoliaSmartSort',
29+
displayName: 'AlgoliaRelevantSort',
3030

3131
getProvidedProps(props, _searchState, searchResults) {
3232
const results = getResults(searchResults, {
@@ -37,13 +37,13 @@ export default createConnector({
3737
if (!results) {
3838
return {
3939
isVirtualReplica: false,
40-
isSmartSorted: false,
40+
isRelevantSorted: false,
4141
};
4242
}
4343

4444
return {
4545
isVirtualReplica: results.appliedRelevancyStrictness !== undefined,
46-
isSmartSorted:
46+
isRelevantSorted:
4747
results.appliedRelevancyStrictness !== undefined &&
4848
results.appliedRelevancyStrictness > 0,
4949
};

packages/react-instantsearch-core/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ export {
5353
} from './connectors/connectRefinementList';
5454
export { default as connectScrollTo } from './connectors/connectScrollTo';
5555
export { default as connectSearchBox } from './connectors/connectSearchBox';
56-
export { default as connectSmartSort } from './connectors/connectSmartSort';
56+
export {
57+
default as connectRelevantSort,
58+
} from './connectors/connectRelevantSort';
5759
export { default as connectSortBy } from './connectors/connectSortBy';
5860
export {
5961
default as connectStateResults,

packages/react-instantsearch-dom/src/components/SmartSort.tsx renamed to packages/react-instantsearch-dom/src/components/RelevantSort.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,56 @@ import PropTypes from 'prop-types';
33
import classNames from 'classnames';
44
import { createClassNames } from '../core/utils';
55

6-
const cx = createClassNames('SmartSort');
6+
const cx = createClassNames('RelevantSort');
77

8-
export type SmartSortComponentProps = {
9-
isSmartSorted: boolean;
8+
export type RelevantSortComponentProps = {
9+
isRelevantSorted: boolean;
1010
};
1111

12-
export type SmartSortProps = {
12+
export type RelevantSortProps = {
1313
className?: string;
1414
isVirtualReplica: boolean;
15-
isSmartSorted: boolean;
16-
buttonTextComponent?: React.FunctionComponent<SmartSortComponentProps>;
17-
textComponent?: React.FunctionComponent<SmartSortComponentProps>;
15+
isRelevantSorted: boolean;
16+
buttonTextComponent?: React.FunctionComponent<RelevantSortComponentProps>;
17+
textComponent?: React.FunctionComponent<RelevantSortComponentProps>;
1818
refine(relevancyStrictness: number | undefined): void;
1919
};
2020

2121
const DefaultButtonTextComponent = ({
22-
isSmartSorted,
23-
}: SmartSortComponentProps) => (
24-
<span>{isSmartSorted ? 'See all results' : 'See relevant results'}</span>
22+
isRelevantSorted,
23+
}: RelevantSortComponentProps) => (
24+
<span>{isRelevantSorted ? 'See all results' : 'See relevant results'}</span>
2525
);
2626

27-
const SmartSort: React.FC<SmartSortProps> = ({
27+
const RelevantSort: React.FC<RelevantSortProps> = ({
2828
className = '',
2929
isVirtualReplica,
30-
isSmartSorted,
30+
isRelevantSorted,
3131
buttonTextComponent: ButtonTextComponent = DefaultButtonTextComponent,
3232
textComponent: TextComponent,
3333
refine,
3434
}) =>
3535
!isVirtualReplica ? null : (
3636
<div className={classNames(cx(''), className)}>
3737
<div className={cx('text')}>
38-
{TextComponent && <TextComponent isSmartSorted={isSmartSorted} />}
38+
{TextComponent && <TextComponent isRelevantSorted={isRelevantSorted} />}
3939
</div>
4040
<button
4141
className={cx('button')}
42-
onClick={() => refine(isSmartSorted ? 0 : undefined)}
42+
onClick={() => refine(isRelevantSorted ? 0 : undefined)}
4343
>
44-
<ButtonTextComponent isSmartSorted={isSmartSorted} />
44+
<ButtonTextComponent isRelevantSorted={isRelevantSorted} />
4545
</button>
4646
</div>
4747
);
4848

49-
SmartSort.propTypes = {
49+
RelevantSort.propTypes = {
5050
buttonTextComponent: PropTypes.func,
5151
className: PropTypes.string,
5252
isVirtualReplica: PropTypes.bool.isRequired,
53-
isSmartSorted: PropTypes.bool.isRequired,
53+
isRelevantSorted: PropTypes.bool.isRequired,
5454
refine: PropTypes.func.isRequired,
5555
textComponent: PropTypes.func,
5656
};
5757

58-
export default SmartSort;
58+
export default RelevantSort;

0 commit comments

Comments
 (0)