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 } 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
|
|
|
|
38
|
|
|
const bottle = new Bottle(); |
39
|
|
|
|
40
|
|
|
bottle.constant('ScrollToTop', ScrollToTop); |
41
|
|
|
bottle.decorator('ScrollToTop', withRouter); |
42
|
|
|
|
43
|
|
|
bottle.serviceFactory('MainHeader', MainHeader, 'ServersDropdown'); |
44
|
|
|
bottle.decorator('MainHeader', withRouter); |
45
|
|
|
|
46
|
|
|
bottle.serviceFactory('Home', () => Home); |
47
|
|
|
bottle.decorator('Home', connect(pick([ 'servers' ]), { resetSelectedServer })); |
48
|
|
|
|
49
|
|
|
bottle.serviceFactory('MenuLayout', MenuLayout, 'TagsList', 'ShortUrls', 'AsideMenu'); |
50
|
|
|
bottle.decorator( |
51
|
|
|
'MenuLayout', |
52
|
|
|
compose( |
53
|
|
|
connect(pick([ 'selectedServer', 'shortUrlsListParams' ]), { selectServer }), |
54
|
|
|
withRouter |
55
|
|
|
) |
56
|
|
|
); |
57
|
|
|
|
58
|
|
|
bottle.serviceFactory('CreateServer', CreateServer, 'ImportServersBtn'); |
59
|
|
|
bottle.decorator('CreateServer', connect(pick([ 'selectedServer' ]), { createServer, resetSelectedServer })); |
60
|
|
|
|
61
|
|
|
bottle.serviceFactory('App', App, 'MainHeader', 'Home', 'MenuLayout', 'CreateServer'); |
62
|
|
|
|
63
|
|
|
bottle.serviceFactory('ServersDropdown', ServersDropdown, 'ServersExporter'); |
64
|
|
|
bottle.decorator('ServersDropdown', connect(pick([ 'servers', 'selectedServer' ]), { listServers, selectServer })); |
65
|
|
|
|
66
|
|
|
bottle.serviceFactory('TagsList', () => TagsList); |
67
|
|
|
bottle.decorator('TagsList', connect(pick([ 'tagsList' ]), { forceListTags, filterTags })); |
68
|
|
|
|
69
|
|
|
bottle.serviceFactory('ShortUrls', ShortUrls, 'SearchBar', 'ShortUrlsList'); |
70
|
|
|
bottle.decorator('ShortUrls', connect( |
71
|
|
|
(state) => assoc('shortUrlsList', state.shortUrlsList.shortUrls, state.shortUrlsList) |
72
|
|
|
)); |
73
|
|
|
|
74
|
|
|
bottle.serviceFactory('SearchBar', SearchBar, 'Tag'); |
75
|
|
|
bottle.decorator('SearchBar', connect(pick([ 'shortUrlsListParams' ]), { listShortUrls })); |
76
|
|
|
|
77
|
|
|
bottle.serviceFactory('ShortUrlsList', ShortUrlsList, 'ShortUrlsRow'); |
78
|
|
|
bottle.decorator('ShortUrlsList', connect( |
79
|
|
|
pick([ 'selectedServer', 'shortUrlsListParams' ]), |
80
|
|
|
{ listShortUrls, resetShortUrlParams } |
81
|
|
|
)); |
82
|
|
|
|
83
|
|
|
bottle.serviceFactory('Tag', Tag, 'ColorGenerator'); |
84
|
|
|
|
85
|
|
|
bottle.constant('localStorage', global.localStorage); |
86
|
|
|
bottle.service('Storage', Storage, 'localStorage'); |
87
|
|
|
bottle.service('ColorGenerator', ColorGenerator, 'Storage'); |
88
|
|
|
|
89
|
|
|
bottle.serviceFactory('ShortUrlsRow', ShortUrlsRow, 'Tag', 'ShortUrlsRowMenu'); |
90
|
|
|
|
91
|
|
|
bottle.serviceFactory('ShortUrlsRowMenu', () => ShortUrlsRowMenu); |
92
|
|
|
|
93
|
|
|
bottle.constant('axios', axios); |
94
|
|
|
bottle.service('ShlinkApiClient', ShlinkApiClient, 'axios'); |
95
|
|
|
|
96
|
|
|
bottle.serviceFactory('DeleteServerModal', () => DeleteServerModal); |
97
|
|
|
bottle.decorator('DeleteServerModal', compose(withRouter, connect(null, { deleteServer }))); |
98
|
|
|
|
99
|
|
|
bottle.serviceFactory('DeleteServerButton', DeleteServerButton, 'DeleteServerModal'); |
100
|
|
|
bottle.serviceFactory('AsideMenu', AsideMenu, 'DeleteServerButton'); |
101
|
|
|
|
102
|
|
|
bottle.serviceFactory('ImportServersBtn', ImportServersBtn, 'ServersImporter'); |
103
|
|
|
bottle.decorator('ImportServersBtn', connect(null, { createServers })); |
104
|
|
|
|
105
|
|
|
bottle.constant('csvjson', csvjson); |
106
|
|
|
bottle.constant('window', global.window); |
107
|
|
|
bottle.service('ServersImporter', ServersImporter, 'csvjson'); |
108
|
|
|
bottle.service('ServersService', ServersService, 'Storage'); |
109
|
|
|
bottle.service('ServersExporter', ServersExporter, 'ServersService', 'window', 'csvjson'); |
110
|
|
|
|
111
|
|
|
export default bottle.container; |
112
|
|
|
|