@strapi/content-manager 0.0.0-experimental.e0df4d50334a17a1beb3d203bff414fbbff62f7b → 0.0.0-experimental.e12978dcee698470990e9c5c63384faf2c307443
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/dist/admin/chunks/{ComponentConfigurationPage-C5H-5L1u.js → ComponentConfigurationPage-Ci3dN40b.js} +5 -6
- package/dist/admin/chunks/{ComponentConfigurationPage-C5H-5L1u.js.map → ComponentConfigurationPage-Ci3dN40b.js.map} +1 -1
- package/dist/admin/chunks/{ComponentConfigurationPage-BN2kOtDm.mjs → ComponentConfigurationPage-DFPdl9pm.mjs} +5 -6
- package/dist/admin/chunks/{ComponentConfigurationPage-BN2kOtDm.mjs.map → ComponentConfigurationPage-DFPdl9pm.mjs.map} +1 -1
- package/dist/admin/chunks/{EditConfigurationPage-BExtZuB7.js → EditConfigurationPage-7xe8u-Pp.js} +5 -6
- package/dist/admin/chunks/{EditConfigurationPage-BExtZuB7.js.map → EditConfigurationPage-7xe8u-Pp.js.map} +1 -1
- package/dist/admin/chunks/{EditConfigurationPage-tMgOELQG.mjs → EditConfigurationPage-BFse-urJ.mjs} +5 -6
- package/dist/admin/chunks/{EditConfigurationPage-tMgOELQG.mjs.map → EditConfigurationPage-BFse-urJ.mjs.map} +1 -1
- package/dist/admin/chunks/{EditViewPage-CYe7wAXF.mjs → EditViewPage-BNpRr7fZ.mjs} +99 -98
- package/dist/admin/chunks/EditViewPage-BNpRr7fZ.mjs.map +1 -0
- package/dist/admin/chunks/{EditViewPage-DFkloeMZ.js → EditViewPage-CwYSs8Cq.js} +99 -98
- package/dist/admin/chunks/EditViewPage-CwYSs8Cq.js.map +1 -0
- package/dist/admin/chunks/{Form-DTO0ZIaB.mjs → Form-D9Ee-exF.mjs} +3 -3
- package/dist/admin/chunks/{Form-DTO0ZIaB.mjs.map → Form-D9Ee-exF.mjs.map} +1 -1
- package/dist/admin/chunks/{Form-DGUP3zQO.js → Form-DDbxreII.js} +5 -5
- package/dist/admin/chunks/{Form-DGUP3zQO.js.map → Form-DDbxreII.js.map} +1 -1
- package/dist/admin/chunks/{History-CQznK1pG.js → History-D5joC76n.js} +17 -13
- package/dist/admin/chunks/History-D5joC76n.js.map +1 -0
- package/dist/admin/chunks/{History-C333pgXF.mjs → History-FuD7Tp5I.mjs} +16 -12
- package/dist/admin/chunks/History-FuD7Tp5I.mjs.map +1 -0
- package/dist/admin/chunks/{Input-BexkC_pp.mjs → Input-BHucdqva.mjs} +1108 -47
- package/dist/admin/chunks/Input-BHucdqva.mjs.map +1 -0
- package/dist/admin/chunks/{Input-DLJZHw9Y.js → Input-BJCenRYN.js} +1121 -57
- package/dist/admin/chunks/Input-BJCenRYN.js.map +1 -0
- package/dist/admin/chunks/{ListConfigurationPage-BX2WR7MI.mjs → ListConfigurationPage-3kSfz9xV.mjs} +4 -5
- package/dist/admin/chunks/{ListConfigurationPage-BX2WR7MI.mjs.map → ListConfigurationPage-3kSfz9xV.mjs.map} +1 -1
- package/dist/admin/chunks/{ListConfigurationPage-71I_stAM.js → ListConfigurationPage-CgJEcEkD.js} +6 -7
- package/dist/admin/chunks/{ListConfigurationPage-71I_stAM.js.map → ListConfigurationPage-CgJEcEkD.js.map} +1 -1
- package/dist/admin/chunks/{ListViewPage-DV3heO4F.js → ListViewPage-CvQ1w8IW.js} +7 -8
- package/dist/admin/chunks/{ListViewPage-DV3heO4F.js.map → ListViewPage-CvQ1w8IW.js.map} +1 -1
- package/dist/admin/chunks/{ListViewPage-BDeT3Dkk.mjs → ListViewPage-DPUYRHss.mjs} +3 -4
- package/dist/admin/chunks/{ListViewPage-BDeT3Dkk.mjs.map → ListViewPage-DPUYRHss.mjs.map} +1 -1
- package/dist/admin/chunks/{NoContentTypePage-9JHYpYVX.mjs → NoContentTypePage-BRLLtjLb.mjs} +2 -2
- package/dist/admin/chunks/{NoContentTypePage-9JHYpYVX.mjs.map → NoContentTypePage-BRLLtjLb.mjs.map} +1 -1
- package/dist/admin/chunks/{NoContentTypePage-COih9y2J.js → NoContentTypePage-C5Vut1Af.js} +2 -2
- package/dist/admin/chunks/{NoContentTypePage-COih9y2J.js.map → NoContentTypePage-C5Vut1Af.js.map} +1 -1
- package/dist/admin/chunks/{NoPermissionsPage-DTe9I47q.mjs → NoPermissionsPage-B5HJbcjm.mjs} +2 -2
- package/dist/admin/chunks/{NoPermissionsPage-DTe9I47q.mjs.map → NoPermissionsPage-B5HJbcjm.mjs.map} +1 -1
- package/dist/admin/chunks/{NoPermissionsPage-DGAwRIlN.js → NoPermissionsPage-BBXnpc7M.js} +2 -2
- package/dist/admin/chunks/{NoPermissionsPage-DGAwRIlN.js.map → NoPermissionsPage-BBXnpc7M.js.map} +1 -1
- package/dist/admin/chunks/{Preview-BEq0FXda.mjs → Preview-C3lnOgQx.mjs} +244 -116
- package/dist/admin/chunks/Preview-C3lnOgQx.mjs.map +1 -0
- package/dist/admin/chunks/{Preview-CXtc9yEV.js → Preview-DB7ZGawL.js} +240 -112
- package/dist/admin/chunks/Preview-DB7ZGawL.js.map +1 -0
- package/dist/admin/chunks/{en-C1CjdAtC.js → en-CH__IC8g.js} +4 -1
- package/dist/admin/chunks/{en-C1CjdAtC.js.map → en-CH__IC8g.js.map} +1 -1
- package/dist/admin/chunks/{en-LfhocNG2.mjs → en-DBP0Gaid.mjs} +4 -1
- package/dist/admin/chunks/{en-LfhocNG2.mjs.map → en-DBP0Gaid.mjs.map} +1 -1
- package/dist/admin/chunks/{index-Cs6qwFQu.mjs → index-DYrCidCq.mjs} +225 -140
- package/dist/admin/chunks/index-DYrCidCq.mjs.map +1 -0
- package/dist/admin/chunks/{index-BHimg6jW.js → index-DoUQnFTk.js} +227 -138
- package/dist/admin/chunks/index-DoUQnFTk.js.map +1 -0
- package/dist/admin/chunks/{layout-Dtahn4Ue.js → layout-CqndYVtU.js} +86 -13
- package/dist/admin/chunks/layout-CqndYVtU.js.map +1 -0
- package/dist/admin/chunks/{layout-DStNia_P.mjs → layout-D2NJmgCw.mjs} +78 -5
- package/dist/admin/chunks/layout-D2NJmgCw.mjs.map +1 -0
- package/dist/admin/chunks/{useDragAndDrop-gcqEJMnO.js → objects-BJTP843m.js} +73 -1
- package/dist/admin/chunks/objects-BJTP843m.js.map +1 -0
- package/dist/admin/chunks/{useDragAndDrop-HYwNDExe.mjs → objects-D2z-IJgu.mjs} +72 -2
- package/dist/admin/chunks/objects-D2z-IJgu.mjs.map +1 -0
- package/dist/admin/chunks/uk-BtM6WnaE.mjs +313 -0
- package/dist/admin/chunks/uk-BtM6WnaE.mjs.map +1 -0
- package/dist/admin/chunks/uk-DB6OgySY.js +318 -0
- package/dist/admin/chunks/uk-DB6OgySY.js.map +1 -0
- package/dist/admin/chunks/{relations-XOYEEqMz.js → usePrev-Cm_0-qRC.js} +18 -2
- package/dist/admin/chunks/usePrev-Cm_0-qRC.js.map +1 -0
- package/dist/admin/chunks/{relations-Cq8NRUto.mjs → usePrev-DinC2aha.mjs} +18 -4
- package/dist/admin/chunks/usePrev-DinC2aha.mjs.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/InjectionZone.d.ts +7 -1
- package/dist/admin/src/content-manager.d.ts +4 -0
- package/dist/admin/src/features/DocumentContext.d.ts +48 -0
- package/dist/admin/src/features/DocumentRBAC.d.ts +3 -2
- package/dist/admin/src/hooks/useDocument.d.ts +2 -0
- package/dist/admin/src/hooks/useDocumentActions.d.ts +1 -0
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +2 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +7 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/{Relations.d.ts → Relations/Relations.d.ts} +9 -4
- package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +5 -2
- package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +3 -3
- package/dist/admin/src/preview/components/PreviewContent.d.ts +1 -2
- package/dist/admin/src/preview/pages/Preview.d.ts +2 -0
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +1 -1
- package/dist/server/index.mjs.map +1 -1
- package/package.json +8 -8
- package/dist/admin/chunks/EditViewPage-CYe7wAXF.mjs.map +0 -1
- package/dist/admin/chunks/EditViewPage-DFkloeMZ.js.map +0 -1
- package/dist/admin/chunks/History-C333pgXF.mjs.map +0 -1
- package/dist/admin/chunks/History-CQznK1pG.js.map +0 -1
- package/dist/admin/chunks/Input-BexkC_pp.mjs.map +0 -1
- package/dist/admin/chunks/Input-DLJZHw9Y.js.map +0 -1
- package/dist/admin/chunks/Preview-BEq0FXda.mjs.map +0 -1
- package/dist/admin/chunks/Preview-CXtc9yEV.js.map +0 -1
- package/dist/admin/chunks/Relations-o7_hVGyK.js +0 -1318
- package/dist/admin/chunks/Relations-o7_hVGyK.js.map +0 -1
- package/dist/admin/chunks/Relations-qeZyLDgQ.mjs +0 -1291
- package/dist/admin/chunks/Relations-qeZyLDgQ.mjs.map +0 -1
- package/dist/admin/chunks/index-BHimg6jW.js.map +0 -1
- package/dist/admin/chunks/index-Cs6qwFQu.mjs.map +0 -1
- package/dist/admin/chunks/layout-DStNia_P.mjs.map +0 -1
- package/dist/admin/chunks/layout-Dtahn4Ue.js.map +0 -1
- package/dist/admin/chunks/objects-C3EebVVe.js +0 -76
- package/dist/admin/chunks/objects-C3EebVVe.js.map +0 -1
- package/dist/admin/chunks/objects-wl73iEma.mjs +0 -73
- package/dist/admin/chunks/objects-wl73iEma.mjs.map +0 -1
- package/dist/admin/chunks/relations-Cq8NRUto.mjs.map +0 -1
- package/dist/admin/chunks/relations-XOYEEqMz.js.map +0 -1
- package/dist/admin/chunks/uk-B24MoTVg.js +0 -145
- package/dist/admin/chunks/uk-B24MoTVg.js.map +0 -1
- package/dist/admin/chunks/uk-Cpgmm7gE.mjs +0 -140
- package/dist/admin/chunks/uk-Cpgmm7gE.mjs.map +0 -1
- package/dist/admin/chunks/useDragAndDrop-HYwNDExe.mjs.map +0 -1
- package/dist/admin/chunks/useDragAndDrop-gcqEJMnO.js.map +0 -1
- package/dist/admin/chunks/usePrev-Bjw2dhmq.mjs +0 -18
- package/dist/admin/chunks/usePrev-Bjw2dhmq.mjs.map +0 -1
- package/dist/admin/chunks/usePrev-DIYl-IAL.js +0 -21
- package/dist/admin/chunks/usePrev-DIYl-IAL.js.map +0 -1
@@ -56,6 +56,9 @@ const INJECTION_ZONES = {
|
|
56
56
|
deleteModalAdditionalInfos: [],
|
57
57
|
publishModalAdditionalInfos: [],
|
58
58
|
unpublishModalAdditionalInfos: []
|
59
|
+
},
|
60
|
+
preview: {
|
61
|
+
actions: []
|
59
62
|
}
|
60
63
|
};
|
61
64
|
/**
|
@@ -116,102 +119,6 @@ const DOCUMENT_META_FIELDS = [
|
|
116
119
|
const SINGLE_TYPES = 'single-types';
|
117
120
|
const COLLECTION_TYPES = 'collection-types';
|
118
121
|
|
119
|
-
const [DocumentRBACProvider, useDocumentRBAC] = strapiAdmin.createContext('DocumentRBAC', {
|
120
|
-
canCreate: false,
|
121
|
-
canCreateFields: [],
|
122
|
-
canDelete: false,
|
123
|
-
canPublish: false,
|
124
|
-
canRead: false,
|
125
|
-
canReadFields: [],
|
126
|
-
canUpdate: false,
|
127
|
-
canUpdateFields: [],
|
128
|
-
canUserAction: ()=>false,
|
129
|
-
isLoading: false
|
130
|
-
});
|
131
|
-
/**
|
132
|
-
* @internal This component is not meant to be used outside of the Content Manager plugin.
|
133
|
-
* It depends on knowing the slug/model of the content-type using the params of the URL.
|
134
|
-
* If you do use the hook outside of the context, we default to `false` for all actions.
|
135
|
-
*
|
136
|
-
* It then creates an list of `can{Action}` that are passed to the context for consumption
|
137
|
-
* within the app to enforce RBAC.
|
138
|
-
*/ const DocumentRBAC = ({ children, permissions })=>{
|
139
|
-
const { slug } = reactRouterDom.useParams();
|
140
|
-
if (!slug) {
|
141
|
-
throw new Error('Cannot find the slug param in the URL');
|
142
|
-
}
|
143
|
-
const [{ rawQuery }] = strapiAdmin.useQueryParams();
|
144
|
-
const userPermissions = strapiAdmin.useAuth('DocumentRBAC', (state)=>state.permissions);
|
145
|
-
const contentTypePermissions = React__namespace.useMemo(()=>{
|
146
|
-
const contentTypePermissions = userPermissions.filter((permission)=>permission.subject === slug);
|
147
|
-
return contentTypePermissions.reduce((acc, permission)=>{
|
148
|
-
const [action] = permission.action.split('.').slice(-1);
|
149
|
-
return {
|
150
|
-
...acc,
|
151
|
-
[action]: [
|
152
|
-
permission
|
153
|
-
]
|
154
|
-
};
|
155
|
-
}, {});
|
156
|
-
}, [
|
157
|
-
slug,
|
158
|
-
userPermissions
|
159
|
-
]);
|
160
|
-
const { isLoading, allowedActions } = strapiAdmin.useRBAC(contentTypePermissions, permissions ?? undefined, // TODO: useRBAC context should be typed and built differently
|
161
|
-
// We are passing raw query as context to the hook so that it can
|
162
|
-
// rely on the locale provided from DocumentRBAC for its permission calculations.
|
163
|
-
rawQuery);
|
164
|
-
const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
|
165
|
-
const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
|
166
|
-
const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
|
167
|
-
/**
|
168
|
-
* @description Checks if the user can perform an action on a field based on the field names
|
169
|
-
* provided as the second argument.
|
170
|
-
*/ const canUserAction = React__namespace.useCallback((fieldName, fieldsUserCanAction, fieldType)=>{
|
171
|
-
const name = removeNumericalStrings(fieldName.split('.'));
|
172
|
-
const componentFieldNames = fieldsUserCanAction// filter out fields that aren't components (components are dot separated)
|
173
|
-
.filter((field)=>field.split('.').length > 1);
|
174
|
-
if (fieldType === 'component') {
|
175
|
-
// check if the field name is within any of those arrays
|
176
|
-
return componentFieldNames.some((field)=>{
|
177
|
-
return field.includes(name.join('.'));
|
178
|
-
});
|
179
|
-
}
|
180
|
-
/**
|
181
|
-
* The field is within a component.
|
182
|
-
*/ if (name.length > 1) {
|
183
|
-
return componentFieldNames.includes(name.join('.'));
|
184
|
-
}
|
185
|
-
/**
|
186
|
-
* just a regular field
|
187
|
-
*/ return fieldsUserCanAction.includes(fieldName);
|
188
|
-
}, []);
|
189
|
-
if (isLoading) {
|
190
|
-
return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Page.Loading, {});
|
191
|
-
}
|
192
|
-
return /*#__PURE__*/ jsxRuntime.jsx(DocumentRBACProvider, {
|
193
|
-
isLoading: isLoading,
|
194
|
-
canCreateFields: canCreateFields,
|
195
|
-
canReadFields: canReadFields,
|
196
|
-
canUpdateFields: canUpdateFields,
|
197
|
-
canUserAction: canUserAction,
|
198
|
-
...allowedActions,
|
199
|
-
children: children
|
200
|
-
});
|
201
|
-
};
|
202
|
-
/**
|
203
|
-
* @internal it's really small, but it's used three times in a row and DRY for something this straight forward.
|
204
|
-
*/ const extractAndDedupeFields = (permissions = [])=>permissions.flatMap((permission)=>permission.properties?.fields).filter((field, index, arr)=>arr.indexOf(field) === index && typeof field === 'string');
|
205
|
-
/**
|
206
|
-
* @internal removes numerical strings from arrays.
|
207
|
-
* @example
|
208
|
-
* ```ts
|
209
|
-
* const name = 'a.0.b';
|
210
|
-
* const res = removeNumericalStrings(name.split('.'));
|
211
|
-
* console.log(res); // ['a', 'b']
|
212
|
-
* ```
|
213
|
-
*/ const removeNumericalStrings = (arr)=>arr.filter((item)=>isNaN(Number(item)));
|
214
|
-
|
215
122
|
const BLOCK_LIST_ATTRIBUTE_KEYS = [
|
216
123
|
'__component',
|
217
124
|
'__temp_key__'
|
@@ -1522,7 +1429,7 @@ const checkIfAttributeIsDisplayable = (attribute)=>{
|
|
1522
1429
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1523
1430
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1524
1431
|
const { formatMessage } = reactIntl.useIntl();
|
1525
|
-
const { currentData: data, isLoading: isLoadingDocument, isFetching: isFetchingDocument, error } = useGetDocumentQuery(args, {
|
1432
|
+
const { currentData: data, isLoading: isLoadingDocument, isFetching: isFetchingDocument, error, refetch } = useGetDocumentQuery(args, {
|
1526
1433
|
...opts,
|
1527
1434
|
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
1528
1435
|
});
|
@@ -1621,7 +1528,8 @@ const checkIfAttributeIsDisplayable = (attribute)=>{
|
|
1621
1528
|
schemas,
|
1622
1529
|
validate,
|
1623
1530
|
getTitle,
|
1624
|
-
getInitialFormValues
|
1531
|
+
getInitialFormValues,
|
1532
|
+
refetch
|
1625
1533
|
};
|
1626
1534
|
};
|
1627
1535
|
/* -------------------------------------------------------------------------------------------------
|
@@ -1694,6 +1602,140 @@ const checkIfAttributeIsDisplayable = (attribute)=>{
|
|
1694
1602
|
};
|
1695
1603
|
};
|
1696
1604
|
|
1605
|
+
const [DocumentProvider, useDocumentContext] = strapiAdmin.createContext('DocumentContext');
|
1606
|
+
/**
|
1607
|
+
* TODO: Document in contributor docs, Add unit test
|
1608
|
+
*
|
1609
|
+
* This context provider and its associated hook are used to access a document at its root level
|
1610
|
+
* and expose a function to change the current document being viewed to one of the root level docuemnt's relations.
|
1611
|
+
*
|
1612
|
+
* The useDocumentContext hook exposes:
|
1613
|
+
* - meta: information about the currentDocument,
|
1614
|
+
* - document: the actual document,
|
1615
|
+
* - changeDocument: a function to change the current document to one of its relations.
|
1616
|
+
*/ const DocumentContextProvider = ({ children, initialDocument })=>{
|
1617
|
+
/**
|
1618
|
+
* Initialize with the "root" document and expose a setter method to change to
|
1619
|
+
* one of the root level document's relations.
|
1620
|
+
*/ const [currentDocumentMeta, changeDocument] = React__namespace.useState(initialDocument);
|
1621
|
+
const params = React__namespace.useMemo(()=>buildValidParams(currentDocumentMeta.params ?? {}), [
|
1622
|
+
currentDocumentMeta.params
|
1623
|
+
]);
|
1624
|
+
const document = useDocument({
|
1625
|
+
...currentDocumentMeta,
|
1626
|
+
params
|
1627
|
+
});
|
1628
|
+
return /*#__PURE__*/ jsxRuntime.jsx(DocumentProvider, {
|
1629
|
+
changeDocument: changeDocument,
|
1630
|
+
document: document,
|
1631
|
+
rootDocumentMeta: {
|
1632
|
+
documentId: initialDocument.documentId,
|
1633
|
+
model: initialDocument.model,
|
1634
|
+
collectionType: initialDocument.collectionType,
|
1635
|
+
params: initialDocument.params
|
1636
|
+
},
|
1637
|
+
meta: currentDocumentMeta,
|
1638
|
+
children: children
|
1639
|
+
});
|
1640
|
+
};
|
1641
|
+
|
1642
|
+
const [DocumentRBACProvider, useDocumentRBAC] = strapiAdmin.createContext('DocumentRBAC', {
|
1643
|
+
canCreate: false,
|
1644
|
+
canCreateFields: [],
|
1645
|
+
canDelete: false,
|
1646
|
+
canPublish: false,
|
1647
|
+
canRead: false,
|
1648
|
+
canReadFields: [],
|
1649
|
+
canUpdate: false,
|
1650
|
+
canUpdateFields: [],
|
1651
|
+
canUserAction: ()=>false,
|
1652
|
+
isLoading: false
|
1653
|
+
});
|
1654
|
+
/**
|
1655
|
+
* @internal This component is not meant to be used outside of the Content Manager plugin.
|
1656
|
+
* It depends on knowing the slug/model of the content-type using the params of the URL or the model if it is passed as arg.
|
1657
|
+
* If you do use the hook outside of the context, we default to `false` for all actions.
|
1658
|
+
*
|
1659
|
+
* It then creates an list of `can{Action}` that are passed to the context for consumption
|
1660
|
+
* within the app to enforce RBAC.
|
1661
|
+
*/ const DocumentRBAC = ({ children, permissions, model })=>{
|
1662
|
+
const { slug } = reactRouterDom.useParams();
|
1663
|
+
if (!slug && !model) {
|
1664
|
+
throw new Error('Cannot find the slug param in the URL or the model prop is not provided.');
|
1665
|
+
}
|
1666
|
+
const contentTypeUid = model ?? slug;
|
1667
|
+
const [{ rawQuery }] = strapiAdmin.useQueryParams();
|
1668
|
+
const userPermissions = strapiAdmin.useAuth('DocumentRBAC', (state)=>state.permissions);
|
1669
|
+
const contentTypePermissions = React__namespace.useMemo(()=>{
|
1670
|
+
const contentTypePermissions = userPermissions.filter((permission)=>permission.subject === contentTypeUid);
|
1671
|
+
return contentTypePermissions.reduce((acc, permission)=>{
|
1672
|
+
const [action] = permission.action.split('.').slice(-1);
|
1673
|
+
return {
|
1674
|
+
...acc,
|
1675
|
+
[action]: [
|
1676
|
+
permission
|
1677
|
+
]
|
1678
|
+
};
|
1679
|
+
}, {});
|
1680
|
+
}, [
|
1681
|
+
contentTypeUid,
|
1682
|
+
userPermissions
|
1683
|
+
]);
|
1684
|
+
const { isLoading, allowedActions } = strapiAdmin.useRBAC(contentTypePermissions, permissions ?? undefined, // TODO: useRBAC context should be typed and built differently
|
1685
|
+
// We are passing raw query as context to the hook so that it can
|
1686
|
+
// rely on the locale provided from DocumentRBAC for its permission calculations.
|
1687
|
+
rawQuery);
|
1688
|
+
const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
|
1689
|
+
const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
|
1690
|
+
const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
|
1691
|
+
/**
|
1692
|
+
* @description Checks if the user can perform an action on a field based on the field names
|
1693
|
+
* provided as the second argument.
|
1694
|
+
*/ const canUserAction = React__namespace.useCallback((fieldName, fieldsUserCanAction, fieldType)=>{
|
1695
|
+
const name = removeNumericalStrings(fieldName.split('.'));
|
1696
|
+
const componentFieldNames = fieldsUserCanAction// filter out fields that aren't components (components are dot separated)
|
1697
|
+
.filter((field)=>field.split('.').length > 1);
|
1698
|
+
if (fieldType === 'component') {
|
1699
|
+
// check if the field name is within any of those arrays
|
1700
|
+
return componentFieldNames.some((field)=>{
|
1701
|
+
return field.includes(name.join('.'));
|
1702
|
+
});
|
1703
|
+
}
|
1704
|
+
/**
|
1705
|
+
* The field is within a component.
|
1706
|
+
*/ if (name.length > 1) {
|
1707
|
+
return componentFieldNames.includes(name.join('.'));
|
1708
|
+
}
|
1709
|
+
/**
|
1710
|
+
* just a regular field
|
1711
|
+
*/ return fieldsUserCanAction.includes(fieldName);
|
1712
|
+
}, []);
|
1713
|
+
if (isLoading) {
|
1714
|
+
return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Page.Loading, {});
|
1715
|
+
}
|
1716
|
+
return /*#__PURE__*/ jsxRuntime.jsx(DocumentRBACProvider, {
|
1717
|
+
isLoading: isLoading,
|
1718
|
+
canCreateFields: canCreateFields,
|
1719
|
+
canReadFields: canReadFields,
|
1720
|
+
canUpdateFields: canUpdateFields,
|
1721
|
+
canUserAction: canUserAction,
|
1722
|
+
...allowedActions,
|
1723
|
+
children: children
|
1724
|
+
});
|
1725
|
+
};
|
1726
|
+
/**
|
1727
|
+
* @internal it's really small, but it's used three times in a row and DRY for something this straight forward.
|
1728
|
+
*/ const extractAndDedupeFields = (permissions = [])=>permissions.flatMap((permission)=>permission.properties?.fields).filter((field, index, arr)=>arr.indexOf(field) === index && typeof field === 'string');
|
1729
|
+
/**
|
1730
|
+
* @internal removes numerical strings from arrays.
|
1731
|
+
* @example
|
1732
|
+
* ```ts
|
1733
|
+
* const name = 'a.0.b';
|
1734
|
+
* const res = removeNumericalStrings(name.split('.'));
|
1735
|
+
* console.log(res); // ['a', 'b']
|
1736
|
+
* ```
|
1737
|
+
*/ const removeNumericalStrings = (arr)=>arr.filter((item)=>isNaN(Number(item)));
|
1738
|
+
|
1697
1739
|
const prefixPluginTranslations = (trad, pluginId)=>{
|
1698
1740
|
return Object.keys(trad).reduce((acc, current)=>{
|
1699
1741
|
acc[`${pluginId}.${current}`] = trad[current];
|
@@ -1735,7 +1777,7 @@ const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
|
1735
1777
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1736
1778
|
const navigate = reactRouterDom.useNavigate();
|
1737
1779
|
const setCurrentStep = strapiAdmin.useGuidedTour('useDocumentActions', (state)=>state.setCurrentStep);
|
1738
|
-
const [deleteDocument] = useDeleteDocumentMutation();
|
1780
|
+
const [deleteDocument, { isLoading: isDeleting }] = useDeleteDocumentMutation();
|
1739
1781
|
const _delete = React__namespace.useCallback(async ({ collectionType, model, documentId, params }, trackerProperty)=>{
|
1740
1782
|
try {
|
1741
1783
|
trackUsage('willDeleteEntry', trackerProperty);
|
@@ -1781,7 +1823,7 @@ const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
|
1781
1823
|
formatMessage,
|
1782
1824
|
formatAPIError
|
1783
1825
|
]);
|
1784
|
-
const [deleteManyDocuments] = useDeleteManyDocumentsMutation();
|
1826
|
+
const [deleteManyDocuments, { isLoading: isDeletingMany }] = useDeleteManyDocumentsMutation();
|
1785
1827
|
const deleteMany = React__namespace.useCallback(async ({ model, documentIds, params })=>{
|
1786
1828
|
try {
|
1787
1829
|
trackUsage('willBulkDeleteEntries');
|
@@ -1824,7 +1866,7 @@ const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
|
1824
1866
|
formatMessage,
|
1825
1867
|
formatAPIError
|
1826
1868
|
]);
|
1827
|
-
const [discardDocument] = useDiscardDocumentMutation();
|
1869
|
+
const [discardDocument, { isLoading: isDiscardingDocument }] = useDiscardDocumentMutation();
|
1828
1870
|
const discard = React__namespace.useCallback(async ({ collectionType, model, documentId, params })=>{
|
1829
1871
|
try {
|
1830
1872
|
const res = await discardDocument({
|
@@ -1863,7 +1905,7 @@ const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
|
1863
1905
|
formatMessage,
|
1864
1906
|
toggleNotification
|
1865
1907
|
]);
|
1866
|
-
const [publishDocument] = usePublishDocumentMutation();
|
1908
|
+
const [publishDocument, { isLoading: isPublishing }] = usePublishDocumentMutation();
|
1867
1909
|
const publish = React__namespace.useCallback(async ({ collectionType, model, documentId, params }, data)=>{
|
1868
1910
|
try {
|
1869
1911
|
trackUsage('willPublishEntry');
|
@@ -1906,7 +1948,7 @@ const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
|
1906
1948
|
formatMessage,
|
1907
1949
|
formatAPIError
|
1908
1950
|
]);
|
1909
|
-
const [publishManyDocuments] = usePublishManyDocumentsMutation();
|
1951
|
+
const [publishManyDocuments, { isLoading: isPublishingMany }] = usePublishManyDocumentsMutation();
|
1910
1952
|
const publishMany = React__namespace.useCallback(async ({ model, documentIds, params })=>{
|
1911
1953
|
try {
|
1912
1954
|
// TODO Confirm tracking events for bulk publish?
|
@@ -1946,7 +1988,7 @@ const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
|
1946
1988
|
formatMessage,
|
1947
1989
|
formatAPIError
|
1948
1990
|
]);
|
1949
|
-
const [updateDocument] = useUpdateDocumentMutation();
|
1991
|
+
const [updateDocument, { isLoading: isUpdating }] = useUpdateDocumentMutation();
|
1950
1992
|
const update = React__namespace.useCallback(async ({ collectionType, model, documentId, params }, data, trackerProperty)=>{
|
1951
1993
|
try {
|
1952
1994
|
trackUsage('willEditEntry', trackerProperty);
|
@@ -2042,7 +2084,7 @@ const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
|
2042
2084
|
formatMessage,
|
2043
2085
|
formatAPIError
|
2044
2086
|
]);
|
2045
|
-
const [unpublishManyDocuments] = useUnpublishManyDocumentsMutation();
|
2087
|
+
const [unpublishManyDocuments, { isLoading: isUnpublishingMany }] = useUnpublishManyDocumentsMutation();
|
2046
2088
|
const unpublishMany = React__namespace.useCallback(async ({ model, documentIds, params })=>{
|
2047
2089
|
try {
|
2048
2090
|
trackUsage('willBulkUnpublishEntries');
|
@@ -2233,6 +2275,7 @@ const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
|
2233
2275
|
getDoc
|
2234
2276
|
]);
|
2235
2277
|
return {
|
2278
|
+
isLoading: isPublishing || isUpdating || isDiscardingDocument || isDeleting || isDeletingMany || isUnpublishingMany || isPublishingMany,
|
2236
2279
|
autoClone,
|
2237
2280
|
clone,
|
2238
2281
|
create,
|
@@ -2248,7 +2291,7 @@ const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
|
2248
2291
|
};
|
2249
2292
|
};
|
2250
2293
|
|
2251
|
-
const ProtectedHistoryPage = /*#__PURE__*/ React__namespace.lazy(()=>Promise.resolve().then(function () { return require('./History-
|
2294
|
+
const ProtectedHistoryPage = /*#__PURE__*/ React__namespace.lazy(()=>Promise.resolve().then(function () { return require('./History-D5joC76n.js'); }).then((mod)=>({
|
2252
2295
|
default: mod.ProtectedHistoryPage
|
2253
2296
|
})));
|
2254
2297
|
/**
|
@@ -2264,7 +2307,7 @@ const ProtectedHistoryPage = /*#__PURE__*/ React__namespace.lazy(()=>Promise.res
|
|
2264
2307
|
}
|
2265
2308
|
];
|
2266
2309
|
|
2267
|
-
const ProtectedPreviewPage = /*#__PURE__*/ React__namespace.lazy(()=>Promise.resolve().then(function () { return require('./Preview-
|
2310
|
+
const ProtectedPreviewPage = /*#__PURE__*/ React__namespace.lazy(()=>Promise.resolve().then(function () { return require('./Preview-DB7ZGawL.js'); }).then((mod)=>({
|
2268
2311
|
default: mod.ProtectedPreviewPage
|
2269
2312
|
})));
|
2270
2313
|
const routes$1 = [
|
@@ -2278,25 +2321,25 @@ const routes$1 = [
|
|
2278
2321
|
}
|
2279
2322
|
];
|
2280
2323
|
|
2281
|
-
const ProtectedEditViewPage = /*#__PURE__*/ React.lazy(()=>Promise.resolve().then(function () { return require('./EditViewPage-
|
2324
|
+
const ProtectedEditViewPage = /*#__PURE__*/ React.lazy(()=>Promise.resolve().then(function () { return require('./EditViewPage-CwYSs8Cq.js'); }).then((mod)=>({
|
2282
2325
|
default: mod.ProtectedEditViewPage
|
2283
2326
|
})));
|
2284
|
-
const ProtectedListViewPage = /*#__PURE__*/ React.lazy(()=>Promise.resolve().then(function () { return require('./ListViewPage-
|
2327
|
+
const ProtectedListViewPage = /*#__PURE__*/ React.lazy(()=>Promise.resolve().then(function () { return require('./ListViewPage-CvQ1w8IW.js'); }).then((mod)=>({
|
2285
2328
|
default: mod.ProtectedListViewPage
|
2286
2329
|
})));
|
2287
|
-
const ProtectedListConfiguration = /*#__PURE__*/ React.lazy(()=>Promise.resolve().then(function () { return require('./ListConfigurationPage-
|
2330
|
+
const ProtectedListConfiguration = /*#__PURE__*/ React.lazy(()=>Promise.resolve().then(function () { return require('./ListConfigurationPage-CgJEcEkD.js'); }).then((mod)=>({
|
2288
2331
|
default: mod.ProtectedListConfiguration
|
2289
2332
|
})));
|
2290
|
-
const ProtectedEditConfigurationPage = /*#__PURE__*/ React.lazy(()=>Promise.resolve().then(function () { return require('./EditConfigurationPage-
|
2333
|
+
const ProtectedEditConfigurationPage = /*#__PURE__*/ React.lazy(()=>Promise.resolve().then(function () { return require('./EditConfigurationPage-7xe8u-Pp.js'); }).then((mod)=>({
|
2291
2334
|
default: mod.ProtectedEditConfigurationPage
|
2292
2335
|
})));
|
2293
|
-
const ProtectedComponentConfigurationPage = /*#__PURE__*/ React.lazy(()=>Promise.resolve().then(function () { return require('./ComponentConfigurationPage-
|
2336
|
+
const ProtectedComponentConfigurationPage = /*#__PURE__*/ React.lazy(()=>Promise.resolve().then(function () { return require('./ComponentConfigurationPage-Ci3dN40b.js'); }).then((mod)=>({
|
2294
2337
|
default: mod.ProtectedComponentConfigurationPage
|
2295
2338
|
})));
|
2296
|
-
const NoPermissions = /*#__PURE__*/ React.lazy(()=>Promise.resolve().then(function () { return require('./NoPermissionsPage-
|
2339
|
+
const NoPermissions = /*#__PURE__*/ React.lazy(()=>Promise.resolve().then(function () { return require('./NoPermissionsPage-BBXnpc7M.js'); }).then((mod)=>({
|
2297
2340
|
default: mod.NoPermissions
|
2298
2341
|
})));
|
2299
|
-
const NoContentType = /*#__PURE__*/ React.lazy(()=>Promise.resolve().then(function () { return require('./NoContentTypePage-
|
2342
|
+
const NoContentType = /*#__PURE__*/ React.lazy(()=>Promise.resolve().then(function () { return require('./NoContentTypePage-C5Vut1Af.js'); }).then((mod)=>({
|
2300
2343
|
default: mod.NoContentType
|
2301
2344
|
})));
|
2302
2345
|
const CollectionTypePages = ()=>{
|
@@ -2432,6 +2475,7 @@ const DocumentActionButton = (action)=>{
|
|
2432
2475
|
variant: action.variant || 'default',
|
2433
2476
|
paddingTop: "7px",
|
2434
2477
|
paddingBottom: "7px",
|
2478
|
+
loading: action.loading,
|
2435
2479
|
children: action.label
|
2436
2480
|
}),
|
2437
2481
|
action.dialog?.type === 'dialog' ? /*#__PURE__*/ jsxRuntime.jsx(DocumentActionConfirmDialog, {
|
@@ -2586,7 +2630,7 @@ const convertActionVariantToIconColor = (variant = 'secondary')=>{
|
|
2586
2630
|
return 'primary600';
|
2587
2631
|
}
|
2588
2632
|
};
|
2589
|
-
const DocumentActionConfirmDialog = ({ onClose, onCancel, onConfirm, title, content, isOpen, variant = 'secondary' })=>{
|
2633
|
+
const DocumentActionConfirmDialog = ({ onClose, onCancel, onConfirm, title, content, isOpen, variant = 'secondary', loading })=>{
|
2590
2634
|
const { formatMessage } = reactIntl.useIntl();
|
2591
2635
|
const handleClose = async ()=>{
|
2592
2636
|
if (onCancel) {
|
@@ -2627,6 +2671,7 @@ const DocumentActionConfirmDialog = ({ onClose, onCancel, onConfirm, title, cont
|
|
2627
2671
|
onClick: handleConfirm,
|
2628
2672
|
variant: variant,
|
2629
2673
|
fullWidth: true,
|
2674
|
+
loading: loading,
|
2630
2675
|
children: formatMessage({
|
2631
2676
|
id: 'app.components.Button.confirm',
|
2632
2677
|
defaultMessage: 'Confirm'
|
@@ -2681,8 +2726,8 @@ const transformData = (data)=>{
|
|
2681
2726
|
};
|
2682
2727
|
/* -------------------------------------------------------------------------------------------------
|
2683
2728
|
* DocumentActionComponents
|
2684
|
-
* -----------------------------------------------------------------------------------------------*/ const PublishAction$1 = ({ activeTab, documentId, model, collectionType, meta, document })=>{
|
2685
|
-
const
|
2729
|
+
* -----------------------------------------------------------------------------------------------*/ const PublishAction$1 = ({ activeTab, documentId, model, collectionType, meta, document, onPreview })=>{
|
2730
|
+
const schema = useDocumentContext('PublishAction', (state)=>state.document.schema);
|
2686
2731
|
const navigate = reactRouterDom.useNavigate();
|
2687
2732
|
const { toggleNotification } = strapiAdmin.useNotification();
|
2688
2733
|
const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
|
@@ -2691,7 +2736,7 @@ const transformData = (data)=>{
|
|
2691
2736
|
const { id } = reactRouterDom.useParams();
|
2692
2737
|
const { formatMessage } = reactIntl.useIntl();
|
2693
2738
|
const canPublish = useDocumentRBAC('PublishAction', ({ canPublish })=>canPublish);
|
2694
|
-
const { publish } = useDocumentActions();
|
2739
|
+
const { publish, isLoading } = useDocumentActions();
|
2695
2740
|
const [countDraftRelations, { isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }] = useLazyGetDraftRelationCountQuery();
|
2696
2741
|
const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React__namespace.useState(0);
|
2697
2742
|
const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React__namespace.useState(0);
|
@@ -2705,6 +2750,8 @@ const transformData = (data)=>{
|
|
2705
2750
|
const validate = strapiAdmin.useForm('PublishAction', (state)=>state.validate);
|
2706
2751
|
const setErrors = strapiAdmin.useForm('PublishAction', (state)=>state.setErrors);
|
2707
2752
|
const formValues = strapiAdmin.useForm('PublishAction', ({ values })=>values);
|
2753
|
+
const rootDocumentMeta = useDocumentContext('PublishAction', (state)=>state.rootDocumentMeta);
|
2754
|
+
const currentDocumentMeta = useDocumentContext('PublishAction', (state)=>state.meta);
|
2708
2755
|
React__namespace.useEffect(()=>{
|
2709
2756
|
if (isErrorDraftRelations) {
|
2710
2757
|
toggleNotification({
|
@@ -2807,11 +2854,12 @@ const transformData = (data)=>{
|
|
2807
2854
|
});
|
2808
2855
|
return;
|
2809
2856
|
}
|
2857
|
+
const isPublishingRelation = rootDocumentMeta.documentId !== currentDocumentMeta.documentId;
|
2810
2858
|
const res = await publish({
|
2811
2859
|
collectionType,
|
2812
2860
|
model,
|
2813
2861
|
documentId,
|
2814
|
-
params
|
2862
|
+
params: isPublishingRelation ? currentDocumentMeta.params : params
|
2815
2863
|
}, transformData(formValues));
|
2816
2864
|
if ('data' in res && collectionType !== SINGLE_TYPES) {
|
2817
2865
|
/**
|
@@ -2827,6 +2875,9 @@ const transformData = (data)=>{
|
|
2827
2875
|
}
|
2828
2876
|
} finally{
|
2829
2877
|
setSubmitting(false);
|
2878
|
+
if (onPreview) {
|
2879
|
+
onPreview();
|
2880
|
+
}
|
2830
2881
|
}
|
2831
2882
|
};
|
2832
2883
|
const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
|
@@ -2835,6 +2886,12 @@ const transformData = (data)=>{
|
|
2835
2886
|
const enableDraftRelationsCount = false;
|
2836
2887
|
const hasDraftRelations = enableDraftRelationsCount;
|
2837
2888
|
return {
|
2889
|
+
loading: isLoading,
|
2890
|
+
position: [
|
2891
|
+
'panel',
|
2892
|
+
'preview',
|
2893
|
+
'relation-modal'
|
2894
|
+
],
|
2838
2895
|
/**
|
2839
2896
|
* Disabled when:
|
2840
2897
|
* - currently if you're cloning a document we don't support publish & clone at the same time.
|
@@ -2872,15 +2929,19 @@ const transformData = (data)=>{
|
|
2872
2929
|
};
|
2873
2930
|
};
|
2874
2931
|
PublishAction$1.type = 'publish';
|
2875
|
-
PublishAction$1.position =
|
2876
|
-
|
2932
|
+
PublishAction$1.position = [
|
2933
|
+
'panel',
|
2934
|
+
'preview',
|
2935
|
+
'relation-modal'
|
2936
|
+
];
|
2937
|
+
const UpdateAction = ({ activeTab, documentId, model, collectionType, onPreview })=>{
|
2877
2938
|
const navigate = reactRouterDom.useNavigate();
|
2878
2939
|
const { toggleNotification } = strapiAdmin.useNotification();
|
2879
2940
|
const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
|
2880
2941
|
const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
|
2881
2942
|
const isCloning = cloneMatch !== null;
|
2882
2943
|
const { formatMessage } = reactIntl.useIntl();
|
2883
|
-
const { create, update, clone } = useDocumentActions();
|
2944
|
+
const { create, update, clone, isLoading } = useDocumentActions();
|
2884
2945
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
2885
2946
|
const params = React__namespace.useMemo(()=>buildValidParams(query), [
|
2886
2947
|
query
|
@@ -2892,6 +2953,8 @@ const UpdateAction = ({ activeTab, documentId, model, collectionType })=>{
|
|
2892
2953
|
const validate = strapiAdmin.useForm('UpdateAction', (state)=>state.validate);
|
2893
2954
|
const setErrors = strapiAdmin.useForm('UpdateAction', (state)=>state.setErrors);
|
2894
2955
|
const resetForm = strapiAdmin.useForm('PublishAction', ({ resetForm })=>resetForm);
|
2956
|
+
const rootDocumentMeta = useDocumentContext('UpdateAction', (state)=>state.rootDocumentMeta);
|
2957
|
+
const currentDocumentMeta = useDocumentContext('UpdateAction', (state)=>state.meta);
|
2895
2958
|
const handleUpdate = React__namespace.useCallback(async ()=>{
|
2896
2959
|
setSubmitting(true);
|
2897
2960
|
try {
|
@@ -2928,11 +2991,12 @@ const UpdateAction = ({ activeTab, documentId, model, collectionType })=>{
|
|
2928
2991
|
setErrors(formatValidationErrors(res.error));
|
2929
2992
|
}
|
2930
2993
|
} else if (documentId || collectionType === SINGLE_TYPES) {
|
2994
|
+
const isEditingRelation = rootDocumentMeta.documentId !== currentDocumentMeta.documentId;
|
2931
2995
|
const res = await update({
|
2932
2996
|
collectionType,
|
2933
2997
|
model,
|
2934
2998
|
documentId,
|
2935
|
-
params
|
2999
|
+
params: isEditingRelation ? currentDocumentMeta.params : params
|
2936
3000
|
}, transformData(document));
|
2937
3001
|
if ('error' in res && isBaseQueryError(res.error) && res.error.name === 'ValidationError') {
|
2938
3002
|
setErrors(formatValidationErrors(res.error));
|
@@ -2958,6 +3022,9 @@ const UpdateAction = ({ activeTab, documentId, model, collectionType })=>{
|
|
2958
3022
|
}
|
2959
3023
|
} finally{
|
2960
3024
|
setSubmitting(false);
|
3025
|
+
if (onPreview) {
|
3026
|
+
onPreview();
|
3027
|
+
}
|
2961
3028
|
}
|
2962
3029
|
}, [
|
2963
3030
|
clone,
|
@@ -2997,6 +3064,7 @@ const UpdateAction = ({ activeTab, documentId, model, collectionType })=>{
|
|
2997
3064
|
handleUpdate
|
2998
3065
|
]);
|
2999
3066
|
return {
|
3067
|
+
loading: isLoading,
|
3000
3068
|
/**
|
3001
3069
|
* Disabled when:
|
3002
3070
|
* - the form is submitting
|
@@ -3007,11 +3075,20 @@ const UpdateAction = ({ activeTab, documentId, model, collectionType })=>{
|
|
3007
3075
|
id: 'global.save',
|
3008
3076
|
defaultMessage: 'Save'
|
3009
3077
|
}),
|
3010
|
-
onClick: handleUpdate
|
3078
|
+
onClick: handleUpdate,
|
3079
|
+
position: [
|
3080
|
+
'panel',
|
3081
|
+
'preview',
|
3082
|
+
'relation-modal'
|
3083
|
+
]
|
3011
3084
|
};
|
3012
3085
|
};
|
3013
3086
|
UpdateAction.type = 'update';
|
3014
|
-
UpdateAction.position =
|
3087
|
+
UpdateAction.position = [
|
3088
|
+
'panel',
|
3089
|
+
'preview',
|
3090
|
+
'relation-modal'
|
3091
|
+
];
|
3015
3092
|
const UNPUBLISH_DRAFT_OPTIONS = {
|
3016
3093
|
KEEP: 'keep',
|
3017
3094
|
DISCARD: 'discard'
|
@@ -3161,7 +3238,7 @@ const DiscardAction = ({ activeTab, documentId, model, collectionType, document
|
|
3161
3238
|
const { formatMessage } = reactIntl.useIntl();
|
3162
3239
|
const { schema } = useDoc();
|
3163
3240
|
const canUpdate = useDocumentRBAC('DiscardAction', ({ canUpdate })=>canUpdate);
|
3164
|
-
const { discard } = useDocumentActions();
|
3241
|
+
const { discard, isLoading } = useDocumentActions();
|
3165
3242
|
const [{ query }] = strapiAdmin.useQueryParams();
|
3166
3243
|
const params = React__namespace.useMemo(()=>buildValidParams(query), [
|
3167
3244
|
query
|
@@ -3207,6 +3284,7 @@ const DiscardAction = ({ activeTab, documentId, model, collectionType, document
|
|
3207
3284
|
})
|
3208
3285
|
]
|
3209
3286
|
}),
|
3287
|
+
loading: isLoading,
|
3210
3288
|
onConfirm: async ()=>{
|
3211
3289
|
await discard({
|
3212
3290
|
collectionType,
|
@@ -3301,6 +3379,8 @@ const capitalise = (str)=>str.charAt(0).toUpperCase() + str.slice(1);
|
|
3301
3379
|
...restProps,
|
3302
3380
|
size: size,
|
3303
3381
|
variant: statusVariant,
|
3382
|
+
role: "status",
|
3383
|
+
"aria-label": status,
|
3304
3384
|
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
|
3305
3385
|
tag: "span",
|
3306
3386
|
variant: "omega",
|
@@ -3643,7 +3723,7 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document })=>{
|
|
3643
3723
|
const { formatMessage } = reactIntl.useIntl();
|
3644
3724
|
const listViewPathMatch = reactRouterDom.useMatch(LIST_PATH);
|
3645
3725
|
const canDelete = useDocumentRBAC('DeleteAction', (state)=>state.canDelete);
|
3646
|
-
const { delete: deleteAction } = useDocumentActions();
|
3726
|
+
const { delete: deleteAction, isLoading } = useDocumentActions();
|
3647
3727
|
const { toggleNotification } = strapiAdmin.useNotification();
|
3648
3728
|
const setSubmitting = strapiAdmin.useForm('DeleteAction', (state)=>state.setSubmitting);
|
3649
3729
|
const isLocalized = document?.locale != null;
|
@@ -3682,6 +3762,7 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document })=>{
|
|
3682
3762
|
})
|
3683
3763
|
]
|
3684
3764
|
}),
|
3765
|
+
loading: isLoading,
|
3685
3766
|
onConfirm: async ()=>{
|
3686
3767
|
/**
|
3687
3768
|
* If we have a match, we're in the list view
|
@@ -4363,7 +4444,7 @@ const SelectedEntriesModalContent = ({ listViewSelectedEntries, toggleModal, set
|
|
4363
4444
|
schema
|
4364
4445
|
]);
|
4365
4446
|
const [isDialogOpen, setIsDialogOpen] = React__namespace.useState(false);
|
4366
|
-
const { publishMany: bulkPublishAction } = useDocumentActions();
|
4447
|
+
const { publishMany: bulkPublishAction, isLoading: isPublishing } = useDocumentActions();
|
4367
4448
|
const [, { isLoading: isSubmittingForm }] = usePublishManyDocumentsMutation();
|
4368
4449
|
const selectedRows = strapiAdmin.useTable('publishAction', (state)=>state.selectedRows);
|
4369
4450
|
// Filter selected entries from the updated modal table rows
|
@@ -4435,7 +4516,7 @@ const SelectedEntriesModalContent = ({ listViewSelectedEntries, toggleModal, set
|
|
4435
4516
|
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
|
4436
4517
|
onClick: toggleDialog,
|
4437
4518
|
disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublishedCount === selectedEntries.length || isLoading,
|
4438
|
-
loading: isSubmittingForm,
|
4519
|
+
loading: isPublishing || isSubmittingForm,
|
4439
4520
|
children: formatMessage({
|
4440
4521
|
id: 'app.utils.publish',
|
4441
4522
|
defaultMessage: 'Publish'
|
@@ -4448,7 +4529,7 @@ const SelectedEntriesModalContent = ({ listViewSelectedEntries, toggleModal, set
|
|
4448
4529
|
/*#__PURE__*/ jsxRuntime.jsx(ConfirmDialogPublishAll, {
|
4449
4530
|
isOpen: isDialogOpen,
|
4450
4531
|
onToggleDialog: toggleDialog,
|
4451
|
-
isConfirmButtonLoading: isSubmittingForm,
|
4532
|
+
isConfirmButtonLoading: isPublishing || isSubmittingForm,
|
4452
4533
|
onConfirm: handleConfirmBulkPublish
|
4453
4534
|
})
|
4454
4535
|
]
|
@@ -4540,7 +4621,7 @@ const SelectedEntriesModalContent = ({ listViewSelectedEntries, toggleModal, set
|
|
4540
4621
|
query
|
4541
4622
|
]);
|
4542
4623
|
const hasDeletePermission = useDocumentRBAC('deleteAction', (state)=>state.canDelete);
|
4543
|
-
const { deleteMany: bulkDeleteAction } = useDocumentActions();
|
4624
|
+
const { deleteMany: bulkDeleteAction, isLoading } = useDocumentActions();
|
4544
4625
|
const documentIds = documents.map(({ documentId })=>documentId);
|
4545
4626
|
const handleConfirmBulkDelete = async ()=>{
|
4546
4627
|
const res = await bulkDeleteAction({
|
@@ -4565,6 +4646,7 @@ const SelectedEntriesModalContent = ({ listViewSelectedEntries, toggleModal, set
|
|
4565
4646
|
id: 'app.components.ConfirmDialog.title',
|
4566
4647
|
defaultMessage: 'Confirmation'
|
4567
4648
|
}),
|
4649
|
+
loading: isLoading,
|
4568
4650
|
content: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
4569
4651
|
direction: "column",
|
4570
4652
|
alignItems: "stretch",
|
@@ -4613,7 +4695,7 @@ const UnpublishAction = ({ documents, model })=>{
|
|
4613
4695
|
const hasPublishPermission = useDocumentRBAC('unpublishAction', (state)=>state.canPublish);
|
4614
4696
|
const hasI18nEnabled = Boolean(schema?.pluginOptions?.i18n);
|
4615
4697
|
const hasDraftAndPublishEnabled = Boolean(schema?.options?.draftAndPublish);
|
4616
|
-
const { unpublishMany: bulkUnpublishAction } = useDocumentActions();
|
4698
|
+
const { unpublishMany: bulkUnpublishAction, isLoading } = useDocumentActions();
|
4617
4699
|
const documentIds = documents.map(({ documentId })=>documentId);
|
4618
4700
|
const [{ query }] = strapiAdmin.useQueryParams();
|
4619
4701
|
const params = React__namespace.useMemo(()=>buildValidParams(query), [
|
@@ -4643,6 +4725,7 @@ const UnpublishAction = ({ documents, model })=>{
|
|
4643
4725
|
id: 'app.components.ConfirmDialog.title',
|
4644
4726
|
defaultMessage: 'Confirmation'
|
4645
4727
|
}),
|
4728
|
+
loading: isLoading,
|
4646
4729
|
content: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
4647
4730
|
direction: "column",
|
4648
4731
|
alignItems: "stretch",
|
@@ -5024,9 +5107,11 @@ const DEFAULT_TABLE_ROW_ACTIONS = [
|
|
5024
5107
|
* The response should still be filtered by the position, as the static property is new
|
5025
5108
|
* and not mandatory to avoid a breaking change.
|
5026
5109
|
*/ if (position) {
|
5027
|
-
return this.documentActions.filter((action)=>
|
5110
|
+
return this.documentActions.filter((action)=>{
|
5111
|
+
return action.position == undefined || [
|
5028
5112
|
action.position
|
5029
|
-
].flat().includes(position)
|
5113
|
+
].flat().includes(position);
|
5114
|
+
});
|
5030
5115
|
}
|
5031
5116
|
return this.documentActions;
|
5032
5117
|
},
|
@@ -5278,7 +5363,7 @@ function __variableDynamicImportRuntime1__(path) {
|
|
5278
5363
|
case './translations/ca.json': return Promise.resolve().then(function () { return require('./ca-ClDTvatJ.js'); });
|
5279
5364
|
case './translations/cs.json': return Promise.resolve().then(function () { return require('./cs-BJFxwIWj.js'); });
|
5280
5365
|
case './translations/de.json': return Promise.resolve().then(function () { return require('./de-CbImAUA5.js'); });
|
5281
|
-
case './translations/en.json': return Promise.resolve().then(function () { return require('./en-
|
5366
|
+
case './translations/en.json': return Promise.resolve().then(function () { return require('./en-CH__IC8g.js'); });
|
5282
5367
|
case './translations/es.json': return Promise.resolve().then(function () { return require('./es-C8vLuvZL.js'); });
|
5283
5368
|
case './translations/eu.json': return Promise.resolve().then(function () { return require('./eu-BJW3AvXu.js'); });
|
5284
5369
|
case './translations/fr.json': return Promise.resolve().then(function () { return require('./fr-gQSilC7w.js'); });
|
@@ -5301,7 +5386,7 @@ function __variableDynamicImportRuntime1__(path) {
|
|
5301
5386
|
case './translations/sv.json': return Promise.resolve().then(function () { return require('./sv-BstBC1Yp.js'); });
|
5302
5387
|
case './translations/th.json': return Promise.resolve().then(function () { return require('./th-lXoOCqPC.js'); });
|
5303
5388
|
case './translations/tr.json': return Promise.resolve().then(function () { return require('./tr-CkS6sLIE.js'); });
|
5304
|
-
case './translations/uk.json': return Promise.resolve().then(function () { return require('./uk-
|
5389
|
+
case './translations/uk.json': return Promise.resolve().then(function () { return require('./uk-DB6OgySY.js'); });
|
5305
5390
|
case './translations/vi.json': return Promise.resolve().then(function () { return require('./vi-BGr1X_HZ.js'); });
|
5306
5391
|
case './translations/zh-Hans.json': return Promise.resolve().then(function () { return require('./zh-Hans-JVK9x7xr.js'); });
|
5307
5392
|
case './translations/zh.json': return Promise.resolve().then(function () { return require('./zh-DwFu_Kfj.js'); });
|
@@ -5332,7 +5417,7 @@ var index = {
|
|
5332
5417
|
app.router.addRoute({
|
5333
5418
|
path: 'content-manager/*',
|
5334
5419
|
lazy: async ()=>{
|
5335
|
-
const { Layout } = await Promise.resolve().then(function () { return require('./layout-
|
5420
|
+
const { Layout } = await Promise.resolve().then(function () { return require('./layout-CqndYVtU.js'); });
|
5336
5421
|
return {
|
5337
5422
|
Component: Layout
|
5338
5423
|
};
|
@@ -5373,6 +5458,8 @@ exports.CLONE_PATH = CLONE_PATH;
|
|
5373
5458
|
exports.COLLECTION_TYPES = COLLECTION_TYPES;
|
5374
5459
|
exports.CREATOR_FIELDS = CREATOR_FIELDS;
|
5375
5460
|
exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
|
5461
|
+
exports.DocumentActionButton = DocumentActionButton;
|
5462
|
+
exports.DocumentContextProvider = DocumentContextProvider;
|
5376
5463
|
exports.DocumentRBAC = DocumentRBAC;
|
5377
5464
|
exports.DocumentStatus = DocumentStatus;
|
5378
5465
|
exports.HOOKS = HOOKS;
|
@@ -5406,6 +5493,7 @@ exports.useDoc = useDoc;
|
|
5406
5493
|
exports.useDocLayout = useDocLayout;
|
5407
5494
|
exports.useDocument = useDocument;
|
5408
5495
|
exports.useDocumentActions = useDocumentActions;
|
5496
|
+
exports.useDocumentContext = useDocumentContext;
|
5409
5497
|
exports.useDocumentLayout = useDocumentLayout;
|
5410
5498
|
exports.useDocumentRBAC = useDocumentRBAC;
|
5411
5499
|
exports.useGetAllContentTypeSettingsQuery = useGetAllContentTypeSettingsQuery;
|
@@ -5413,5 +5501,6 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
|
5413
5501
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
5414
5502
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
5415
5503
|
exports.useGetPreviewUrlQuery = useGetPreviewUrlQuery;
|
5504
|
+
exports.useLazyGetDocumentQuery = useLazyGetDocumentQuery;
|
5416
5505
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
5417
|
-
//# sourceMappingURL=index-
|
5506
|
+
//# sourceMappingURL=index-DoUQnFTk.js.map
|