From cab74246d680d089377fe6c25a21f3a631d263d5 Mon Sep 17 00:00:00 2001 From: cmoinier Date: Thu, 14 Nov 2024 15:29:50 +0100 Subject: [PATCH 001/168] feat: add logout url logic --- apps/metadata-editor/src/app/app.module.ts | 5 +++++ conf/default.toml | 1 + .../repository/src/lib/gn4/auth/auth.service.ts | 14 +++++++++++--- libs/util/app-config/src/lib/app-config.ts | 2 ++ libs/util/app-config/src/lib/fixtures.ts | 1 + libs/util/app-config/src/lib/model.ts | 1 + 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/apps/metadata-editor/src/app/app.module.ts b/apps/metadata-editor/src/app/app.module.ts index 87354808bc..c2a3784725 100644 --- a/apps/metadata-editor/src/app/app.module.ts +++ b/apps/metadata-editor/src/app/app.module.ts @@ -26,6 +26,7 @@ import { DashboardPageComponent } from './dashboard/dashboard-page.component' import { EditorRouterService } from './router.service' import { LOGIN_URL, + LOGOUT_URL, provideGn4, provideRepositoryUrl, } from '@geonetwork-ui/api/repository' @@ -70,6 +71,10 @@ import { FeatureEditorModule } from '@geonetwork-ui/feature/editor' provide: LOGIN_URL, useFactory: () => getGlobalConfig().LOGIN_URL, }, + { + provide: LOGOUT_URL, + useFactory: () => getGlobalConfig().LOGOUT_URL, + }, ], bootstrap: [AppComponent], }) diff --git a/conf/default.toml b/conf/default.toml index 0cd7d309d6..cdd3ade555 100644 --- a/conf/default.toml +++ b/conf/default.toml @@ -23,6 +23,7 @@ proxy_path = "" # - ${lang2}, ${lang3}: indicates if and where the current language should be part of the login URL in language 2 or 3 letter code # Example to use the georchestra login page: # login_url = "/cas/login?service=${current_url}" +# logout_url = "/geonetwork/signout?redirectUrl=\${current_url}" # This optional URL should point to the static html page wc-embedder.html which allows to display a web component (like chart and table) via a permalink. # URLs can be indicated from the root of the same server starting with a "/" or as an external URL. Be conscious of potential CORS issues when using an external URL. # The default location in the dockerized datahub app for example is "/datahub/wc-embedder.html". diff --git a/libs/api/repository/src/lib/gn4/auth/auth.service.ts b/libs/api/repository/src/lib/gn4/auth/auth.service.ts index fae24500ba..e564950a44 100644 --- a/libs/api/repository/src/lib/gn4/auth/auth.service.ts +++ b/libs/api/repository/src/lib/gn4/auth/auth.service.ts @@ -5,11 +5,15 @@ import { TranslateService } from '@ngx-translate/core' export const DEFAULT_GN4_LOGIN_URL = `/geonetwork/srv/\${lang3}/catalog.signin?redirect=\${current_url}` export const LOGIN_URL = new InjectionToken('loginUrl') +export const DEFAULT_GN4_LOGOUT_URL = `/geonetwork/signout` +export const LOGOUT_URL = new InjectionToken('loginUrl') + @Injectable({ providedIn: 'root', }) export class AuthService { baseLoginUrl = this.baseLoginUrlToken || DEFAULT_GN4_LOGIN_URL + baseLogoutUrl = this.baseLogoutUrlToken || DEFAULT_GN4_LOGOUT_URL get loginUrl() { let baseUrl = this.baseLoginUrl const locationHasQueryParams = !!window.location.search @@ -25,10 +29,14 @@ export class AuthService { LANG_2_TO_3_MAPPER[this.translateService.currentLang] ) } + + get logoutUrl() { + return this.baseLogoutUrl + } + constructor( - @Optional() - @Inject(LOGIN_URL) - private baseLoginUrlToken: string, + @Optional() @Inject(LOGIN_URL) private baseLoginUrlToken: string, + @Optional() @Inject(LOGOUT_URL) private baseLogoutUrlToken: string, private translateService: TranslateService ) {} } diff --git a/libs/util/app-config/src/lib/app-config.ts b/libs/util/app-config/src/lib/app-config.ts index 04ca6b87fd..540073903c 100644 --- a/libs/util/app-config/src/lib/app-config.ts +++ b/libs/util/app-config/src/lib/app-config.ts @@ -98,6 +98,7 @@ export function loadAppConfig() { 'proxy_path', 'metadata_language', 'login_url', + 'logout_url', 'web_component_embedder_url', 'languages', 'contact_email', @@ -124,6 +125,7 @@ export function loadAppConfig() { ).toLowerCase() : undefined, LOGIN_URL: parsedGlobalSection.login_url, + LOGOUT_URL: parsedGlobalSection.logout_url, WEB_COMPONENT_EMBEDDER_URL: parsedGlobalSection.web_component_embedder_url, LANGUAGES: parsedGlobalSection.languages, diff --git a/libs/util/app-config/src/lib/fixtures.ts b/libs/util/app-config/src/lib/fixtures.ts index 2a7cec35d4..731ce788e3 100644 --- a/libs/util/app-config/src/lib/fixtures.ts +++ b/libs/util/app-config/src/lib/fixtures.ts @@ -6,6 +6,7 @@ geonetwork4_api_url = "/geonetwork/srv/api" proxy_path = "/proxy/?url=" metadata_language = "fre" login_url = "/cas/login?service=" +logout_url = "/geonetwork/signout?redirectUrl=" web_component_embedder_url = "/datahub/wc-embedder.html" [map] diff --git a/libs/util/app-config/src/lib/model.ts b/libs/util/app-config/src/lib/model.ts index 84682b6eee..742aa7fc4b 100644 --- a/libs/util/app-config/src/lib/model.ts +++ b/libs/util/app-config/src/lib/model.ts @@ -6,6 +6,7 @@ export interface GlobalConfig { PROXY_PATH?: string METADATA_LANGUAGE?: string LOGIN_URL?: string + LOGOUT_URL?: string WEB_COMPONENT_EMBEDDER_URL?: string LANGUAGES?: string[] CONTACT_EMAIL?: string From c22bf1c8309886a58ea323f3ad7e4cf986fb25f8 Mon Sep 17 00:00:00 2001 From: cmoinier Date: Thu, 14 Nov 2024 15:30:19 +0100 Subject: [PATCH 002/168] feat: implement logout in sidebar --- .../dashboard/sidebar/sidebar.component.html | 8 ++++++- .../dashboard/sidebar/sidebar.component.ts | 24 +++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html index 0c81c789b8..8491a2091f 100644 --- a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html +++ b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html @@ -31,8 +31,14 @@ - Log out + Log out diff --git a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts index 0aeb4afca0..8c662165b2 100644 --- a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts +++ b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts @@ -3,7 +3,10 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core' import { TranslateModule } from '@ngx-translate/core' import { DashboardMenuComponent } from '../dashboard-menu/dashboard-menu.component' import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' -import { AvatarServiceInterface } from '@geonetwork-ui/api/repository' +import { + AuthService, + AvatarServiceInterface, +} from '@geonetwork-ui/api/repository' import { LetDirective } from '@ngrx/component' import { UiElementsModule } from '@geonetwork-ui/ui/elements' import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' @@ -31,7 +34,8 @@ export class SidebarComponent implements OnInit { constructor( public platformService: PlatformServiceInterface, private avatarService: AvatarServiceInterface, - public organisationsService: OrganizationsServiceInterface + public organisationsService: OrganizationsServiceInterface, + private authService: AuthService ) {} ngOnInit(): void { @@ -41,4 +45,20 @@ export class SidebarComponent implements OnInit { (orgs, me) => orgs.filter((org) => org.name === me?.organisation) ) } + + logOut() { + fetch(this.authService.logoutUrl, { + method: 'GET', + }) + .then((response) => { + if (response.ok) { + window.location.href = 'http://localhost:4200' + } else { + console.error('Logout failed') + } + }) + .catch((error) => { + console.error('Error during logout request:', error) + }) + } } From b514139704633f0ad207f62dc5db99bfaa25dd2f Mon Sep 17 00:00:00 2001 From: cmoinier Date: Thu, 14 Nov 2024 15:30:31 +0100 Subject: [PATCH 003/168] feat: add ut and e2e --- .../src/e2e/dashboard.cy.ts | 22 ++++++++--- .../sidebar/sidebar.component.spec.ts | 37 ++++++++++++++++++- .../src/lib/gn4/auth/auth.service.spec.ts | 9 +++++ 3 files changed, 61 insertions(+), 7 deletions(-) diff --git a/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts b/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts index 5cee3c2b69..91b7df4e7d 100644 --- a/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts +++ b/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts @@ -344,11 +344,23 @@ describe('dashboard (authenticated)', () => { }) }) -describe('when the user is not logged in', () => { - beforeEach(() => { - cy.visit('/catalog/search') +describe('Logging in and out', () => { + describe('when the user is not logged in', () => { + beforeEach(() => { + cy.visit('/catalog/search') + }) + it('redirects to the login page', () => { + cy.url().should('include', '/catalog.signin?redirect=') + }) }) - it('redirects to the login page', () => { - cy.url().should('include', '/catalog.signin?redirect=') + describe('Logging out', () => { + beforeEach(() => { + cy.login('admin', 'admin', false) + cy.visit('/catalog/search') + }) + it('logs out the user', () => { + cy.get('md-editor-sidebar').find('gn-ui-button').eq(1).click() + cy.url().should('include', '/catalog.signin?redirect=') + }) }) }) diff --git a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts index 50982f3777..2bda7b2737 100644 --- a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts +++ b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts @@ -1,19 +1,27 @@ import { ComponentFixture, TestBed } from '@angular/core/testing' -import { AvatarServiceInterface } from '@geonetwork-ui/api/repository' +import { + AuthService, + AvatarServiceInterface, +} from '@geonetwork-ui/api/repository' import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' import { TranslateModule } from '@ngx-translate/core' -import { MockBuilder, MockProviders } from 'ng-mocks' +import { MockBuilder, MockProvider, MockProviders } from 'ng-mocks' import { SidebarComponent } from './sidebar.component' describe('SidebarComponent', () => { let component: SidebarComponent let fixture: ComponentFixture + let service: AuthService beforeEach(() => { return MockBuilder(SidebarComponent) }) + afterEach(() => { + jest.resetAllMocks() + }) + beforeEach(async () => { await TestBed.configureTestingModule({ imports: [SidebarComponent, TranslateModule.forRoot()], @@ -23,9 +31,13 @@ describe('SidebarComponent', () => { AvatarServiceInterface, OrganizationsServiceInterface ), + MockProvider(AuthService, { + logoutUrl: 'http://logout.com/bla?', + }), ], }).compileComponents() + service = TestBed.inject(AuthService) fixture = TestBed.createComponent(SidebarComponent) component = fixture.componentInstance fixture.detectChanges() @@ -34,4 +46,25 @@ describe('SidebarComponent', () => { it('should create', () => { expect(component).toBeTruthy() }) + + describe('logOut', () => { + it('should log out', async () => { + jest.spyOn(window, 'fetch').mockResolvedValue({ + ok: true, + } as Response) + + delete window.location + Object.defineProperty(window, 'location', { + value: { href: 'http://app-url.com' }, + writable: true, + }) + + await component.logOut() + + expect(window.fetch).toHaveBeenCalledWith(service.logoutUrl, { + method: 'GET', + }) + expect(window.location.href).toBe('http://localhost:4200') + }) + }) }) diff --git a/libs/api/repository/src/lib/gn4/auth/auth.service.spec.ts b/libs/api/repository/src/lib/gn4/auth/auth.service.spec.ts index f604788788..dabc434e34 100644 --- a/libs/api/repository/src/lib/gn4/auth/auth.service.spec.ts +++ b/libs/api/repository/src/lib/gn4/auth/auth.service.spec.ts @@ -82,4 +82,13 @@ describe('AuthService', () => { ) }) }) + + describe('Logout', () => { + beforeEach(() => { + service = TestBed.inject(AuthService) + }) + it('should return the logout url', () => { + expect(service.logoutUrl).toEqual('/geonetwork/signout') + }) + }) }) From cd1cb3590536e314c9ef2b347a6437d0d638374e Mon Sep 17 00:00:00 2001 From: cmoinier Date: Thu, 14 Nov 2024 15:30:43 +0100 Subject: [PATCH 004/168] feat: add translations --- translations/de.json | 1 + translations/en.json | 1 + translations/es.json | 1 + translations/fr.json | 1 + translations/it.json | 1 + translations/nl.json | 1 + translations/pt.json | 1 + translations/sk.json | 1 + 8 files changed, 8 insertions(+) diff --git a/translations/de.json b/translations/de.json index 63d5ec7762..00ae56f652 100644 --- a/translations/de.json +++ b/translations/de.json @@ -296,6 +296,7 @@ "editor.record.undo.tooltip.disabled": "", "editor.record.undo.tooltip.enabled": "", "editor.record.upToDate": "Dieser Datensatz ist auf dem neuesten Stand", + "editor.sidebar.logout": "", "editor.sidebar.menu.editor": "", "editor.temporary.disabled": "", "externalviewer.dataset.unnamed": "Datensatz aus dem Datahub", diff --git a/translations/en.json b/translations/en.json index 3f15cfe258..f4c7e19558 100644 --- a/translations/en.json +++ b/translations/en.json @@ -296,6 +296,7 @@ "editor.record.undo.tooltip.disabled": "There are no pending changes on this record", "editor.record.undo.tooltip.enabled": "Clicking this button will cancel the pending changes on this record.", "editor.record.upToDate": "This record is up to date", + "editor.sidebar.logout": "Log out", "editor.sidebar.menu.editor": "Editor", "editor.temporary.disabled": "Not implemented yet", "externalviewer.dataset.unnamed": "Datahub layer", diff --git a/translations/es.json b/translations/es.json index 10e1c8cb55..12e2cba9ce 100644 --- a/translations/es.json +++ b/translations/es.json @@ -296,6 +296,7 @@ "editor.record.undo.tooltip.disabled": "", "editor.record.undo.tooltip.enabled": "", "editor.record.upToDate": "", + "editor.sidebar.logout": "", "editor.sidebar.menu.editor": "", "editor.temporary.disabled": "", "externalviewer.dataset.unnamed": "", diff --git a/translations/fr.json b/translations/fr.json index a12538009c..ba4da4eef8 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -296,6 +296,7 @@ "editor.record.undo.tooltip.disabled": "Il n'y a pas de modifications en cours sur cette fiche", "editor.record.undo.tooltip.enabled": "Cliquez sur ce bouton pour annuler les modifications apportées à cette fiche", "editor.record.upToDate": "", + "editor.sidebar.logout": "Se déconnecter", "editor.sidebar.menu.editor": "", "editor.temporary.disabled": "Pas encore implémenté", "externalviewer.dataset.unnamed": "Couche du datahub", diff --git a/translations/it.json b/translations/it.json index ed95d6c683..272d8d2da0 100644 --- a/translations/it.json +++ b/translations/it.json @@ -296,6 +296,7 @@ "editor.record.undo.tooltip.disabled": "", "editor.record.undo.tooltip.enabled": "", "editor.record.upToDate": "", + "editor.sidebar.logout": "", "editor.sidebar.menu.editor": "", "editor.temporary.disabled": "", "externalviewer.dataset.unnamed": "Layer del datahub", diff --git a/translations/nl.json b/translations/nl.json index 1c50db16cd..fc38f38858 100644 --- a/translations/nl.json +++ b/translations/nl.json @@ -296,6 +296,7 @@ "editor.record.undo.tooltip.disabled": "", "editor.record.undo.tooltip.enabled": "", "editor.record.upToDate": "", + "editor.sidebar.logout": "", "editor.sidebar.menu.editor": "", "editor.temporary.disabled": "", "externalviewer.dataset.unnamed": "", diff --git a/translations/pt.json b/translations/pt.json index 3d48db46d9..4a412c2691 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -296,6 +296,7 @@ "editor.record.undo.tooltip.disabled": "", "editor.record.undo.tooltip.enabled": "", "editor.record.upToDate": "", + "editor.sidebar.logout": "", "editor.sidebar.menu.editor": "", "editor.temporary.disabled": "", "externalviewer.dataset.unnamed": "", diff --git a/translations/sk.json b/translations/sk.json index cb11870799..bef5dc3a42 100644 --- a/translations/sk.json +++ b/translations/sk.json @@ -296,6 +296,7 @@ "editor.record.undo.tooltip.disabled": "", "editor.record.undo.tooltip.enabled": "", "editor.record.upToDate": "", + "editor.sidebar.logout": "", "editor.sidebar.menu.editor": "", "editor.temporary.disabled": "", "externalviewer.dataset.unnamed": "", From ab0d566677940d2a0acbb90c5c9853fade1c100a Mon Sep 17 00:00:00 2001 From: cmoinier Date: Thu, 14 Nov 2024 16:33:00 +0100 Subject: [PATCH 005/168] fix: add logout url in ut fixture --- libs/util/app-config/src/lib/app-config.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/util/app-config/src/lib/app-config.spec.ts b/libs/util/app-config/src/lib/app-config.spec.ts index e590d8a9ad..c943624127 100644 --- a/libs/util/app-config/src/lib/app-config.spec.ts +++ b/libs/util/app-config/src/lib/app-config.spec.ts @@ -133,6 +133,7 @@ describe('app config utils', () => { PROXY_PATH: '/proxy/?url=', METADATA_LANGUAGE: 'fre', LOGIN_URL: '/cas/login?service=', + LOGOUT_URL: '/geonetwork/signout?redirectUrl=', WEB_COMPONENT_EMBEDDER_URL: '/datahub/wc-embedder.html', }) }) From 07f9e57d1913d1a5baebc33de87e34bdf853b526 Mon Sep 17 00:00:00 2001 From: cmoinier Date: Fri, 15 Nov 2024 08:16:22 +0100 Subject: [PATCH 006/168] feat: shorten logout urls --- conf/default.toml | 2 +- libs/util/app-config/src/lib/app-config.spec.ts | 2 +- libs/util/app-config/src/lib/fixtures.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/default.toml b/conf/default.toml index cdd3ade555..bae70b32dc 100644 --- a/conf/default.toml +++ b/conf/default.toml @@ -23,7 +23,7 @@ proxy_path = "" # - ${lang2}, ${lang3}: indicates if and where the current language should be part of the login URL in language 2 or 3 letter code # Example to use the georchestra login page: # login_url = "/cas/login?service=${current_url}" -# logout_url = "/geonetwork/signout?redirectUrl=\${current_url}" +# logout_url = "/geonetwork/signout" # This optional URL should point to the static html page wc-embedder.html which allows to display a web component (like chart and table) via a permalink. # URLs can be indicated from the root of the same server starting with a "/" or as an external URL. Be conscious of potential CORS issues when using an external URL. # The default location in the dockerized datahub app for example is "/datahub/wc-embedder.html". diff --git a/libs/util/app-config/src/lib/app-config.spec.ts b/libs/util/app-config/src/lib/app-config.spec.ts index c943624127..53b05d6bfa 100644 --- a/libs/util/app-config/src/lib/app-config.spec.ts +++ b/libs/util/app-config/src/lib/app-config.spec.ts @@ -133,7 +133,7 @@ describe('app config utils', () => { PROXY_PATH: '/proxy/?url=', METADATA_LANGUAGE: 'fre', LOGIN_URL: '/cas/login?service=', - LOGOUT_URL: '/geonetwork/signout?redirectUrl=', + LOGOUT_URL: '/geonetwork/signout', WEB_COMPONENT_EMBEDDER_URL: '/datahub/wc-embedder.html', }) }) diff --git a/libs/util/app-config/src/lib/fixtures.ts b/libs/util/app-config/src/lib/fixtures.ts index 731ce788e3..3126cb0492 100644 --- a/libs/util/app-config/src/lib/fixtures.ts +++ b/libs/util/app-config/src/lib/fixtures.ts @@ -6,7 +6,7 @@ geonetwork4_api_url = "/geonetwork/srv/api" proxy_path = "/proxy/?url=" metadata_language = "fre" login_url = "/cas/login?service=" -logout_url = "/geonetwork/signout?redirectUrl=" +logout_url = "/geonetwork/signout" web_component_embedder_url = "/datahub/wc-embedder.html" [map] From 30a0bd9303592faf6016f291b39d70d9677e18a1 Mon Sep 17 00:00:00 2001 From: ronitjadhav Date: Mon, 18 Nov 2024 14:21:48 +0100 Subject: [PATCH 007/168] Left align the Updated On column text --- .../search/src/lib/results-table/results-table.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ui/search/src/lib/results-table/results-table.component.html b/libs/ui/search/src/lib/results-table/results-table.component.html index 595b2ac468..aaebff9110 100644 --- a/libs/ui/search/src/lib/results-table/results-table.component.html +++ b/libs/ui/search/src/lib/results-table/results-table.component.html @@ -128,7 +128,7 @@ record.metadata.updatedOn -
+
{{ isUnsavedDraft(item) ? '-' : dateToString(item.recordUpdated) }}
From ca25e5870b9383c656503b2a503cfdae7f964b3a Mon Sep 17 00:00:00 2001 From: cmoinier Date: Mon, 18 Nov 2024 14:44:35 +0100 Subject: [PATCH 008/168] fix: use actual host instead --- .../src/app/dashboard/sidebar/sidebar.component.spec.ts | 8 ++------ .../src/app/dashboard/sidebar/sidebar.component.ts | 3 ++- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts index 2bda7b2737..15419cda92 100644 --- a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts +++ b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts @@ -53,18 +53,14 @@ describe('SidebarComponent', () => { ok: true, } as Response) - delete window.location - Object.defineProperty(window, 'location', { - value: { href: 'http://app-url.com' }, - writable: true, - }) + const originalUrl = window.location.href await component.logOut() expect(window.fetch).toHaveBeenCalledWith(service.logoutUrl, { method: 'GET', }) - expect(window.location.href).toBe('http://localhost:4200') + expect(window.location.href).toBe(originalUrl) }) }) }) diff --git a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts index 8c662165b2..53fc909f64 100644 --- a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts +++ b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts @@ -47,12 +47,13 @@ export class SidebarComponent implements OnInit { } logOut() { + const current_url = window.location.toString() fetch(this.authService.logoutUrl, { method: 'GET', }) .then((response) => { if (response.ok) { - window.location.href = 'http://localhost:4200' + window.location.href = current_url } else { console.error('Logout failed') } From 69c6f3dfcb1b785acaff8827a63134fcb61ba87b Mon Sep 17 00:00:00 2001 From: cmoinier Date: Mon, 18 Nov 2024 14:45:27 +0100 Subject: [PATCH 009/168] fix: change token name --- libs/api/repository/src/lib/gn4/auth/auth.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/api/repository/src/lib/gn4/auth/auth.service.ts b/libs/api/repository/src/lib/gn4/auth/auth.service.ts index e564950a44..667e817aa3 100644 --- a/libs/api/repository/src/lib/gn4/auth/auth.service.ts +++ b/libs/api/repository/src/lib/gn4/auth/auth.service.ts @@ -6,7 +6,7 @@ export const DEFAULT_GN4_LOGIN_URL = `/geonetwork/srv/\${lang3}/catalog.signin?r export const LOGIN_URL = new InjectionToken('loginUrl') export const DEFAULT_GN4_LOGOUT_URL = `/geonetwork/signout` -export const LOGOUT_URL = new InjectionToken('loginUrl') +export const LOGOUT_URL = new InjectionToken('logoutUrl') @Injectable({ providedIn: 'root', From 9aae01902b36388f7b456a51af4db22a7c077490 Mon Sep 17 00:00:00 2001 From: cmoinier Date: Mon, 18 Nov 2024 14:45:47 +0100 Subject: [PATCH 010/168] fix: add avatar-based logout test --- apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts b/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts index 91b7df4e7d..47132f26e7 100644 --- a/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts +++ b/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts @@ -359,8 +359,10 @@ describe('Logging in and out', () => { cy.visit('/catalog/search') }) it('logs out the user', () => { + cy.get('gn-ui-avatar').should('be.visible') cy.get('md-editor-sidebar').find('gn-ui-button').eq(1).click() cy.url().should('include', '/catalog.signin?redirect=') + cy.get('gn-ui-avatar').should('not.exist') }) }) }) From 562d37e0795e4bd47894f889899a2869de2156ad Mon Sep 17 00:00:00 2001 From: cmoinier Date: Mon, 18 Nov 2024 14:47:46 +0100 Subject: [PATCH 011/168] fix: add translation for alt --- .../src/app/dashboard/sidebar/sidebar.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html index 8491a2091f..fc99769cb1 100644 --- a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html +++ b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html @@ -35,7 +35,7 @@ > Log out From 2584e0e29e7fe63404fbe1c7630d8fdc4cf10c70 Mon Sep 17 00:00:00 2001 From: cmoinier Date: Thu, 14 Nov 2024 17:50:55 +0100 Subject: [PATCH 012/168] feat: transform input into resizable textarea --- .../form-field/form-field.component.html | 18 +++++++++++------- .../form-field/form-field.component.ts | 9 ++++++++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html b/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html index 60344f8c67..ebc1167dc3 100644 --- a/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html +++ b/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html @@ -24,14 +24,18 @@
- -
+ class="grow font-title text-3xl font-normal overflow-hidden" + (click)="isEditing = true" + (change)="valueChange.emit($event.target.value)" + >{{ valueAsString }} +
Date: Thu, 14 Nov 2024 17:51:15 +0100 Subject: [PATCH 013/168] feat: adapt e2e test --- apps/metadata-editor-e2e/src/e2e/edit.cy.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/metadata-editor-e2e/src/e2e/edit.cy.ts b/apps/metadata-editor-e2e/src/e2e/edit.cy.ts index 7d37930ba8..0de2de39b5 100644 --- a/apps/metadata-editor-e2e/src/e2e/edit.cy.ts +++ b/apps/metadata-editor-e2e/src/e2e/edit.cy.ts @@ -123,7 +123,7 @@ describe('editor form', () => { it('shows the title', () => { cy.get('gn-ui-form-field') .first() - .find('input') + .find('textarea') .invoke('val') .should( 'eq', @@ -132,16 +132,16 @@ describe('editor form', () => { }) it('edits and saves the title', () => { cy.editor_wrapPreviousDraft() - cy.get('gn-ui-form-field').first().find('input').clear() + cy.get('gn-ui-form-field').first().find('textarea').clear() cy.get('gn-ui-form-field') .first() - .find('input') + .find('textarea') .type('Test record modified') cy.editor_publishAndReload() cy.get('@saveStatus').should('eq', 'record_up_to_date') cy.get('gn-ui-form-field') .first() - .find('input') + .find('textarea') .invoke('val') .should('eq', 'Test record modified') }) From 02b190404a52cca220af3f38ee70020c1a711517 Mon Sep 17 00:00:00 2001 From: cmoinier Date: Fri, 15 Nov 2024 07:50:49 +0100 Subject: [PATCH 014/168] fix: textarea need focus in e2e --- apps/metadata-editor-e2e/src/e2e/edit.cy.ts | 9 ++++----- apps/metadata-editor-e2e/src/e2e/record-actions.cy.ts | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/apps/metadata-editor-e2e/src/e2e/edit.cy.ts b/apps/metadata-editor-e2e/src/e2e/edit.cy.ts index 0de2de39b5..de9e567bed 100644 --- a/apps/metadata-editor-e2e/src/e2e/edit.cy.ts +++ b/apps/metadata-editor-e2e/src/e2e/edit.cy.ts @@ -132,11 +132,10 @@ describe('editor form', () => { }) it('edits and saves the title', () => { cy.editor_wrapPreviousDraft() - cy.get('gn-ui-form-field').first().find('textarea').clear() - cy.get('gn-ui-form-field') - .first() - .find('textarea') - .type('Test record modified') + cy.get('gn-ui-form-field').first().find('textarea').focus() + cy.focused().clear() + cy.get('gn-ui-form-field').first().find('textarea').focus() + cy.focused().type('Test record modified') cy.editor_publishAndReload() cy.get('@saveStatus').should('eq', 'record_up_to_date') cy.get('gn-ui-form-field') diff --git a/apps/metadata-editor-e2e/src/e2e/record-actions.cy.ts b/apps/metadata-editor-e2e/src/e2e/record-actions.cy.ts index 41f73ae209..6bbe256f0b 100644 --- a/apps/metadata-editor-e2e/src/e2e/record-actions.cy.ts +++ b/apps/metadata-editor-e2e/src/e2e/record-actions.cy.ts @@ -189,7 +189,7 @@ describe('record-actions', () => { cy.get('gn-ui-form-field') .first() - .find('input') + .find('textarea') .invoke('val') .should('eq', 'Accroches vélos MEL (Copy)') @@ -254,7 +254,7 @@ describe('record-actions', () => { cy.get('gn-ui-record-form') .find('gn-ui-form-field') .eq(0) - .find('input') + .find('textarea') .invoke('val') .should('contain', 'Copy') }) From d13ca991b5883748d17698e526ac77ef8d319e4b Mon Sep 17 00:00:00 2001 From: cmoinier Date: Mon, 18 Nov 2024 16:38:15 +0100 Subject: [PATCH 015/168] fix: make pen icon work again --- .../record-form/form-field/form-field.component.html | 2 +- .../components/record-form/form-field/form-field.component.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html b/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html index ebc1167dc3..6afa94e197 100644 --- a/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html +++ b/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html @@ -25,13 +25,13 @@
diff --git a/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts b/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts index 465606ed9d..56a9aa619c 100644 --- a/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts +++ b/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts @@ -101,14 +101,13 @@ export class FormFieldComponent { @ViewChild('titleInput') titleInput: ElementRef isOpenData = false isHidden = false - isEditing = false toggleIsOpenData(event: boolean) { this.isOpenData = event } focusTitleInput() { - this.isEditing = !this.isEditing + this.titleInput.nativeElement.focus() } get withoutWrapper() { From b073f6a82eb93ac36b6071fd051711fe7b0a943c Mon Sep 17 00:00:00 2001 From: cmoinier Date: Mon, 18 Nov 2024 16:47:44 +0100 Subject: [PATCH 016/168] fix: use long title for e2e test --- apps/metadata-editor-e2e/src/e2e/edit.cy.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/metadata-editor-e2e/src/e2e/edit.cy.ts b/apps/metadata-editor-e2e/src/e2e/edit.cy.ts index de9e567bed..035cc85583 100644 --- a/apps/metadata-editor-e2e/src/e2e/edit.cy.ts +++ b/apps/metadata-editor-e2e/src/e2e/edit.cy.ts @@ -130,6 +130,16 @@ describe('editor form', () => { "Stations d'épuration selon la directive Eaux Résiduelles Urbaines (91/271/CEE) en Wallonie (Copy)" ) }) + it('shows very long titles entirely', () => { + cy.editor_wrapPreviousDraft() + cy.get('gn-ui-form-field').first().find('textarea').focus() + cy.focused().clear() + cy.get('gn-ui-form-field').first().find('textarea').focus() + cy.focused().type( + 'Metadata for E2E testing purpose. (this title is very long and should take several lines, so we can test the behavior of the title field when it is very long. just keep going until it hits 4 lines, now it should be long enough)' + ) + cy.get('gn-ui-form-field').first().invoke('height').should('eq', 156) + }) it('edits and saves the title', () => { cy.editor_wrapPreviousDraft() cy.get('gn-ui-form-field').first().find('textarea').focus() From 95666fe95099aedb0446631d71197d6a207a153a Mon Sep 17 00:00:00 2001 From: cmoinier Date: Mon, 18 Nov 2024 17:05:37 +0100 Subject: [PATCH 017/168] fix: remove unused var libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts --- .../components/record-form/form-field/form-field.component.html | 1 - .../components/record-form/form-field/form-field.component.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html b/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html index 6afa94e197..7612a1c2aa 100644 --- a/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html +++ b/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html @@ -26,7 +26,6 @@