|
|
@ -1,10 +1,19 @@ |
|
|
import { Injectable } from '@angular/core'; |
|
|
import { Injectable, isDevMode } from '@angular/core'; |
|
|
import { Action, createSelector, Selector, State, StateContext } from '@ngxs/store'; |
|
|
import { Action, createSelector, Selector, State, StateContext } from '@ngxs/store'; |
|
|
import snq from 'snq'; |
|
|
import snq from 'snq'; |
|
|
import { AddReplaceableComponent } from '../actions/replaceable-components.actions'; |
|
|
import { AddReplaceableComponent } from '../actions/replaceable-components.actions'; |
|
|
import { ReplaceableComponents } from '../models/replaceable-components'; |
|
|
import { ReplaceableComponents } from '../models/replaceable-components'; |
|
|
import { ReplaceableComponentsService } from '../services/replaceable-components.service'; |
|
|
import { ReplaceableComponentsService } from '../services/replaceable-components.service'; |
|
|
|
|
|
|
|
|
|
|
|
function logDeprecationMsg() { |
|
|
|
|
|
if (isDevMode()) { |
|
|
|
|
|
console.warn(` |
|
|
|
|
|
ReplacableComponentsState has been deprecated. Use ReplaceableComponentsService instead. |
|
|
|
|
|
See the doc https://docs.abp.io/en/abp/latest/UI/Angular/Component-Replacement
|
|
|
|
|
|
`);
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// tslint:disable: max-line-length
|
|
|
// tslint:disable: max-line-length
|
|
|
/** |
|
|
/** |
|
|
* @deprecated To be deleted in v4.0. Use ReplaceableComponentsService instead. See the doc (https://docs.abp.io/en/abp/latest/UI/Angular/Component-Replacement)
|
|
|
* @deprecated To be deleted in v4.0. Use ReplaceableComponentsService instead. See the doc (https://docs.abp.io/en/abp/latest/UI/Angular/Component-Replacement)
|
|
|
@ -19,6 +28,7 @@ export class ReplaceableComponentsState { |
|
|
static getAll({ |
|
|
static getAll({ |
|
|
replaceableComponents, |
|
|
replaceableComponents, |
|
|
}: ReplaceableComponents.State): ReplaceableComponents.ReplaceableComponent[] { |
|
|
}: ReplaceableComponents.State): ReplaceableComponents.ReplaceableComponent[] { |
|
|
|
|
|
logDeprecationMsg(); |
|
|
return replaceableComponents || []; |
|
|
return replaceableComponents || []; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -26,6 +36,7 @@ export class ReplaceableComponentsState { |
|
|
const selector = createSelector( |
|
|
const selector = createSelector( |
|
|
[ReplaceableComponentsState], |
|
|
[ReplaceableComponentsState], |
|
|
(state: ReplaceableComponents.State): ReplaceableComponents.ReplaceableComponent => { |
|
|
(state: ReplaceableComponents.State): ReplaceableComponents.ReplaceableComponent => { |
|
|
|
|
|
logDeprecationMsg(); |
|
|
return snq(() => state.replaceableComponents.find(component => component.key === key)); |
|
|
return snq(() => state.replaceableComponents.find(component => component.key === key)); |
|
|
}, |
|
|
}, |
|
|
); |
|
|
); |
|
|
@ -40,6 +51,8 @@ export class ReplaceableComponentsState { |
|
|
{ getState, patchState }: StateContext<ReplaceableComponents.State>, |
|
|
{ getState, patchState }: StateContext<ReplaceableComponents.State>, |
|
|
{ payload, reload }: AddReplaceableComponent, |
|
|
{ payload, reload }: AddReplaceableComponent, |
|
|
) { |
|
|
) { |
|
|
|
|
|
logDeprecationMsg(); |
|
|
|
|
|
|
|
|
let { replaceableComponents } = getState(); |
|
|
let { replaceableComponents } = getState(); |
|
|
|
|
|
|
|
|
const index = snq( |
|
|
const index = snq( |
|
|
|