diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/models.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/models.ts index fea55a82c03..ae21936427d 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/models.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/models.ts @@ -91,6 +91,7 @@ export interface ToolbarProps { bookmarksUrl: string; copyUrl: string; apiUrl: string; + isDefaultVariant: boolean; showInfoDisplay: boolean; currentLanguage: DotLanguage; runningExperiment?: DotExperiment; diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withEditorToolbar.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withEditorToolbar.ts index 61594b55cef..5abd50896f2 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withEditorToolbar.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withEditorToolbar.ts @@ -67,9 +67,10 @@ export function withEditorToolbar() { inode: pageAPIResponse?.page.inode, loading: store.status() === UVE_STATUS.LOADING }; + const isDefaultVariant = getIsDefaultVariant(pageAPIResponse?.viewAs.variantId); const shouldShowInfoDisplay = - !getIsDefaultVariant(pageAPIResponse?.viewAs.variantId) || + !isDefaultVariant || !store.canEditPage() || isPageLocked || !!store.device() || @@ -94,6 +95,7 @@ export function withEditorToolbar() { runningExperiment: isExperimentRunning ? experiment : null, workflowActionsInode: store.canEditPage() ? pageAPIResponse?.page.inode : null, unlockButton: shouldShowUnlock ? unlockButton : null, + isDefaultVariant, showInfoDisplay: shouldShowInfoDisplay, deviceSelector: { apiLink: `${clientHost}${pageAPI}`, diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/withEditor.spec.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/withEditor.spec.ts index b98da56a966..42b223695ad 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/withEditor.spec.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/withEditor.spec.ts @@ -130,6 +130,7 @@ describe('withEditor', () => { value: MOCK_RESPONSE_HEADLESS.viewAs.persona ?? DEFAULT_PERSONA }, runningExperiment: null, + isDefaultVariant: true, showInfoDisplay: false, unlockButton: null, urlContentMap: null, @@ -331,6 +332,35 @@ describe('withEditor', () => { expect(store.$toolbarProps().showInfoDisplay).toBe(false); }); }); + + describe('isDefaultVariant', () => { + it('should have isDefaultVariant as true if the page variant is default', () => { + patchState(store, { + pageAPIResponse: { + ...MOCK_RESPONSE_HEADLESS, + viewAs: { + ...MOCK_RESPONSE_HEADLESS.viewAs, + variantId: DEFAULT_VARIANT_ID + } + } + }); + + expect(store.$toolbarProps().isDefaultVariant).toBe(true); + }); + it('should have isDefaultVariant as false if the page is a variant different from default', () => { + patchState(store, { + pageAPIResponse: { + ...MOCK_RESPONSE_HEADLESS, + viewAs: { + ...MOCK_RESPONSE_HEADLESS.viewAs, + variantId: 'test' + } + } + }); + + expect(store.$toolbarProps().isDefaultVariant).toBe(false); + }); + }); }); describe('$infoDisplayOptions', () => {