Skip to content

Commit

Permalink
feat(core): provide information about stalled search to widgets (#2569)
Browse files Browse the repository at this point in the history
* feat(core): the core provides information about stalled search
This commit adds a new step that can update the UI. In this change,
the widgets are rendered when there are new results (previous behaviour)
and when the search is found to be stalled. The information is
propagated through a new option `searchMetadata` to the render method of
the widgets. This is an object that contains the flag `isStalledSearch`
that is set to `true` when there are still pending search after a delay
(for now 200ms).

* feat(searchbox): implements a loading indicator
* chore(lint): fix prettier and eslint check
* feat(core): add option to configure stalled search delay
* feat(searchbox): add options to set a loading indicator
* chore: update test to match the lib changes
* chore(search-box-test): remove sinon
* chore(connectSearchBox): remove sinon from test
* chore(doc): add isStalledSearch on connectSearchBox rendering options
* chore(validation): merge commit length should not be checked

Merge commits are automatically generated and are already standardized
by git, therefore there is no point in checking their length. Worst
truncating them would make use loose information.

* test(core): test new render step with stalled search
* chore(searchbox): test with input tag container
* chore(doc): fix inconsistencies and add details
* chore(searchbox): use `.ais-stalled-search` and fix use of input
* chore(doc): fix content
* chore: merge with 2.3, update snapshot
  • Loading branch information
bobylito authored Nov 28, 2017
1 parent fe79136 commit d104be1
Show file tree
Hide file tree
Showing 14 changed files with 731 additions and 145 deletions.
55 changes: 55 additions & 0 deletions dev/app/builtin/stories/search-box.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,34 @@ export default () => {
);
})
)
.add(
'display loading indicator',
wrapWithHits(container => {
window.search.addWidget(
instantsearch.widgets.searchBox({
container,
placeholder: 'Search for products',
poweredBy: true,
loadingIndicator: true,
})
);
})
)
.add(
'display loading indicator with a template',
wrapWithHits(container => {
window.search.addWidget(
instantsearch.widgets.searchBox({
container,
placeholder: 'Search for products',
poweredBy: true,
loadingIndicator: {
template: '⚡️',
},
})
);
})
)
.add(
'with custom templates',
wrapWithHits(container => {
Expand Down Expand Up @@ -66,5 +94,32 @@ export default () => {
})
);
})
)
.add(
'with a provided input',
wrapWithHits(container => {
container.innerHTML = '<input/>';
const input = container.firstChild;
container.appendChild(input);
window.search.addWidget(
instantsearch.widgets.searchBox({
container: input,
})
);
})
)
.add(
'with a provided input and the loading indicator',
wrapWithHits(container => {
container.innerHTML = '<input/>';
const input = container.firstChild;
container.appendChild(input);
window.search.addWidget(
instantsearch.widgets.searchBox({
container: input,
loadingIndicator: true,
})
);
})
);
};
6 changes: 3 additions & 3 deletions scripts/validate-commit-msgs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ for sha in `git log --format=oneline "$RANGE" | cut '-d ' -f1`; do

FIRST_LINE=`git log --format=%B -n 1 $sha | head -1`
MSG_LENGTH=`echo "$FIRST_LINE" | wc -c`
if [ $MSG_LENGTH -gt 100 ]; then
if echo $FIRST_LINE | grep -qE '^Merge (pull request|branch)'; then
echo "OK (merge)"
elif [ $MSG_LENGTH -gt 100 ]; then
echo "KO (too long): $FIRST_LINE"
EXIT=2
elif echo $FIRST_LINE | grep -qE '^v\d+\.\d+\.\d+(-beta\.\d+)?'; then
echo "OK (version)"
elif echo $FIRST_LINE | grep -qE '^Merge (pull request|branch)'; then
echo "OK (merge)"
elif echo $FIRST_LINE | grep -qE '^(feat|fix|docs?|style|refactor|perf|tests?|chore|revert)(\(.+\))?: .*'; then
echo "OK"
else
Expand Down
Loading

0 comments on commit d104be1

Please sign in to comment.