Browse Source

chore: remove config plugin

pull/6156/head
mehmet-erim 6 years ago
parent
commit
817ca703b3
  1. 19
      npm/ng-packs/packages/core/src/lib/core.module.ts
  2. 35
      npm/ng-packs/packages/core/src/lib/plugins/config.plugin.ts
  3. 1
      npm/ng-packs/packages/core/src/lib/plugins/index.ts

19
npm/ng-packs/packages/core/src/lib/core.module.ts

@ -1,10 +1,10 @@
import { APP_BASE_HREF, CommonModule } from '@angular/common';
import { HttpClientModule, HTTP_INTERCEPTORS, HttpClientXsrfModule } from '@angular/common/http';
import { HttpClientModule, HttpClientXsrfModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { APP_INITIALIZER, Injector, ModuleWithProviders, NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { NgxsRouterPluginModule } from '@ngxs/router-plugin';
import { NgxsModule, NGXS_PLUGINS } from '@ngxs/store';
import { NgxsModule } from '@ngxs/store';
import { OAuthModule, OAuthStorage } from 'angular-oauth2-oidc';
import { AbstractNgModelComponent } from './abstracts/ng-model.component';
import { DynamicLayoutComponent } from './components/dynamic-layout.component';
@ -27,17 +27,15 @@ import { LocalizationModule } from './localization.module';
import { ABP } from './models/common';
import { LocalizationPipe, MockLocalizationPipe } from './pipes/localization.pipe';
import { SortPipe } from './pipes/sort.pipe';
import { ConfigPlugin, NGXS_CONFIG_PLUGIN_OPTIONS } from './plugins/config.plugin';
import { LocaleProvider } from './providers/locale.provider';
import { LocalizationService } from './services/localization.service';
import { ConfigState } from './states/config.state';
import { ProfileState } from './states/profile.state';
import { ReplaceableComponentsState } from './states/replaceable-components.state';
import { oAuthStorage } from './strategies/auth-flow.strategy';
import { coreOptionsFactory, CORE_OPTIONS } from './tokens/options.token';
import { noop } from './utils/common-utils';
import './utils/date-extensions';
import { getInitialData, localeInitializer } from './utils/initial-utils';
import { oAuthStorage } from './strategies/auth-flow.strategy';
export function storageFactory(): OAuthStorage {
return oAuthStorage;
@ -115,7 +113,7 @@ export class BaseCoreModule {}
imports: [
BaseCoreModule,
LocalizationModule,
NgxsModule.forFeature([ReplaceableComponentsState, ProfileState, ConfigState]),
NgxsModule.forFeature([ReplaceableComponentsState, ProfileState]),
NgxsRouterPluginModule.forRoot(),
OAuthModule.forRoot(),
HttpClientXsrfModule.withOptions({
@ -164,15 +162,6 @@ export class CoreModule {
ngModule: RootCoreModule,
providers: [
LocaleProvider,
{
provide: NGXS_PLUGINS,
useClass: ConfigPlugin,
multi: true,
},
{
provide: NGXS_CONFIG_PLUGIN_OPTIONS,
useValue: { environment: options.environment },
},
{
provide: 'CORE_OPTIONS',
useValue: options,

35
npm/ng-packs/packages/core/src/lib/plugins/config.plugin.ts

@ -1,35 +0,0 @@
import { Inject, Injectable, InjectionToken } from '@angular/core';
import {
actionMatcher,
InitState,
NgxsNextPluginFn,
NgxsPlugin,
setValue,
UpdateState,
} from '@ngxs/store';
import { ABP } from '../models/common';
export const NGXS_CONFIG_PLUGIN_OPTIONS = new InjectionToken('NGXS_CONFIG_PLUGIN_OPTIONS');
@Injectable()
export class ConfigPlugin implements NgxsPlugin {
private initialized = false;
constructor(@Inject(NGXS_CONFIG_PLUGIN_OPTIONS) private options: ABP.Root) {}
handle(state: any, event: any, next: NgxsNextPluginFn) {
const matches = actionMatcher(event);
const isInitAction = matches(InitState) || matches(UpdateState);
if (isInitAction && !this.initialized) {
state = setValue(state, 'ConfigState', {
...(state.ConfigState && { ...state.ConfigState }),
...this.options,
});
this.initialized = true;
}
return next(state, event);
}
}

1
npm/ng-packs/packages/core/src/lib/plugins/index.ts

@ -1 +0,0 @@
export * from './config.plugin';
Loading…
Cancel
Save