Antonio-Maranhao commented on a change in pull request #1141: Convert
activetasks to redux
URL: https://github.com/apache/couchdb-fauxton/pull/1141#discussion_r225173629
##########
File path: app/addons/activetasks/actions.js
##########
@@ -9,72 +9,79 @@
// 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 FauxtonAPI from "../../core/api";
+import FauxtonAPI from '../../core/api';
import ActionTypes from "./actiontypes";
+import fetchActiveTasks from './api';
-export default {
+export const setActiveTaskIsLoading = (boolean) => {
+ return {
+ type: ActionTypes.ACTIVE_TASKS_SET_IS_LOADING,
+ options: boolean
+ };
+};
- init: function (activeTasks) {
- this.fetchAndSetActiveTasks(activeTasks.table, activeTasks);
- FauxtonAPI.when(activeTasks.fetch()).then(function () {
- this.fetchAndSetActiveTasks(activeTasks.table, activeTasks);
- this.setActiveTaskIsLoading(false);
- }.bind(this));
- },
+export const setActiveTasks = (tasks) => {
+ return {
+ type: ActionTypes.ACTIVE_TASKS_FETCH_AND_SET,
+ options: tasks
+ };
+};
- fetchAndSetActiveTasks: function (collection, backboneCollection) {
- FauxtonAPI.dispatch({
- type: ActionTypes.ACTIVE_TASKS_FETCH_AND_SET,
- options: {
- collectionTable: collection,
- backboneCollection: backboneCollection
- }
- });
- },
- changePollingInterval: function (interval) {
- FauxtonAPI.dispatch({
- type: ActionTypes.ACTIVE_TASKS_CHANGE_POLLING_INTERVAL,
- options: interval
- });
- },
- switchTab: function (tab) {
- FauxtonAPI.dispatch({
- type: ActionTypes.ACTIVE_TASKS_SWITCH_TAB,
- options: tab
- });
- },
- setCollection: function (collection) {
- FauxtonAPI.dispatch({
- type: ActionTypes.ACTIVE_TASKS_SET_COLLECTION,
- options: collection
- });
- },
- setSearchTerm: function (searchTerm) {
- FauxtonAPI.dispatch({
- type: ActionTypes.ACTIVE_TASKS_SET_SEARCH_TERM,
- options: searchTerm
- });
- },
- sortByColumnHeader: function (columnName) {
- FauxtonAPI.dispatch({
- type: ActionTypes.ACTIVE_TASKS_SORT_BY_COLUMN_HEADER,
- options: {
- columnName: columnName
- }
- });
- },
- setActiveTaskIsLoading: function (boolean) {
- FauxtonAPI.dispatch({
- type: ActionTypes.ACTIVE_TASKS_SET_IS_LOADING,
- options: boolean
+export const init = () => (dispatch) => {
+ dispatch(setActiveTaskIsLoading(true));
+ fetchActiveTasks()
+ .then(tasks => {
+ dispatch(setActiveTaskIsLoading(false));
+ dispatch(setActiveTasks(tasks));
+ })
+ .catch(error => {
+ FauxtonAPI.addNotification({
+ msg: `Fetching active tasks failed: ${error}`,
+ type: 'error'
+ });
});
- },
- runPollingUpdate (collection) {
- collection.pollingFetch().then(() => {
- FauxtonAPI.dispatch({
- type: ActionTypes.ACTIVE_TASKS_POLLING_COLLECTION,
- options: collection.table
+};
+
+export const fetchAndSetActiveTasks = (collection, backboneCollection) => {
Review comment:
`fetchAndSetActiveTasks` is not being used anywhere, so it can be removed
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services