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