Registered first actions as services

This commit is contained in:
Alejandro Celaya 2018-12-18 04:54:32 +01:00
parent d6e53918a2
commit 12ddeebedf
2 changed files with 9 additions and 8 deletions

View file

@ -136,10 +136,15 @@ bottle.decorator('DeleteShortUrlModal', connectDecorator(
[ 'shortUrlDeletion' ],
{ deleteShortUrl, resetDeleteShortUrl, shortUrlDeleted }
));
bottle.serviceFactory('editShortUrlTags', editShortUrlTags, 'ShlinkApiClient');
bottle.serviceFactory('resetShortUrlsTags', () => resetShortUrlsTags);
bottle.serviceFactory('shortUrlTagsEdited', () => shortUrlTagsEdited);
bottle.serviceFactory('EditTagsModal', EditTagsModal, 'TagsSelector');
bottle.decorator('EditTagsModal', connectDecorator(
[ 'shortUrlTags' ],
{ editShortUrlTags, resetShortUrlsTags, shortUrlTagsEdited }
[ 'editShortUrlTags', 'resetShortUrlsTags', 'shortUrlTagsEdited' ]
));
export default container;

View file

@ -1,6 +1,5 @@
import { curry } from 'ramda';
import PropTypes from 'prop-types';
import shlinkApiClient from '../../api/ShlinkApiClient';
import { pick } from 'ramda';
/* eslint-disable padding-line-between-statements, newline-after-var */
export const EDIT_SHORT_URL_TAGS_START = 'shlink/shortUrlTags/EDIT_SHORT_URL_TAGS_START';
@ -40,8 +39,7 @@ export default function reducer(state = defaultState, action) {
};
case EDIT_SHORT_URL_TAGS:
return {
shortCode: action.shortCode,
tags: action.tags,
...pick([ 'shortCode', 'tags' ], action),
saving: false,
error: false,
};
@ -52,7 +50,7 @@ export default function reducer(state = defaultState, action) {
}
}
export const _editShortUrlTags = (shlinkApiClient, shortCode, tags) => async (dispatch) => {
export const editShortUrlTags = (shlinkApiClient) => (shortCode, tags) => async (dispatch) => {
dispatch({ type: EDIT_SHORT_URL_TAGS_START });
try {
@ -66,8 +64,6 @@ export const _editShortUrlTags = (shlinkApiClient, shortCode, tags) => async (di
}
};
export const editShortUrlTags = curry(_editShortUrlTags)(shlinkApiClient);
export const resetShortUrlsTags = () => ({ type: RESET_EDIT_SHORT_URL_TAGS });
export const shortUrlTagsEdited = (shortCode, tags) => ({