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';
|
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';
|
|
|
|
import { deleteShortUrl, resetDeleteShortUrl, shortUrlDeleted } from '../reducers/shortUrlDeletion';
|
|
|
|
import { editShortUrlTags, resetShortUrlsTags, shortUrlTagsEdited } from '../reducers/shortUrlTags';
|
|
|
|
import { resetShortUrlParams } from '../reducers/shortUrlsListParams';
|
2020-01-17 23:07:59 +03:00
|
|
|
import EditMetaModal from '../helpers/EditMetaModal';
|
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)
|
|
|
|
));
|
|
|
|
|
|
|
|
bottle.serviceFactory('SearchBar', SearchBar, 'ColorGenerator');
|
|
|
|
bottle.decorator('SearchBar', connect([ 'shortUrlsListParams' ], [ 'listShortUrls' ]));
|
|
|
|
|
|
|
|
bottle.serviceFactory('ShortUrlsList', ShortUrlsList, 'ShortUrlsRow');
|
|
|
|
bottle.decorator('ShortUrlsList', connect(
|
|
|
|
[ 'selectedServer', 'shortUrlsListParams' ],
|
|
|
|
[ 'listShortUrls', 'resetShortUrlParams' ]
|
|
|
|
));
|
|
|
|
|
2019-01-08 22:49:47 +03:00
|
|
|
bottle.serviceFactory('ShortUrlsRow', ShortUrlsRow, 'ShortUrlsRowMenu', 'ColorGenerator', 'stateFlagTimeout');
|
2018-12-18 21:59:50 +03:00
|
|
|
|
2020-01-17 23:07:59 +03:00
|
|
|
bottle.serviceFactory('ShortUrlsRowMenu', ShortUrlsRowMenu, 'DeleteShortUrlModal', 'EditTagsModal', 'EditMetaModal');
|
2019-01-08 22:49:47 +03:00
|
|
|
bottle.serviceFactory('CreateShortUrlResult', CreateShortUrlResult, 'stateFlagTimeout');
|
2018-12-18 21:59:50 +03:00
|
|
|
|
2019-01-08 22:49:47 +03:00
|
|
|
bottle.serviceFactory('CreateShortUrl', CreateShortUrl, 'TagsSelector', 'CreateShortUrlResult');
|
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);
|
|
|
|
bottle.decorator('DeleteShortUrlModal', connect(
|
|
|
|
[ 'shortUrlDeletion' ],
|
|
|
|
[ 'deleteShortUrl', 'resetDeleteShortUrl', 'shortUrlDeleted' ]
|
|
|
|
));
|
|
|
|
|
|
|
|
bottle.serviceFactory('EditTagsModal', EditTagsModal, 'TagsSelector');
|
|
|
|
bottle.decorator('EditTagsModal', connect(
|
|
|
|
[ 'shortUrlTags' ],
|
|
|
|
[ 'editShortUrlTags', 'resetShortUrlsTags', 'shortUrlTagsEdited' ]
|
|
|
|
));
|
|
|
|
|
2020-01-17 23:07:59 +03:00
|
|
|
bottle.serviceFactory('EditMetaModal', () => EditMetaModal);
|
|
|
|
bottle.decorator('EditMetaModal', connect(
|
|
|
|
[ 'shortUrlMeta' ],
|
|
|
|
[ 'editShortUrlMeta', 'shortUrlMetaEdited', 'resetShortUrlMeta' ]
|
|
|
|
));
|
|
|
|
|
2018-12-18 21:59:50 +03:00
|
|
|
// Actions
|
|
|
|
bottle.serviceFactory('editShortUrlTags', editShortUrlTags, 'buildShlinkApiClient');
|
|
|
|
bottle.serviceFactory('resetShortUrlsTags', () => resetShortUrlsTags);
|
|
|
|
bottle.serviceFactory('shortUrlTagsEdited', () => shortUrlTagsEdited);
|
|
|
|
|
|
|
|
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);
|
|
|
|
bottle.serviceFactory('shortUrlDeleted', () => shortUrlDeleted);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default provideServices;
|