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 c5e4c7a
Showing
11 changed files
with
73 additions
and
15 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; | ||
} |
Empty file.
14 changes: 14 additions & 0 deletions
14
src/themes/custom/app/shared/log-in/methods/oidc/log-in-oidc.component.ts
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Component, } from '@angular/core'; | ||
|
||
import { AuthMethodType } from '../../../../../../../app/core/auth/models/auth.method-type'; | ||
import { renderAuthMethodFor } from '../../../../../../../app/shared/log-in/methods/log-in.methods-decorator'; | ||
import { LogInOidcComponent as BaseComponent } from '../../../../../../../app/shared/log-in/methods/oidc/log-in-oidc.component'; | ||
|
||
@Component({ | ||
selector: 'ds-log-in-oidc', | ||
// templateUrl: './log-in-oidc.component.html', | ||
templateUrl: '../../../../../../../app/shared/log-in/methods/oidc/log-in-oidc.component.html', | ||
}) | ||
@renderAuthMethodFor(AuthMethodType.Oidc, 'custom') | ||
export class LogInOidcComponent extends BaseComponent { | ||
} |
Empty file.
Empty file.
18 changes: 18 additions & 0 deletions
18
src/themes/custom/app/shared/log-in/methods/password/log-in-password.component.ts
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
import { AuthMethodType } from '../../../../../../../app/core/auth/models/auth.method-type'; | ||
import { fadeOut } from '../../../../../../../app/shared/animations/fade'; | ||
import { renderAuthMethodFor } from '../../../../../../../app/shared/log-in/methods/log-in.methods-decorator'; | ||
import { LogInPasswordComponent as BaseComponent } from '../../../../../../../app/shared/log-in/methods/password/log-in-password.component'; | ||
|
||
@Component({ | ||
selector: 'ds-log-in-password', | ||
// templateUrl: './log-in-password.component.html', | ||
templateUrl: '../../../../../../../app/shared/log-in/methods/password/log-in-password.component.html', | ||
// styleUrls: ['./log-in-password.component.scss'], | ||
styleUrls: ['../../../../../../../app/shared/log-in/methods/password/log-in-password.component.scss'], | ||
animations: [fadeOut], | ||
}) | ||
@renderAuthMethodFor(AuthMethodType.Password, 'custom') | ||
export class LogInPasswordComponent extends BaseComponent { | ||
} |
Empty file.
Empty file.
16 changes: 16 additions & 0 deletions
16
src/themes/custom/app/shared/log-in/methods/shibboleth/log-in-shibboleth.component.ts
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Component, } from '@angular/core'; | ||
|
||
import { AuthMethodType } from '../../../../../../../app/core/auth/models/auth.method-type'; | ||
import { renderAuthMethodFor } from '../../../../../../../app/shared/log-in/methods/log-in.methods-decorator'; | ||
import { LogInShibbolethComponent as BaseComponent } from '../../../../../../../app/shared/log-in/methods/shibboleth/log-in-shibboleth.component'; | ||
|
||
@Component({ | ||
selector: 'ds-log-in-shibboleth', | ||
// templateUrl: './log-in-shibboleth.component.html', | ||
templateUrl: '../../../../../../../app/shared/log-in/methods/shibboleth/log-in-shibboleth.component.html', | ||
// styleUrls: ['./log-in-shibboleth.component.scss'], | ||
styleUrls: ['../../../../../../../app/shared/log-in/methods/shibboleth/log-in-shibboleth.component.scss'], | ||
}) | ||
@renderAuthMethodFor(AuthMethodType.Shibboleth, 'custom') | ||
export class LogInShibbolethComponent extends BaseComponent { | ||
} |
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,5 +1,11 @@ | ||
import { PublicationComponent } from './app/item-page/simple/item-types/publication/publication.component'; | ||
import { LogInOidcComponent } from './app/shared/log-in/methods/oidc/log-in-oidc.component'; | ||
import { LogInPasswordComponent } from './app/shared/log-in/methods/password/log-in-password.component'; | ||
import { LogInShibbolethComponent } from './app/shared/log-in/methods/shibboleth/log-in-shibboleth.component'; | ||
|
||
export const ENTRY_COMPONENTS = [ | ||
PublicationComponent | ||
PublicationComponent, | ||
LogInOidcComponent, | ||
LogInPasswordComponent, | ||
LogInShibbolethComponent, | ||
]; |