From 85cca02be0160452c38dd25853b38f5733fe50cd Mon Sep 17 00:00:00 2001 From: attilatilman <attila.tilman@gmail.com> Date: Tue, 4 Feb 2025 15:25:29 +0100 Subject: [PATCH 1/3] 3503415: Clicking on page title navigates to edit page. --- ui/src/components/pageInfo/PageInfo.tsx | 8 +++++++- ui/tests/e2e/navigation.cy.js | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ui/src/components/pageInfo/PageInfo.tsx b/ui/src/components/pageInfo/PageInfo.tsx index 3dc77a1be4..296c283d3e 100644 --- a/ui/src/components/pageInfo/PageInfo.tsx +++ b/ui/src/components/pageInfo/PageInfo.tsx @@ -25,6 +25,7 @@ import { useGetContentListQuery } from '@/services/contentList'; import { useCreateContentMutation } from '@/services/contentCreate'; import { useNavigationUtils } from '@/hooks/useNavigationUtils'; import { useErrorBoundary } from 'react-error-boundary'; +import type { ContentStub } from '@/types/Content'; interface PageType { [key: string]: ReactElement; @@ -73,6 +74,11 @@ const PageInfo = () => { }); } + // TODO: Update once XB usable on multiple entity types https://www.drupal.org/project/experience_builder/issues/3498525. + function handleOnSelect(item: ContentStub) { + setEditorEntity('xb_page', String(item.id)); + } + useEffect(() => { if (isCreateContentSuccess) { setEditorEntity( @@ -118,7 +124,7 @@ const PageInfo = () => { items={pageItems || []} onNewPage={handleNewPage} onSearch={handleNonWorkingBtn} - onSelect={handleNonWorkingBtn} + onSelect={handleOnSelect} onRename={handleNonWorkingBtn} onDuplicate={handleNonWorkingBtn} onSetHomepage={handleNonWorkingBtn} diff --git a/ui/tests/e2e/navigation.cy.js b/ui/tests/e2e/navigation.cy.js index 9b43092f27..5e7e4da428 100644 --- a/ui/tests/e2e/navigation.cy.js +++ b/ui/tests/e2e/navigation.cy.js @@ -53,6 +53,17 @@ describe('Navigation functionality', () => { cy.url().should('contain', '/xb/xb_page/3'); }); + it('Clicking page title navigates to edit page', () => { + cy.loadURLandWaitForXBLoaded({ url: 'xb/xb_page/1' }); + + cy.findByTestId(navigationButtonTestId).click(); + cy.contains('div', '/test-page').click(); + cy.url().should('contain', '/xb/xb_page/2'); + cy.findByTestId(navigationButtonTestId).click(); + cy.contains('div', '/homepage').click(); + cy.url().should('contain', '/xb/xb_page/1'); + }); + it('Clicking the back button navigates to last visited page', () => { const BASE_URL = `${Cypress.config().baseUrl}/`; const CONFIG_PAGE_URL = `${BASE_URL}admin/config`; -- GitLab From 3a76f9780ce7f5bfdf17d1863ba8aff76ad676fa Mon Sep 17 00:00:00 2001 From: attilatilman <attila.tilman@gmail.com> Date: Wed, 5 Feb 2025 16:01:43 +0100 Subject: [PATCH 2/3] 3503415: Minor refactor. --- ui/src/hooks/useNavigationUtils.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/src/hooks/useNavigationUtils.ts b/ui/src/hooks/useNavigationUtils.ts index d42cebd106..f74ae666fb 100644 --- a/ui/src/hooks/useNavigationUtils.ts +++ b/ui/src/hooks/useNavigationUtils.ts @@ -1,3 +1,5 @@ +import { useAppSelector } from '@/app/hooks'; +import { selectBaseUrl } from '@/features/configuration/configurationSlice'; import { useNavigate, useParams } from 'react-router-dom'; import { DEFAULT_REGION } from '@/features/ui/uiSlice'; import { useCallback } from 'react'; @@ -5,6 +7,7 @@ import { useCallback } from 'react'; export function useNavigationUtils() { const { regionId } = useParams(); const navigate = useNavigate(); + const baseUrl = useAppSelector(selectBaseUrl); const setSelectedComponent = useCallback( (componentUuid: string) => { @@ -49,9 +52,9 @@ export function useNavigationUtils() { // @todo revisit approach (like using routing) in https://www.drupal.org/i/3502887 const setEditorEntity = useCallback( (entityType: string, entityId: string) => { - window.location.href = `/xb/${entityType}/${entityId}`; + window.location.href = `${baseUrl}/xb/${entityType}/${entityId}`; }, - [], + [baseUrl], ); return { -- GitLab From 48b1433b66bc7460ab48d5846e7618a2f82b8735 Mon Sep 17 00:00:00 2001 From: attilatilman <attila.tilman@gmail.com> Date: Wed, 5 Feb 2025 16:21:30 +0100 Subject: [PATCH 3/3] 3503415: Update todo. --- ui/src/components/pageInfo/PageInfo.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/components/pageInfo/PageInfo.tsx b/ui/src/components/pageInfo/PageInfo.tsx index 296c283d3e..a8522cb118 100644 --- a/ui/src/components/pageInfo/PageInfo.tsx +++ b/ui/src/components/pageInfo/PageInfo.tsx @@ -74,7 +74,7 @@ const PageInfo = () => { }); } - // TODO: Update once XB usable on multiple entity types https://www.drupal.org/project/experience_builder/issues/3498525. + // @todo https://www.drupal.org/i/3498525 should generalize this to all eligible content entity types. function handleOnSelect(item: ContentStub) { setEditorEntity('xb_page', String(item.id)); } -- GitLab