mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-13 02:53:47 +00:00
Migrated a lot more components to new DI system
This commit is contained in:
@@ -2,37 +2,110 @@ import Bottle from 'bottlejs';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { connect } from 'react-redux';
|
||||
import { compose } from 'redux';
|
||||
import { pick } from 'ramda';
|
||||
import { assoc, pick } from 'ramda';
|
||||
import csvjson from 'csvjson';
|
||||
import axios from 'axios';
|
||||
import App from '../App';
|
||||
import ScrollToTop from '../common/ScrollToTop';
|
||||
import MainHeader from '../common/MainHeader';
|
||||
import { resetSelectedServer, selectServer } from '../servers/reducers/selectedServer';
|
||||
import Home from '../common/Home';
|
||||
import MenuLayout from '../common/MenuLayout';
|
||||
import { createServer } from '../servers/reducers/server';
|
||||
import { createServer, createServers, deleteServer, listServers } from '../servers/reducers/server';
|
||||
import CreateServer from '../servers/CreateServer';
|
||||
import store from './store';
|
||||
import ServersDropdown from '../servers/ServersDropdown';
|
||||
import TagsList from '../tags/TagsList';
|
||||
import { filterTags, forceListTags } from '../tags/reducers/tagsList';
|
||||
import ShortUrls from '../short-urls/ShortUrls';
|
||||
import SearchBar from '../short-urls/SearchBar';
|
||||
import { listShortUrls } from '../short-urls/reducers/shortUrlsList';
|
||||
import ShortUrlsList from '../short-urls/ShortUrlsList';
|
||||
import { resetShortUrlParams } from '../short-urls/reducers/shortUrlsListParams';
|
||||
import Tag from '../tags/helpers/Tag';
|
||||
import { ColorGenerator } from '../utils/ColorGenerator';
|
||||
import { Storage } from '../utils/Storage';
|
||||
import ShortUrlsRow from '../short-urls/helpers/ShortUrlsRow';
|
||||
import ShortUrlsRowMenu from '../short-urls/helpers/ShortUrlsRowMenu';
|
||||
import { ShlinkApiClient } from '../api/ShlinkApiClient';
|
||||
import DeleteServerModal from '../servers/DeleteServerModal';
|
||||
import DeleteServerButton from '../servers/DeleteServerButton';
|
||||
import AsideMenu from '../common/AsideMenu';
|
||||
import ImportServersBtn from '../servers/helpers/ImportServersBtn';
|
||||
import { ServersImporter } from '../servers/services/ServersImporter';
|
||||
import { ServersExporter } from '../servers/services/ServersExporter';
|
||||
import { ServersService } from '../servers/services/ServersService';
|
||||
|
||||
const bottle = new Bottle();
|
||||
|
||||
bottle.constant('store', store);
|
||||
bottle.serviceFactory('ScrollToTop', () => withRouter(ScrollToTop));
|
||||
bottle.serviceFactory('MainHeader', () => withRouter(MainHeader()));
|
||||
bottle.serviceFactory('Home', () => connect(pick([ 'servers' ]), { resetSelectedServer })(Home));
|
||||
bottle.serviceFactory(
|
||||
bottle.constant('ScrollToTop', ScrollToTop);
|
||||
bottle.decorator('ScrollToTop', withRouter);
|
||||
|
||||
bottle.serviceFactory('MainHeader', MainHeader, 'ServersDropdown');
|
||||
bottle.decorator('MainHeader', withRouter);
|
||||
|
||||
bottle.serviceFactory('Home', () => Home);
|
||||
bottle.decorator('Home', connect(pick([ 'servers' ]), { resetSelectedServer }));
|
||||
|
||||
bottle.serviceFactory('MenuLayout', MenuLayout, 'TagsList', 'ShortUrls', 'AsideMenu');
|
||||
bottle.decorator(
|
||||
'MenuLayout',
|
||||
() => compose(
|
||||
compose(
|
||||
connect(pick([ 'selectedServer', 'shortUrlsListParams' ]), { selectServer }),
|
||||
withRouter
|
||||
)(MenuLayout)
|
||||
);
|
||||
bottle.serviceFactory(
|
||||
'CreateServer',
|
||||
() => connect(
|
||||
pick([ 'selectedServer' ]),
|
||||
{ createServer, resetSelectedServer }
|
||||
)(CreateServer)
|
||||
)
|
||||
);
|
||||
|
||||
bottle.serviceFactory('CreateServer', CreateServer, 'ImportServersBtn');
|
||||
bottle.decorator('CreateServer', connect(pick([ 'selectedServer' ]), { createServer, resetSelectedServer }));
|
||||
|
||||
bottle.serviceFactory('App', App, 'MainHeader', 'Home', 'MenuLayout', 'CreateServer');
|
||||
|
||||
bottle.serviceFactory('ServersDropdown', ServersDropdown, 'ServersExporter');
|
||||
bottle.decorator('ServersDropdown', connect(pick([ 'servers', 'selectedServer' ]), { listServers, selectServer }));
|
||||
|
||||
bottle.serviceFactory('TagsList', () => TagsList);
|
||||
bottle.decorator('TagsList', connect(pick([ 'tagsList' ]), { forceListTags, filterTags }));
|
||||
|
||||
bottle.serviceFactory('ShortUrls', ShortUrls, 'SearchBar', 'ShortUrlsList');
|
||||
bottle.decorator('ShortUrls', connect(
|
||||
(state) => assoc('shortUrlsList', state.shortUrlsList.shortUrls, state.shortUrlsList)
|
||||
));
|
||||
|
||||
bottle.serviceFactory('SearchBar', SearchBar, 'Tag');
|
||||
bottle.decorator('SearchBar', connect(pick([ 'shortUrlsListParams' ]), { listShortUrls }));
|
||||
|
||||
bottle.serviceFactory('ShortUrlsList', ShortUrlsList, 'ShortUrlsRow');
|
||||
bottle.decorator('ShortUrlsList', connect(
|
||||
pick([ 'selectedServer', 'shortUrlsListParams' ]),
|
||||
{ listShortUrls, resetShortUrlParams }
|
||||
));
|
||||
|
||||
bottle.serviceFactory('Tag', Tag, 'ColorGenerator');
|
||||
|
||||
bottle.constant('localStorage', global.localStorage);
|
||||
bottle.service('Storage', Storage, 'localStorage');
|
||||
bottle.service('ColorGenerator', ColorGenerator, 'Storage');
|
||||
|
||||
bottle.serviceFactory('ShortUrlsRow', ShortUrlsRow, 'Tag', 'ShortUrlsRowMenu');
|
||||
|
||||
bottle.serviceFactory('ShortUrlsRowMenu', () => ShortUrlsRowMenu);
|
||||
|
||||
bottle.constant('axios', axios);
|
||||
bottle.service('ShlinkApiClient', ShlinkApiClient, 'axios');
|
||||
|
||||
bottle.serviceFactory('DeleteServerModal', () => DeleteServerModal);
|
||||
bottle.decorator('DeleteServerModal', compose(withRouter, connect(null, { deleteServer })));
|
||||
|
||||
bottle.serviceFactory('DeleteServerButton', DeleteServerButton, 'DeleteServerModal');
|
||||
bottle.serviceFactory('AsideMenu', AsideMenu, 'DeleteServerButton');
|
||||
|
||||
bottle.serviceFactory('ImportServersBtn', ImportServersBtn, 'ServersImporter');
|
||||
bottle.decorator('ImportServersBtn', connect(null, { createServers }));
|
||||
|
||||
bottle.constant('csvjson', csvjson);
|
||||
bottle.constant('window', global.window);
|
||||
bottle.service('ServersImporter', ServersImporter, 'csvjson');
|
||||
bottle.service('ServersService', ServersService, 'Storage');
|
||||
bottle.service('ServersExporter', ServersExporter, 'ServersService', 'window', 'csvjson');
|
||||
|
||||
export default bottle.container;
|
||||
|
||||
Reference in New Issue
Block a user