@blaze-cms/react-page-builder 0.128.0-project-admin-customisations.0 → 0.128.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 (34) hide show
  1. package/CHANGELOG.md +46 -373
  2. package/lib/components/ContentGroupSection/ContentGroupSection.js +4 -1
  3. package/lib/components/ContentGroupSection/ContentGroupSection.js.map +1 -1
  4. package/lib/components/DataSummary/DataSummaryFactory.js +2 -1
  5. package/lib/components/DataSummary/DataSummaryFactory.js.map +1 -1
  6. package/lib/components/DataSummary/helpers/get-link-props.js +23 -0
  7. package/lib/components/DataSummary/helpers/get-link-props.js.map +1 -0
  8. package/lib/components/DataSummary/helpers/get-link-to-published-content.js +7 -12
  9. package/lib/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
  10. package/lib/components/DataSummary/helpers/index.js +7 -0
  11. package/lib/components/DataSummary/helpers/index.js.map +1 -1
  12. package/lib/helpers/build-props-query.js +34 -24
  13. package/lib/helpers/build-props-query.js.map +1 -1
  14. package/lib-es/components/ContentGroupSection/ContentGroupSection.js +8 -4
  15. package/lib-es/components/ContentGroupSection/ContentGroupSection.js.map +1 -1
  16. package/lib-es/components/DataSummary/DataSummaryFactory.js +3 -2
  17. package/lib-es/components/DataSummary/DataSummaryFactory.js.map +1 -1
  18. package/lib-es/components/DataSummary/helpers/get-link-props.js +6 -0
  19. package/lib-es/components/DataSummary/helpers/get-link-props.js.map +1 -0
  20. package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js +4 -7
  21. package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
  22. package/lib-es/components/DataSummary/helpers/index.js +2 -1
  23. package/lib-es/components/DataSummary/helpers/index.js.map +1 -1
  24. package/lib-es/helpers/build-props-query.js +22 -9
  25. package/lib-es/helpers/build-props-query.js.map +1 -1
  26. package/package.json +10 -10
  27. package/src/components/ContentGroupSection/ContentGroupSection.js +1 -1
  28. package/src/components/DataSummary/DataSummaryFactory.js +3 -2
  29. package/src/components/DataSummary/helpers/get-link-props.js +7 -0
  30. package/src/components/DataSummary/helpers/get-link-to-published-content.js +4 -8
  31. package/src/components/DataSummary/helpers/index.js +3 -1
  32. package/src/helpers/build-props-query.js +46 -33
  33. package/tests/unit/src/components/DataSummary/helpers/get-link-props.test.js +35 -0
  34. package/tests/unit/src/components/DataSummary/helpers/get-link-to-published-content.test.js +0 -3
@@ -1 +1 @@
1
- {"version":3,"file":"build-props-query.js","names":["CATEGORY_ID","ID","PREHEADER_PROP","HEADLINE_PROP","defaultProps","categoryProps","checkProps","props","Object","keys","filter","prop","length","buildPropsQuery","entitySchema","extraProps","cardOptions","parsedSchema","getEntitySchema","extraPropsHaveCategory","includes","typeBasedProps","shouldAddCategoryProps","getTypeBaseProps","allProps","uniqueProps","Set","basicProps","i","arr","indexOf","complexProps","buildComplexProps","join","relations","map","nested","split","base","matchingRelation","find","localField","nestedProps","extraProp","startsWith","push","jointNestedProps","isCard","displayCategory","displayThumbnail","interfaces","properties","dynamicProperties","isContent","hasCategory","hasPreheader","getCategoyProps","getContentProps","url"],"sources":["../../src/helpers/build-props-query.js"],"sourcesContent":["import { CATEGORY_ID, ID, PREHEADER_PROP, HEADLINE_PROP } from '../constants';\n\nconst defaultProps = [ID, 'name'];\nconst categoryProps = 'id publishedListingPage{id, url}';\n\nconst checkProps = props =>\n !!(props && Object.keys(props).filter(prop => prop === CATEGORY_ID).length);\n\nconst buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null) => {\n const parsedSchema = entitySchema.getEntitySchema ? entitySchema.getEntitySchema : entitySchema;\n const extraPropsHaveCategory = !!extraProps.filter(prop => prop.includes('category.')).length;\n const { typeBasedProps, shouldAddCategoryProps } = getTypeBaseProps(\n parsedSchema,\n cardOptions,\n extraPropsHaveCategory\n );\n\n const allProps = [...typeBasedProps, ...extraProps];\n\n const uniqueProps = [...new Set([...allProps])];\n\n const basicProps = uniqueProps\n .filter(prop => prop && !prop.includes('.'))\n .filter((prop, i, arr) => arr.indexOf(prop) === i);\n const complexProps = buildComplexProps(shouldAddCategoryProps, uniqueProps, parsedSchema);\n return [...basicProps, ...complexProps].join(',');\n};\n\nconst buildComplexProps = (shouldAddCategoryProps, props, { relations }) =>\n props\n .filter(prop => prop && prop.includes('.'))\n .map(nested => nested.split('.')[0])\n .filter((prop, i, arr) => arr.indexOf(prop) === i)\n .map(base => {\n const matchingRelation = relations.find(({ localField }) => localField === base);\n const nestedProps = props\n .filter(\n (extraProp, i, arr) =>\n extraProp && extraProp.startsWith(`${base}.`) && arr.indexOf(extraProp) === i\n )\n .map(nested => nested.split('.')[1]);\n if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');\n\n const jointNestedProps = nestedProps.join(',');\n if (base === 'category' && shouldAddCategoryProps)\n return `${base}{${jointNestedProps}, ${categoryProps}}`;\n if (base.includes('published')) {\n return `${base}{${jointNestedProps},url}`;\n }\n return `${base}{${jointNestedProps}}`;\n });\n\nconst getTypeBaseProps = (entitySchema, cardOptions, extraPropsHaveCategory) => {\n const isCard = !!cardOptions;\n const { displayCategory = true, displayThumbnail = true } = cardOptions || {};\n\n const shouldAddCategoryProps =\n (isCard && displayCategory) || (!isCard && !extraPropsHaveCategory);\n\n if (!isCard) return { typeBasedProps: [ID], shouldAddCategoryProps };\n\n const { interfaces, properties, dynamicProperties, relations } = entitySchema;\n\n const isContent = !!interfaces.includes('content/content');\n const hasCategory = checkProps(properties) || checkProps(dynamicProperties);\n const hasPreheader = properties[PREHEADER_PROP];\n\n const typeBasedProps = [...defaultProps];\n\n typeBasedProps.push(...getCategoyProps(shouldAddCategoryProps, hasCategory, hasPreheader));\n typeBasedProps.push(...getContentProps(isContent));\n\n if (properties.url || dynamicProperties.url) typeBasedProps.push('url');\n\n if (displayThumbnail && relations.find(({ localField }) => localField === 'image')) {\n typeBasedProps.push('image.id', 'image.url', 'image.data');\n }\n\n return { typeBasedProps, shouldAddCategoryProps };\n};\n\nconst getContentProps = isContent => (isContent ? ['url', 'sponsored', 'featured'] : []);\n\nconst getCategoyProps = (shouldAddCategoryProps, hasCategory, hasPreheader) => {\n if (!shouldAddCategoryProps) return [];\n\n const props = [];\n\n if (hasCategory) {\n props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');\n }\n\n if (hasPreheader) {\n props.push(`${PREHEADER_PROP}{name}`);\n props.push(HEADLINE_PROP);\n }\n\n return props;\n};\n\nexport default buildPropsQuery;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,EAAE,EAAEC,cAAc,EAAEC,aAAa,QAAQ,cAAc;AAE7E,MAAMC,YAAY,GAAG,CAACH,EAAE,EAAE,MAAM,CAAC;AACjC,MAAMI,aAAa,GAAG,kCAAkC;AAExD,MAAMC,UAAU,GAAGC,KAAK,IACtB,CAAC,EAAEA,KAAK,IAAIC,MAAM,CAACC,IAAI,CAACF,KAAK,CAAC,CAACG,MAAM,CAACC,IAAI,IAAIA,IAAI,KAAKX,WAAW,CAAC,CAACY,MAAM,CAAC;AAE7E,MAAMC,eAAe,GAAGA,CAACC,YAAY,EAAEC,UAAU,GAAG,EAAE,EAAEC,WAAW,GAAG,IAAI,KAAK;EAC7E,MAAMC,YAAY,GAAGH,YAAY,CAACI,eAAe,GAAGJ,YAAY,CAACI,eAAe,GAAGJ,YAAY;EAC/F,MAAMK,sBAAsB,GAAG,CAAC,CAACJ,UAAU,CAACL,MAAM,CAACC,IAAI,IAAIA,IAAI,CAACS,QAAQ,CAAC,WAAW,CAAC,CAAC,CAACR,MAAM;EAC7F,MAAM;IAAES,cAAc;IAAEC;EAAuB,CAAC,GAAGC,gBAAgB,CACjEN,YAAY,EACZD,WAAW,EACXG,sBAAsB,CACvB;EAED,MAAMK,QAAQ,GAAG,CAAC,GAAGH,cAAc,EAAE,GAAGN,UAAU,CAAC;EAEnD,MAAMU,WAAW,GAAG,CAAC,GAAG,IAAIC,GAAG,CAAC,CAAC,GAAGF,QAAQ,CAAC,CAAC,CAAC;EAE/C,MAAMG,UAAU,GAAGF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ADLINE_PROP","defaultProps","categoryProps","checkProps","props","Object","keys","filter","prop","length","buildPropsQuery","entitySchema","extraProps","cardOptions","linkProps","parsedSchema","getEntitySchema","extraPropsHaveCategory","includes","typeBasedProps","shouldAddCategoryProps","getTypeBaseProps","allProps","uniqueProps","Set","basicProps","nestedProps","forEach","push","base","nested","split","complexProps","buildComplexProps","join","relations","dynamicProperties","map","hasLink","find","linkProp","matchingRelation","localField","matchingDynamicProp","dynamicKey","jointNestedProps","isCard","displayCategory","displayThumbnail","interfaces","properties","isContent","hasCategory","hasPreheader","getCategoyProps","getContentProps","url"],"sources":["../../src/helpers/build-props-query.js"],"sourcesContent":["import { CATEGORY_ID, ID, PREHEADER_PROP, HEADLINE_PROP } from '../constants';\n\nconst defaultProps = [ID, 'name'];\nconst categoryProps = 'id publishedListingPage{id, url}';\n\nconst checkProps = props =>\n !!(props && Object.keys(props).filter(prop => prop === CATEGORY_ID).length);\n\nconst buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null, linkProps = []) => {\n const parsedSchema = entitySchema.getEntitySchema ? entitySchema.getEntitySchema : entitySchema;\n const extraPropsHaveCategory = !!extraProps.filter(prop => prop.includes('category.')).length;\n const { typeBasedProps, shouldAddCategoryProps } = getTypeBaseProps(\n parsedSchema,\n cardOptions,\n extraPropsHaveCategory\n );\n\n const allProps = [...typeBasedProps, ...extraProps];\n const uniqueProps = [...new Set([...allProps])];\n const basicProps = [];\n const nestedProps = {};\n uniqueProps.forEach(prop => {\n if (prop) {\n if (!prop.includes('.')) {\n basicProps.push(prop);\n return;\n }\n const [base, nested] = prop.split('.');\n if (!nestedProps[base]) nestedProps[base] = [nested];\n else nestedProps[base].push(nested);\n }\n });\n\n const complexProps = buildComplexProps(\n shouldAddCategoryProps,\n nestedProps,\n parsedSchema,\n linkProps\n );\n\n return [...basicProps, ...complexProps].join(',');\n};\n\nconst buildComplexProps = (\n shouldAddCategoryProps,\n props,\n { relations = [], dynamicProperties = {} },\n linkProps\n) =>\n Object.keys(props).map(base => {\n const nestedProps = props[base];\n const hasLink = !!linkProps.find(linkProp => linkProp.includes(base));\n const matchingRelation = relations.find(({ localField }) => localField === base);\n const matchingDynamicProp = Object.keys(dynamicProperties).find(\n dynamicKey => dynamicKey === base\n );\n\n if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');\n if (hasLink && (!!matchingRelation || !!matchingDynamicProp)) nestedProps.push('url');\n const jointNestedProps = nestedProps.join(',');\n if (base === 'category' && shouldAddCategoryProps)\n return `${base}{${jointNestedProps}, ${categoryProps}}`;\n if (base.includes('published')) {\n return `${base}{${jointNestedProps},url}`;\n }\n return `${base}{${jointNestedProps}}`;\n });\n\nconst getTypeBaseProps = (entitySchema, cardOptions, extraPropsHaveCategory) => {\n const isCard = !!cardOptions;\n const { displayCategory = true, displayThumbnail = true } = cardOptions || {};\n\n const shouldAddCategoryProps =\n (isCard && displayCategory) || (!isCard && !extraPropsHaveCategory);\n\n if (!isCard) return { typeBasedProps: [ID], shouldAddCategoryProps };\n\n const { interfaces, properties, dynamicProperties, relations } = entitySchema;\n\n const isContent = !!interfaces.includes('content/content');\n const hasCategory = checkProps(properties) || checkProps(dynamicProperties);\n const hasPreheader = properties[PREHEADER_PROP];\n\n const typeBasedProps = [...defaultProps];\n\n typeBasedProps.push(...getCategoyProps(shouldAddCategoryProps, hasCategory, hasPreheader));\n typeBasedProps.push(...getContentProps(isContent));\n\n if (properties.url || dynamicProperties.url) typeBasedProps.push('url');\n\n if (displayThumbnail && relations.find(({ localField }) => localField === 'image')) {\n typeBasedProps.push('image.id', 'image.url', 'image.data');\n }\n\n return { typeBasedProps, shouldAddCategoryProps };\n};\n\nconst getContentProps = isContent => (isContent ? ['url', 'sponsored', 'featured'] : []);\n\nconst getCategoyProps = (shouldAddCategoryProps, hasCategory, hasPreheader) => {\n if (!shouldAddCategoryProps) return [];\n const props = [];\n if (hasCategory)\n props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');\n\n if (hasPreheader) {\n props.push(`${PREH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react-page-builder",
3
- "version": "0.128.0-project-admin-customisations.0",
3
+ "version": "0.128.0",
4
4
  "description": "Blaze react page builder",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-es/index.js",
@@ -27,15 +27,15 @@
27
27
  },
28
28
  "license": "GPL-3.0",
29
29
  "dependencies": {
30
- "@blaze-cms/core-auth-ui": "0.128.0-project-admin-customisations.0",
31
- "@blaze-cms/core-errors": "0.128.0-project-admin-customisations.0",
32
- "@blaze-cms/core-errors-ui": "0.128.0-project-admin-customisations.0",
30
+ "@blaze-cms/core-auth-ui": "^0.128.0",
31
+ "@blaze-cms/core-errors": "^0.127.0",
32
+ "@blaze-cms/core-errors-ui": "^0.128.0",
33
33
  "@blaze-cms/image-cdn-react": "0.3.0-alpha.5",
34
- "@blaze-cms/nextjs-components": "0.128.0-project-admin-customisations.0",
35
- "@blaze-cms/plugin-search-ui": "0.128.0-project-admin-customisations.0",
36
- "@blaze-cms/setup-ui": "0.128.0-project-admin-customisations.0",
37
- "@blaze-cms/utils": "0.128.0-project-admin-customisations.0",
38
- "@blaze-cms/utils-handlebars": "0.128.0-project-admin-customisations.0",
34
+ "@blaze-cms/nextjs-components": "^0.128.0",
35
+ "@blaze-cms/plugin-search-ui": "^0.128.0",
36
+ "@blaze-cms/setup-ui": "^0.128.0",
37
+ "@blaze-cms/utils": "^0.128.0",
38
+ "@blaze-cms/utils-handlebars": "^0.128.0",
39
39
  "@blaze-react/breadcrumb": "0.8.0-alpha.60",
40
40
  "@blaze-react/button": "0.5.19",
41
41
  "@blaze-react/checkboxes": "0.5.31",
@@ -89,5 +89,5 @@
89
89
  "lib/*",
90
90
  "lib-es/*"
91
91
  ],
92
- "gitHead": "e980a4e631f7e2d3a8939a754d87167f48da315f"
92
+ "gitHead": "fb7948536c8e7ab915cf63397b6885c272f79be2"
93
93
  }
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { hasChildren } from '../../helpers';
4
4
 
5
- const ContentGroupSection = ({ children, name }) => {
5
+ const ContentGroupSection = ({ children, name, ...props }) => {
6
6
  if (!hasChildren(children)) return null;
7
7
 
8
8
  return (
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
4
4
  import { MainContext } from '@blaze-cms/nextjs-components';
5
5
  import { getSingleEntitySchema } from '../../application/query';
6
6
  import { buildPropsQuery, checkPropsToUse } from '../../helpers';
7
- import { getDataSummaryQuery } from './helpers';
7
+ import { getDataSummaryQuery, getLinkProps } from './helpers';
8
8
  import DataSummaryRender from './DataSummaryRender';
9
9
 
10
10
  const DataSummaryFactory = ({
@@ -31,7 +31,8 @@ const DataSummaryFactory = ({
31
31
  if (!data) return null;
32
32
  if (!propsToDisplay || !propsToDisplay.length) return null;
33
33
  const propsToDisplayValues = checkPropsToUse(propsToDisplay);
34
- const propsQueryString = buildPropsQuery(data, propsToDisplayValues);
34
+ const linkProps = getLinkProps(propsToDisplay);
35
+ const propsQueryString = buildPropsQuery(data, propsToDisplayValues, null, linkProps);
35
36
  const dataSummaryQuery = getDataSummaryQuery(data, isPreview, propsQueryString);
36
37
  const recordId = dataRecordId[0] || dataSummaryProps.parent.itemId;
37
38
 
@@ -0,0 +1,7 @@
1
+ const getLinkProps = (props = []) =>
2
+ props
3
+ .map(({ propertiesToDisplay, enableLink }) => enableLink && propertiesToDisplay)
4
+ .flat()
5
+ .filter(Boolean);
6
+
7
+ export default getLinkProps;
@@ -1,12 +1,8 @@
1
1
  const getLinkToPublishedContent = (key = '', props = {}) => {
2
- if (key.includes('published')) {
3
- const [baseKey] = key.split('.');
4
- if (!props[baseKey]) return '';
5
-
6
- const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
7
- return content && content.url ? content.url : '';
8
- }
9
- return '';
2
+ const [baseKey] = key.split('.');
3
+ if (!props[baseKey]) return '';
4
+ const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
5
+ return content && content.url ? content.url : '';
10
6
  };
11
7
 
12
8
  export default getLinkToPublishedContent;
@@ -5,6 +5,7 @@ import stripSummaryPropsContent from './strip-summary-props-content';
5
5
  import buildLoopPropsContent from './build-loop-props-content';
6
6
  import parseBooleanValues from './parse-boolean-values';
7
7
  import getLinkBasedOnValue from './get-link-based-on-value';
8
+ import getLinkProps from './get-link-props';
8
9
 
9
10
  export {
10
11
  getDataSummaryQuery,
@@ -13,5 +14,6 @@ export {
13
14
  stripSummaryPropsContent,
14
15
  buildLoopPropsContent,
15
16
  parseBooleanValues,
16
- getLinkBasedOnValue
17
+ getLinkBasedOnValue,
18
+ getLinkProps
17
19
  };
@@ -6,7 +6,7 @@ const categoryProps = 'id publishedListingPage{id, url}';
6
6
  const checkProps = props =>
7
7
  !!(props && Object.keys(props).filter(prop => prop === CATEGORY_ID).length);
8
8
 
9
- const buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null) => {
9
+ const buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null, linkProps = []) => {
10
10
  const parsedSchema = entitySchema.getEntitySchema ? entitySchema.getEntitySchema : entitySchema;
11
11
  const extraPropsHaveCategory = !!extraProps.filter(prop => prop.includes('category.')).length;
12
12
  const { typeBasedProps, shouldAddCategoryProps } = getTypeBaseProps(
@@ -16,39 +16,55 @@ const buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null) => {
16
16
  );
17
17
 
18
18
  const allProps = [...typeBasedProps, ...extraProps];
19
-
20
19
  const uniqueProps = [...new Set([...allProps])];
20
+ const basicProps = [];
21
+ const nestedProps = {};
22
+ uniqueProps.forEach(prop => {
23
+ if (prop) {
24
+ if (!prop.includes('.')) {
25
+ basicProps.push(prop);
26
+ return;
27
+ }
28
+ const [base, nested] = prop.split('.');
29
+ if (!nestedProps[base]) nestedProps[base] = [nested];
30
+ else nestedProps[base].push(nested);
31
+ }
32
+ });
33
+
34
+ const complexProps = buildComplexProps(
35
+ shouldAddCategoryProps,
36
+ nestedProps,
37
+ parsedSchema,
38
+ linkProps
39
+ );
21
40
 
22
- const basicProps = uniqueProps
23
- .filter(prop => prop && !prop.includes('.'))
24
- .filter((prop, i, arr) => arr.indexOf(prop) === i);
25
- const complexProps = buildComplexProps(shouldAddCategoryProps, uniqueProps, parsedSchema);
26
41
  return [...basicProps, ...complexProps].join(',');
27
42
  };
28
43
 
29
- const buildComplexProps = (shouldAddCategoryProps, props, { relations }) =>
30
- props
31
- .filter(prop => prop && prop.includes('.'))
32
- .map(nested => nested.split('.')[0])
33
- .filter((prop, i, arr) => arr.indexOf(prop) === i)
34
- .map(base => {
35
- const matchingRelation = relations.find(({ localField }) => localField === base);
36
- const nestedProps = props
37
- .filter(
38
- (extraProp, i, arr) =>
39
- extraProp && extraProp.startsWith(`${base}.`) && arr.indexOf(extraProp) === i
40
- )
41
- .map(nested => nested.split('.')[1]);
42
- if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');
43
-
44
- const jointNestedProps = nestedProps.join(',');
45
- if (base === 'category' && shouldAddCategoryProps)
46
- return `${base}{${jointNestedProps}, ${categoryProps}}`;
47
- if (base.includes('published')) {
48
- return `${base}{${jointNestedProps},url}`;
49
- }
50
- return `${base}{${jointNestedProps}}`;
51
- });
44
+ const buildComplexProps = (
45
+ shouldAddCategoryProps,
46
+ props,
47
+ { relations = [], dynamicProperties = {} },
48
+ linkProps
49
+ ) =>
50
+ Object.keys(props).map(base => {
51
+ const nestedProps = props[base];
52
+ const hasLink = !!linkProps.find(linkProp => linkProp.includes(base));
53
+ const matchingRelation = relations.find(({ localField }) => localField === base);
54
+ const matchingDynamicProp = Object.keys(dynamicProperties).find(
55
+ dynamicKey => dynamicKey === base
56
+ );
57
+
58
+ if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');
59
+ if (hasLink && (!!matchingRelation || !!matchingDynamicProp)) nestedProps.push('url');
60
+ const jointNestedProps = nestedProps.join(',');
61
+ if (base === 'category' && shouldAddCategoryProps)
62
+ return `${base}{${jointNestedProps}, ${categoryProps}}`;
63
+ if (base.includes('published')) {
64
+ return `${base}{${jointNestedProps},url}`;
65
+ }
66
+ return `${base}{${jointNestedProps}}`;
67
+ });
52
68
 
53
69
  const getTypeBaseProps = (entitySchema, cardOptions, extraPropsHaveCategory) => {
54
70
  const isCard = !!cardOptions;
@@ -83,12 +99,9 @@ const getContentProps = isContent => (isContent ? ['url', 'sponsored', 'featured
83
99
 
84
100
  const getCategoyProps = (shouldAddCategoryProps, hasCategory, hasPreheader) => {
85
101
  if (!shouldAddCategoryProps) return [];
86
-
87
102
  const props = [];
88
-
89
- if (hasCategory) {
103
+ if (hasCategory)
90
104
  props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');
91
- }
92
105
 
93
106
  if (hasPreheader) {
94
107
  props.push(`${PREHEADER_PROP}{name}`);
@@ -0,0 +1,35 @@
1
+ import '@testing-library/jest-dom/extend-expect';
2
+ import getLinkProps from '../../../../../../src/components/DataSummary/helpers/get-link-props';
3
+
4
+ describe('get link props helper', () => {
5
+ const noProps = getLinkProps();
6
+
7
+ const withEnableLink = getLinkProps([
8
+ { enableLink: true, propertiesToDisplay: ['prop1', 'prop2'] }
9
+ ]);
10
+
11
+ const multipleProps = getLinkProps([
12
+ { enableLink: true, propertiesToDisplay: ['prop1', 'prop2'] },
13
+ { enableLink: true, propertiesToDisplay: ['prop3'] },
14
+ { enableLink: true, propertiesToDisplay: [] },
15
+ { enableLink: false, propertiesToDisplay: ['prop4'] }
16
+ ]);
17
+
18
+ it('should always return an array', () => {
19
+ expect(Array.isArray(noProps)).toEqual(true);
20
+ expect(Array.isArray(withEnableLink)).toEqual(true);
21
+ expect(Array.isArray(multipleProps)).toEqual(true);
22
+ });
23
+
24
+ it('should return empty array if no props are passed', () => {
25
+ expect(noProps).toEqual([]);
26
+ });
27
+
28
+ it('should return props if enableLink is true', () => {
29
+ expect(withEnableLink).toEqual(['prop1', 'prop2']);
30
+ });
31
+
32
+ it('should return props if enableLink is true and props are nested', () => {
33
+ expect(multipleProps).toEqual(['prop1', 'prop2', 'prop3']);
34
+ });
35
+ });
@@ -4,9 +4,6 @@ import getLinkToPublishedContent from '../../../../../../src/components/DataSumm
4
4
  describe('get link to published content', () => {
5
5
  const publishedKey = 'content.published';
6
6
  const content = { url: 'url' };
7
- it('should be a function', () => {
8
- expect(typeof getLinkToPublishedContent).toEqual('function');
9
- });
10
7
 
11
8
  it('should always return a string', () => {
12
9
  const result = getLinkToPublishedContent();