@designcrowd/library.brand-page 6.2.10 → 6.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/src/{CreatedOnBrandCrowd-de-de-CTEj6D-p.js → CreatedOnBrandCrowd-de-de-DDcraD5S.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-en-us-ByFNuMoA.js → CreatedOnBrandCrowd-en-us-DtOeaisf.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-es-es-lA_3mWIj.js → CreatedOnBrandCrowd-es-es-BZpmJPew.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-fr-CS_YkUz3.js → CreatedOnBrandCrowd-fr-ca-CqRwC4e7.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-ca-CS_YkUz3.js → CreatedOnBrandCrowd-fr-fr-CqRwC4e7.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-pt-BoduQ7zJ.js → CreatedOnBrandCrowd-pt-br-DId9Dfjh.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-br-BoduQ7zJ.js → CreatedOnBrandCrowd-pt-pt-DId9Dfjh.js} +1 -1
- package/lib/src/{CreatedOnDcom-de-de-Co1OO4_u.js → CreatedOnDcom-de-de-BTDfmOcm.js} +1 -1
- package/lib/src/{CreatedOnDcom-en-us-DqFyqxOJ.js → CreatedOnDcom-en-us-CeAu9Ayx.js} +1 -1
- package/lib/src/{CreatedOnDcom-es-es-DhQWyb7C.js → CreatedOnDcom-es-es-WCv0K41H.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-ca-DIxstLTf.js → CreatedOnDcom-fr-ca-BlfevQDY.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-fr-B-z8V1cH.js → CreatedOnDcom-fr-fr-Cvt7MHPZ.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-br-B7AMR1sc.js → CreatedOnDcom-pt-br-DipZuylv.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-pt-Cdci4yr3.js → CreatedOnDcom-pt-pt-BCw4lcKN.js} +1 -1
- package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.d.ts +1 -0
- package/lib/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.d.ts +1 -0
- package/lib/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.js +3 -1
- package/lib/src/index.mjs +1 -1
- package/lib/src/{lib-Y-hakSU_.js → lib-1AqtEmvQ.js} +721 -707
- package/lib/src/shared/content-settings/components/content-settings/ContentSettings.mixin.d.ts +1 -0
- package/lib/src/shared/content-settings/components/content-settings/ReplaceImageSettingsForContent.mixin.d.ts +1 -0
- package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItemField.mixin.d.ts +1 -0
- package/lib/src/shared/content-settings/components/payment-config-field/PaymentConfigField.mixin.d.ts +1 -0
- package/lib/src/shared/logo-settings/components/LogoSettings.mixin.d.ts +1 -0
- package/lib/src/shared/page-settings/components/new-page-modal/NewPageModal.mixin.d.ts +1 -0
- package/lib/src/shared/page-settings/components/page-settings/PageSettings.mixin.d.ts +1 -0
- package/lib/src/shared/page-settings/components/page-settings/PageSettings.mixin.js +1 -0
- package/lib/src/shared/page-settings/components/page-settings-section-styles/PageSettingsSectionStyles.mixin.d.ts +1 -0
- package/lib/src/shared/page-settings/store/page-settings-store.d.ts +1 -0
- package/lib/src/shared/page-settings/store/page-settings-store.js +28 -1
- package/package.json +1 -1
- package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.test.ts +23 -0
- package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.ts +3 -1
- package/src/shared/page-settings/components/page-settings/PageSettings.mixin.test.ts +26 -0
- package/src/shared/page-settings/components/page-settings/PageSettings.mixin.ts +1 -0
- package/src/shared/page-settings/store/page-settings-store.test.ts +142 -1
- package/src/shared/page-settings/store/page-settings-store.ts +41 -0
package/lib/src/shared/content-settings/components/content-settings/ContentSettings.mixin.d.ts
CHANGED
|
@@ -552,6 +552,7 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
|
552
552
|
logoImageWidth: string | undefined;
|
|
553
553
|
}): void;
|
|
554
554
|
updatePaymentConfigCurrency(updatedPaymentConfig: import("@brand-page").BrandPagePaymentConfig, newCurrency: import("@brand-page").BrandPagePaymentConfigCurrency): void;
|
|
555
|
+
resetStalePageLinks(): void;
|
|
555
556
|
setPageTitle({ pageTitle, pageId, }: {
|
|
556
557
|
pageTitle: string;
|
|
557
558
|
pageId: string;
|
|
@@ -559,6 +559,7 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
|
559
559
|
logoImageWidth: string | undefined;
|
|
560
560
|
}): void;
|
|
561
561
|
updatePaymentConfigCurrency(updatedPaymentConfig: import("@brand-page").BrandPagePaymentConfig, newCurrency: import("@brand-page").BrandPagePaymentConfigCurrency): void;
|
|
562
|
+
resetStalePageLinks(): void;
|
|
562
563
|
setPageTitle({ pageTitle, pageId, }: {
|
|
563
564
|
pageTitle: string;
|
|
564
565
|
pageId: string;
|
|
@@ -781,6 +781,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
781
781
|
logoImageWidth: string | undefined;
|
|
782
782
|
}): void;
|
|
783
783
|
updatePaymentConfigCurrency(updatedPaymentConfig: import("@brand-page").BrandPagePaymentConfig, newCurrency: import("@brand-page").BrandPagePaymentConfigCurrency): void;
|
|
784
|
+
resetStalePageLinks(): void;
|
|
784
785
|
setPageTitle({ pageTitle, pageId, }: {
|
|
785
786
|
pageTitle: string;
|
|
786
787
|
pageId: string;
|
|
@@ -563,6 +563,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
563
563
|
logoImageWidth: string | undefined;
|
|
564
564
|
}): void;
|
|
565
565
|
updatePaymentConfigCurrency(updatedPaymentConfig: BrandPagePaymentConfig, newCurrency: BrandPagePaymentConfigCurrency): void;
|
|
566
|
+
resetStalePageLinks(): void;
|
|
566
567
|
setPageTitle({ pageTitle, pageId, }: {
|
|
567
568
|
pageTitle: string;
|
|
568
569
|
pageId: string;
|
|
@@ -730,6 +730,7 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
|
730
730
|
logoImageWidth: string | undefined;
|
|
731
731
|
}): void;
|
|
732
732
|
updatePaymentConfigCurrency(updatedPaymentConfig: import("../../../brand-page").BrandPagePaymentConfig, newCurrency: import("../../../brand-page").BrandPagePaymentConfigCurrency): void;
|
|
733
|
+
resetStalePageLinks(): void;
|
|
733
734
|
setPageTitle({ pageTitle, pageId, }: {
|
|
734
735
|
pageTitle: string;
|
|
735
736
|
pageId: string;
|
|
@@ -60,6 +60,7 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
|
60
60
|
logoImageWidth: string | undefined;
|
|
61
61
|
}): void;
|
|
62
62
|
updatePaymentConfigCurrency(updatedPaymentConfig: import("../../../../brand-page").BrandPagePaymentConfig, newCurrency: import("../../../../brand-page").BrandPagePaymentConfigCurrency): void;
|
|
63
|
+
resetStalePageLinks(): void;
|
|
63
64
|
setPageTitle({ pageTitle, pageId, }: {
|
|
64
65
|
pageTitle: string;
|
|
65
66
|
pageId: string;
|
|
@@ -4195,6 +4195,7 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
|
4195
4195
|
logoImageWidth: string | undefined;
|
|
4196
4196
|
}): void;
|
|
4197
4197
|
updatePaymentConfigCurrency(updatedPaymentConfig: import("@brand-page").BrandPagePaymentConfig, newCurrency: import("@brand-page").BrandPagePaymentConfigCurrency): void;
|
|
4198
|
+
resetStalePageLinks(): void;
|
|
4198
4199
|
setPageTitle({ pageTitle, pageId, }: {
|
|
4199
4200
|
pageTitle: string;
|
|
4200
4201
|
pageId: string;
|
|
@@ -281,6 +281,7 @@ export default defineComponent({
|
|
|
281
281
|
this.pageNavigationStore.removeNavRoute(navRouteId);
|
|
282
282
|
}
|
|
283
283
|
this.updatePages(this.pageFields);
|
|
284
|
+
this.pageSettingsStore.resetStalePageLinks();
|
|
284
285
|
// The deleted page's sections may have held the only references to palette
|
|
285
286
|
// customs — reclaim them now.
|
|
286
287
|
this.brandPageMakerStore.pruneUnusedPaletteCustoms();
|
|
@@ -3473,6 +3473,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
3473
3473
|
logoImageWidth: string | undefined;
|
|
3474
3474
|
}): void;
|
|
3475
3475
|
updatePaymentConfigCurrency(updatedPaymentConfig: import("@brand-page").BrandPagePaymentConfig, newCurrency: import("@brand-page").BrandPagePaymentConfigCurrency): void;
|
|
3476
|
+
resetStalePageLinks(): void;
|
|
3476
3477
|
setPageTitle({ pageTitle, pageId, }: {
|
|
3477
3478
|
pageTitle: string;
|
|
3478
3479
|
pageId: string;
|
|
@@ -97,6 +97,7 @@ export declare const useUiPageSettingsStore: import("pinia").StoreDefinition<"ui
|
|
|
97
97
|
logoImageWidth: string | undefined;
|
|
98
98
|
}): void;
|
|
99
99
|
updatePaymentConfigCurrency(updatedPaymentConfig: BrandPagePaymentConfig, newCurrency: BrandPagePaymentConfigCurrency): void;
|
|
100
|
+
resetStalePageLinks(): void;
|
|
100
101
|
setPageTitle({ pageTitle, pageId, }: {
|
|
101
102
|
pageTitle: string;
|
|
102
103
|
pageId: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineStore } from 'pinia';
|
|
2
|
-
import { PageHeaderDesktop, PageHeaderMobile, PageFooterDesktop, PageFooterMobile, VIEWPORTS, getNavigationType, } from '@brand-page';
|
|
2
|
+
import { BUTTON_LINK_TYPE, PageHeaderDesktop, PageHeaderMobile, PageFooterDesktop, PageFooterMobile, VIEWPORTS, getNavigationType, } from '@brand-page';
|
|
3
3
|
import { v4 as uuid } from 'uuid';
|
|
4
4
|
import { PAGE_SECTIONS } from '../models';
|
|
5
5
|
import { toPageModels } from '../utils';
|
|
@@ -225,6 +225,33 @@ export const useUiPageSettingsStore = defineStore('uiPageSettings', {
|
|
|
225
225
|
Object.assign(shopConfigStore.paymentConfig, currencyUpdate);
|
|
226
226
|
}
|
|
227
227
|
},
|
|
228
|
+
resetStalePageLinks() {
|
|
229
|
+
const pageIds = new Set(this.pages.map(({ id }) => id));
|
|
230
|
+
const isSinglePage = this.pages.length === 1;
|
|
231
|
+
const reset = (link) => {
|
|
232
|
+
if (link.buttonLinkType !== BUTTON_LINK_TYPE.page ||
|
|
233
|
+
pageIds.has(link.buttonPageId ?? '')) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
// The Page link option is not offered once one page is left, so the link falls back
|
|
237
|
+
// to a URL link, keeping its stored address.
|
|
238
|
+
if (isSinglePage)
|
|
239
|
+
link.buttonLinkType = BUTTON_LINK_TYPE.url;
|
|
240
|
+
link.buttonPageId = '';
|
|
241
|
+
};
|
|
242
|
+
this.pages.forEach(({ contents }) => {
|
|
243
|
+
contents.forEach(({ settings: { content } }) => {
|
|
244
|
+
const holder = content;
|
|
245
|
+
reset(holder);
|
|
246
|
+
holder.items?.forEach(reset);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
[VIEWPORTS.desktop, VIEWPORTS.mobile].forEach((viewport) => {
|
|
250
|
+
const { headerButton } = this.sections[PAGE_SECTIONS.header][viewport];
|
|
251
|
+
if (headerButton)
|
|
252
|
+
reset(headerButton);
|
|
253
|
+
});
|
|
254
|
+
},
|
|
228
255
|
setPageTitle({ pageTitle, pageId, }) {
|
|
229
256
|
const currentPageId = pageId;
|
|
230
257
|
const pageNavigationStore = usePageNavigationStore();
|
package/package.json
CHANGED
|
@@ -1057,6 +1057,29 @@ describe('brand page maker store module', () => {
|
|
|
1057
1057
|
).toBe(true);
|
|
1058
1058
|
});
|
|
1059
1059
|
|
|
1060
|
+
test('initialiseStoresByBrandPageModelAsync clears a button link to a page the AI removed', async () => {
|
|
1061
|
+
const makerStore = useBrandPageMakerStore();
|
|
1062
|
+
|
|
1063
|
+
await makerStore.initialise(INITIALISE_PAYLOAD);
|
|
1064
|
+
|
|
1065
|
+
const model: typeof makerStore.brandPageData = JSON.parse(
|
|
1066
|
+
JSON.stringify(makerStore.brandPageData),
|
|
1067
|
+
);
|
|
1068
|
+
const [firstPage] = model.pages;
|
|
1069
|
+
|
|
1070
|
+
Object.assign(firstPage.contents[0], {
|
|
1071
|
+
buttonLinkType: 'page',
|
|
1072
|
+
buttonPageId: 'page-removed-by-ai',
|
|
1073
|
+
});
|
|
1074
|
+
model.pages = [firstPage, { ...firstPage, id: 'page-kept', contents: [] }];
|
|
1075
|
+
|
|
1076
|
+
await makerStore.initialiseStoresByBrandPageModelAsync(model);
|
|
1077
|
+
|
|
1078
|
+
expect(
|
|
1079
|
+
useUiPageSettingsStore().pages[0].contents[0].settings.content,
|
|
1080
|
+
).toMatchObject({ buttonLinkType: 'page', buttonPageId: '' });
|
|
1081
|
+
});
|
|
1082
|
+
|
|
1060
1083
|
test('applyHistorySnapshot restores styles.colors (undo of a palette edit is no longer a no-op)', async () => {
|
|
1061
1084
|
const makerStore = useBrandPageMakerStore();
|
|
1062
1085
|
const paletteStore = useUiColorPaletteStore();
|
|
@@ -1206,6 +1206,7 @@ export const useBrandPageMakerStore = defineStore('brandPageMaker', {
|
|
|
1206
1206
|
const backgroundSettingsStore = useUiBackgroundSettingsStore();
|
|
1207
1207
|
const styleSettingsStore = useUiStyleSettingsStore();
|
|
1208
1208
|
const navigationStyleSettingsStore = useUiNavigationStyleSettingsStore();
|
|
1209
|
+
const pageSettingsStore = useUiPageSettingsStore();
|
|
1209
1210
|
|
|
1210
1211
|
pageNavigationStore.setNav({ nav: brandPageModel.nav });
|
|
1211
1212
|
|
|
@@ -1222,6 +1223,8 @@ export const useBrandPageMakerStore = defineStore('brandPageMaker', {
|
|
|
1222
1223
|
},
|
|
1223
1224
|
},
|
|
1224
1225
|
});
|
|
1226
|
+
// An AI changeset can remove a page that buttons still link to.
|
|
1227
|
+
pageSettingsStore.resetStalePageLinks();
|
|
1225
1228
|
|
|
1226
1229
|
navigationStyleSettingsStore.setState({
|
|
1227
1230
|
newState: {
|
|
@@ -1268,7 +1271,6 @@ export const useBrandPageMakerStore = defineStore('brandPageMaker', {
|
|
|
1268
1271
|
});
|
|
1269
1272
|
}
|
|
1270
1273
|
|
|
1271
|
-
const pageSettingsStore = useUiPageSettingsStore();
|
|
1272
1274
|
const { externalEditor } = useExternalRichTextEditor();
|
|
1273
1275
|
|
|
1274
1276
|
transformToRTE(
|
|
@@ -69,6 +69,7 @@ describe('PageSettings.mixin onConfirmDeletePage GCs orphaned palette customs',
|
|
|
69
69
|
pages: pageFields.map((pf) => pf.page) as never[],
|
|
70
70
|
});
|
|
71
71
|
},
|
|
72
|
+
pageSettingsStore,
|
|
72
73
|
brandPageMakerStore: useBrandPageMakerStore(),
|
|
73
74
|
eventTracker: { sendWebsiteManageRemovePageEvent: vi.fn() },
|
|
74
75
|
deleteModalPageTitle: 'page-2',
|
|
@@ -108,6 +109,31 @@ describe('PageSettings.mixin onConfirmDeletePage GCs orphaned palette customs',
|
|
|
108
109
|
]);
|
|
109
110
|
});
|
|
110
111
|
|
|
112
|
+
test('deleting down to one page turns a page-linked button into a url link, in the same update as the delete', () => {
|
|
113
|
+
const context = setup();
|
|
114
|
+
|
|
115
|
+
Object.assign(context.pageFields[0].page.contents[0].settings.content, {
|
|
116
|
+
buttonLinkType: 'page',
|
|
117
|
+
buttonPageId: 'page-2',
|
|
118
|
+
url: 'https://example.com',
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
onConfirmDeletePage.call(context, 'page-2');
|
|
122
|
+
|
|
123
|
+
const pageSettingsStore = useUiPageSettingsStore();
|
|
124
|
+
|
|
125
|
+
// One synchronous call did both: the page is gone and the link already
|
|
126
|
+
// reset, so a single undo-history flush captures both.
|
|
127
|
+
expect(pageSettingsStore.pages).toHaveLength(1);
|
|
128
|
+
expect(
|
|
129
|
+
pageSettingsStore.pages[0].contents[0].settings.content,
|
|
130
|
+
).toMatchObject({
|
|
131
|
+
buttonLinkType: 'url',
|
|
132
|
+
buttonPageId: '',
|
|
133
|
+
url: 'https://example.com',
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
111
137
|
test('a page with a nav route removes the route before the pages write, then prunes', () => {
|
|
112
138
|
const context = setup({ routes: [{ id: 'route-2', pageId: 'page-2' }] });
|
|
113
139
|
|
|
@@ -3,7 +3,13 @@ import type Vue from 'vue';
|
|
|
3
3
|
import { createApp } from 'vue';
|
|
4
4
|
import { createPinia, setActivePinia } from 'pinia';
|
|
5
5
|
import type { ContentPage } from '../models';
|
|
6
|
-
import type {
|
|
6
|
+
import type {
|
|
7
|
+
BannerSectionContent,
|
|
8
|
+
Content,
|
|
9
|
+
HeaderButton,
|
|
10
|
+
ImagesSectionContent,
|
|
11
|
+
TextContent,
|
|
12
|
+
} from '@brand-page';
|
|
7
13
|
import type { ContentItem } from '../../content-settings/models';
|
|
8
14
|
import {
|
|
9
15
|
UNLIMITED_MAX_NUM_OF_PAGES,
|
|
@@ -278,6 +284,141 @@ describe('page store module', () => {
|
|
|
278
284
|
expect(pageSettingsStore.currentPage.id).toEqual(PAGE_TWO.id);
|
|
279
285
|
});
|
|
280
286
|
|
|
287
|
+
describe('resetStalePageLinks', () => {
|
|
288
|
+
type PageLink = Pick<
|
|
289
|
+
HeaderButton,
|
|
290
|
+
'buttonLinkType' | 'buttonPageId' | 'url'
|
|
291
|
+
>;
|
|
292
|
+
|
|
293
|
+
const linkTo = (pageId: string): PageLink => ({
|
|
294
|
+
buttonLinkType: 'page',
|
|
295
|
+
buttonPageId: pageId,
|
|
296
|
+
url: 'https://example.com',
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
const setUp = (
|
|
300
|
+
pages: ContentPage[],
|
|
301
|
+
pageId: string,
|
|
302
|
+
): ReturnType<typeof useUiPageSettingsStore> => {
|
|
303
|
+
const pageSettingsStore = useUiPageSettingsStore();
|
|
304
|
+
|
|
305
|
+
pageSettingsStore.setPages({ pages });
|
|
306
|
+
(['desktop', 'mobile'] as const).forEach((viewport) => {
|
|
307
|
+
pageSettingsStore.sections.header[viewport].headerButton = {
|
|
308
|
+
isVisible: true,
|
|
309
|
+
text: 'Contact',
|
|
310
|
+
...linkTo(pageId),
|
|
311
|
+
};
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
return pageSettingsStore;
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
const homeWithLinksTo = (pageId: string): ContentPage => ({
|
|
318
|
+
...PAGE_ONE,
|
|
319
|
+
contents: [
|
|
320
|
+
{
|
|
321
|
+
id: 'banner',
|
|
322
|
+
type: 'banner-section',
|
|
323
|
+
settings: { content: linkTo(pageId) },
|
|
324
|
+
} as ContentItem<BannerSectionContent>,
|
|
325
|
+
{
|
|
326
|
+
id: 'images',
|
|
327
|
+
type: 'images-section',
|
|
328
|
+
settings: { content: { items: [linkTo(pageId)] } },
|
|
329
|
+
} as ContentItem<ImagesSectionContent>,
|
|
330
|
+
],
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
const linksOf = (
|
|
334
|
+
pageSettingsStore: ReturnType<typeof useUiPageSettingsStore>,
|
|
335
|
+
): (Partial<PageLink> | undefined)[] => {
|
|
336
|
+
const [banner, images] = pageSettingsStore.pages[0].contents;
|
|
337
|
+
|
|
338
|
+
return [
|
|
339
|
+
banner.settings.content as BannerSectionContent,
|
|
340
|
+
(images.settings.content as ImagesSectionContent).items[0],
|
|
341
|
+
pageSettingsStore.sections.header.desktop.headerButton,
|
|
342
|
+
pageSettingsStore.sections.header.mobile.headerButton,
|
|
343
|
+
];
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
test('with 2+ pages left, a link to a deleted page keeps Page and clears its page', () => {
|
|
347
|
+
const pageSettingsStore = setUp(
|
|
348
|
+
[homeWithLinksTo('page-deleted'), PAGE_TWO],
|
|
349
|
+
'page-deleted',
|
|
350
|
+
);
|
|
351
|
+
|
|
352
|
+
pageSettingsStore.resetStalePageLinks();
|
|
353
|
+
|
|
354
|
+
linksOf(pageSettingsStore).forEach((link) =>
|
|
355
|
+
expect(link).toMatchObject({
|
|
356
|
+
buttonLinkType: 'page',
|
|
357
|
+
buttonPageId: '',
|
|
358
|
+
}),
|
|
359
|
+
);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
test('at one page, a link to a deleted page becomes a url link keeping its url', () => {
|
|
363
|
+
const pageSettingsStore = setUp(
|
|
364
|
+
[homeWithLinksTo('page-deleted')],
|
|
365
|
+
'page-deleted',
|
|
366
|
+
);
|
|
367
|
+
|
|
368
|
+
pageSettingsStore.resetStalePageLinks();
|
|
369
|
+
|
|
370
|
+
linksOf(pageSettingsStore).forEach((link) =>
|
|
371
|
+
expect(link).toMatchObject({
|
|
372
|
+
buttonLinkType: 'url',
|
|
373
|
+
buttonPageId: '',
|
|
374
|
+
url: 'https://example.com',
|
|
375
|
+
}),
|
|
376
|
+
);
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
test('a link to a page that still exists is untouched, even at one page', () => {
|
|
380
|
+
const pageSettingsStore = setUp(
|
|
381
|
+
[homeWithLinksTo(PAGE_ONE.id)],
|
|
382
|
+
PAGE_ONE.id,
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
pageSettingsStore.resetStalePageLinks();
|
|
386
|
+
|
|
387
|
+
linksOf(pageSettingsStore).forEach((link) =>
|
|
388
|
+
expect(link).toMatchObject(linkTo(PAGE_ONE.id)),
|
|
389
|
+
);
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
test('a non-page link is untouched', () => {
|
|
393
|
+
const emailLink: PageLink = {
|
|
394
|
+
buttonLinkType: 'mailTo',
|
|
395
|
+
buttonPageId: '',
|
|
396
|
+
url: 'jane@example.com',
|
|
397
|
+
};
|
|
398
|
+
const pageSettingsStore = setUp(
|
|
399
|
+
[
|
|
400
|
+
{
|
|
401
|
+
...PAGE_ONE,
|
|
402
|
+
contents: [
|
|
403
|
+
{
|
|
404
|
+
id: 'banner',
|
|
405
|
+
type: 'banner-section',
|
|
406
|
+
settings: { content: { ...emailLink } },
|
|
407
|
+
} as ContentItem<BannerSectionContent>,
|
|
408
|
+
],
|
|
409
|
+
},
|
|
410
|
+
],
|
|
411
|
+
PAGE_ONE.id,
|
|
412
|
+
);
|
|
413
|
+
|
|
414
|
+
pageSettingsStore.resetStalePageLinks();
|
|
415
|
+
|
|
416
|
+
expect(
|
|
417
|
+
pageSettingsStore.pages[0].contents[0].settings.content,
|
|
418
|
+
).toMatchObject(emailLink);
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
|
|
281
422
|
describe('setPreviousSelectedNavigationDisplayType', () => {
|
|
282
423
|
beforeEach(() => {
|
|
283
424
|
useUiPageSettingsStore().$patch(($state) => {
|
|
@@ -2,6 +2,7 @@ import { defineStore } from 'pinia';
|
|
|
2
2
|
import type { ContentItem } from '../../content-settings/models';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
+
BUTTON_LINK_TYPE,
|
|
5
6
|
PageHeaderDesktop,
|
|
6
7
|
PageHeaderMobile,
|
|
7
8
|
PageFooterDesktop,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
} from '@brand-page';
|
|
12
13
|
import type { NavigationType } from '@brand-page';
|
|
13
14
|
import type {
|
|
15
|
+
ButtonLinkType,
|
|
14
16
|
Content,
|
|
15
17
|
HeaderButton,
|
|
16
18
|
ImageGalleryItem,
|
|
@@ -456,6 +458,45 @@ export const useUiPageSettingsStore = defineStore('uiPageSettings', {
|
|
|
456
458
|
Object.assign(shopConfigStore.paymentConfig, currencyUpdate);
|
|
457
459
|
}
|
|
458
460
|
},
|
|
461
|
+
resetStalePageLinks(): void {
|
|
462
|
+
const pageIds = new Set(this.pages.map(({ id }) => id));
|
|
463
|
+
const isSinglePage = this.pages.length === 1;
|
|
464
|
+
|
|
465
|
+
type ButtonLink = {
|
|
466
|
+
buttonLinkType?: ButtonLinkType;
|
|
467
|
+
buttonPageId?: string;
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
const reset = (link: ButtonLink): void => {
|
|
471
|
+
if (
|
|
472
|
+
link.buttonLinkType !== BUTTON_LINK_TYPE.page ||
|
|
473
|
+
pageIds.has(link.buttonPageId ?? '')
|
|
474
|
+
) {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// The Page link option is not offered once one page is left, so the link falls back
|
|
479
|
+
// to a URL link, keeping its stored address.
|
|
480
|
+
if (isSinglePage) link.buttonLinkType = BUTTON_LINK_TYPE.url;
|
|
481
|
+
|
|
482
|
+
link.buttonPageId = '';
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
this.pages.forEach(({ contents }) => {
|
|
486
|
+
contents.forEach(({ settings: { content } }) => {
|
|
487
|
+
const holder = content as ButtonLink & { items?: ButtonLink[] };
|
|
488
|
+
|
|
489
|
+
reset(holder);
|
|
490
|
+
holder.items?.forEach(reset);
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
[VIEWPORTS.desktop, VIEWPORTS.mobile].forEach((viewport) => {
|
|
495
|
+
const { headerButton } = this.sections[PAGE_SECTIONS.header][viewport];
|
|
496
|
+
|
|
497
|
+
if (headerButton) reset(headerButton);
|
|
498
|
+
});
|
|
499
|
+
},
|
|
459
500
|
setPageTitle({
|
|
460
501
|
pageTitle,
|
|
461
502
|
pageId,
|