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