[CST-15073][CST-15074] Fixes

This commit is contained in:
Alisa Ismailati
2024-09-24 16:20:05 +02:00
committed by Vincenzo Mecca
parent 83615a1c90
commit 1565a1dc32
10 changed files with 31 additions and 14 deletions

View File

@@ -63,6 +63,7 @@ import {
import { ClientCookieService } from './core/services/client-cookie.service'; import { ClientCookieService } from './core/services/client-cookie.service';
import { ListableModule } from './core/shared/listable.module'; import { ListableModule } from './core/shared/listable.module';
import { XsrfInterceptor } from './core/xsrf/xsrf.interceptor'; import { XsrfInterceptor } from './core/xsrf/xsrf.interceptor';
import { LOGIN_METHOD_FOR_DECORATOR_MAP } from './external-log-in/decorators/external-log-in.methods-decorator';
import { RootModule } from './root.module'; import { RootModule } from './root.module';
import { AUTH_METHOD_FOR_DECORATOR_MAP } from './shared/log-in/methods/log-in.methods-decorator'; import { AUTH_METHOD_FOR_DECORATOR_MAP } from './shared/log-in/methods/log-in.methods-decorator';
import { METADATA_REPRESENTATION_COMPONENT_DECORATOR_MAP } from './shared/metadata-representation/metadata-representation.decorator'; import { METADATA_REPRESENTATION_COMPONENT_DECORATOR_MAP } from './shared/metadata-representation/metadata-representation.decorator';
@@ -157,6 +158,7 @@ export const commonAppConfig: ApplicationConfig = {
/* Use models object so all decorators are actually called */ /* Use models object so all decorators are actually called */
const modelList = models; const modelList = models;
const loginMethodForDecoratorMap = LOGIN_METHOD_FOR_DECORATOR_MAP;
const workflowTasks = WORKFLOW_TASK_OPTION_DECORATOR_MAP; const workflowTasks = WORKFLOW_TASK_OPTION_DECORATOR_MAP;
const advancedWorfklowTasks = ADVANCED_WORKFLOW_TASK_OPTION_DECORATOR_MAP; const advancedWorfklowTasks = ADVANCED_WORKFLOW_TASK_OPTION_DECORATOR_MAP;
const metadataRepresentations = METADATA_REPRESENTATION_COMPONENT_DECORATOR_MAP; const metadataRepresentations = METADATA_REPRESENTATION_COMPONENT_DECORATOR_MAP;

View File

@@ -1,9 +1,14 @@
import { AuthRegistrationType } from 'src/app/core/auth/models/auth.registration-type'; import { AuthRegistrationType } from 'src/app/core/auth/models/auth.registration-type';
/** import { OrcidConfirmationComponent } from '../registration-types/orcid-confirmation/orcid-confirmation.component';
* Map to store the external login confirmation component for the given auth method type
*/ export type ExternalLoginTypeComponent =
const authMethodsMap = new Map(); typeof OrcidConfirmationComponent;
export const LOGIN_METHOD_FOR_DECORATOR_MAP = new Map<AuthRegistrationType, ExternalLoginTypeComponent>([
[AuthRegistrationType.Orcid, OrcidConfirmationComponent],
]);
/** /**
* Decorator to register the external login confirmation component for the given auth method type * Decorator to register the external login confirmation component for the given auth method type
* @param authMethodType the type of the external login method * @param authMethodType the type of the external login method
@@ -15,7 +20,7 @@ export function renderExternalLoginConfirmationFor(
if (!objectElement) { if (!objectElement) {
return; return;
} }
authMethodsMap.set(authMethodType, objectElement); LOGIN_METHOD_FOR_DECORATOR_MAP.set(authMethodType, objectElement);
}; };
} }
/** /**
@@ -25,5 +30,5 @@ export function renderExternalLoginConfirmationFor(
export function getExternalLoginConfirmationType( export function getExternalLoginConfirmationType(
authMethodType: AuthRegistrationType, authMethodType: AuthRegistrationType,
) { ) {
return authMethodsMap.get(authMethodType); return LOGIN_METHOD_FOR_DECORATOR_MAP.get(authMethodType);
} }

View File

@@ -30,7 +30,10 @@ import {
isEmpty, isEmpty,
} from '../../shared/empty.util'; } from '../../shared/empty.util';
import { ThemedLogInComponent } from '../../shared/log-in/themed-log-in.component'; import { ThemedLogInComponent } from '../../shared/log-in/themed-log-in.component';
import { getExternalLoginConfirmationType } from '../decorators/external-log-in.methods-decorator'; import {
ExternalLoginTypeComponent,
getExternalLoginConfirmationType,
} from '../decorators/external-log-in.methods-decorator';
import { ConfirmEmailComponent } from '../email-confirmation/confirm-email/confirm-email.component'; import { ConfirmEmailComponent } from '../email-confirmation/confirm-email/confirm-email.component';
import { ProvideEmailComponent } from '../email-confirmation/provide-email/provide-email.component'; import { ProvideEmailComponent } from '../email-confirmation/provide-email/provide-email.component';
@@ -151,7 +154,7 @@ export class ExternalLogInComponent implements OnInit, OnDestroy {
/** /**
* Get the registration type to be rendered * Get the registration type to be rendered
*/ */
getExternalLoginConfirmationType() { getExternalLoginConfirmationType(): ExternalLoginTypeComponent {
return getExternalLoginConfirmationType(this.registrationType); return getExternalLoginConfirmationType(this.registrationType);
} }

View File

@@ -12,10 +12,8 @@ import {
} from '@angular/forms'; } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { AuthRegistrationType } from '../../../core/auth/models/auth.registration-type';
import { Registration } from '../../../core/shared/registration.model'; import { Registration } from '../../../core/shared/registration.model';
import { BrowserOnlyPipe } from '../../../shared/utils/browser-only.pipe'; import { BrowserOnlyPipe } from '../../../shared/utils/browser-only.pipe';
import { renderExternalLoginConfirmationFor } from '../../decorators/external-log-in.methods-decorator';
import { ExternalLoginMethodEntryComponent } from '../../decorators/external-login-method-entry.component'; import { ExternalLoginMethodEntryComponent } from '../../decorators/external-login-method-entry.component';
@Component({ @Component({
@@ -31,7 +29,6 @@ import { ExternalLoginMethodEntryComponent } from '../../decorators/external-log
], ],
standalone: true, standalone: true,
}) })
@renderExternalLoginConfirmationFor(AuthRegistrationType.Orcid)
export class OrcidConfirmationComponent extends ExternalLoginMethodEntryComponent implements OnInit { export class OrcidConfirmationComponent extends ExternalLoginMethodEntryComponent implements OnInit {
/** /**

View File

@@ -67,7 +67,7 @@ export class ExternalLoginService {
return this.store.pipe( return this.store.pipe(
select(getAuthenticationMethods), select(getAuthenticationMethods),
filter((methods: AuthMethod[]) => methods.length > 0), filter((methods: AuthMethod[]) => methods.length > 0),
map((methods: AuthMethod[]) => methods.find(m => m.authMethodType === registrationType.toLocaleLowerCase()).location), map((methods: AuthMethod[]) => methods.find((m: AuthMethod) => m.authMethodType.toString() === registrationType.toLocaleLowerCase()).location),
); );
} }
} }

View File

@@ -4,4 +4,7 @@
<ds-log-in-container [authMethod]="authMethod" [isStandalonePage]="isStandalonePage"></ds-log-in-container> <ds-log-in-container [authMethod]="authMethod" [isStandalonePage]="isStandalonePage"></ds-log-in-container>
<div *ngIf="!last" class="dropdown-divider my-2"></div> <div *ngIf="!last" class="dropdown-divider my-2"></div>
</ng-container> </ng-container>
<ng-container *ngIf="(authMethods | async).length === 0">
{{ 'login.no-auth-methods' | translate }}
</ng-container>
</div> </div>

View File

@@ -13,6 +13,7 @@ import {
select, select,
Store, Store,
} from '@ngrx/store'; } from '@ngrx/store';
import { TranslateModule } from '@ngx-translate/core';
import uniqBy from 'lodash/uniqBy'; import uniqBy from 'lodash/uniqBy';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
@@ -38,7 +39,7 @@ import { rendersAuthMethodType } from './methods/log-in.methods-decorator';
styleUrls: ['./log-in.component.scss'], styleUrls: ['./log-in.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true, standalone: true,
imports: [NgIf, ThemedLoadingComponent, NgFor, LogInContainerComponent, AsyncPipe], imports: [NgIf, ThemedLoadingComponent, NgFor, LogInContainerComponent, AsyncPipe, TranslateModule],
}) })
export class LogInComponent implements OnInit { export class LogInComponent implements OnInit {

View File

@@ -3202,6 +3202,8 @@
"login.breadcrumbs": "Login", "login.breadcrumbs": "Login",
"login.no-auth-methods": "No other authentication methods are available for this DSpace instance. Please contact your administrator.",
"logout.form.header": "Log out from DSpace", "logout.form.header": "Log out from DSpace",
"logout.form.submit": "Log out", "logout.form.submit": "Log out",

View File

@@ -4227,6 +4227,9 @@
// "login.breadcrumbs": "Login", // "login.breadcrumbs": "Login",
"login.breadcrumbs": "Accesso", "login.breadcrumbs": "Accesso",
// "login.no-auth-methods": "No other authentication methods are available for this DSpace instance. Please contact your administrator.",
// TODO New key - Add a translation
"login.no-auth-methods": "No other authentication methods are available for this DSpace instance. Please contact your administrator.",
// "logout.form.header": "Log out from DSpace", // "logout.form.header": "Log out from DSpace",

View File

@@ -4,6 +4,7 @@ import {
NgIf, NgIf,
} from '@angular/common'; } from '@angular/common';
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import { ThemedLoadingComponent } from 'src/app/shared/loading/themed-loading.component'; import { ThemedLoadingComponent } from 'src/app/shared/loading/themed-loading.component';
import { LogInContainerComponent } from 'src/app/shared/log-in/container/log-in-container.component'; import { LogInContainerComponent } from 'src/app/shared/log-in/container/log-in-container.component';
@@ -16,7 +17,7 @@ import { LogInComponent as BaseComponent } from '../../../../../app/shared/log-i
// styleUrls: ['./log-in.component.scss'], // styleUrls: ['./log-in.component.scss'],
styleUrls: ['../../../../../app/shared/log-in/log-in.component.scss'], styleUrls: ['../../../../../app/shared/log-in/log-in.component.scss'],
standalone: true, standalone: true,
imports: [NgIf, ThemedLoadingComponent, NgFor, LogInContainerComponent, AsyncPipe], imports: [NgIf, ThemedLoadingComponent, NgFor, LogInContainerComponent, AsyncPipe, TranslateModule],
}) })
export class LogInComponent extends BaseComponent { export class LogInComponent extends BaseComponent {
} }