1
|
|
|
import Bottle from 'bottlejs'; |
2
|
|
|
import { withRouter } from 'react-router-dom'; |
3
|
|
|
import { connect } from 'react-redux'; |
4
|
|
|
import { compose } from 'redux'; |
5
|
|
|
import { assoc, pick } from 'ramda'; |
6
|
|
|
import csvjson from 'csvjson'; |
7
|
|
|
import axios from 'axios'; |
8
|
|
|
import App from '../App'; |
9
|
|
|
import ScrollToTop from '../common/ScrollToTop'; |
10
|
|
|
import MainHeader from '../common/MainHeader'; |
11
|
|
|
import { resetSelectedServer, selectServer } from '../servers/reducers/selectedServer'; |
12
|
|
|
import Home from '../common/Home'; |
13
|
|
|
import MenuLayout from '../common/MenuLayout'; |
14
|
|
|
import { createServer, createServers, deleteServer, listServers } from '../servers/reducers/server'; |
15
|
|
|
import CreateServer from '../servers/CreateServer'; |
16
|
|
|
import ServersDropdown from '../servers/ServersDropdown'; |
17
|
|
|
import TagsList from '../tags/TagsList'; |
18
|
|
|
import { filterTags, forceListTags, listTags } from '../tags/reducers/tagsList'; |
19
|
|
|
import ShortUrls from '../short-urls/ShortUrls'; |
20
|
|
|
import SearchBar from '../short-urls/SearchBar'; |
21
|
|
|
import { listShortUrls } from '../short-urls/reducers/shortUrlsList'; |
22
|
|
|
import ShortUrlsList from '../short-urls/ShortUrlsList'; |
23
|
|
|
import { resetShortUrlParams } from '../short-urls/reducers/shortUrlsListParams'; |
24
|
|
|
import Tag from '../tags/helpers/Tag'; |
25
|
|
|
import { ColorGenerator } from '../utils/ColorGenerator'; |
26
|
|
|
import { Storage } from '../utils/Storage'; |
27
|
|
|
import ShortUrlsRow from '../short-urls/helpers/ShortUrlsRow'; |
28
|
|
|
import ShortUrlsRowMenu from '../short-urls/helpers/ShortUrlsRowMenu'; |
29
|
|
|
import { ShlinkApiClient } from '../api/ShlinkApiClient'; |
30
|
|
|
import DeleteServerModal from '../servers/DeleteServerModal'; |
31
|
|
|
import DeleteServerButton from '../servers/DeleteServerButton'; |
32
|
|
|
import AsideMenu from '../common/AsideMenu'; |
33
|
|
|
import ImportServersBtn from '../servers/helpers/ImportServersBtn'; |
34
|
|
|
import { ServersImporter } from '../servers/services/ServersImporter'; |
35
|
|
|
import { ServersExporter } from '../servers/services/ServersExporter'; |
36
|
|
|
import { ServersService } from '../servers/services/ServersService'; |
37
|
|
|
import CreateShortUrl from '../short-urls/CreateShortUrl'; |
38
|
|
|
import { createShortUrl, resetCreateShortUrl } from '../short-urls/reducers/shortUrlCreation'; |
39
|
|
|
import TagsSelector from '../tags/helpers/TagsSelector'; |
40
|
|
|
import DeleteShortUrlModal from '../short-urls/helpers/DeleteShortUrlModal'; |
41
|
|
|
import { deleteShortUrl, resetDeleteShortUrl, shortUrlDeleted } from '../short-urls/reducers/shortUrlDeletion'; |
42
|
|
|
import EditTagsModal from '../short-urls/helpers/EditTagsModal'; |
43
|
4 |
|
import { editShortUrlTags, resetShortUrlsTags, shortUrlTagsEdited } from '../short-urls/reducers/shortUrlTags'; |
44
|
|
|
|
45
|
|
|
const bottle = new Bottle(); |
46
|
|
|
|
47
|
|
|
bottle.constant('ScrollToTop', ScrollToTop); |
48
|
|
|
bottle.decorator('ScrollToTop', withRouter); |
49
|
|
|
|
50
|
|
|
bottle.serviceFactory('MainHeader', MainHeader, 'ServersDropdown'); |
51
|
|
|
bottle.decorator('MainHeader', withRouter); |
52
|
|
|
|
53
|
|
|
bottle.serviceFactory('Home', () => Home); |
54
|
|
|
bottle.decorator('Home', connect(pick([ 'servers' ]), { resetSelectedServer })); |
55
|
|
|
|
56
|
|
|
bottle.serviceFactory('MenuLayout', MenuLayout, 'TagsList', 'ShortUrls', 'AsideMenu', 'CreateShortUrl'); |
57
|
|
|
bottle.decorator( |
58
|
|
|
'MenuLayout', |
59
|
|
|
compose( |
60
|
|
|
connect(pick([ 'selectedServer', 'shortUrlsListParams' ]), { selectServer }), |
61
|
|
|
withRouter |
62
|
|
|
) |
63
|
|
|
); |
64
|
|
|
|
65
|
|
|
bottle.serviceFactory('CreateServer', CreateServer, 'ImportServersBtn'); |
66
|
|
|
bottle.decorator('CreateServer', connect(pick([ 'selectedServer' ]), { createServer, resetSelectedServer })); |
67
|
|
|
|
68
|
|
|
bottle.serviceFactory('App', App, 'MainHeader', 'Home', 'MenuLayout', 'CreateServer'); |
69
|
|
|
|
70
|
|
|
bottle.serviceFactory('ServersDropdown', ServersDropdown, 'ServersExporter'); |
71
|
|
|
bottle.decorator('ServersDropdown', connect(pick([ 'servers', 'selectedServer' ]), { listServers, selectServer })); |
72
|
|
|
|
73
|
|
|
bottle.serviceFactory('TagsList', () => TagsList); |
74
|
|
|
bottle.decorator('TagsList', connect(pick([ 'tagsList' ]), { forceListTags, filterTags })); |
75
|
|
|
|
76
|
|
|
bottle.serviceFactory('ShortUrls', ShortUrls, 'SearchBar', 'ShortUrlsList'); |
77
|
|
|
bottle.decorator('ShortUrls', connect( |
78
|
|
|
(state) => assoc('shortUrlsList', state.shortUrlsList.shortUrls, state.shortUrlsList) |
79
|
|
|
)); |
80
|
|
|
|
81
|
|
|
bottle.serviceFactory('SearchBar', SearchBar, 'Tag'); |
82
|
|
|
bottle.decorator('SearchBar', connect(pick([ 'shortUrlsListParams' ]), { listShortUrls })); |
83
|
|
|
|
84
|
|
|
bottle.serviceFactory('ShortUrlsList', ShortUrlsList, 'ShortUrlsRow'); |
85
|
|
|
bottle.decorator('ShortUrlsList', connect( |
86
|
|
|
pick([ 'selectedServer', 'shortUrlsListParams' ]), |
87
|
|
|
{ listShortUrls, resetShortUrlParams } |
88
|
|
|
)); |
89
|
|
|
|
90
|
|
|
bottle.serviceFactory('Tag', Tag, 'ColorGenerator'); |
91
|
|
|
|
92
|
|
|
bottle.constant('localStorage', global.localStorage); |
93
|
|
|
bottle.service('Storage', Storage, 'localStorage'); |
94
|
|
|
bottle.service('ColorGenerator', ColorGenerator, 'Storage'); |
95
|
|
|
|
96
|
|
|
bottle.serviceFactory('ShortUrlsRow', ShortUrlsRow, 'Tag', 'ShortUrlsRowMenu'); |
97
|
|
|
|
98
|
|
|
bottle.serviceFactory('ShortUrlsRowMenu', ShortUrlsRowMenu, 'DeleteShortUrlModal', 'EditTagsModal'); |
99
|
|
|
|
100
|
|
|
bottle.constant('axios', axios); |
101
|
|
|
bottle.service('ShlinkApiClient', ShlinkApiClient, 'axios'); |
102
|
|
|
|
103
|
|
|
bottle.serviceFactory('DeleteServerModal', () => DeleteServerModal); |
104
|
|
|
bottle.decorator('DeleteServerModal', compose(withRouter, connect(null, { deleteServer }))); |
105
|
|
|
|
106
|
|
|
bottle.serviceFactory('DeleteServerButton', DeleteServerButton, 'DeleteServerModal'); |
107
|
|
|
bottle.serviceFactory('AsideMenu', AsideMenu, 'DeleteServerButton'); |
108
|
|
|
|
109
|
|
|
bottle.serviceFactory('ImportServersBtn', ImportServersBtn, 'ServersImporter'); |
110
|
|
|
bottle.decorator('ImportServersBtn', connect(null, { createServers })); |
111
|
|
|
|
112
|
|
|
bottle.constant('csvjson', csvjson); |
113
|
|
|
bottle.constant('window', global.window); |
114
|
|
|
bottle.service('ServersImporter', ServersImporter, 'csvjson'); |
115
|
|
|
bottle.service('ServersService', ServersService, 'Storage'); |
116
|
|
|
bottle.service('ServersExporter', ServersExporter, 'ServersService', 'window', 'csvjson'); |
117
|
|
|
|
118
|
|
|
bottle.serviceFactory('CreateShortUrl', CreateShortUrl, 'TagsSelector'); |
119
|
|
|
bottle.decorator('CreateShortUrl', connect(pick([ 'shortUrlCreationResult' ]), { |
120
|
|
|
createShortUrl, |
121
|
|
|
resetCreateShortUrl, |
122
|
|
|
})); |
123
|
|
|
|
124
|
|
|
bottle.serviceFactory('TagsSelector', TagsSelector, 'ColorGenerator'); |
125
|
|
|
bottle.decorator('TagsSelector', connect(pick([ 'tagsList' ]), { listTags })); |
126
|
|
|
|
127
|
|
|
bottle.serviceFactory('DeleteShortUrlModal', () => DeleteShortUrlModal); |
128
|
|
|
bottle.decorator('DeleteShortUrlModal', connect( |
129
|
|
|
pick([ 'shortUrlDeletion' ]), |
130
|
|
|
{ deleteShortUrl, resetDeleteShortUrl, shortUrlDeleted } |
131
|
|
|
)); |
132
|
|
|
bottle.serviceFactory('EditTagsModal', EditTagsModal, 'TagsSelector'); |
133
|
|
|
bottle.decorator('EditTagsModal', connect( |
134
|
|
|
pick([ 'shortUrlTags' ]), |
135
|
|
|
{ editShortUrlTags, resetShortUrlsTags, shortUrlTagsEdited } |
136
|
|
|
)); |
137
|
|
|
|
138
|
|
|
export default bottle.container; |
139
|
|
|
|