mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-09 17:57:26 +03:00
Create redux store for shlink-web-component
This commit is contained in:
parent
682de08204
commit
4b2a9ea158
5 changed files with 62 additions and 24 deletions
|
@ -8,7 +8,7 @@ import { provideServices as provideCommonServices } from '../common/services/pro
|
||||||
import { provideServices as provideMercureServices } from '../mercure/services/provideServices';
|
import { provideServices as provideMercureServices } from '../mercure/services/provideServices';
|
||||||
import { provideServices as provideServersServices } from '../servers/services/provideServices';
|
import { provideServices as provideServersServices } from '../servers/services/provideServices';
|
||||||
import { provideServices as provideSettingsServices } from '../settings/services/provideServices';
|
import { provideServices as provideSettingsServices } from '../settings/services/provideServices';
|
||||||
import { provideServices as provideWebComponentServices } from '../shlink-web-component/container';
|
import { provideServices as provideWebComponentServices } from '../shlink-web-component/container/provideServices';
|
||||||
import { provideServices as provideDomainsServices } from '../shlink-web-component/domains/services/provideServices';
|
import { provideServices as provideDomainsServices } from '../shlink-web-component/domains/services/provideServices';
|
||||||
import { provideServices as provideShortUrlsServices } from '../shlink-web-component/short-urls/services/provideServices';
|
import { provideServices as provideShortUrlsServices } from '../shlink-web-component/short-urls/services/provideServices';
|
||||||
import { provideServices as provideTagsServices } from '../shlink-web-component/tags/services/provideServices';
|
import { provideServices as provideTagsServices } from '../shlink-web-component/tags/services/provideServices';
|
||||||
|
|
|
@ -1,22 +1,2 @@
|
||||||
import type Bottle from 'bottlejs';
|
// TODO Create a separated container here
|
||||||
import { ShlinkWebComponent } from '../ShlinkWebComponent';
|
export { container } from '../../container';
|
||||||
|
|
||||||
// TODO Build sub-container
|
|
||||||
|
|
||||||
export const provideServices = (bottle: Bottle) => {
|
|
||||||
bottle.serviceFactory(
|
|
||||||
'ShlinkWebComponent',
|
|
||||||
ShlinkWebComponent,
|
|
||||||
'TagsList',
|
|
||||||
'ShortUrlsList',
|
|
||||||
'CreateShortUrl',
|
|
||||||
'ShortUrlVisits',
|
|
||||||
'TagVisits',
|
|
||||||
'DomainVisits',
|
|
||||||
'OrphanVisits',
|
|
||||||
'NonOrphanVisits',
|
|
||||||
'Overview',
|
|
||||||
'EditShortUrl',
|
|
||||||
'ManageDomains',
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
20
src/shlink-web-component/container/provideServices.ts
Normal file
20
src/shlink-web-component/container/provideServices.ts
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import type Bottle from 'bottlejs';
|
||||||
|
import { ShlinkWebComponent } from '../ShlinkWebComponent';
|
||||||
|
|
||||||
|
export const provideServices = (bottle: Bottle) => {
|
||||||
|
bottle.serviceFactory(
|
||||||
|
'ShlinkWebComponent',
|
||||||
|
ShlinkWebComponent,
|
||||||
|
'TagsList',
|
||||||
|
'ShortUrlsList',
|
||||||
|
'CreateShortUrl',
|
||||||
|
'ShortUrlVisits',
|
||||||
|
'TagVisits',
|
||||||
|
'DomainVisits',
|
||||||
|
'OrphanVisits',
|
||||||
|
'NonOrphanVisits',
|
||||||
|
'Overview',
|
||||||
|
'EditShortUrl',
|
||||||
|
'ManageDomains',
|
||||||
|
);
|
||||||
|
};
|
34
src/shlink-web-component/container/store.ts
Normal file
34
src/shlink-web-component/container/store.ts
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import { combineReducers, configureStore } from '@reduxjs/toolkit';
|
||||||
|
import type { IContainer } from 'bottlejs';
|
||||||
|
|
||||||
|
const isProduction = process.env.NODE_ENV === 'production';
|
||||||
|
|
||||||
|
export const setUpStore = (container: IContainer) => configureStore({
|
||||||
|
devTools: !isProduction,
|
||||||
|
reducer: combineReducers({
|
||||||
|
// TODO Check if this should be here or not
|
||||||
|
mercureInfo: container.mercureInfoReducer,
|
||||||
|
|
||||||
|
// Nested shlink-web-component reducers
|
||||||
|
shortUrlsList: container.shortUrlsListReducer,
|
||||||
|
shortUrlCreation: container.shortUrlCreationReducer,
|
||||||
|
shortUrlDeletion: container.shortUrlDeletionReducer,
|
||||||
|
shortUrlEdition: container.shortUrlEditionReducer,
|
||||||
|
shortUrlDetail: container.shortUrlDetailReducer,
|
||||||
|
shortUrlVisits: container.shortUrlVisitsReducer,
|
||||||
|
tagVisits: container.tagVisitsReducer,
|
||||||
|
domainVisits: container.domainVisitsReducer,
|
||||||
|
orphanVisits: container.orphanVisitsReducer,
|
||||||
|
nonOrphanVisits: container.nonOrphanVisitsReducer,
|
||||||
|
tagsList: container.tagsListReducer,
|
||||||
|
tagDelete: container.tagDeleteReducer,
|
||||||
|
tagEdit: container.tagEditReducer,
|
||||||
|
domainsList: container.domainsListReducer,
|
||||||
|
visitsOverview: container.visitsOverviewReducer,
|
||||||
|
}),
|
||||||
|
middleware: (defaultMiddlewaresIncludingReduxThunk) => defaultMiddlewaresIncludingReduxThunk({
|
||||||
|
// State is too big for these
|
||||||
|
immutableCheck: false,
|
||||||
|
serializableCheck: false,
|
||||||
|
}),
|
||||||
|
});
|
|
@ -1 +1,5 @@
|
||||||
export * from './ShlinkWebComponent';
|
import { container } from './container';
|
||||||
|
|
||||||
|
export const { ShlinkWebComponent } = container;
|
||||||
|
|
||||||
|
export type { ShlinkWebComponentType } from './ShlinkWebComponent';
|
||||||
|
|
Loading…
Reference in a new issue