garrensmith commented on a change in pull request #906: Toolbar redesign for all docs URL: https://github.com/apache/couchdb-fauxton/pull/906#discussion_r122695672
########## File path: app/addons/documents/index-results/apis/base-api.js ########## @@ -0,0 +1,95 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + +import ActionTypes from '../actiontypes'; + +export const nowLoading = () => { + return { + type: ActionTypes.INDEX_RESULTS_REDUX_IS_LOADING + }; +}; + +export const resetState = () => { + return { + type: ActionTypes.INDEX_RESULTS_REDUX_RESET_STATE + }; +}; + +export const newResultsAvailable = (docs, params, canShowNext) => { + return { + type: ActionTypes.INDEX_RESULTS_REDUX_NEW_RESULTS, + docs: docs, + params: params, + canShowNext: canShowNext + }; +}; + +export const newSelectedDocs = (selectedDocs = []) => { + return { + type: ActionTypes.INDEX_RESULTS_REDUX_NEW_SELECTED_DOCS, + selectedDocs: selectedDocs + }; +}; + +export const selectDoc = (doc, selectedDocs) => { + const indexInSelectedDocs = selectedDocs.findIndex((selectedDoc) => { Review comment: This function can be improved. You don't need to find the index of the array, remove the doc and add it back in again. You just need to `find` the doc. Set it to `deleted = true`. The object is passed by reference so any change you make to the doc outside the array is made to it inside the array. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services