@designcrowd/library.brand-page 6.0.0-undo-redo-1 → 6.0.0
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-Cbi1PSNS.js → CreatedOnBrandCrowd-de-de-BhimVEpD.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-en-us-B2ZTei1t.js → CreatedOnBrandCrowd-en-us-CcBSmedR.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-es-es-DGz8UfQQ.js → CreatedOnBrandCrowd-es-es-Bywf3OqP.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-fr-C4rUBQUM.js → CreatedOnBrandCrowd-fr-ca-CWpYmK2m.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-ca-C4rUBQUM.js → CreatedOnBrandCrowd-fr-fr-CWpYmK2m.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-pt-Cw7sVI1F.js → CreatedOnBrandCrowd-pt-br-DHM9G51s.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-br-Cw7sVI1F.js → CreatedOnBrandCrowd-pt-pt-DHM9G51s.js} +1 -1
- package/lib/src/{CreatedOnDcom-de-de-DPSPgKj7.js → CreatedOnDcom-de-de-BnUSIarY.js} +1 -1
- package/lib/src/{CreatedOnDcom-en-us-AXXhwSXg.js → CreatedOnDcom-en-us-DzU8X52o.js} +1 -1
- package/lib/src/{CreatedOnDcom-es-es-DY8bmxi_.js → CreatedOnDcom-es-es-rpp-c_OZ.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-ca-D3QxYtYl.js → CreatedOnDcom-fr-ca-MJ7nCJTH.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-fr-KIt7qTPd.js → CreatedOnDcom-fr-fr-B3USPvBZ.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-br-Bv4bHhuR.js → CreatedOnDcom-pt-br-DJv7sfEZ.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-pt-NNO1huza.js → CreatedOnDcom-pt-pt-DAPP7A-E.js} +1 -1
- package/lib/src/brand-page/utils/logo.util.d.ts +0 -14
- package/lib/src/brand-page/utils/logo.util.js +0 -19
- package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.js +1 -1
- package/lib/src/brand-page-maker/composables/useUndoRedoFlag.d.ts +7 -6
- package/lib/src/brand-page-maker/composables/useUndoRedoFlag.js +12 -7
- package/lib/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.js +6 -2
- package/lib/src/index.mjs +1 -1
- package/lib/src/{lib-IDusUqYG.js → lib-Cfx4mNMR.js} +12442 -12439
- package/package.json +2 -2
- package/src/brand-page/utils/logo.util.test.ts +1 -54
- package/src/brand-page/utils/logo.util.ts +0 -23
- package/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.ts +1 -1
- package/src/brand-page-maker/composables/useUndoRedoFlag.ts +13 -7
- package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.ts +16 -2
- package/lib/src/metadata-builder/builders/reorder-pages-builder.d.ts +0 -13
- package/lib/src/metadata-builder/builders/reorder-pages-builder.js +0 -49
- package/src/metadata-builder/builders/reorder-pages-builder.ts +0 -80
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@designcrowd/library.brand-page",
|
|
3
3
|
"description": "A collection of Maker/Designer applications",
|
|
4
|
-
"version": "6.0.0
|
|
4
|
+
"version": "6.0.0",
|
|
5
5
|
"author": "Design.com Eng",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"type": "module",
|
|
@@ -248,4 +248,4 @@
|
|
|
248
248
|
"public"
|
|
249
249
|
]
|
|
250
250
|
}
|
|
251
|
-
}
|
|
251
|
+
}
|
|
@@ -12,12 +12,7 @@ import {
|
|
|
12
12
|
PageHeaderMobile,
|
|
13
13
|
PageStyles,
|
|
14
14
|
} from '../models';
|
|
15
|
-
import type {
|
|
16
|
-
BrandPageModel,
|
|
17
|
-
BrandPageType,
|
|
18
|
-
LogoContent,
|
|
19
|
-
PageModel,
|
|
20
|
-
} from '../models';
|
|
15
|
+
import type { BrandPageModel, LogoContent, PageModel } from '../models';
|
|
21
16
|
import * as logoUtil from './logo.util';
|
|
22
17
|
|
|
23
18
|
interface GetLogoVariationIndexFromLogoImageUrlTestCase {
|
|
@@ -217,52 +212,4 @@ describe('logo-util', () => {
|
|
|
217
212
|
logoImage.logoDraftToken,
|
|
218
213
|
);
|
|
219
214
|
});
|
|
220
|
-
|
|
221
|
-
describe('getLogoImageFromModel', () => {
|
|
222
|
-
// Distinct tokens in the content block vs the header so each assertion
|
|
223
|
-
// proves which location the helper read from.
|
|
224
|
-
const buildModel = (brandPageType: BrandPageType): BrandPageModel => {
|
|
225
|
-
const model = createTestBrandPageModel();
|
|
226
|
-
|
|
227
|
-
model.brandPageType = brandPageType;
|
|
228
|
-
(model.pages[0].contents[0] as LogoContent).logoImage = {
|
|
229
|
-
logoDraftToken: 'content-token',
|
|
230
|
-
logoVariation: 0,
|
|
231
|
-
logoLastUpdate: undefined,
|
|
232
|
-
};
|
|
233
|
-
model.pageHeaderDesktop.logoImage = {
|
|
234
|
-
logoDraftToken: 'header-token',
|
|
235
|
-
logoVariation: 0,
|
|
236
|
-
logoLastUpdate: undefined,
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
return model;
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
test('reads the header logo for brand-site', () => {
|
|
243
|
-
const model = buildModel(BRAND_PAGE_TYPES.brandSite);
|
|
244
|
-
|
|
245
|
-
expect(logoUtil.getLogoImageFromModel(model)?.logoDraftToken).toBe(
|
|
246
|
-
'header-token',
|
|
247
|
-
);
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
test('reads the content-block logo for brand-page', () => {
|
|
251
|
-
const model = buildModel(BRAND_PAGE_TYPES.default);
|
|
252
|
-
|
|
253
|
-
expect(logoUtil.getLogoImageFromModel(model)?.logoDraftToken).toBe(
|
|
254
|
-
'content-token',
|
|
255
|
-
);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
// Regression guard: brand-contact previously fell through to the header
|
|
259
|
-
// branch (the `=== brandPage` check) and read a stale header logo on undo.
|
|
260
|
-
test('reads the content-block logo for brand-contact', () => {
|
|
261
|
-
const model = buildModel(BRAND_PAGE_TYPES.brandContact);
|
|
262
|
-
|
|
263
|
-
expect(logoUtil.getLogoImageFromModel(model)?.logoDraftToken).toBe(
|
|
264
|
-
'content-token',
|
|
265
|
-
);
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
215
|
});
|
|
@@ -394,29 +394,6 @@ export const calculateOptimizedLogoDimensions = (
|
|
|
394
394
|
return { width: currentWidth, height: currentHeight };
|
|
395
395
|
};
|
|
396
396
|
|
|
397
|
-
/**
|
|
398
|
-
* Resolves the "current" logo image from a brand-page MODEL (the raw,
|
|
399
|
-
* deserialized shape — not the live stores, whose contents are wrapped in
|
|
400
|
-
* `settings.content`).
|
|
401
|
-
*
|
|
402
|
-
* Brand-site keeps its logo in the page header; brand-page and brand-contact
|
|
403
|
-
* keep it as a logo CONTENT block on the home page — the same `isBrandSite ?
|
|
404
|
-
* header : content` split the logo-settings store getters/setter use. This is
|
|
405
|
-
* the single source of truth for model-level logo reads: initial load and
|
|
406
|
-
* history-restore both call it so the two paths can't drift. They previously
|
|
407
|
-
* hard-coded `=== brandPage`, which silently excluded brand-contact and read a
|
|
408
|
-
* stale header logo on undo.
|
|
409
|
-
*/
|
|
410
|
-
export const getLogoImageFromModel = (
|
|
411
|
-
model: BrandPageModel,
|
|
412
|
-
): LogoImageModel | undefined => {
|
|
413
|
-
if (model.brandPageType === BRAND_PAGE_TYPES.brandSite) {
|
|
414
|
-
return model.pageHeaderDesktop?.logoImage;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
return model.pages?.[0]?.contents?.find(isLogoContent)?.logoImage;
|
|
418
|
-
};
|
|
419
|
-
|
|
420
397
|
export const recalculateLogoContentDimensions = async (
|
|
421
398
|
pageData: any,
|
|
422
399
|
editableLogoVariations: {
|
|
@@ -291,7 +291,7 @@ export default defineComponent({
|
|
|
291
291
|
|
|
292
292
|
// Capture baseline for undo/redo when the feature is active for this
|
|
293
293
|
// session — see useUndoRedoFlag.ts for the gate (LaunchDarkly flag +
|
|
294
|
-
// non-admin maker
|
|
294
|
+
// brand-site + non-admin maker).
|
|
295
295
|
if (useUndoRedoFlag().value) {
|
|
296
296
|
useHistoryStore().captureBaseline();
|
|
297
297
|
}
|
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
import { computed, type ComputedRef } from 'vue';
|
|
2
2
|
import { useBrandPageMakerUserStore } from '@brand-page-maker/stores/user';
|
|
3
|
+
import { useBrandPageMakerStore } from '@brand-page-maker/stores/brandpage-maker/brandpage-maker-store';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
* Returns whether undo/redo is active for the current maker session.
|
|
6
|
-
* conditions must hold:
|
|
6
|
+
* Returns whether undo/redo is active for the current maker session. All
|
|
7
|
+
* three conditions must hold:
|
|
7
8
|
*
|
|
8
9
|
* 1. `userStore.features.canUseUndoRedo` is true. The flag is populated by
|
|
9
10
|
* the consumer (BrandCrowd.Net / web-renderer) via the
|
|
10
11
|
* `WebsiteDesignUserFeatures.CanUseUndoRedo` boolean on the ViewModel —
|
|
11
|
-
* same precedent as RichTextEditor / GettyVideos / AITextGenerator.
|
|
12
|
-
*
|
|
13
|
-
* brand-
|
|
14
|
-
*
|
|
12
|
+
* same precedent as RichTextEditor / GettyVideos / AITextGenerator.
|
|
13
|
+
* 2. The maker is a brand-site (Website Maker). V1 scope is brand-site
|
|
14
|
+
* only; brand-page (single-page profile) and brand-contact (vCard) are
|
|
15
|
+
* out of scope.
|
|
16
|
+
* 3. The session is NOT in admin-maker mode (`userStore.isAdmin`). The
|
|
15
17
|
* admin maker uses the same components but a different editing flow
|
|
16
18
|
* (template authoring) where undo/redo is out of scope.
|
|
17
19
|
*/
|
|
18
20
|
export function useUndoRedoFlag(): ComputedRef<boolean> {
|
|
19
21
|
const userStore = useBrandPageMakerUserStore();
|
|
22
|
+
const brandPageMakerStore = useBrandPageMakerStore();
|
|
20
23
|
|
|
21
24
|
return computed(
|
|
22
|
-
() =>
|
|
25
|
+
() =>
|
|
26
|
+
userStore.features.canUseUndoRedo &&
|
|
27
|
+
brandPageMakerStore.isBrandSite &&
|
|
28
|
+
!userStore.isAdmin,
|
|
23
29
|
);
|
|
24
30
|
}
|
|
@@ -945,7 +945,14 @@ export const useBrandPageMakerStore = defineStore('brandPageMaker', {
|
|
|
945
945
|
}
|
|
946
946
|
}
|
|
947
947
|
|
|
948
|
-
const logoImage =
|
|
948
|
+
const logoImage =
|
|
949
|
+
snapshot.brandPageType === BRAND_PAGE_TYPES.default
|
|
950
|
+
? (
|
|
951
|
+
snapshot.pages?.[0]?.contents?.find(
|
|
952
|
+
(c) => c.type === 'logo',
|
|
953
|
+
) as any
|
|
954
|
+
)?.logoImage
|
|
955
|
+
: snapshot.pageHeaderDesktop?.logoImage;
|
|
949
956
|
|
|
950
957
|
if (!logoImage) return;
|
|
951
958
|
|
|
@@ -1266,7 +1273,14 @@ export const useBrandPageMakerStore = defineStore('brandPageMaker', {
|
|
|
1266
1273
|
brandPageType: _brandPageType,
|
|
1267
1274
|
});
|
|
1268
1275
|
|
|
1269
|
-
let logoImage =
|
|
1276
|
+
let logoImage =
|
|
1277
|
+
brandPageModel.brandPageType === BRAND_PAGE_TYPES.default
|
|
1278
|
+
? (
|
|
1279
|
+
brandPageModel.pages?.[0].contents.find(
|
|
1280
|
+
(c) => c.type === 'logo',
|
|
1281
|
+
) as any
|
|
1282
|
+
)?.logoImage
|
|
1283
|
+
: brandPageModel.pageHeaderDesktop?.logoImage;
|
|
1270
1284
|
|
|
1271
1285
|
if (!logoImage?.logoDraftToken) {
|
|
1272
1286
|
logoImage = logoUtil.safeGetLogoImageFromLogoImageUrl(
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { BrandPageModel } from '../../brand-page/models';
|
|
2
|
-
import { BaseMetadataBuilder, type BuilderResult, type MetadataBuilderRequest } from '../models';
|
|
3
|
-
import type { Logger } from '../logger';
|
|
4
|
-
export interface ReorderPagesPayload {
|
|
5
|
-
pageOrder: string[];
|
|
6
|
-
}
|
|
7
|
-
export declare class ReorderPagesBuilder extends BaseMetadataBuilder<ReorderPagesPayload> {
|
|
8
|
-
constructor(request: MetadataBuilderRequest<ReorderPagesPayload>, logger?: Logger);
|
|
9
|
-
validateAsync(): Promise<{
|
|
10
|
-
errors: string[];
|
|
11
|
-
}>;
|
|
12
|
-
buildAsync(model: BrandPageModel): Promise<BuilderResult>;
|
|
13
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { BaseMetadataBuilder, } from '../models';
|
|
2
|
-
export class ReorderPagesBuilder extends BaseMetadataBuilder {
|
|
3
|
-
constructor(request, logger) {
|
|
4
|
-
super(request, logger);
|
|
5
|
-
}
|
|
6
|
-
async validateAsync() {
|
|
7
|
-
const errors = [];
|
|
8
|
-
const payload = this.request.payload;
|
|
9
|
-
if (!payload?.pageOrder?.length) {
|
|
10
|
-
errors.push('page_order is required for reorder_pages');
|
|
11
|
-
}
|
|
12
|
-
return { errors };
|
|
13
|
-
}
|
|
14
|
-
async buildAsync(model) {
|
|
15
|
-
this.log('Build called');
|
|
16
|
-
const validation = await this.validateAsync();
|
|
17
|
-
if (validation.errors.length) {
|
|
18
|
-
return { request: this.request, model, errors: validation.errors };
|
|
19
|
-
}
|
|
20
|
-
const { pageOrder } = this.request.payload;
|
|
21
|
-
// Build pageId → routeId lookup from nav.routes
|
|
22
|
-
const pageIdToRouteId = new Map();
|
|
23
|
-
for (const route of model.nav.routes) {
|
|
24
|
-
pageIdToRouteId.set(route.pageId, route.id);
|
|
25
|
-
}
|
|
26
|
-
// Build new nav.orders from the flat page_order (array of pageIds)
|
|
27
|
-
const newOrders = [];
|
|
28
|
-
const seenRouteIds = new Set();
|
|
29
|
-
for (const pageId of pageOrder) {
|
|
30
|
-
const routeId = pageIdToRouteId.get(pageId);
|
|
31
|
-
if (!routeId)
|
|
32
|
-
continue;
|
|
33
|
-
newOrders.push({ routeId, subRoutes: [] });
|
|
34
|
-
seenRouteIds.add(routeId);
|
|
35
|
-
}
|
|
36
|
-
// Safety: append any routes not mentioned (don't lose pages)
|
|
37
|
-
for (const route of model.nav.routes) {
|
|
38
|
-
const routeId = pageIdToRouteId.get(route.pageId);
|
|
39
|
-
if (routeId && !seenRouteIds.has(routeId)) {
|
|
40
|
-
newOrders.push({ routeId, subRoutes: [] });
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
model.nav.orders = newOrders;
|
|
44
|
-
this.log({
|
|
45
|
-
message: `Reordered pages: ${pageOrder.join(', ')}`,
|
|
46
|
-
});
|
|
47
|
-
return { request: this.request, model };
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import type { BrandPageModel, NavOrder } from '../../brand-page/models';
|
|
2
|
-
import {
|
|
3
|
-
BaseMetadataBuilder,
|
|
4
|
-
type BuilderResult,
|
|
5
|
-
type MetadataBuilderRequest,
|
|
6
|
-
} from '../models';
|
|
7
|
-
import type { Logger } from '../logger';
|
|
8
|
-
|
|
9
|
-
export interface ReorderPagesPayload {
|
|
10
|
-
pageOrder: string[];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export class ReorderPagesBuilder extends BaseMetadataBuilder<ReorderPagesPayload> {
|
|
14
|
-
constructor(
|
|
15
|
-
request: MetadataBuilderRequest<ReorderPagesPayload>,
|
|
16
|
-
logger?: Logger,
|
|
17
|
-
) {
|
|
18
|
-
super(request, logger);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async validateAsync(): Promise<{ errors: string[] }> {
|
|
22
|
-
const errors: string[] = [];
|
|
23
|
-
const payload = this.request.payload;
|
|
24
|
-
|
|
25
|
-
if (!payload?.pageOrder?.length) {
|
|
26
|
-
errors.push('page_order is required for reorder_pages');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return { errors };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async buildAsync(model: BrandPageModel): Promise<BuilderResult> {
|
|
33
|
-
this.log('Build called');
|
|
34
|
-
|
|
35
|
-
const validation = await this.validateAsync();
|
|
36
|
-
|
|
37
|
-
if (validation.errors.length) {
|
|
38
|
-
return { request: this.request, model, errors: validation.errors };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const { pageOrder } = this.request.payload!;
|
|
42
|
-
|
|
43
|
-
// Build pageId → routeId lookup from nav.routes
|
|
44
|
-
const pageIdToRouteId = new Map<string, string>();
|
|
45
|
-
|
|
46
|
-
for (const route of model.nav.routes) {
|
|
47
|
-
pageIdToRouteId.set(route.pageId, route.id);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Build new nav.orders from the flat page_order (array of pageIds)
|
|
51
|
-
const newOrders: NavOrder[] = [];
|
|
52
|
-
const seenRouteIds = new Set<string>();
|
|
53
|
-
|
|
54
|
-
for (const pageId of pageOrder) {
|
|
55
|
-
const routeId = pageIdToRouteId.get(pageId);
|
|
56
|
-
|
|
57
|
-
if (!routeId) continue;
|
|
58
|
-
|
|
59
|
-
newOrders.push({ routeId, subRoutes: [] });
|
|
60
|
-
seenRouteIds.add(routeId);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Safety: append any routes not mentioned (don't lose pages)
|
|
64
|
-
for (const route of model.nav.routes) {
|
|
65
|
-
const routeId = pageIdToRouteId.get(route.pageId);
|
|
66
|
-
|
|
67
|
-
if (routeId && !seenRouteIds.has(routeId)) {
|
|
68
|
-
newOrders.push({ routeId, subRoutes: [] });
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
model.nav.orders = newOrders;
|
|
73
|
-
|
|
74
|
-
this.log({
|
|
75
|
-
message: `Reordered pages: ${pageOrder.join(', ')}`,
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
return { request: this.request, model };
|
|
79
|
-
}
|
|
80
|
-
}
|