@blaze-cms/react-page-builder 0.133.0-project-admin-customisations.0 → 0.133.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.
Files changed (89) hide show
  1. package/CHANGELOG.md +76 -6
  2. package/lib/components/Button.js +3 -1
  3. package/lib/components/Button.js.map +1 -1
  4. package/lib/components/ContentGroupSection/ContentGroupSection.js +4 -1
  5. package/lib/components/ContentGroupSection/ContentGroupSection.js.map +1 -1
  6. package/lib/components/DataSummary/helpers/build-loop-props-content.js +2 -3
  7. package/lib/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
  8. package/lib/components/DataSummary/helpers/get-link-to-published-content.js +0 -2
  9. package/lib/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
  10. package/lib/components/List/helpers/get-sort-props.js +9 -6
  11. package/lib/components/List/helpers/get-sort-props.js.map +1 -1
  12. package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +2 -2
  13. package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
  14. package/lib/components/SearchFilter/SearchFilterContainer.js +58 -22
  15. package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
  16. package/lib/components/SearchFilter/helpers/build-filters-query.js +18 -16
  17. package/lib/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
  18. package/lib/components/SearchFilter/helpers/build-url-query.js +3 -2
  19. package/lib/components/SearchFilter/helpers/build-url-query.js.map +1 -1
  20. package/lib/components/SearchFilter/helpers/get-initial-filter-values.js +33 -0
  21. package/lib/components/SearchFilter/helpers/get-initial-filter-values.js.map +1 -0
  22. package/lib/components/SearchFilter/helpers/get-updated-filter-by.js +38 -0
  23. package/lib/components/SearchFilter/helpers/get-updated-filter-by.js.map +1 -0
  24. package/lib/components/SearchFilter/helpers/index.js +8 -1
  25. package/lib/components/SearchFilter/helpers/index.js.map +1 -1
  26. package/lib/components/SocialFollow/sf.config.js +2 -1
  27. package/lib/components/SocialFollow/sf.config.js.map +1 -1
  28. package/lib/helpers/build-raw-query.js +7 -6
  29. package/lib/helpers/build-raw-query.js.map +1 -1
  30. package/lib/helpers/build-sort-values.js +4 -1
  31. package/lib/helpers/build-sort-values.js.map +1 -1
  32. package/lib-es/components/Button.js +2 -1
  33. package/lib-es/components/Button.js.map +1 -1
  34. package/lib-es/components/ContentGroupSection/ContentGroupSection.js +8 -4
  35. package/lib-es/components/ContentGroupSection/ContentGroupSection.js.map +1 -1
  36. package/lib-es/components/DataSummary/helpers/build-loop-props-content.js +2 -3
  37. package/lib-es/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
  38. package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js +1 -2
  39. package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
  40. package/lib-es/components/List/helpers/get-sort-props.js +9 -6
  41. package/lib-es/components/List/helpers/get-sort-props.js.map +1 -1
  42. package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js +3 -3
  43. package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
  44. package/lib-es/components/SearchFilter/SearchFilterContainer.js +54 -13
  45. package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
  46. package/lib-es/components/SearchFilter/helpers/build-filters-query.js +18 -16
  47. package/lib-es/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
  48. package/lib-es/components/SearchFilter/helpers/build-url-query.js +1 -2
  49. package/lib-es/components/SearchFilter/helpers/build-url-query.js.map +1 -1
  50. package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js +21 -0
  51. package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js.map +1 -0
  52. package/lib-es/components/SearchFilter/helpers/get-updated-filter-by.js +19 -0
  53. package/lib-es/components/SearchFilter/helpers/get-updated-filter-by.js.map +1 -0
  54. package/lib-es/components/SearchFilter/helpers/index.js +3 -2
  55. package/lib-es/components/SearchFilter/helpers/index.js.map +1 -1
  56. package/lib-es/components/SocialFollow/sf.config.js +3 -2
  57. package/lib-es/components/SocialFollow/sf.config.js.map +1 -1
  58. package/lib-es/helpers/build-raw-query.js +5 -4
  59. package/lib-es/helpers/build-raw-query.js.map +1 -1
  60. package/lib-es/helpers/build-sort-values.js +1 -1
  61. package/lib-es/helpers/build-sort-values.js.map +1 -1
  62. package/package.json +11 -11
  63. package/src/components/Button.js +6 -1
  64. package/src/components/ContentGroupSection/ContentGroupSection.js +1 -1
  65. package/src/components/DataSummary/helpers/build-loop-props-content.js +2 -3
  66. package/src/components/DataSummary/helpers/get-link-to-published-content.js +1 -4
  67. package/src/components/List/helpers/get-sort-props.js +4 -6
  68. package/src/components/SearchFilter/SearchFilter/SearchFilter.js +6 -3
  69. package/src/components/SearchFilter/SearchFilterContainer.js +42 -14
  70. package/src/components/SearchFilter/helpers/build-filters-query.js +23 -20
  71. package/src/components/SearchFilter/helpers/build-url-query.js +1 -3
  72. package/src/components/SearchFilter/helpers/get-initial-filter-values.js +24 -0
  73. package/src/components/SearchFilter/helpers/get-updated-filter-by.js +18 -0
  74. package/src/components/SearchFilter/helpers/index.js +5 -3
  75. package/src/components/SocialFollow/sf.config.js +2 -2
  76. package/src/helpers/build-raw-query.js +5 -1
  77. package/src/helpers/build-sort-values.js +1 -1
  78. package/tests/unit/src/components/DataSummary/helpers/build-loop-props-content.test.js +0 -41
  79. package/tests/unit/src/components/DataSummary/helpers/get-link-to-published-content.test.js +0 -21
  80. package/tests/unit/src/components/List/helpers/get-sort-props.test.js +23 -0
  81. package/tests/unit/src/components/SearchFilter/helpers/build-query.test.js +6 -0
  82. package/tests/unit/src/components/SearchFilter/helpers/get-updated-filter-by.test.js +28 -0
  83. package/tests/unit/src/components/SocialFollow/__snapshots__/SocialFollow.test.js.snap +1 -1
  84. package/tests/unit/src/helpers/build-raw-query.test.js +70 -1
  85. package/tests/unit/src/helpers/build-sort-values.test.js +20 -0
  86. package/tests/unit/src/helpers/get-generic-render-variables.test.js +25 -0
  87. package/tests/unit/src/components/PlaceholderIcon/__snapshots__/index.test.js.snap +0 -72
  88. package/tests/unit/src/components/PlaceholderIcon/index.test.js +0 -20
  89. /package/tests/unit/src/components/SearchFilter/helpers/{build-new-query.test.js → build-new-url.test.js} +0 -0
@@ -90,45 +90,4 @@ describe('buildLoopPropsContent helper function', () => {
90
90
  });
91
91
  expect.hasAssertions();
92
92
  });
93
-
94
- it('should nested items with urls', () => {
95
- const data = {
96
- nestedLoopProp: [
97
- {
98
- nestedValue: 'abc',
99
- url: 'http://blazecms.app/abc'
100
- },
101
- {
102
- nestedValue: '123',
103
- url: 'http://blazecms.app/123'
104
- },
105
- {
106
- nestedValue: 'no url',
107
- url: null
108
- }
109
- ]
110
- };
111
- const withUrl = buildLoopPropsContent(
112
- mockedLoopProps,
113
- [
114
- {
115
- bold: false,
116
- enableLink: true,
117
- label: '',
118
- modifier: '',
119
- prefix: '',
120
- propertiesToDisplay: ['nestedLoopProp.nestedValue'],
121
- shouldStrip: true
122
- }
123
- ],
124
- 0,
125
- data
126
- );
127
-
128
- withUrl.forEach(([, value, url], index) => {
129
- expect(value).toEqual(data.nestedLoopProp[index].nestedValue);
130
- expect(url).toEqual(data.nestedLoopProp[index].url || '');
131
- });
132
- expect.hasAssertions();
133
- });
134
93
  });
@@ -38,25 +38,4 @@ describe('get link to published content', () => {
38
38
  const result = getLinkToPublishedContent(publishedKey, props);
39
39
  expect(result).toEqual('');
40
40
  });
41
-
42
- it('should return url from the currentValue', () => {
43
- const currentValue = { url: 'currentValueUrl' };
44
- const props = { content: [content] };
45
- const result = getLinkToPublishedContent(publishedKey, props, currentValue);
46
- expect(result).toEqual(currentValue.url);
47
- });
48
-
49
- it('should return url from the currentValue even if falsey', () => {
50
- const currentValue = { url: null };
51
- const props = { content: [content] };
52
- const result = getLinkToPublishedContent(publishedKey, props, currentValue);
53
- expect(result).toEqual(currentValue.url);
54
- });
55
-
56
- it('should not return url from the currentValue if not set', () => {
57
- const currentValue = {};
58
- const props = { content: [content] };
59
- const result = getLinkToPublishedContent(publishedKey, props, currentValue);
60
- expect(result).toEqual(content.url);
61
- });
62
41
  });
@@ -60,6 +60,29 @@ describe('getSortProps helper function', () => {
60
60
  ]);
61
61
  });
62
62
 
63
+ it('should add score sort as first value if has textSearch but no sort applied', () => {
64
+ const { updatedSortProperties } = getSortProps({
65
+ ...props,
66
+ isTextSearchFilterApplied: true
67
+ });
68
+ expect(updatedSortProperties).toEqual([{ isScore: true }, ...sortProperties]);
69
+ });
70
+
71
+ it('should add default sort and score sort as first value if has textSearch and no other sort', () => {
72
+ const { updatedSortProperties } = getSortProps({
73
+ ...props,
74
+ sortProperties: [],
75
+ isTextSearchFilterApplied: true
76
+ });
77
+ expect(updatedSortProperties).toEqual([
78
+ { isScore: true },
79
+ {
80
+ propsToDisplay: props.defaultSortBy,
81
+ sort: props.defaultSort
82
+ }
83
+ ]);
84
+ });
85
+
63
86
  it('should use old style sort', () => {
64
87
  const { sortbyFilters, updatedSortProperties } = getSortProps({
65
88
  ...props,
@@ -11,6 +11,7 @@ const mockedProps = [
11
11
  ];
12
12
 
13
13
  describe('buildUrlQuery helper function', () => {
14
+ const noProps = buildUrlQuery();
14
15
  const simpleExample = buildUrlQuery(...mockedProps[0]);
15
16
  const withTextSearch = buildUrlQuery(...mockedProps[1]);
16
17
  const withSearchAndRange = buildUrlQuery(...mockedProps[2]);
@@ -20,6 +21,11 @@ describe('buildUrlQuery helper function', () => {
20
21
  anotherQuery: '123'
21
22
  });
22
23
 
24
+ it('should not break if no params are passed', () => {
25
+ expect(typeof noProps).toBe('string');
26
+ expect(noProps).toEqual('');
27
+ });
28
+
23
29
  it('should always return a string', () => {
24
30
  expect(typeof simpleExample).toBe('string');
25
31
  });
@@ -0,0 +1,28 @@
1
+ import getUpdatedFilterBy from '../../../../../../src/components/SearchFilter/helpers/get-updated-filter-by';
2
+
3
+ const mockedFilterByProperty = ['categoryId/product', 'subjectIds/product'];
4
+
5
+ const mockedParentData = {
6
+ id: 'abc123d',
7
+ categoryId: null,
8
+ subjectIds: ['subjectid123s']
9
+ };
10
+
11
+ describe('getUpdatedFilterBy helper', () => {
12
+ const mockedFilterBy = [1, 2, 3];
13
+ const noParentData = getUpdatedFilterBy(mockedFilterBy, [], {});
14
+ const withFilterBy = getUpdatedFilterBy(mockedFilterBy, [], { id: '123' });
15
+ const withUpdatedFilterBy = getUpdatedFilterBy([], mockedFilterByProperty, mockedParentData);
16
+
17
+ it('should return current filterBy and filterByProperty if no parentData or if filterBy values exist', () => {
18
+ expect(noParentData).toEqual({ updatedFilterBy: mockedFilterBy, updatedFilterByProperty: [] });
19
+ expect(withFilterBy).toEqual({ updatedFilterBy: mockedFilterBy, updatedFilterByProperty: [] });
20
+ });
21
+
22
+ it('should return updated filterBy based on parent data matchess', () => {
23
+ expect(withUpdatedFilterBy).toEqual({
24
+ updatedFilterBy: ['subjectIds/subjectid123s'],
25
+ updatedFilterByProperty: mockedFilterByProperty
26
+ });
27
+ });
28
+ });
@@ -61,7 +61,7 @@ exports[`SocialFollow component should render without throwing an error and matc
61
61
  xmlns="http://www.w3.org/2000/svg"
62
62
  >
63
63
  <path
64
- d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"
64
+ d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"
65
65
  />
66
66
  </svg>
67
67
  </i>
@@ -32,6 +32,7 @@ const filterData = {
32
32
  relations: [],
33
33
  stringProps: []
34
34
  };
35
+ const customProperty = 'lastname';
35
36
 
36
37
  describe('build raw query', () => {
37
38
  const {
@@ -365,7 +366,6 @@ describe('build raw query', () => {
365
366
  });
366
367
 
367
368
  it('should return query with aggs if requested using custom az param', () => {
368
- const customProperty = 'lastname';
369
369
  const queryWithAggs = buildRawQuery({
370
370
  docType,
371
371
  operator,
@@ -387,4 +387,73 @@ describe('build raw query', () => {
387
387
 
388
388
  expect(JSON.stringify(queryWithAggs)).toContain(`${customProperty}.keyword`);
389
389
  });
390
+
391
+ it('should handle filters with search where custom sort is also set', () => {
392
+ const queryWithAggs = buildRawQuery({
393
+ docType,
394
+ operator,
395
+ searchValues: {
396
+ searchValuesText,
397
+ searchValuesCheckboxSelectRange,
398
+ searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
399
+ },
400
+ filterData,
401
+ id,
402
+ itemsToDisplay: [],
403
+ shouldApplySort: true,
404
+ azOptions: {
405
+ shouldReturnAggs: false,
406
+ isAZ: false,
407
+ sortProperties: [{ isScore: true }]
408
+ }
409
+ });
410
+
411
+ expect(JSON.stringify(queryWithAggs)).not.toContain('sort');
412
+ });
413
+
414
+ it('should handle search filters with az listing using custom sort', () => {
415
+ const queryWithAggs = buildRawQuery({
416
+ docType,
417
+ operator,
418
+ searchValues: {
419
+ searchValuesText,
420
+ searchValuesCheckboxSelectRange,
421
+ searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
422
+ },
423
+ filterData,
424
+ id,
425
+ itemsToDisplay: [],
426
+ shouldApplySort: true,
427
+ azOptions: {
428
+ shouldReturnAggs: true,
429
+ isAZ: true,
430
+ sortProperties: [{ isScore: true }, { propsToDisplay: [customProperty] }]
431
+ }
432
+ });
433
+
434
+ expect(JSON.stringify(queryWithAggs)).toContain(`${customProperty}.keyword`);
435
+ });
436
+
437
+ it('should handle search filters with az listing using custom default', () => {
438
+ const queryWithAggs = buildRawQuery({
439
+ docType,
440
+ operator,
441
+ searchValues: {
442
+ searchValuesText,
443
+ searchValuesCheckboxSelectRange,
444
+ searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
445
+ },
446
+ filterData,
447
+ id,
448
+ itemsToDisplay: [],
449
+ shouldApplySort: true,
450
+ azOptions: {
451
+ shouldReturnAggs: true,
452
+ isAZ: true,
453
+ sortProperties: [{ isScore: true }]
454
+ }
455
+ });
456
+
457
+ expect(queryWithAggs).toEqual(RAW_QUERY_WITH_AGGS);
458
+ });
390
459
  });
@@ -31,4 +31,24 @@ describe('buildSortValues helper function', () => {
31
31
  );
32
32
  expect(withUseSortObject).toEqual({ 'slug.keyword': 'asc' });
33
33
  });
34
+
35
+ it('should filter out duplicate sort values', () => {
36
+ const sort = buildSortValues(
37
+ [
38
+ {
39
+ propsToDisplay: ['slug'],
40
+ sort: 'ASC',
41
+ label: ''
42
+ },
43
+ {
44
+ propsToDisplay: ['slug'],
45
+ sort: 'ASC',
46
+ label: ''
47
+ }
48
+ ],
49
+ [],
50
+ ['name', 'slug', 'metaTitle']
51
+ );
52
+ expect(sort).toEqual({ sort: 'slug.keyword:asc' });
53
+ });
34
54
  });
@@ -122,4 +122,29 @@ describe('get card/list render variables', () => {
122
122
 
123
123
  expect(sort).toEqual('tag.name.keyword:asc');
124
124
  });
125
+
126
+ it('should handle multiple sort properties', () => {
127
+ const sortProperties = [
128
+ {
129
+ propsToDisplay: ['featured'],
130
+ sort: 'DESC',
131
+ label: '',
132
+ status: 'show'
133
+ },
134
+ {
135
+ propsToDisplay: ['date'],
136
+ sort: 'DESC',
137
+ label: '',
138
+ items: null,
139
+ status: 'show'
140
+ }
141
+ ];
142
+ const { sort } = getGenericRenderVariables({
143
+ relations: [{ localField: 'tag', entityIdentifier: 'tags' }],
144
+ filterProps: mockedProps({ sort: '', sortby: '', sortProperties }),
145
+ stringProps: ['tags.name']
146
+ });
147
+
148
+ expect(sort).toEqual('featured:desc,date:desc');
149
+ });
125
150
  });
@@ -1,72 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Placeholder component should render PlaceholderIcon 1`] = `
4
- <DocumentFragment>
5
- <div
6
- class="editor-view__placeholder"
7
- data-testid="placeholder-icon"
8
- >
9
- <svg
10
- height="25px"
11
- version="1.1"
12
- viewBox="0 0 16 16"
13
- width="25px"
14
- xmlns="http://www.w3.org/2000/svg"
15
- >
16
- <title>
17
- card
18
- </title>
19
- <g
20
- fill="none"
21
- fill-rule="evenodd"
22
- id="Icons"
23
- stroke="none"
24
- stroke-width="1"
25
- >
26
- <g
27
- id="card"
28
- transform="translate(-261.000000, -216.000000)"
29
- >
30
- <g
31
- transform="translate(261.000000, 216.000000)"
32
- >
33
- <path
34
- d="M15,1 L15,9.53124644 L14.998,9.531 L14.9986024,7.67959976 L11.4210663,4.62547112 L7.4590683,8.08893259 C7.08560181,8.77082265 6.07591438,8.77082265 5.51715851,8.27688661 L3.50145721,6.5 L1,8.77 L1,7.323 L2.58011188,5.9054667 C3.10161735,5.44445974 3.91799869,5.41372594 4.47882094,5.81326531 L4.59488493,5.9054667 L6.4402744,7.56106172 L10.4252459,3.98593625 C10.9840017,3.49200022 11.8812631,3.49200022 12.4400189,3.98593625 L14.9986024,6.28137475 L14.998,1 Z M6.14778213,2.60821539 C6.69719001,2.60821539 7.14257312,3.0379169 7.14257312,3.56798059 C7.14257312,4.09804429 6.69719002,4.52774581 6.14778213,4.52774581 C5.88422964,4.52580316 5.6316942,4.42547921 5.44313851,4.24781429 C5.25594548,4.06784498 5.15142164,3.82293899 5.15297371,3.56798059 C5.15297371,3.0379169 5.59837425,2.60821539 6.14778213,2.60821539 Z"
35
- fill="#63779C"
36
- fill-rule="nonzero"
37
- id="Combined-Shape"
38
- />
39
- <path
40
- d="M3,13 C3,12.7238576 3.22385763,12.5 3.5,12.5 L12.5,12.5 C12.7761424,12.5 13,12.7238576 13,13 C13,13.2761424 12.7761424,13.5 12.5,13.5 L3.5,13.5 C3.22385763,13.5 3,13.2761424 3,13 Z"
41
- fill="#899BBC"
42
- fill-rule="nonzero"
43
- id="Shape"
44
- />
45
- <rect
46
- height="15"
47
- id="Rectangle"
48
- rx="2"
49
- stroke="#899BBC"
50
- width="15"
51
- x="0.5"
52
- y="0.5"
53
- />
54
- <line
55
- id="Line-2"
56
- stroke="#63779C"
57
- stroke-linecap="square"
58
- x1="0.5"
59
- x2="15.5"
60
- y1="10.5"
61
- y2="10.5"
62
- />
63
- </g>
64
- </g>
65
- </g>
66
- </svg>
67
- <span>
68
- card
69
- </span>
70
- </div>
71
- </DocumentFragment>
72
- `;
@@ -1,20 +0,0 @@
1
- /**
2
- * @jest-environment jsdom
3
- */
4
- import { render } from '@blaze-cms/tools/test-helpers/test-functions';
5
-
6
- import PlaceholderIcon from '../../../../../../blaze-plugin-page-builder-ui/src/components/EditorView/PlaceholderIcon';
7
- import { CardIcon } from '../../../../../../blaze-plugin-page-builder-ui/src/components/EditorView/Icons';
8
-
9
- const mockedProps = {
10
- type: 'card',
11
- icon: CardIcon
12
- };
13
-
14
- describe('Placeholder component', () => {
15
- it('should render PlaceholderIcon', () => {
16
- const { asFragment, getByTestId } = render(PlaceholderIcon, mockedProps);
17
- expect(getByTestId('placeholder-icon')).toBeDefined();
18
- expect(asFragment()).toMatchSnapshot();
19
- });
20
- });