1
|
|
|
import csvjson from 'csvjson'; |
2
|
|
|
import CreateServer from '../CreateServer'; |
3
|
|
|
import ServersDropdown from '../ServersDropdown'; |
4
|
|
|
import DeleteServerModal from '../DeleteServerModal'; |
5
|
|
|
import DeleteServerButton from '../DeleteServerButton'; |
6
|
|
|
import { EditServer } from '../EditServer'; |
7
|
|
|
import ImportServersBtn from '../helpers/ImportServersBtn'; |
8
|
|
|
import { resetSelectedServer, selectServer } from '../reducers/selectedServer'; |
9
|
|
|
import { createServer, createServers, deleteServer, editServer } from '../reducers/servers'; |
10
|
|
|
import { fetchServers } from '../reducers/remoteServers'; |
11
|
|
|
import ForServerVersion from '../helpers/ForServerVersion'; |
12
|
|
|
import { ServerError } from '../helpers/ServerError'; |
13
|
|
|
import ServersImporter from './ServersImporter'; |
14
|
|
|
import ServersExporter from './ServersExporter'; |
15
|
|
|
|
16
|
|
|
const provideServices = (bottle, connect, withRouter) => { |
17
|
|
|
// Components |
18
|
|
|
bottle.serviceFactory('CreateServer', CreateServer, 'ImportServersBtn', 'useStateFlagTimeout'); |
19
|
|
|
bottle.decorator('CreateServer', connect([ 'selectedServer' ], [ 'createServer', 'resetSelectedServer' ])); |
20
|
|
|
|
21
|
|
|
bottle.serviceFactory('EditServer', EditServer, 'ServerError'); |
22
|
|
|
bottle.decorator('EditServer', connect([ 'selectedServer' ], [ 'editServer', 'selectServer' ])); |
23
|
|
|
|
24
|
|
|
bottle.serviceFactory('ServersDropdown', ServersDropdown, 'ServersExporter'); |
25
|
|
|
bottle.decorator('ServersDropdown', connect([ 'servers', 'selectedServer' ])); |
26
|
|
|
|
27
|
|
|
bottle.serviceFactory('DeleteServerModal', () => DeleteServerModal); |
28
|
|
|
bottle.decorator('DeleteServerModal', withRouter); |
29
|
|
|
bottle.decorator('DeleteServerModal', connect(null, [ 'deleteServer' ])); |
30
|
|
|
|
31
|
|
|
bottle.serviceFactory('DeleteServerButton', DeleteServerButton, 'DeleteServerModal'); |
32
|
|
|
|
33
|
|
|
bottle.serviceFactory('ImportServersBtn', ImportServersBtn, 'ServersImporter'); |
34
|
|
|
bottle.decorator('ImportServersBtn', connect(null, [ 'createServers' ])); |
35
|
|
|
|
36
|
|
|
bottle.serviceFactory('ForServerVersion', () => ForServerVersion); |
37
|
|
|
bottle.decorator('ForServerVersion', connect([ 'selectedServer' ])); |
38
|
|
|
|
39
|
|
|
bottle.serviceFactory('ServerError', ServerError, 'DeleteServerButton'); |
40
|
|
|
bottle.decorator('ServerError', connect([ 'servers', 'selectedServer' ])); |
41
|
|
|
|
42
|
|
|
// Services |
43
|
|
|
bottle.constant('csvjson', csvjson); |
44
|
|
|
bottle.service('ServersImporter', ServersImporter, 'csvjson'); |
45
|
|
|
bottle.service('ServersExporter', ServersExporter, 'Storage', 'window', 'csvjson'); |
46
|
|
|
|
47
|
|
|
// Actions |
48
|
|
|
bottle.serviceFactory('selectServer', selectServer, 'buildShlinkApiClient', 'loadMercureInfo'); |
49
|
|
|
bottle.serviceFactory('createServer', () => createServer); |
50
|
|
|
bottle.serviceFactory('createServers', () => createServers); |
51
|
|
|
bottle.serviceFactory('deleteServer', () => deleteServer); |
52
|
|
|
bottle.serviceFactory('editServer', () => editServer); |
53
|
|
|
bottle.serviceFactory('fetchServers', fetchServers, 'axios'); |
54
|
|
|
|
55
|
|
|
bottle.serviceFactory('resetSelectedServer', () => resetSelectedServer); |
56
|
|
|
}; |
57
|
|
|
|
58
|
|
|
export default provideServices; |
59
|
|
|
|