@contentful/field-editor-reference 6.21.1 → 6.21.2
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.
|
@@ -41,21 +41,15 @@ function useContentTypePermissions({ entityType, validations, sdk, allContentTyp
|
|
|
41
41
|
const [creatableContentTypes, setCreatableContentTypes] = (0, _react.useState)(availableContentTypes);
|
|
42
42
|
const { canPerformActionOnEntryOfType } = (0, _useAccessApi.useAccessApi)(sdk.access);
|
|
43
43
|
(0, _react.useEffect)(()=>{
|
|
44
|
-
function getContentTypes(action) {
|
|
45
|
-
return filter(availableContentTypes, (ct)=>canPerformActionOnEntryOfType(action, ct.sys.id));
|
|
46
|
-
}
|
|
47
44
|
async function checkContentTypeAccess() {
|
|
48
|
-
const creatable = await
|
|
49
|
-
|
|
50
|
-
setCreatableContentTypes(creatable);
|
|
51
|
-
}
|
|
45
|
+
const creatable = await filter(availableContentTypes, (ct)=>canPerformActionOnEntryOfType('create', ct.sys.id));
|
|
46
|
+
setCreatableContentTypes((creatableContentTypes)=>(0, _isEqual.default)(creatable, creatableContentTypes) ? creatableContentTypes : creatable);
|
|
52
47
|
}
|
|
53
48
|
if (availableContentTypes.length > 0) {
|
|
54
49
|
void checkContentTypeAccess();
|
|
55
50
|
}
|
|
56
51
|
}, [
|
|
57
|
-
availableContentTypes
|
|
58
|
-
creatableContentTypes
|
|
52
|
+
availableContentTypes
|
|
59
53
|
]);
|
|
60
54
|
return {
|
|
61
55
|
creatableContentTypes,
|
|
@@ -17,8 +17,8 @@ function useEditorPermissions({ sdk, entityType, parameters, allContentTypes })
|
|
|
17
17
|
const itemsValidations = sdk.field.type === 'Array' ? sdk.field.items?.validations : undefined;
|
|
18
18
|
const validations = (0, _react.useMemo)(()=>(0, _fromFieldValidations.fromFieldValidations)(sdk.field), [
|
|
19
19
|
sdk.field,
|
|
20
|
-
fieldValidations,
|
|
21
|
-
itemsValidations
|
|
20
|
+
JSON.stringify(fieldValidations),
|
|
21
|
+
JSON.stringify(itemsValidations)
|
|
22
22
|
]);
|
|
23
23
|
const [canCreateEntity, setCanCreateEntity] = (0, _react.useState)(true);
|
|
24
24
|
const [canLinkEntity, setCanLinkEntity] = (0, _react.useState)(true);
|
|
@@ -26,21 +26,15 @@ export function useContentTypePermissions({ entityType, validations, sdk, allCon
|
|
|
26
26
|
const [creatableContentTypes, setCreatableContentTypes] = useState(availableContentTypes);
|
|
27
27
|
const { canPerformActionOnEntryOfType } = useAccessApi(sdk.access);
|
|
28
28
|
useEffect(()=>{
|
|
29
|
-
function getContentTypes(action) {
|
|
30
|
-
return filter(availableContentTypes, (ct)=>canPerformActionOnEntryOfType(action, ct.sys.id));
|
|
31
|
-
}
|
|
32
29
|
async function checkContentTypeAccess() {
|
|
33
|
-
const creatable = await
|
|
34
|
-
|
|
35
|
-
setCreatableContentTypes(creatable);
|
|
36
|
-
}
|
|
30
|
+
const creatable = await filter(availableContentTypes, (ct)=>canPerformActionOnEntryOfType('create', ct.sys.id));
|
|
31
|
+
setCreatableContentTypes((creatableContentTypes)=>isEqual(creatable, creatableContentTypes) ? creatableContentTypes : creatable);
|
|
37
32
|
}
|
|
38
33
|
if (availableContentTypes.length > 0) {
|
|
39
34
|
void checkContentTypeAccess();
|
|
40
35
|
}
|
|
41
36
|
}, [
|
|
42
|
-
availableContentTypes
|
|
43
|
-
creatableContentTypes
|
|
37
|
+
availableContentTypes
|
|
44
38
|
]);
|
|
45
39
|
return {
|
|
46
40
|
creatableContentTypes,
|
|
@@ -7,8 +7,8 @@ export function useEditorPermissions({ sdk, entityType, parameters, allContentTy
|
|
|
7
7
|
const itemsValidations = sdk.field.type === 'Array' ? sdk.field.items?.validations : undefined;
|
|
8
8
|
const validations = useMemo(()=>fromFieldValidations(sdk.field), [
|
|
9
9
|
sdk.field,
|
|
10
|
-
fieldValidations,
|
|
11
|
-
itemsValidations
|
|
10
|
+
JSON.stringify(fieldValidations),
|
|
11
|
+
JSON.stringify(itemsValidations)
|
|
12
12
|
]);
|
|
13
13
|
const [canCreateEntity, setCanCreateEntity] = useState(true);
|
|
14
14
|
const [canLinkEntity, setCanLinkEntity] = useState(true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-reference",
|
|
3
|
-
"version": "6.21.
|
|
3
|
+
"version": "6.21.2",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"registry": "https://npm.pkg.github.com/"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "cd410dabfce5b53342a2211863edbe0cc00e7c87"
|
|
72
72
|
}
|