Browse Source

feat: use extension tokens and guard in identity module

pull/6628/head
Arman Ozak 6 years ago
parent
commit
b12031fc86
  1. 41
      npm/ng-packs/packages/identity/src/lib/identity.module.ts

41
npm/ng-packs/packages/identity/src/lib/identity.module.ts

@ -1,14 +1,24 @@
import { CoreModule, LazyModuleFactory } from '@abp/ng.core'; import { CoreModule, LazyModuleFactory } from '@abp/ng.core';
import { PermissionManagementModule } from '@abp/ng.permission-management'; import { PermissionManagementModule } from '@abp/ng.permission-management';
import { ThemeSharedModule } from '@abp/ng.theme.shared'; import { ThemeSharedModule } from '@abp/ng.theme.shared';
import { UiExtensionsModule } from '@abp/ng.theme.shared/extensions';
import { ModuleWithProviders, NgModule, NgModuleFactory } from '@angular/core'; import { ModuleWithProviders, NgModule, NgModuleFactory } from '@angular/core';
import { NgbDropdownModule, NgbNavModule } from '@ng-bootstrap/ng-bootstrap'; import { NgbDropdownModule, NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
import { NgxValidateCoreModule } from '@ngx-validate/core'; import { NgxValidateCoreModule } from '@ngx-validate/core';
import { NgxsModule } from '@ngxs/store'; import { NgxsModule } from '@ngxs/store';
import { RolesComponent } from './components/roles/roles.component'; import { RolesComponent } from './components/roles/roles.component';
import { UsersComponent } from './components/users/users.component'; import { UsersComponent } from './components/users/users.component';
import { IdentityExtensionsGuard } from './guards/extensions.guard';
import { IdentityRoutingModule } from './identity-routing.module'; import { IdentityRoutingModule } from './identity-routing.module';
import { IdentityConfigOptions } from './models/config-options';
import { IdentityState } from './states/identity.state'; import { IdentityState } from './states/identity.state';
import {
IDENTITY_CREATE_FORM_PROP_CONTRIBUTORS,
IDENTITY_EDIT_FORM_PROP_CONTRIBUTORS,
IDENTITY_ENTITY_ACTION_CONTRIBUTORS,
IDENTITY_ENTITY_PROP_CONTRIBUTORS,
IDENTITY_TOOLBAR_ACTION_CONTRIBUTORS,
} from './tokens/extensions.token';
@NgModule({ @NgModule({
declarations: [RolesComponent, UsersComponent], declarations: [RolesComponent, UsersComponent],
@ -19,20 +29,43 @@ import { IdentityState } from './states/identity.state';
IdentityRoutingModule, IdentityRoutingModule,
NgbNavModule, NgbNavModule,
ThemeSharedModule, ThemeSharedModule,
UiExtensionsModule,
NgbDropdownModule, NgbDropdownModule,
PermissionManagementModule, PermissionManagementModule,
NgxValidateCoreModule, NgxValidateCoreModule,
], ],
}) })
export class IdentityModule { export class IdentityModule {
static forChild(): ModuleWithProviders<IdentityModule> { static forChild(options: IdentityConfigOptions = {}): ModuleWithProviders<IdentityModule> {
return { return {
ngModule: IdentityModule, ngModule: IdentityModule,
providers: [], providers: [
{
provide: IDENTITY_ENTITY_ACTION_CONTRIBUTORS,
useValue: options.entityActionContributors,
},
{
provide: IDENTITY_TOOLBAR_ACTION_CONTRIBUTORS,
useValue: options.toolbarActionContributors,
},
{
provide: IDENTITY_ENTITY_PROP_CONTRIBUTORS,
useValue: options.entityPropContributors,
},
{
provide: IDENTITY_CREATE_FORM_PROP_CONTRIBUTORS,
useValue: options.createFormPropContributors,
},
{
provide: IDENTITY_EDIT_FORM_PROP_CONTRIBUTORS,
useValue: options.editFormPropContributors,
},
IdentityExtensionsGuard,
],
}; };
} }
static forLazy(): NgModuleFactory<IdentityModule> { static forLazy(options: IdentityConfigOptions = {}): NgModuleFactory<IdentityModule> {
return new LazyModuleFactory(IdentityModule.forChild()); return new LazyModuleFactory(IdentityModule.forChild(options));
} }
} }

Loading…
Cancel
Save