1
|
|
|
import { connect as reduxConnect } from 'react-redux'; |
2
|
|
|
import { assoc } from 'ramda'; |
3
|
|
|
import ShortUrls from '../ShortUrls'; |
4
|
|
|
import SearchBar from '../SearchBar'; |
5
|
|
|
import ShortUrlsList from '../ShortUrlsList'; |
6
|
|
|
import ShortUrlsRow from '../helpers/ShortUrlsRow'; |
7
|
|
|
import ShortUrlsRowMenu from '../helpers/ShortUrlsRowMenu'; |
8
|
|
|
import CreateShortUrl from '../CreateShortUrl'; |
9
|
|
|
import DeleteShortUrlModal from '../helpers/DeleteShortUrlModal'; |
10
|
|
|
import EditTagsModal from '../helpers/EditTagsModal'; |
11
|
|
|
import { listShortUrls } from '../reducers/shortUrlsList'; |
12
|
|
|
import { createShortUrl, resetCreateShortUrl } from '../reducers/shortUrlCreation'; |
13
|
|
|
import { deleteShortUrl, resetDeleteShortUrl, shortUrlDeleted } from '../reducers/shortUrlDeletion'; |
14
|
|
|
import { editShortUrlTags, resetShortUrlsTags, shortUrlTagsEdited } from '../reducers/shortUrlTags'; |
15
|
4 |
|
import { resetShortUrlParams } from '../reducers/shortUrlsListParams'; |
16
|
|
|
|
17
|
|
|
const provideServices = (bottle, connect) => { |
18
|
|
|
// Components |
19
|
|
|
bottle.serviceFactory('ShortUrls', ShortUrls, 'SearchBar', 'ShortUrlsList'); |
20
|
|
|
bottle.decorator('ShortUrls', reduxConnect( |
21
|
|
|
(state) => assoc('shortUrlsList', state.shortUrlsList.shortUrls, state.shortUrlsList) |
22
|
|
|
)); |
23
|
|
|
|
24
|
|
|
bottle.serviceFactory('SearchBar', SearchBar, 'ColorGenerator'); |
25
|
|
|
bottle.decorator('SearchBar', connect([ 'shortUrlsListParams' ], [ 'listShortUrls' ])); |
26
|
|
|
|
27
|
|
|
bottle.serviceFactory('ShortUrlsList', ShortUrlsList, 'ShortUrlsRow'); |
28
|
|
|
bottle.decorator('ShortUrlsList', connect( |
29
|
|
|
[ 'selectedServer', 'shortUrlsListParams' ], |
30
|
|
|
[ 'listShortUrls', 'resetShortUrlParams' ] |
31
|
|
|
)); |
32
|
|
|
|
33
|
|
|
bottle.serviceFactory('ShortUrlsRow', ShortUrlsRow, 'ShortUrlsRowMenu', 'ColorGenerator'); |
34
|
|
|
|
35
|
|
|
bottle.serviceFactory('ShortUrlsRowMenu', ShortUrlsRowMenu, 'DeleteShortUrlModal', 'EditTagsModal'); |
36
|
|
|
|
37
|
|
|
bottle.serviceFactory('CreateShortUrl', CreateShortUrl, 'TagsSelector'); |
38
|
|
|
bottle.decorator( |
39
|
|
|
'CreateShortUrl', |
40
|
|
|
connect([ 'shortUrlCreationResult' ], [ 'createShortUrl', 'resetCreateShortUrl' ]) |
41
|
|
|
); |
42
|
|
|
|
43
|
|
|
bottle.serviceFactory('DeleteShortUrlModal', () => DeleteShortUrlModal); |
44
|
|
|
bottle.decorator('DeleteShortUrlModal', connect( |
45
|
|
|
[ 'shortUrlDeletion' ], |
46
|
|
|
[ 'deleteShortUrl', 'resetDeleteShortUrl', 'shortUrlDeleted' ] |
47
|
|
|
)); |
48
|
|
|
|
49
|
|
|
bottle.serviceFactory('EditTagsModal', EditTagsModal, 'TagsSelector'); |
50
|
|
|
bottle.decorator('EditTagsModal', connect( |
51
|
|
|
[ 'shortUrlTags' ], |
52
|
|
|
[ 'editShortUrlTags', 'resetShortUrlsTags', 'shortUrlTagsEdited' ] |
53
|
|
|
)); |
54
|
|
|
|
55
|
|
|
// Actions |
56
|
|
|
bottle.serviceFactory('editShortUrlTags', editShortUrlTags, 'buildShlinkApiClient'); |
57
|
|
|
bottle.serviceFactory('resetShortUrlsTags', () => resetShortUrlsTags); |
58
|
|
|
bottle.serviceFactory('shortUrlTagsEdited', () => shortUrlTagsEdited); |
59
|
|
|
|
60
|
|
|
bottle.serviceFactory('listShortUrls', listShortUrls, 'buildShlinkApiClient'); |
61
|
|
|
bottle.serviceFactory('resetShortUrlParams', () => resetShortUrlParams); |
62
|
|
|
|
63
|
|
|
bottle.serviceFactory('createShortUrl', createShortUrl, 'buildShlinkApiClient'); |
64
|
|
|
bottle.serviceFactory('resetCreateShortUrl', () => resetCreateShortUrl); |
65
|
|
|
|
66
|
|
|
bottle.serviceFactory('deleteShortUrl', deleteShortUrl, 'buildShlinkApiClient'); |
67
|
|
|
bottle.serviceFactory('resetDeleteShortUrl', () => resetDeleteShortUrl); |
68
|
|
|
bottle.serviceFactory('shortUrlDeleted', () => shortUrlDeleted); |
69
|
|
|
}; |
70
|
|
|
|
71
|
|
|
export default provideServices; |
72
|
|
|
|