@blaze-cms/react-page-builder 0.146.0-node18-core-styles-tooltips.31 → 0.146.0-node18-core-styles-tooltips.34
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/CHANGELOG.md +16 -0
- package/lib/components/DataSummary/DataSummaryFactory.js +2 -1
- package/lib/components/DataSummary/DataSummaryFactory.js.map +1 -1
- package/lib/components/DataSummary/helpers/get-record-id.js +23 -0
- package/lib/components/DataSummary/helpers/get-record-id.js.map +1 -0
- package/lib/components/DataSummary/helpers/index.js +7 -0
- package/lib/components/DataSummary/helpers/index.js.map +1 -1
- package/lib-es/components/DataSummary/DataSummaryFactory.js +3 -2
- package/lib-es/components/DataSummary/DataSummaryFactory.js.map +1 -1
- package/lib-es/components/DataSummary/helpers/get-record-id.js +14 -0
- package/lib-es/components/DataSummary/helpers/get-record-id.js.map +1 -0
- package/lib-es/components/DataSummary/helpers/index.js +2 -1
- package/lib-es/components/DataSummary/helpers/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/DataSummary/DataSummaryFactory.js +4 -2
- package/src/components/DataSummary/helpers/get-record-id.js +14 -0
- package/src/components/DataSummary/helpers/index.js +3 -1
- package/tests/unit/src/components/DataSummary/__snapshots__/DataSummaryFactory.test.js.snap +1 -5
- package/tests/unit/src/components/DataSummary/helpers/get-record-id.test.js +108 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.146.0-node18-core-styles-tooltips.34](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.33...v0.146.0-node18-core-styles-tooltips.34) (2025-11-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @blaze-cms/react-page-builder
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [0.146.0-node18-core-styles-tooltips.32](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.31...v0.146.0-node18-core-styles-tooltips.32) (2025-11-26)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @blaze-cms/react-page-builder
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [0.146.0-node18-core-styles-tooltips.31](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.30...v0.146.0-node18-core-styles-tooltips.31) (2025-11-26)
|
|
7
23
|
|
|
8
24
|
|
|
@@ -46,8 +46,10 @@ var DataSummaryFactory = function DataSummaryFactory(_ref) {
|
|
|
46
46
|
data = _useQuery.data,
|
|
47
47
|
error = _useQuery.error,
|
|
48
48
|
loading = _useQuery.loading;
|
|
49
|
+
var recordId = (0, _helpers2.getRecordId)(entityForQuery, dataRecordId, parent);
|
|
49
50
|
var _useContext = (0, _react.useContext)(_nextjsComponents.MainContext),
|
|
50
51
|
isPreview = _useContext.isPreview;
|
|
52
|
+
if (!recordId) return null;
|
|
51
53
|
if (loading) return '';
|
|
52
54
|
if (error) return error.message;
|
|
53
55
|
if (!data) return null;
|
|
@@ -56,7 +58,6 @@ var DataSummaryFactory = function DataSummaryFactory(_ref) {
|
|
|
56
58
|
var linkProps = (0, _helpers2.getLinkProps)(propsToDisplay);
|
|
57
59
|
var propsQueryString = (0, _helpers.buildPropsQuery)(data, propsToDisplayValues, null, linkProps);
|
|
58
60
|
var dataSummaryQuery = (0, _helpers2.getDataSummaryQuery)(data, isPreview, propsQueryString);
|
|
59
|
-
var recordId = dataRecordId[0] || parent.itemId;
|
|
60
61
|
var isSlider = variant === 'slideSummary';
|
|
61
62
|
return /*#__PURE__*/_react["default"].createElement(_DataSummaryRender["default"], {
|
|
62
63
|
recordId: recordId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataSummaryFactory.js","names":["_react","_interopRequireWildcard","require","_client","_propTypes","_interopRequireDefault","_nextjsComponents","_query","_helpers","_helpers2","_DataSummaryRender","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DataSummaryFactory","_ref","entity","dataRecordId","propsToDisplay","type","useSelectedEntity","elementTitle","modifier","headingStyle","loopProperties","loopLimit","variant","VariantComponent","parent","entityForQuery","itemEntity","_useQuery","useQuery","getSingleEntitySchema","variables","id","data","error","loading","_useContext","useContext","MainContext","isPreview","message","length","propsToDisplayValues","checkPropsToUse","linkProps","getLinkProps","propsQueryString","buildPropsQuery","dataSummaryQuery","getDataSummaryQuery","
|
|
1
|
+
{"version":3,"file":"DataSummaryFactory.js","names":["_react","_interopRequireWildcard","require","_client","_propTypes","_interopRequireDefault","_nextjsComponents","_query","_helpers","_helpers2","_DataSummaryRender","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DataSummaryFactory","_ref","entity","dataRecordId","propsToDisplay","type","useSelectedEntity","elementTitle","modifier","headingStyle","loopProperties","loopLimit","variant","VariantComponent","parent","entityForQuery","itemEntity","_useQuery","useQuery","getSingleEntitySchema","variables","id","data","error","loading","recordId","getRecordId","_useContext","useContext","MainContext","isPreview","message","length","propsToDisplayValues","checkPropsToUse","linkProps","getLinkProps","propsQueryString","buildPropsQuery","dataSummaryQuery","getDataSummaryQuery","isSlider","createElement","query","htmlTag","propTypes","PropTypes","object","isRequired","string","array","bool","number","func","defaultProps","_default","exports"],"sources":["../../../src/components/DataSummary/DataSummaryFactory.js"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport PropTypes from 'prop-types';\nimport { MainContext } from '@blaze-cms/nextjs-components';\nimport { getSingleEntitySchema } from '../../application/query';\nimport { buildPropsQuery, checkPropsToUse } from '../../helpers';\nimport { getDataSummaryQuery, getLinkProps, getRecordId } from './helpers';\nimport DataSummaryRender from './DataSummaryRender';\n\nconst DataSummaryFactory = ({\n entity,\n dataRecordId,\n propsToDisplay,\n type,\n useSelectedEntity,\n elementTitle,\n modifier,\n headingStyle,\n loopProperties,\n loopLimit,\n variant,\n VariantComponent,\n parent\n}) => {\n const entityForQuery = useSelectedEntity ? entity : parent.itemEntity;\n const { data, error, loading } = useQuery(getSingleEntitySchema, {\n variables: { id: entityForQuery }\n });\n\n const recordId = getRecordId(entityForQuery, dataRecordId, parent);\n const { isPreview } = useContext(MainContext);\n\n if (!recordId) return null;\n if (loading) return '';\n if (error) return error.message;\n if (!data) return null;\n if (!propsToDisplay || !propsToDisplay.length) return null;\n const propsToDisplayValues = checkPropsToUse(propsToDisplay);\n const linkProps = getLinkProps(propsToDisplay);\n const propsQueryString = buildPropsQuery(data, propsToDisplayValues, null, linkProps);\n const dataSummaryQuery = getDataSummaryQuery(data, isPreview, propsQueryString);\n const isSlider = variant === 'slideSummary';\n\n return (\n <DataSummaryRender\n recordId={recordId}\n propsToDisplay={propsToDisplay}\n loopProperties={loopProperties}\n loopLimit={loopLimit}\n query={dataSummaryQuery}\n type={type}\n elementTitle={elementTitle}\n modifier={modifier}\n htmlTag={headingStyle}\n variant={variant}\n VariantComponent={VariantComponent}\n isSlider={isSlider}\n />\n );\n};\n\nDataSummaryFactory.propTypes = {\n parent: PropTypes.object.isRequired,\n type: PropTypes.string,\n dataRecordId: PropTypes.array,\n propsToDisplay: PropTypes.array,\n entity: PropTypes.string,\n useSelectedEntity: PropTypes.bool,\n elementTitle: PropTypes.string,\n modifier: PropTypes.string,\n headingStyle: PropTypes.string,\n loopProperties: PropTypes.array,\n loopLimit: PropTypes.number,\n variant: PropTypes.string,\n VariantComponent: PropTypes.func\n};\n\nDataSummaryFactory.defaultProps = {\n type: 'text',\n dataRecordId: [],\n propsToDisplay: [],\n useSelectedEntity: true,\n entity: '',\n elementTitle: '',\n mod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AACC,MAAM,CAACC,UAAU;EACnC3C,IAAI,EAAEyC,qBAAS,CAACG,MAAM;EACtB9C,YAAY,EAAE2C,qBAAS,CAACI,KAAK;EAC7B9C,cAAc,EAAE0C,qBAAS,CAACI,KAAK;EAC/BhD,MAAM,EAAE4C,qBAAS,CAACG,MAAM;EACxB3C,iBAAiB,EAAEwC,qBAAS,CAACK,IAAI;EACjC5C,YAAY,EAAEuC,qBAAS,CAACG,MAAM;EAC9BzC,QAAQ,EAAEsC,qBAAS,CAACG,MAAM;EAC1BxC,YAAY,EAAEqC,qBAAS,CAACG,MAAM;EAC9BvC,cAAc,EAAEoC,qBAAS,CAACI,KAAK;EAC/BvC,SAAS,EAAEmC,qBAAS,CAACM,MAAM;EAC3BxC,OAAO,EAAEkC,qBAAS,CAACG,MAAM;EACzBpC,gBAAgB,EAAEiC,qBAAS,CAACO;AAC9B,CAAC;AAEDrD,kBAAkB,CAACsD,YAAY,GAAG;EAChCjD,IAAI,EAAE,MAAM;EACZF,YAAY,EAAE,EAAE;EAChBC,cAAc,EAAE,EAAE;EAClBE,iBAAiB,EAAE,IAAI;EACvBJ,MAAM,EAAE,EAAE;EACVK,YAAY,EAAE,EAAE;EAChBC,QAAQ,EAAE,EAAE;EACZC,YAAY,EAAE,IAAI;EAClBC,cAAc,EAAE,EAAE;EAClBC,SAAS,EAAE,CAAC;EACZC,OAAO,EAAE,IAAI;EACbC,gBAAgB,EAAE;AACpB,CAAC;AAAC,IAAA0C,QAAA,GAAAC,OAAA,cAEaxD,kBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.object.define-property.js");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _coreAuthUi = require("@blaze-cms/core-auth-ui");
|
|
11
|
+
var getRecordId = function getRecordId(entityForQuery, dataRecordId, parent) {
|
|
12
|
+
var _dataRecordId = (0, _slicedToArray2["default"])(dataRecordId, 1),
|
|
13
|
+
recordId = _dataRecordId[0];
|
|
14
|
+
var foundUserId;
|
|
15
|
+
if (entityForQuery === 'user' && !recordId) {
|
|
16
|
+
var _checkIfLoggedIn = (0, _coreAuthUi.checkIfLoggedIn)(),
|
|
17
|
+
userId = _checkIfLoggedIn.id;
|
|
18
|
+
foundUserId = userId;
|
|
19
|
+
}
|
|
20
|
+
return foundUserId || recordId || parent && parent.itemId;
|
|
21
|
+
};
|
|
22
|
+
var _default = exports["default"] = getRecordId;
|
|
23
|
+
//# sourceMappingURL=get-record-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-record-id.js","names":["_coreAuthUi","require","getRecordId","entityForQuery","dataRecordId","parent","_dataRecordId","_slicedToArray2","recordId","foundUserId","_checkIfLoggedIn","checkIfLoggedIn","userId","id","itemId","_default","exports"],"sources":["../../../../src/components/DataSummary/helpers/get-record-id.js"],"sourcesContent":["import { checkIfLoggedIn } from '@blaze-cms/core-auth-ui';\n\nconst getRecordId = (entityForQuery, dataRecordId, parent) => {\n const [recordId] = dataRecordId;\n let foundUserId;\n\n if (entityForQuery === 'user' && !recordId) {\n const { id: userId } = checkIfLoggedIn();\n foundUserId = userId;\n }\n return foundUserId || recordId || (parent && parent.itemId);\n};\n\nexport default getRecordId;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CAAIC,cAAc,EAAEC,YAAY,EAAEC,MAAM,EAAK;EAC5D,IAAAC,aAAA,OAAAC,eAAA,aAAmBH,YAAY;IAAxBI,QAAQ,GAAAF,aAAA;EACf,IAAIG,WAAW;EAEf,IAAIN,cAAc,KAAK,MAAM,IAAI,CAACK,QAAQ,EAAE;IAC1C,IAAAE,gBAAA,GAAuB,IAAAC,2BAAe,EAAC,CAAC;MAA5BC,MAAM,GAAAF,gBAAA,CAAVG,EAAE;IACVJ,WAAW,GAAGG,MAAM;EACtB;EACA,OAAOH,WAAW,IAAID,QAAQ,IAAKH,MAAM,IAAIA,MAAM,CAACS,MAAO;AAC7D,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,cAEad,WAAW","ignoreList":[]}
|
|
@@ -41,6 +41,12 @@ Object.defineProperty(exports, "getLinkToPublishedContent", {
|
|
|
41
41
|
return _getLinkToPublishedContent["default"];
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
|
+
Object.defineProperty(exports, "getRecordId", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function get() {
|
|
47
|
+
return _getRecordId["default"];
|
|
48
|
+
}
|
|
49
|
+
});
|
|
44
50
|
Object.defineProperty(exports, "parseBooleanValues", {
|
|
45
51
|
enumerable: true,
|
|
46
52
|
get: function get() {
|
|
@@ -61,4 +67,5 @@ var _buildLoopPropsContent = _interopRequireDefault(require("./build-loop-props-
|
|
|
61
67
|
var _parseBooleanValues = _interopRequireDefault(require("./parse-boolean-values"));
|
|
62
68
|
var _getLinkBasedOnValue = _interopRequireDefault(require("./get-link-based-on-value"));
|
|
63
69
|
var _getLinkProps = _interopRequireDefault(require("./get-link-props"));
|
|
70
|
+
var _getRecordId = _interopRequireDefault(require("./get-record-id"));
|
|
64
71
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_getDataSummaryQuery","_interopRequireDefault","require","_buildPropsToDisplayWithContent","_getLinkToPublishedContent","_stripSummaryPropsContent","_buildLoopPropsContent","_parseBooleanValues","_getLinkBasedOnValue","_getLinkProps"],"sources":["../../../../src/components/DataSummary/helpers/index.js"],"sourcesContent":["import getDataSummaryQuery from './get-data-summary-query';\nimport buildPropsToDisplayWithContent from './build-props-to-display-with-content';\nimport getLinkToPublishedContent from './get-link-to-published-content';\nimport stripSummaryPropsContent from './strip-summary-props-content';\nimport buildLoopPropsContent from './build-loop-props-content';\nimport parseBooleanValues from './parse-boolean-values';\nimport getLinkBasedOnValue from './get-link-based-on-value';\nimport getLinkProps from './get-link-props';\n\nexport {\n getDataSummaryQuery,\n buildPropsToDisplayWithContent,\n getLinkToPublishedContent,\n stripSummaryPropsContent,\n buildLoopPropsContent,\n parseBooleanValues,\n getLinkBasedOnValue,\n getLinkProps\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["_getDataSummaryQuery","_interopRequireDefault","require","_buildPropsToDisplayWithContent","_getLinkToPublishedContent","_stripSummaryPropsContent","_buildLoopPropsContent","_parseBooleanValues","_getLinkBasedOnValue","_getLinkProps","_getRecordId"],"sources":["../../../../src/components/DataSummary/helpers/index.js"],"sourcesContent":["import getDataSummaryQuery from './get-data-summary-query';\nimport buildPropsToDisplayWithContent from './build-props-to-display-with-content';\nimport getLinkToPublishedContent from './get-link-to-published-content';\nimport stripSummaryPropsContent from './strip-summary-props-content';\nimport buildLoopPropsContent from './build-loop-props-content';\nimport parseBooleanValues from './parse-boolean-values';\nimport getLinkBasedOnValue from './get-link-based-on-value';\nimport getLinkProps from './get-link-props';\nimport getRecordId from './get-record-id';\n\nexport {\n getDataSummaryQuery,\n buildPropsToDisplayWithContent,\n getLinkToPublishedContent,\n stripSummaryPropsContent,\n buildLoopPropsContent,\n parseBooleanValues,\n getLinkBasedOnValue,\n getLinkProps,\n getRecordId\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,oBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,+BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,0BAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,yBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,sBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,mBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,oBAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,aAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,YAAA,GAAAT,sBAAA,CAAAC,OAAA","ignoreList":[]}
|
|
@@ -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, getLinkProps } from './helpers';
|
|
7
|
+
import { getDataSummaryQuery, getLinkProps, getRecordId } from './helpers';
|
|
8
8
|
import DataSummaryRender from './DataSummaryRender';
|
|
9
9
|
const DataSummaryFactory = ({
|
|
10
10
|
entity,
|
|
@@ -31,9 +31,11 @@ const DataSummaryFactory = ({
|
|
|
31
31
|
id: entityForQuery
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
+
const recordId = getRecordId(entityForQuery, dataRecordId, parent);
|
|
34
35
|
const {
|
|
35
36
|
isPreview
|
|
36
37
|
} = useContext(MainContext);
|
|
38
|
+
if (!recordId) return null;
|
|
37
39
|
if (loading) return '';
|
|
38
40
|
if (error) return error.message;
|
|
39
41
|
if (!data) return null;
|
|
@@ -42,7 +44,6 @@ const DataSummaryFactory = ({
|
|
|
42
44
|
const linkProps = getLinkProps(propsToDisplay);
|
|
43
45
|
const propsQueryString = buildPropsQuery(data, propsToDisplayValues, null, linkProps);
|
|
44
46
|
const dataSummaryQuery = getDataSummaryQuery(data, isPreview, propsQueryString);
|
|
45
|
-
const recordId = dataRecordId[0] || parent.itemId;
|
|
46
47
|
const isSlider = variant === 'slideSummary';
|
|
47
48
|
return /*#__PURE__*/React.createElement(DataSummaryRender, {
|
|
48
49
|
recordId: recordId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataSummaryFactory.js","names":["React","useContext","useQuery","PropTypes","MainContext","getSingleEntitySchema","buildPropsQuery","checkPropsToUse","getDataSummaryQuery","getLinkProps","DataSummaryRender","DataSummaryFactory","entity","dataRecordId","propsToDisplay","type","useSelectedEntity","elementTitle","modifier","headingStyle","loopProperties","loopLimit","variant","VariantComponent","parent","entityForQuery","itemEntity","data","error","loading","variables","id","isPreview","message","length","propsToDisplayValues","linkProps","propsQueryString","dataSummaryQuery","
|
|
1
|
+
{"version":3,"file":"DataSummaryFactory.js","names":["React","useContext","useQuery","PropTypes","MainContext","getSingleEntitySchema","buildPropsQuery","checkPropsToUse","getDataSummaryQuery","getLinkProps","getRecordId","DataSummaryRender","DataSummaryFactory","entity","dataRecordId","propsToDisplay","type","useSelectedEntity","elementTitle","modifier","headingStyle","loopProperties","loopLimit","variant","VariantComponent","parent","entityForQuery","itemEntity","data","error","loading","variables","id","recordId","isPreview","message","length","propsToDisplayValues","linkProps","propsQueryString","dataSummaryQuery","isSlider","createElement","query","htmlTag","propTypes","object","isRequired","string","array","bool","number","func","defaultProps"],"sources":["../../../src/components/DataSummary/DataSummaryFactory.js"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport PropTypes from 'prop-types';\nimport { MainContext } from '@blaze-cms/nextjs-components';\nimport { getSingleEntitySchema } from '../../application/query';\nimport { buildPropsQuery, checkPropsToUse } from '../../helpers';\nimport { getDataSummaryQuery, getLinkProps, getRecordId } from './helpers';\nimport DataSummaryRender from './DataSummaryRender';\n\nconst DataSummaryFactory = ({\n entity,\n dataRecordId,\n propsToDisplay,\n type,\n useSelectedEntity,\n elementTitle,\n modifier,\n headingStyle,\n loopProperties,\n loopLimit,\n variant,\n VariantComponent,\n parent\n}) => {\n const entityForQuery = useSelectedEntity ? entity : parent.itemEntity;\n const { data, error, loading } = useQuery(getSingleEntitySchema, {\n variables: { id: entityForQuery }\n });\n\n const recordId = getRecordId(entityForQuery, dataRecordId, parent);\n const { isPreview } = useContext(MainContext);\n\n if (!recordId) return null;\n if (loading) return '';\n if (error) return error.message;\n if (!data) return null;\n if (!propsToDisplay || !propsToDisplay.length) return null;\n const propsToDisplayValues = checkPropsToUse(propsToDisplay);\n const linkProps = getLinkProps(propsToDisplay);\n const propsQueryString = buildPropsQuery(data, propsToDisplayValues, null, linkProps);\n const dataSummaryQuery = getDataSummaryQuery(data, isPreview, propsQueryString);\n const isSlider = variant === 'slideSummary';\n\n return (\n <DataSummaryRender\n recordId={recordId}\n propsToDisplay={propsToDisplay}\n loopProperties={loopProperties}\n loopLimit={loopLimit}\n query={dataSummaryQuery}\n type={type}\n elementTitle={elementTitle}\n modifier={modifier}\n htmlTag={headingStyle}\n variant={variant}\n VariantComponent={VariantComponent}\n isSlider={isSlider}\n />\n );\n};\n\nDataSummaryFactory.propTypes = {\n parent: PropTypes.object.isRequired,\n type: PropTypes.string,\n dataRecordId: PropTypes.array,\n propsToDisplay: PropTypes.array,\n entity: PropTypes.string,\n useSelectedEntity: PropTypes.bool,\n elementTitle: PropTypes.string,\n modifier: PropTypes.string,\n headingStyle: PropTypes.string,\n loopProperties: PropTypes.array,\n loopLimit: PropTypes.number,\n variant: PropTypes.string,\n VariantComponent: PropTypes.func\n};\n\nDataSummaryFactory.defaultProps = {\n type: 'text',\n dataRecordId: [],\n propsToDisplay: [],\n useSelectedEntity: true,\n entity: '',\n elementTitle: '',\n modifier: '',\n headingStyle: 'h2',\n loopProperties: [],\n loopLimit: 0,\n variant: null,\n VariantComponent: null\n};\n\nexport default DataSummaryFactory;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAAS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E;EAClBE,iBAAiB,EAAE,IAAI;EACvBJ,MAAM,EAAE,EAAE;EACVK,YAAY,EAAE,EAAE;EAChBC,QAAQ,EAAE,EAAE;EACZC,YAAY,EAAE,IAAI;EAClBC,cAAc,EAAE,EAAE;EAClBC,SAAS,EAAE,CAAC;EACZC,OAAO,EAAE,IAAI;EACbC,gBAAgB,EAAE;AACpB,CAAC;AAED,eAAeZ,kBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { checkIfLoggedIn } from '@blaze-cms/core-auth-ui';
|
|
2
|
+
const getRecordId = (entityForQuery, dataRecordId, parent) => {
|
|
3
|
+
const [recordId] = dataRecordId;
|
|
4
|
+
let foundUserId;
|
|
5
|
+
if (entityForQuery === 'user' && !recordId) {
|
|
6
|
+
const {
|
|
7
|
+
id: userId
|
|
8
|
+
} = checkIfLoggedIn();
|
|
9
|
+
foundUserId = userId;
|
|
10
|
+
}
|
|
11
|
+
return foundUserId || recordId || parent && parent.itemId;
|
|
12
|
+
};
|
|
13
|
+
export default getRecordId;
|
|
14
|
+
//# sourceMappingURL=get-record-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-record-id.js","names":["checkIfLoggedIn","getRecordId","entityForQuery","dataRecordId","parent","recordId","foundUserId","id","userId","itemId"],"sources":["../../../../src/components/DataSummary/helpers/get-record-id.js"],"sourcesContent":["import { checkIfLoggedIn } from '@blaze-cms/core-auth-ui';\n\nconst getRecordId = (entityForQuery, dataRecordId, parent) => {\n const [recordId] = dataRecordId;\n let foundUserId;\n\n if (entityForQuery === 'user' && !recordId) {\n const { id: userId } = checkIfLoggedIn();\n foundUserId = userId;\n }\n return foundUserId || recordId || (parent && parent.itemId);\n};\n\nexport default getRecordId;\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,yBAAyB;AAEzD,MAAMC,WAAW,GAAGA,CAACC,cAAc,EAAEC,YAAY,EAAEC,MAAM,KAAK;EAC5D,MAAM,CAACC,QAAQ,CAAC,GAAGF,YAAY;EAC/B,IAAIG,WAAW;EAEf,IAAIJ,cAAc,KAAK,MAAM,IAAI,CAACG,QAAQ,EAAE;IAC1C,MAAM;MAAEE,EAAE,EAAEC;IAAO,CAAC,GAAGR,eAAe,CAAC,CAAC;IACxCM,WAAW,GAAGE,MAAM;EACtB;EACA,OAAOF,WAAW,IAAID,QAAQ,IAAKD,MAAM,IAAIA,MAAM,CAACK,MAAO;AAC7D,CAAC;AAED,eAAeR,WAAW","ignoreList":[]}
|
|
@@ -6,5 +6,6 @@ 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
8
|
import getLinkProps from './get-link-props';
|
|
9
|
-
|
|
9
|
+
import getRecordId from './get-record-id';
|
|
10
|
+
export { getDataSummaryQuery, buildPropsToDisplayWithContent, getLinkToPublishedContent, stripSummaryPropsContent, buildLoopPropsContent, parseBooleanValues, getLinkBasedOnValue, getLinkProps, getRecordId };
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getDataSummaryQuery","buildPropsToDisplayWithContent","getLinkToPublishedContent","stripSummaryPropsContent","buildLoopPropsContent","parseBooleanValues","getLinkBasedOnValue","getLinkProps"],"sources":["../../../../src/components/DataSummary/helpers/index.js"],"sourcesContent":["import getDataSummaryQuery from './get-data-summary-query';\nimport buildPropsToDisplayWithContent from './build-props-to-display-with-content';\nimport getLinkToPublishedContent from './get-link-to-published-content';\nimport stripSummaryPropsContent from './strip-summary-props-content';\nimport buildLoopPropsContent from './build-loop-props-content';\nimport parseBooleanValues from './parse-boolean-values';\nimport getLinkBasedOnValue from './get-link-based-on-value';\nimport getLinkProps from './get-link-props';\n\nexport {\n getDataSummaryQuery,\n buildPropsToDisplayWithContent,\n getLinkToPublishedContent,\n stripSummaryPropsContent,\n buildLoopPropsContent,\n parseBooleanValues,\n getLinkBasedOnValue,\n getLinkProps\n};\n"],"mappings":"AAAA,OAAOA,mBAAmB,MAAM,0BAA0B;AAC1D,OAAOC,8BAA8B,MAAM,uCAAuC;AAClF,OAAOC,yBAAyB,MAAM,iCAAiC;AACvE,OAAOC,wBAAwB,MAAM,+BAA+B;AACpE,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,kBAAkB,MAAM,wBAAwB;AACvD,OAAOC,mBAAmB,MAAM,2BAA2B;AAC3D,OAAOC,YAAY,MAAM,kBAAkB;
|
|
1
|
+
{"version":3,"file":"index.js","names":["getDataSummaryQuery","buildPropsToDisplayWithContent","getLinkToPublishedContent","stripSummaryPropsContent","buildLoopPropsContent","parseBooleanValues","getLinkBasedOnValue","getLinkProps","getRecordId"],"sources":["../../../../src/components/DataSummary/helpers/index.js"],"sourcesContent":["import getDataSummaryQuery from './get-data-summary-query';\nimport buildPropsToDisplayWithContent from './build-props-to-display-with-content';\nimport getLinkToPublishedContent from './get-link-to-published-content';\nimport stripSummaryPropsContent from './strip-summary-props-content';\nimport buildLoopPropsContent from './build-loop-props-content';\nimport parseBooleanValues from './parse-boolean-values';\nimport getLinkBasedOnValue from './get-link-based-on-value';\nimport getLinkProps from './get-link-props';\nimport getRecordId from './get-record-id';\n\nexport {\n getDataSummaryQuery,\n buildPropsToDisplayWithContent,\n getLinkToPublishedContent,\n stripSummaryPropsContent,\n buildLoopPropsContent,\n parseBooleanValues,\n getLinkBasedOnValue,\n getLinkProps,\n getRecordId\n};\n"],"mappings":"AAAA,OAAOA,mBAAmB,MAAM,0BAA0B;AAC1D,OAAOC,8BAA8B,MAAM,uCAAuC;AAClF,OAAOC,yBAAyB,MAAM,iCAAiC;AACvE,OAAOC,wBAAwB,MAAM,+BAA+B;AACpE,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,kBAAkB,MAAM,wBAAwB;AACvD,OAAOC,mBAAmB,MAAM,2BAA2B;AAC3D,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,WAAW,MAAM,iBAAiB;AAEzC,SACER,mBAAmB,EACnBC,8BAA8B,EAC9BC,yBAAyB,EACzBC,wBAAwB,EACxBC,qBAAqB,EACrBC,kBAAkB,EAClBC,mBAAmB,EACnBC,YAAY,EACZC,WAAW","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/react-page-builder",
|
|
3
|
-
"version": "0.146.0-node18-core-styles-tooltips.
|
|
3
|
+
"version": "0.146.0-node18-core-styles-tooltips.34",
|
|
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.146.0-node18-core-styles-tooltips.
|
|
30
|
+
"@blaze-cms/core-auth-ui": "0.146.0-node18-core-styles-tooltips.34",
|
|
31
31
|
"@blaze-cms/core-errors": "0.146.0-node18-core-styles-tooltips.3",
|
|
32
32
|
"@blaze-cms/core-errors-ui": "0.146.0-node18-core-styles-tooltips.3",
|
|
33
33
|
"@blaze-cms/image-cdn-react": "0.3.0-alpha.7",
|
|
34
|
-
"@blaze-cms/nextjs-components": "0.146.0-node18-core-styles-tooltips.
|
|
34
|
+
"@blaze-cms/nextjs-components": "0.146.0-node18-core-styles-tooltips.32",
|
|
35
35
|
"@blaze-cms/plugin-search-ui": "0.146.0-node18-core-styles-tooltips.30",
|
|
36
36
|
"@blaze-cms/setup-ui": "0.146.0-node18-core-styles-tooltips.3",
|
|
37
37
|
"@blaze-cms/utils": "0.146.0-node18-core-styles-tooltips.30",
|
|
38
|
-
"@blaze-cms/utils-handlebars": "0.146.0-node18-core-styles-tooltips.
|
|
38
|
+
"@blaze-cms/utils-handlebars": "0.146.0-node18-core-styles-tooltips.32",
|
|
39
39
|
"@blaze-react/badge": "^0.7.0",
|
|
40
40
|
"@blaze-react/breadcrumb": "0.8.0-alpha.60",
|
|
41
41
|
"@blaze-react/button": "0.8.0-alpha.82",
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"lib/*",
|
|
93
93
|
"lib-es/*"
|
|
94
94
|
],
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "bc44cc75ae3c732cf5582cac16a88f73dab6a99b"
|
|
96
96
|
}
|
|
@@ -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, getLinkProps } from './helpers';
|
|
7
|
+
import { getDataSummaryQuery, getLinkProps, getRecordId } from './helpers';
|
|
8
8
|
import DataSummaryRender from './DataSummaryRender';
|
|
9
9
|
|
|
10
10
|
const DataSummaryFactory = ({
|
|
@@ -27,7 +27,10 @@ const DataSummaryFactory = ({
|
|
|
27
27
|
variables: { id: entityForQuery }
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
+
const recordId = getRecordId(entityForQuery, dataRecordId, parent);
|
|
30
31
|
const { isPreview } = useContext(MainContext);
|
|
32
|
+
|
|
33
|
+
if (!recordId) return null;
|
|
31
34
|
if (loading) return '';
|
|
32
35
|
if (error) return error.message;
|
|
33
36
|
if (!data) return null;
|
|
@@ -36,7 +39,6 @@ const DataSummaryFactory = ({
|
|
|
36
39
|
const linkProps = getLinkProps(propsToDisplay);
|
|
37
40
|
const propsQueryString = buildPropsQuery(data, propsToDisplayValues, null, linkProps);
|
|
38
41
|
const dataSummaryQuery = getDataSummaryQuery(data, isPreview, propsQueryString);
|
|
39
|
-
const recordId = dataRecordId[0] || parent.itemId;
|
|
40
42
|
const isSlider = variant === 'slideSummary';
|
|
41
43
|
|
|
42
44
|
return (
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { checkIfLoggedIn } from '@blaze-cms/core-auth-ui';
|
|
2
|
+
|
|
3
|
+
const getRecordId = (entityForQuery, dataRecordId, parent) => {
|
|
4
|
+
const [recordId] = dataRecordId;
|
|
5
|
+
let foundUserId;
|
|
6
|
+
|
|
7
|
+
if (entityForQuery === 'user' && !recordId) {
|
|
8
|
+
const { id: userId } = checkIfLoggedIn();
|
|
9
|
+
foundUserId = userId;
|
|
10
|
+
}
|
|
11
|
+
return foundUserId || recordId || (parent && parent.itemId);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default getRecordId;
|
|
@@ -6,6 +6,7 @@ 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
8
|
import getLinkProps from './get-link-props';
|
|
9
|
+
import getRecordId from './get-record-id';
|
|
9
10
|
|
|
10
11
|
export {
|
|
11
12
|
getDataSummaryQuery,
|
|
@@ -15,5 +16,6 @@ export {
|
|
|
15
16
|
buildLoopPropsContent,
|
|
16
17
|
parseBooleanValues,
|
|
17
18
|
getLinkBasedOnValue,
|
|
18
|
-
getLinkProps
|
|
19
|
+
getLinkProps,
|
|
20
|
+
getRecordId
|
|
19
21
|
};
|
|
@@ -4,8 +4,4 @@ exports[`DataSummaryFactory component should not render if no data is returned 1
|
|
|
4
4
|
|
|
5
5
|
exports[`DataSummaryFactory component should render without throwing an error for heading_large 1`] = `<DocumentFragment />`;
|
|
6
6
|
|
|
7
|
-
exports[`DataSummaryFactory component should return error message if exists 1`] =
|
|
8
|
-
<DocumentFragment>
|
|
9
|
-
No Entity
|
|
10
|
-
</DocumentFragment>
|
|
11
|
-
`;
|
|
7
|
+
exports[`DataSummaryFactory component should return error message if exists 1`] = `<DocumentFragment />`;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import getRecordId from '../../../../../../src/components/DataSummary/helpers/get-record-id';
|
|
2
|
+
|
|
3
|
+
// Mock the auth module
|
|
4
|
+
jest.mock('@blaze-cms/core-auth-ui', () => ({
|
|
5
|
+
checkIfLoggedIn: jest.fn()
|
|
6
|
+
}));
|
|
7
|
+
|
|
8
|
+
const { checkIfLoggedIn } = require('@blaze-cms/core-auth-ui');
|
|
9
|
+
|
|
10
|
+
describe('getRecordId', () => {
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
jest.clearAllMocks();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('when entityForQuery is "user" and dataRecordId is empty', () => {
|
|
16
|
+
it('should return the logged-in user ID when available', () => {
|
|
17
|
+
const mockUserId = 'user-123';
|
|
18
|
+
checkIfLoggedIn.mockReturnValue({ id: mockUserId });
|
|
19
|
+
|
|
20
|
+
const result = getRecordId('user', [], { itemId: 'parent-id' });
|
|
21
|
+
|
|
22
|
+
expect(checkIfLoggedIn).toHaveBeenCalledTimes(1);
|
|
23
|
+
expect(result).toBe(mockUserId);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should fallback to parent.itemId when user ID is null', () => {
|
|
27
|
+
checkIfLoggedIn.mockReturnValue({ id: null });
|
|
28
|
+
|
|
29
|
+
const result = getRecordId('user', [], { itemId: 'parent-id' });
|
|
30
|
+
|
|
31
|
+
expect(checkIfLoggedIn).toHaveBeenCalledTimes(1);
|
|
32
|
+
expect(result).toBe('parent-id');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should fallback to parent.itemId when user ID is empty string', () => {
|
|
36
|
+
checkIfLoggedIn.mockReturnValue({ id: '' });
|
|
37
|
+
|
|
38
|
+
const result = getRecordId('user', [], { itemId: 'parent-id' });
|
|
39
|
+
|
|
40
|
+
expect(checkIfLoggedIn).toHaveBeenCalledTimes(1);
|
|
41
|
+
expect(result).toBe('parent-id');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should fallback to parent.itemId when user ID is 0', () => {
|
|
45
|
+
checkIfLoggedIn.mockReturnValue({ id: 0 });
|
|
46
|
+
|
|
47
|
+
const result = getRecordId('user', [], { itemId: 'parent-id' });
|
|
48
|
+
|
|
49
|
+
expect(checkIfLoggedIn).toHaveBeenCalledTimes(1);
|
|
50
|
+
expect(result).toBe('parent-id');
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('when entityForQuery is "user" but dataRecordId has values', () => {
|
|
55
|
+
it('should return the first dataRecordId without checking user auth', () => {
|
|
56
|
+
const result = getRecordId('user', ['record-1', 'record-2'], { itemId: 'parent-id' });
|
|
57
|
+
|
|
58
|
+
expect(checkIfLoggedIn).not.toHaveBeenCalled();
|
|
59
|
+
expect(result).toBe('record-1');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should check logged-in user when first dataRecordId is falsy and fallback to parent.itemId', () => {
|
|
63
|
+
checkIfLoggedIn.mockReturnValue({ id: null });
|
|
64
|
+
const result = getRecordId('user', [null, 'record-2'], { itemId: 'parent-id' });
|
|
65
|
+
|
|
66
|
+
expect(checkIfLoggedIn).toHaveBeenCalledTimes(1);
|
|
67
|
+
expect(result).toBe('parent-id');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should check logged-in user when first dataRecordId is empty string and fallback to parent.itemId', () => {
|
|
71
|
+
checkIfLoggedIn.mockReturnValue({ id: '' });
|
|
72
|
+
const result = getRecordId('user', ['', 'record-2'], { itemId: 'parent-id' });
|
|
73
|
+
|
|
74
|
+
expect(checkIfLoggedIn).toHaveBeenCalledTimes(1);
|
|
75
|
+
expect(result).toBe('parent-id');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('when entityForQuery is not "user"', () => {
|
|
80
|
+
it('should return the first dataRecordId when available', () => {
|
|
81
|
+
const result = getRecordId('post', ['record-1', 'record-2'], { itemId: 'parent-id' });
|
|
82
|
+
|
|
83
|
+
expect(checkIfLoggedIn).not.toHaveBeenCalled();
|
|
84
|
+
expect(result).toBe('record-1');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should return parent.itemId when dataRecordId is empty', () => {
|
|
88
|
+
const result = getRecordId('post', [], { itemId: 'parent-id' });
|
|
89
|
+
|
|
90
|
+
expect(checkIfLoggedIn).not.toHaveBeenCalled();
|
|
91
|
+
expect(result).toBe('parent-id');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should return parent.itemId when first dataRecordId is falsy', () => {
|
|
95
|
+
const result = getRecordId('post', [null, 'record-2'], { itemId: 'parent-id' });
|
|
96
|
+
|
|
97
|
+
expect(checkIfLoggedIn).not.toHaveBeenCalled();
|
|
98
|
+
expect(result).toBe('parent-id');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('should return parent.itemId when first dataRecordId is empty string', () => {
|
|
102
|
+
const result = getRecordId('post', ['', 'record-2'], { itemId: 'parent-id' });
|
|
103
|
+
|
|
104
|
+
expect(checkIfLoggedIn).not.toHaveBeenCalled();
|
|
105
|
+
expect(result).toBe('parent-id');
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
});
|