Skip to content

Commit

Permalink
fix(UVE): Page content is deleted when changing language (#29689)
Browse files Browse the repository at this point in the history
### Proposed Changes
* Page content is deleted when changing language

### Checklist
- [x] Tests

### Videos

#### Before


https://github.com/user-attachments/assets/f64e3a14-a9fc-4f90-8911-bb0cce135a42

#### After



https://github.com/user-attachments/assets/95b2b168-5a48-4ab2-91a3-1d32c634b7d8
  • Loading branch information
rjvelazco authored Aug 21, 2024
1 parent 42f5c51 commit 2a9da94
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,40 +245,82 @@ describe('DotEmaDialogStoreService', () => {
});
});

it('should update the state to show dialog for a translation', () => {
spectator.service.translatePage({
page: {
inode: '123',
liveInode: '1234',
stInode: '12345',
live: true,
title: 'test'
} as DotPage,
newLanguage: 2
});
describe('Dialog for translation', () => {
it('should update the state to show dialog for a translation', () => {
spectator.service.translatePage({
page: {
inode: '123',
liveInode: '1234',
stInode: '12345',
live: true,
title: 'test'
} as DotPage,
newLanguage: 2
});

const queryParams = new URLSearchParams({
p_p_id: 'content',
p_p_action: '1',
p_p_state: 'maximized',
angularCurrentPortlet: 'edit-page',
_content_sibbling: '1234',
_content_cmd: 'edit',
p_p_mode: 'view',
_content_sibblingStructure: '1234',
_content_struts_action: '/ext/contentlet/edit_contentlet',
inode: '',
lang: '2',
populateaccept: 'true',
reuseLastLang: 'true'
const queryParams = new URLSearchParams({
p_p_id: 'content',
p_p_action: '1',
p_p_state: 'maximized',
angularCurrentPortlet: 'edit-page',
_content_sibbling: '123',
_content_cmd: 'edit',
p_p_mode: 'view',
_content_sibblingStructure: '123',
_content_struts_action: '/ext/contentlet/edit_contentlet',
inode: '',
lang: '2',
populateaccept: 'true',
reuseLastLang: 'true'
});

spectator.service.dialogState$.subscribe((state) => {
expect(state).toEqual({
url: LAYOUT_URL + '?' + queryParams.toString(),
status: DialogStatus.LOADING,
header: 'test',
type: 'content'
});
});
});

spectator.service.dialogState$.subscribe((state) => {
expect(state).toEqual({
url: LAYOUT_URL + '?' + queryParams.toString(),
status: DialogStatus.LOADING,
header: 'test',
type: 'content'
it('should update the state to show dialog for a translation with working inode', () => {
spectator.service.translatePage({
page: {
inode: '123',
liveInode: '1234',
stInode: '12345',
live: true,
title: 'test',
working: true,
workingInode: '56789'
} as DotPage,
newLanguage: 2
});

const queryParams = new URLSearchParams({
p_p_id: 'content',
p_p_action: '1',
p_p_state: 'maximized',
angularCurrentPortlet: 'edit-page',
_content_sibbling: '56789',
_content_cmd: 'edit',
p_p_mode: 'view',
_content_sibblingStructure: '56789',
_content_struts_action: '/ext/contentlet/edit_contentlet',
inode: '',
lang: '2',
populateaccept: 'true',
reuseLastLang: 'true'
});

spectator.service.dialogState$.subscribe((state) => {
expect(state).toEqual({
url: LAYOUT_URL + '?' + queryParams.toString(),
status: DialogStatus.LOADING,
header: 'test',
type: 'content'
});
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,20 +309,17 @@ export class DotEmaDialogStore extends ComponentStore<EditEmaDialogState> {
}

private createTranslatePageUrl(page: DotPage, newLanguage: number | string) {
const isLive = page.live;
const pageLiveInode = page.liveInode;
const iNode = page.inode;
const stInode = page.stInode;

const { working, workingInode, inode } = page;
const pageInode = working ? workingInode : inode;
const queryParams = new URLSearchParams({
p_p_id: 'content',
p_p_action: '1',
p_p_state: 'maximized',
angularCurrentPortlet: 'edit-page',
_content_sibbling: isLive ? pageLiveInode : iNode,
_content_sibbling: pageInode,
_content_cmd: 'edit',
p_p_mode: 'view',
_content_sibblingStructure: isLive ? pageLiveInode : stInode,
_content_sibblingStructure: pageInode,
_content_struts_action: '/ext/contentlet/edit_contentlet',
inode: '',
lang: newLanguage.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ export interface DotPage {
live: boolean;
liveInode?: string;
stInode?: string;
working?: boolean;
workingInode?: string;
}

export interface DotDeviceWithIcon extends DotDevice {
Expand Down

0 comments on commit 2a9da94

Please sign in to comment.