forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
116131: Made the @renderAuthMethodFor themeable
- Loading branch information
1 parent
aaf89dc
commit 956d5ea
Showing
2 changed files
with
18 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
import { AuthMethodType } from '../../../core/auth/models/auth.method-type'; | ||
import { DEFAULT_THEME } from '../../object-collection/shared/listable-object/listable-object.decorator'; | ||
import { hasNoValue } from '../../empty.util'; | ||
import { getMatch } from '../../abstract-component-loader/dynamic-component-loader.utils'; | ||
|
||
export const DEFAULT_AUTH_METHOD_TYPE = AuthMethodType.Password; | ||
|
||
const authMethodsMap = new Map(); | ||
|
||
export function renderAuthMethodFor(authMethodType: AuthMethodType) { | ||
return function decorator(objectElement: any) { | ||
if (!objectElement) { | ||
return; | ||
export function renderAuthMethodFor(authMethodType: AuthMethodType, theme = DEFAULT_THEME) { | ||
return function decorator(component: any) { | ||
if (hasNoValue(authMethodsMap.get(authMethodType))) { | ||
authMethodsMap.set(authMethodType, new Map()); | ||
} | ||
authMethodsMap.set(authMethodType, objectElement); | ||
authMethodsMap.get(authMethodType).set(theme, component); | ||
}; | ||
} | ||
|
||
export function rendersAuthMethodType(authMethodType: AuthMethodType) { | ||
return authMethodsMap.get(authMethodType); | ||
export function rendersAuthMethodType(authMethodType: AuthMethodType, theme: string) { | ||
return getMatch(authMethodsMap, [authMethodType, theme], [DEFAULT_AUTH_METHOD_TYPE, DEFAULT_THEME]).match; | ||
} |