You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2019/01/31 14:14:40 UTC
[couchdb-fauxton] branch master updated: Scope docs search to
selected partition key (#1178)
This is an automated email from the ASF dual-hosted git repository.
garren pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb-fauxton.git
The following commit(s) were added to refs/heads/master by this push:
new d2108e4 Scope docs search to selected partition key (#1178)
d2108e4 is described below
commit d2108e4db552c9c22aa9b82d44602ec9a5dc35b0
Author: Antonio Maranhao <30...@users.noreply.github.com>
AuthorDate: Thu Jan 31 11:14:35 2019 -0300
Scope docs search to selected partition key (#1178)
---
app/addons/components/components/throttledreacselect.js | 7 ++++---
app/addons/documents/components/actions.js | 7 ++++---
app/addons/documents/components/header-docs-right.js | 14 +++++++++++---
3 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/app/addons/components/components/throttledreacselect.js b/app/addons/components/components/throttledreacselect.js
index c39f63f..1fd66e3 100644
--- a/app/addons/components/components/throttledreacselect.js
+++ b/app/addons/components/components/throttledreacselect.js
@@ -19,8 +19,6 @@ export class ThrottledReactSelectAsync extends React.Component {
constructor(props) {
super(props);
this.lastCall = undefined;
- const { loadOptions } = props;
- this.throttledLoadOptions = this.wrapThrottler(loadOptions).bind(this);
}
wrapThrottler(loadOptions) {
@@ -38,9 +36,12 @@ export class ThrottledReactSelectAsync extends React.Component {
}
render() {
+ // wrapThrottler() must be called here to ensure a new
+ // function is created when props.loadOptions is updated
+ const throttledLoadOptions = this.wrapThrottler(this.props.loadOptions).bind(this);
const newProps = {
...this.props,
- loadOptions: this.throttledLoadOptions
+ loadOptions: throttledLoadOptions
};
return (
<ReactSelect.Async {...newProps} />
diff --git a/app/addons/documents/components/actions.js b/app/addons/documents/components/actions.js
index 765c7cb..6da915e 100644
--- a/app/addons/documents/components/actions.js
+++ b/app/addons/documents/components/actions.js
@@ -14,11 +14,12 @@ import FauxtonAPI from "../../../core/api";
import { get } from "../../../core/ajax";
export default {
- fetchAllDocsWithKey: (database) => {
+ fetchAllDocsWithKey: (database, partitionKey) => {
+ const keyPrefix = partitionKey ? `${partitionKey}:` : "";
return (id, callback) => {
const query = '?' + app.utils.queryParams({
- startkey: JSON.stringify(id),
- endkey: JSON.stringify(id + "\u9999"),
+ startkey: JSON.stringify(keyPrefix + id),
+ endkey: JSON.stringify(keyPrefix + id + "\u9999"),
limit: 30
});
diff --git a/app/addons/documents/components/header-docs-right.js b/app/addons/documents/components/header-docs-right.js
index 26def63..dfeaaa9 100644
--- a/app/addons/documents/components/header-docs-right.js
+++ b/app/addons/documents/components/header-docs-right.js
@@ -17,13 +17,20 @@ import QueryOptionsContainer from '../index-results/containers/QueryOptionsConta
import JumpToDoc from './jumptodoc';
import Actions from './actions';
-const RightAllDocsHeader = ({database, hideQueryOptions, hideJumpToDoc, queryDocs, ddocsOnly, selectedNavItem}) =>
+const RightAllDocsHeader = ({database, hideQueryOptions, hideJumpToDoc, queryDocs, ddocsOnly, selectedNavItem, partitionKey}) =>
<div className="header-right right-db-header flex-layout flex-row">
<div className="faux-header__searchboxwrapper">
<div className="faux-header__searchboxcontainer">
{hideJumpToDoc ? null :
- <JumpToDoc cache={false} loadOptions={Actions.fetchAllDocsWithKey(database)} database={database} /> }
+ <JumpToDoc
+ // 'key' is set to force mounting a new component when the partition key changes
+ // otherwise the internal ReactSelect doesn't reload the options even though
+ // it loadOptions is assigned a new function
+ key={JSON.stringify(database + partitionKey)}
+ cache={false}
+ loadOptions={Actions.fetchAllDocsWithKey(database, partitionKey)}
+ database={database} /> }
</div>
</div>
{hideQueryOptions ? null :
@@ -35,7 +42,8 @@ RightAllDocsHeader.propTypes = {
hideQueryOptions: PropTypes.bool,
isRedux: PropTypes.bool,
queryDocs: PropTypes.func,
- selectedNavItem: PropTypes.object
+ selectedNavItem: PropTypes.object,
+ partitionKey: PropTypes.string
};
RightAllDocsHeader.defaultProps = {