2018-12-18 21:59:50 +03:00
|
|
|
import { connect as reduxConnect } from 'react-redux';
|
|
|
|
import { assoc } from 'ramda';
|
|
|
|
import ShortUrls from '../ShortUrls';
|
|
|
|
import SearchBar from '../SearchBar';
|
|
|
|
import ShortUrlsList from '../ShortUrlsList';
|
|
|
|
import ShortUrlsRow from '../helpers/ShortUrlsRow';
|
|
|
|
import ShortUrlsRowMenu from '../helpers/ShortUrlsRowMenu';
|
|
|
|
import CreateShortUrl from '../CreateShortUrl';
|
|
|
|
import DeleteShortUrlModal from '../helpers/DeleteShortUrlModal';
|
|
|
|
import EditTagsModal from '../helpers/EditTagsModal';
|
2020-01-19 15:07:33 +03:00
|
|
|
import EditMetaModal from '../helpers/EditMetaModal';
|
2020-03-30 21:42:58 +03:00
|
|
|
import EditShortUrlModal from '../helpers/EditShortUrlModal';
|
2019-01-08 22:49:47 +03:00
|
|
|
import CreateShortUrlResult from '../helpers/CreateShortUrlResult';
|
2018-12-18 21:59:50 +03:00
|
|
|
import { listShortUrls } from '../reducers/shortUrlsList';
|
|
|
|
import { createShortUrl, resetCreateShortUrl } from '../reducers/shortUrlCreation';
|
2020-01-31 22:12:22 +03:00
|
|
|
import { deleteShortUrl, resetDeleteShortUrl } from '../reducers/shortUrlDeletion';
|
2020-01-31 22:06:28 +03:00
|
|
|
import { editShortUrlTags, resetShortUrlsTags } from '../reducers/shortUrlTags';
|
2020-01-19 22:37:12 +03:00
|
|
|
import { editShortUrlMeta, resetShortUrlMeta } from '../reducers/shortUrlMeta';
|
2018-12-18 21:59:50 +03:00
|
|
|
import { resetShortUrlParams } from '../reducers/shortUrlsListParams';
|
2020-03-30 21:47:33 +03:00
|
|
|
import { editShortUrl } from '../reducers/shortUrlEdition';
|
2018-12-18 21:59:50 +03:00
|
|
|
|
|
|
|
const provideServices = (bottle, connect) => {
|
|
|
|
// Components
|
|
|
|
bottle.serviceFactory('ShortUrls', ShortUrls, 'SearchBar', 'ShortUrlsList');
|
|
|
|
bottle.decorator('ShortUrls', reduxConnect(
|
|
|
|
(state) => assoc('shortUrlsList', state.shortUrlsList.shortUrls, state.shortUrlsList)
|
|
|
|
));
|
|
|
|
|
2020-01-28 21:46:36 +03:00
|
|
|
bottle.serviceFactory('SearchBar', SearchBar, 'ColorGenerator', 'ForServerVersion');
|
|
|
|
bottle.decorator('SearchBar', connect([ 'shortUrlsListParams' ], [ 'listShortUrls' ]));
|
2018-12-18 21:59:50 +03:00
|
|
|
|
|
|
|
bottle.serviceFactory('ShortUrlsList', ShortUrlsList, 'ShortUrlsRow');
|
|
|
|
bottle.decorator('ShortUrlsList', connect(
|
2020-04-26 14:00:23 +03:00
|
|
|
[ 'selectedServer', 'shortUrlsListParams', 'mercureInfo', 'settings' ],
|
2020-04-18 13:25:47 +03:00
|
|
|
[ 'listShortUrls', 'resetShortUrlParams', 'createNewVisit', 'loadMercureInfo' ]
|
2018-12-18 21:59:50 +03:00
|
|
|
));
|
|
|
|
|
2020-03-06 23:44:03 +03:00
|
|
|
bottle.serviceFactory('ShortUrlsRow', ShortUrlsRow, 'ShortUrlsRowMenu', 'ColorGenerator', 'useStateFlagTimeout');
|
2018-12-18 21:59:50 +03:00
|
|
|
|
2020-01-28 21:46:36 +03:00
|
|
|
bottle.serviceFactory(
|
|
|
|
'ShortUrlsRowMenu',
|
|
|
|
ShortUrlsRowMenu,
|
|
|
|
'DeleteShortUrlModal',
|
|
|
|
'EditTagsModal',
|
|
|
|
'EditMetaModal',
|
2020-03-30 21:42:58 +03:00
|
|
|
'EditShortUrlModal',
|
2020-01-28 21:46:36 +03:00
|
|
|
'ForServerVersion'
|
|
|
|
);
|
2020-05-31 11:16:09 +03:00
|
|
|
bottle.serviceFactory('CreateShortUrlResult', CreateShortUrlResult, 'useStateFlagTimeout');
|
2018-12-18 21:59:50 +03:00
|
|
|
|
2020-01-28 21:46:36 +03:00
|
|
|
bottle.serviceFactory('CreateShortUrl', CreateShortUrl, 'TagsSelector', 'CreateShortUrlResult', 'ForServerVersion');
|
2018-12-18 21:59:50 +03:00
|
|
|
bottle.decorator(
|
|
|
|
'CreateShortUrl',
|
2019-10-05 11:20:33 +03:00
|
|
|
connect([ 'shortUrlCreationResult', 'selectedServer' ], [ 'createShortUrl', 'resetCreateShortUrl' ])
|
2018-12-18 21:59:50 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
bottle.serviceFactory('DeleteShortUrlModal', () => DeleteShortUrlModal);
|
2020-01-31 22:12:22 +03:00
|
|
|
bottle.decorator('DeleteShortUrlModal', connect([ 'shortUrlDeletion' ], [ 'deleteShortUrl', 'resetDeleteShortUrl' ]));
|
2018-12-18 21:59:50 +03:00
|
|
|
|
|
|
|
bottle.serviceFactory('EditTagsModal', EditTagsModal, 'TagsSelector');
|
2020-01-31 22:06:28 +03:00
|
|
|
bottle.decorator('EditTagsModal', connect([ 'shortUrlTags' ], [ 'editShortUrlTags', 'resetShortUrlsTags' ]));
|
2018-12-18 21:59:50 +03:00
|
|
|
|
2020-01-17 23:07:59 +03:00
|
|
|
bottle.serviceFactory('EditMetaModal', () => EditMetaModal);
|
2020-01-19 22:37:12 +03:00
|
|
|
bottle.decorator('EditMetaModal', connect([ 'shortUrlMeta' ], [ 'editShortUrlMeta', 'resetShortUrlMeta' ]));
|
2020-01-17 23:07:59 +03:00
|
|
|
|
2020-03-30 21:42:58 +03:00
|
|
|
bottle.serviceFactory('EditShortUrlModal', () => EditShortUrlModal);
|
2020-03-30 21:47:33 +03:00
|
|
|
bottle.decorator('EditShortUrlModal', connect([ 'shortUrlEdition' ], [ 'editShortUrl' ]));
|
2020-03-30 21:42:58 +03:00
|
|
|
|
2018-12-18 21:59:50 +03:00
|
|
|
// Actions
|
|
|
|
bottle.serviceFactory('editShortUrlTags', editShortUrlTags, 'buildShlinkApiClient');
|
|
|
|
bottle.serviceFactory('resetShortUrlsTags', () => resetShortUrlsTags);
|
|
|
|
|
|
|
|
bottle.serviceFactory('listShortUrls', listShortUrls, 'buildShlinkApiClient');
|
|
|
|
bottle.serviceFactory('resetShortUrlParams', () => resetShortUrlParams);
|
|
|
|
|
|
|
|
bottle.serviceFactory('createShortUrl', createShortUrl, 'buildShlinkApiClient');
|
|
|
|
bottle.serviceFactory('resetCreateShortUrl', () => resetCreateShortUrl);
|
|
|
|
|
|
|
|
bottle.serviceFactory('deleteShortUrl', deleteShortUrl, 'buildShlinkApiClient');
|
|
|
|
bottle.serviceFactory('resetDeleteShortUrl', () => resetDeleteShortUrl);
|
2020-01-19 15:07:33 +03:00
|
|
|
|
|
|
|
bottle.serviceFactory('editShortUrlMeta', editShortUrlMeta, 'buildShlinkApiClient');
|
2020-01-19 22:37:12 +03:00
|
|
|
bottle.serviceFactory('resetShortUrlMeta', () => resetShortUrlMeta);
|
2020-03-30 21:42:58 +03:00
|
|
|
|
|
|
|
bottle.serviceFactory('editShortUrl', editShortUrl, 'buildShlinkApiClient');
|
2018-12-18 21:59:50 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export default provideServices;
|