@strapi/content-releases 0.0.0-experimental.edc24aaa3bb5a90fa5fd4fee208167dd4e2e38d4 → 0.0.0-experimental.f0a0bc26f5ef0693aaea2a616bc6b816cfee54b6
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/_chunks/{App-UQxgTJY5.mjs → App-FQyYFBJT.mjs} +313 -105
- package/dist/_chunks/App-FQyYFBJT.mjs.map +1 -0
- package/dist/_chunks/{App-D-lWdVb2.js → App-lx4Ucy9W.js} +352 -144
- package/dist/_chunks/App-lx4Ucy9W.js.map +1 -0
- package/dist/_chunks/{ReleasesSettingsPage-CuUXvABk.mjs → ReleasesSettingsPage-DqBxvJ9i.mjs} +4 -4
- package/dist/_chunks/ReleasesSettingsPage-DqBxvJ9i.mjs.map +1 -0
- package/dist/_chunks/{ReleasesSettingsPage-xfAoY8N3.js → ReleasesSettingsPage-T5VEAV03.js} +4 -4
- package/dist/_chunks/ReleasesSettingsPage-T5VEAV03.js.map +1 -0
- package/dist/_chunks/{en-BCDLTJn3.js → en-BWPPsSH-.js} +12 -2
- package/dist/_chunks/en-BWPPsSH-.js.map +1 -0
- package/dist/_chunks/{en-CGXIF4vQ.mjs → en-D9Q4YW03.mjs} +12 -2
- package/dist/_chunks/en-D9Q4YW03.mjs.map +1 -0
- package/dist/_chunks/{index-b3Ej95H7.mjs → index-CK9G80CL.mjs} +307 -26
- package/dist/_chunks/index-CK9G80CL.mjs.map +1 -0
- package/dist/_chunks/{index-jnv9zdcE.js → index-Cl3tM1YW.js} +304 -23
- package/dist/_chunks/index-Cl3tM1YW.js.map +1 -0
- package/dist/_chunks/{schemas-z5zp-_Gd.js → schemas-BE1LxE9J.js} +2 -2
- package/dist/_chunks/schemas-BE1LxE9J.js.map +1 -0
- package/dist/_chunks/{schemas-63pFihNF.mjs → schemas-DdA2ic2U.mjs} +2 -2
- package/dist/_chunks/schemas-DdA2ic2U.mjs.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/EntryValidationPopover.d.ts +13 -0
- package/dist/admin/src/components/ReleaseListCell.d.ts +28 -0
- package/dist/admin/src/services/release.d.ts +34 -32
- package/dist/server/index.js +191 -88
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +191 -88
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/controllers/index.d.ts +2 -0
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/release-action.d.ts +1 -0
- package/dist/server/src/controllers/release-action.d.ts.map +1 -1
- package/dist/server/src/controllers/release.d.ts +1 -0
- package/dist/server/src/controllers/release.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +6 -6
- package/dist/server/src/middlewares/documents.d.ts.map +1 -1
- package/dist/server/src/migrations/database/5.0.0-document-id-in-actions.d.ts.map +1 -1
- package/dist/server/src/routes/release-action.d.ts.map +1 -1
- package/dist/server/src/routes/release.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +4 -6
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/release-action.d.ts +6 -8
- package/dist/server/src/services/release-action.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/shared/contracts/release-actions.d.ts +11 -6
- package/dist/shared/contracts/release-actions.d.ts.map +1 -1
- package/dist/shared/contracts/releases.d.ts +3 -2
- package/dist/shared/contracts/releases.d.ts.map +1 -1
- package/package.json +17 -15
- package/dist/_chunks/App-D-lWdVb2.js.map +0 -1
- package/dist/_chunks/App-UQxgTJY5.mjs.map +0 -1
- package/dist/_chunks/ReleasesSettingsPage-CuUXvABk.mjs.map +0 -1
- package/dist/_chunks/ReleasesSettingsPage-xfAoY8N3.js.map +0 -1
- package/dist/_chunks/en-BCDLTJn3.js.map +0 -1
- package/dist/_chunks/en-CGXIF4vQ.mjs.map +0 -1
- package/dist/_chunks/index-b3Ej95H7.mjs.map +0 -1
- package/dist/_chunks/index-jnv9zdcE.js.map +0 -1
- package/dist/_chunks/schemas-63pFihNF.mjs.map +0 -1
- package/dist/_chunks/schemas-z5zp-_Gd.js.map +0 -1
- package/strapi-server.js +0 -3
package/dist/server/index.mjs
CHANGED
|
@@ -88,6 +88,13 @@ const isEntryValid = async (contentTypeUid, entry, { strapi: strapi2 }) => {
|
|
|
88
88
|
// @ts-expect-error - FIXME: entity here is unnecessary
|
|
89
89
|
entry
|
|
90
90
|
);
|
|
91
|
+
const workflowsService = strapi2.plugin("review-workflows").service("workflows");
|
|
92
|
+
const workflow = await workflowsService.getAssignedWorkflow(contentTypeUid, {
|
|
93
|
+
populate: "stageRequiredToPublish"
|
|
94
|
+
});
|
|
95
|
+
if (workflow?.stageRequiredToPublish) {
|
|
96
|
+
return entry.strapi_stage.id === workflow.stageRequiredToPublish.id;
|
|
97
|
+
}
|
|
91
98
|
return true;
|
|
92
99
|
} catch {
|
|
93
100
|
return false;
|
|
@@ -101,7 +108,11 @@ const getEntry = async ({
|
|
|
101
108
|
status = "draft"
|
|
102
109
|
}, { strapi: strapi2 }) => {
|
|
103
110
|
if (documentId) {
|
|
104
|
-
|
|
111
|
+
const entry = await strapi2.documents(contentType).findOne({ documentId, locale, populate, status });
|
|
112
|
+
if (status === "published" && !entry) {
|
|
113
|
+
return strapi2.documents(contentType).findOne({ documentId, locale, populate, status: "draft" });
|
|
114
|
+
}
|
|
115
|
+
return entry;
|
|
105
116
|
}
|
|
106
117
|
return strapi2.documents(contentType).findFirst({ locale, populate, status });
|
|
107
118
|
};
|
|
@@ -306,6 +317,10 @@ async function enableContentTypeLocalized({ oldContentTypes, contentTypes: conte
|
|
|
306
317
|
const addEntryDocumentToReleaseActions = {
|
|
307
318
|
name: "content-releases::5.0.0-add-entry-document-id-to-release-actions",
|
|
308
319
|
async up(trx, db) {
|
|
320
|
+
const hasTable = await trx.schema.hasTable("strapi_release_actions");
|
|
321
|
+
if (!hasTable) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
309
324
|
const hasPolymorphicColumn = await trx.schema.hasColumn("strapi_release_actions", "target_id");
|
|
310
325
|
if (hasPolymorphicColumn) {
|
|
311
326
|
const hasEntryDocumentIdColumn = await trx.schema.hasColumn(
|
|
@@ -347,6 +362,7 @@ const register = async ({ strapi: strapi2 }) => {
|
|
|
347
362
|
const updateActionsStatusAndUpdateReleaseStatus = async (contentType, entry) => {
|
|
348
363
|
const releases = await strapi.db.query(RELEASE_MODEL_UID).findMany({
|
|
349
364
|
where: {
|
|
365
|
+
releasedAt: null,
|
|
350
366
|
actions: {
|
|
351
367
|
contentType,
|
|
352
368
|
entryDocumentId: entry.documentId,
|
|
@@ -355,7 +371,7 @@ const updateActionsStatusAndUpdateReleaseStatus = async (contentType, entry) =>
|
|
|
355
371
|
}
|
|
356
372
|
});
|
|
357
373
|
const entryStatus = await isEntryValid(contentType, entry, { strapi });
|
|
358
|
-
await strapi.db.query(RELEASE_ACTION_MODEL_UID).
|
|
374
|
+
await strapi.db.query(RELEASE_ACTION_MODEL_UID).updateMany({
|
|
359
375
|
where: {
|
|
360
376
|
contentType,
|
|
361
377
|
entryDocumentId: entry.documentId,
|
|
@@ -459,8 +475,8 @@ const bootstrap = async ({ strapi: strapi2 }) => {
|
|
|
459
475
|
const { where } = event.params;
|
|
460
476
|
deleteReleasesActionsAndUpdateReleaseStatus({
|
|
461
477
|
contentType: model.uid,
|
|
462
|
-
locale: where
|
|
463
|
-
...where
|
|
478
|
+
locale: where?.locale ?? null,
|
|
479
|
+
...where?.documentId && { entryDocumentId: where.documentId }
|
|
464
480
|
});
|
|
465
481
|
}
|
|
466
482
|
} catch (error) {
|
|
@@ -906,7 +922,7 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
906
922
|
return contentTypesData;
|
|
907
923
|
};
|
|
908
924
|
return {
|
|
909
|
-
async create(releaseId, action) {
|
|
925
|
+
async create(releaseId, action, { disableUpdateReleaseStatus = false } = {}) {
|
|
910
926
|
const { validateEntryData, validateUniqueEntry } = getService("release-validation", {
|
|
911
927
|
strapi: strapi2
|
|
912
928
|
});
|
|
@@ -914,6 +930,14 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
914
930
|
validateEntryData(action.contentType, action.entryDocumentId),
|
|
915
931
|
validateUniqueEntry(releaseId, action)
|
|
916
932
|
]);
|
|
933
|
+
const model = strapi2.contentType(action.contentType);
|
|
934
|
+
if (model.kind === "singleType") {
|
|
935
|
+
const document = await strapi2.db.query(model.uid).findOne({ select: ["documentId"] });
|
|
936
|
+
if (!document) {
|
|
937
|
+
throw new errors.NotFoundError(`No entry found for contentType ${action.contentType}`);
|
|
938
|
+
}
|
|
939
|
+
action.entryDocumentId = document.documentId;
|
|
940
|
+
}
|
|
917
941
|
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({ where: { id: releaseId } });
|
|
918
942
|
if (!release2) {
|
|
919
943
|
throw new errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
@@ -939,7 +963,9 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
939
963
|
},
|
|
940
964
|
populate: { release: { select: ["id"] } }
|
|
941
965
|
});
|
|
942
|
-
|
|
966
|
+
if (!disableUpdateReleaseStatus) {
|
|
967
|
+
getService("release", { strapi: strapi2 }).updateReleaseStatus(release2.id);
|
|
968
|
+
}
|
|
943
969
|
return releaseAction2;
|
|
944
970
|
},
|
|
945
971
|
async findPage(releaseId, query) {
|
|
@@ -1005,16 +1031,26 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
1005
1031
|
const groupName = getGroupName(groupBy);
|
|
1006
1032
|
return _.groupBy(groupName)(formattedData);
|
|
1007
1033
|
},
|
|
1008
|
-
getContentTypeModelsFromActions(actions) {
|
|
1034
|
+
async getContentTypeModelsFromActions(actions) {
|
|
1009
1035
|
const contentTypeUids = actions.reduce((acc, action) => {
|
|
1010
1036
|
if (!acc.includes(action.contentType)) {
|
|
1011
1037
|
acc.push(action.contentType);
|
|
1012
1038
|
}
|
|
1013
1039
|
return acc;
|
|
1014
1040
|
}, []);
|
|
1015
|
-
const
|
|
1016
|
-
|
|
1017
|
-
|
|
1041
|
+
const workflowsService = strapi2.plugin("review-workflows").service("workflows");
|
|
1042
|
+
const contentTypeModelsMap = await async.reduce(contentTypeUids)(
|
|
1043
|
+
async (accPromise, contentTypeUid) => {
|
|
1044
|
+
const acc = await accPromise;
|
|
1045
|
+
const contentTypeModel = strapi2.getModel(contentTypeUid);
|
|
1046
|
+
const workflow = await workflowsService.getAssignedWorkflow(contentTypeUid, {
|
|
1047
|
+
populate: "stageRequiredToPublish"
|
|
1048
|
+
});
|
|
1049
|
+
acc[contentTypeUid] = {
|
|
1050
|
+
...contentTypeModel,
|
|
1051
|
+
hasReviewWorkflow: !!workflow,
|
|
1052
|
+
stageRequiredToPublish: workflow?.stageRequiredToPublish
|
|
1053
|
+
};
|
|
1018
1054
|
return acc;
|
|
1019
1055
|
},
|
|
1020
1056
|
{}
|
|
@@ -1042,7 +1078,7 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
1042
1078
|
`Action with id ${actionId} not found in release with id ${releaseId} or it is already published`
|
|
1043
1079
|
);
|
|
1044
1080
|
}
|
|
1045
|
-
const actionStatus = update.type === "publish" ? getDraftEntryValidStatus(
|
|
1081
|
+
const actionStatus = update.type === "publish" ? await getDraftEntryValidStatus(
|
|
1046
1082
|
{
|
|
1047
1083
|
contentType: action.contentType,
|
|
1048
1084
|
documentId: action.entryDocumentId,
|
|
@@ -1089,6 +1125,54 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
1089
1125
|
}
|
|
1090
1126
|
getService("release", { strapi: strapi2 }).updateReleaseStatus(releaseId);
|
|
1091
1127
|
return deletedAction;
|
|
1128
|
+
},
|
|
1129
|
+
async validateActionsByContentTypes(contentTypeUids) {
|
|
1130
|
+
const actions = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).findMany({
|
|
1131
|
+
where: {
|
|
1132
|
+
contentType: {
|
|
1133
|
+
$in: contentTypeUids
|
|
1134
|
+
},
|
|
1135
|
+
// We only want to validate actions that are going to be published
|
|
1136
|
+
type: "publish",
|
|
1137
|
+
release: {
|
|
1138
|
+
releasedAt: {
|
|
1139
|
+
$null: true
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
},
|
|
1143
|
+
populate: { release: true }
|
|
1144
|
+
});
|
|
1145
|
+
const releasesUpdated = [];
|
|
1146
|
+
await async.map(actions, async (action) => {
|
|
1147
|
+
const isValid = await getDraftEntryValidStatus(
|
|
1148
|
+
{
|
|
1149
|
+
contentType: action.contentType,
|
|
1150
|
+
documentId: action.entryDocumentId,
|
|
1151
|
+
locale: action.locale
|
|
1152
|
+
},
|
|
1153
|
+
{ strapi: strapi2 }
|
|
1154
|
+
);
|
|
1155
|
+
await strapi2.db.query(RELEASE_ACTION_MODEL_UID).update({
|
|
1156
|
+
where: {
|
|
1157
|
+
id: action.id
|
|
1158
|
+
},
|
|
1159
|
+
data: {
|
|
1160
|
+
isEntryValid: isValid
|
|
1161
|
+
}
|
|
1162
|
+
});
|
|
1163
|
+
if (!releasesUpdated.includes(action.release.id)) {
|
|
1164
|
+
releasesUpdated.push(action.release.id);
|
|
1165
|
+
}
|
|
1166
|
+
return {
|
|
1167
|
+
id: action.id,
|
|
1168
|
+
isEntryValid: isValid
|
|
1169
|
+
};
|
|
1170
|
+
});
|
|
1171
|
+
if (releasesUpdated.length > 0) {
|
|
1172
|
+
await async.map(releasesUpdated, async (releaseId) => {
|
|
1173
|
+
await getService("release", { strapi: strapi2 }).updateReleaseStatus(releaseId);
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1092
1176
|
}
|
|
1093
1177
|
};
|
|
1094
1178
|
};
|
|
@@ -1112,11 +1196,11 @@ const createReleaseValidationService = ({ strapi: strapi2 }) => ({
|
|
|
1112
1196
|
throw new errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
1113
1197
|
}
|
|
1114
1198
|
const isEntryInRelease = release2.actions.some(
|
|
1115
|
-
(action) =>
|
|
1199
|
+
(action) => action.entryDocumentId === releaseActionArgs.entryDocumentId && action.contentType === releaseActionArgs.contentType && (releaseActionArgs.locale ? action.locale === releaseActionArgs.locale : true)
|
|
1116
1200
|
);
|
|
1117
1201
|
if (isEntryInRelease) {
|
|
1118
1202
|
throw new AlreadyOnReleaseError(
|
|
1119
|
-
`Entry with documentId ${releaseActionArgs.entryDocumentId}
|
|
1203
|
+
`Entry with documentId ${releaseActionArgs.entryDocumentId}${releaseActionArgs.locale ? `( ${releaseActionArgs.locale})` : ""} and contentType ${releaseActionArgs.contentType} already exists in release with id ${releaseId}`
|
|
1120
1204
|
);
|
|
1121
1205
|
}
|
|
1122
1206
|
},
|
|
@@ -1283,7 +1367,15 @@ const releaseController = {
|
|
|
1283
1367
|
const releaseService = getService("release", { strapi });
|
|
1284
1368
|
const query = await permissionsManager.sanitizeQuery(ctx.query);
|
|
1285
1369
|
await validatefindByDocumentAttachedParams(query);
|
|
1286
|
-
const
|
|
1370
|
+
const model = strapi.getModel(query.contentType);
|
|
1371
|
+
if (model.kind && model.kind === "singleType") {
|
|
1372
|
+
const document = await strapi.db.query(model.uid).findOne({ select: ["documentId"] });
|
|
1373
|
+
if (!document) {
|
|
1374
|
+
throw new errors.NotFoundError(`No entry found for contentType ${query.contentType}`);
|
|
1375
|
+
}
|
|
1376
|
+
query.entryDocumentId = document.documentId;
|
|
1377
|
+
}
|
|
1378
|
+
const { contentType, hasEntryAttached, entryDocumentId, locale } = query;
|
|
1287
1379
|
const isEntryAttached = typeof hasEntryAttached === "string" ? Boolean(JSON.parse(hasEntryAttached)) : false;
|
|
1288
1380
|
if (isEntryAttached) {
|
|
1289
1381
|
const releases = await releaseService.findMany({
|
|
@@ -1297,7 +1389,12 @@ const releaseController = {
|
|
|
1297
1389
|
},
|
|
1298
1390
|
populate: {
|
|
1299
1391
|
actions: {
|
|
1300
|
-
fields: ["type"]
|
|
1392
|
+
fields: ["type"],
|
|
1393
|
+
filters: {
|
|
1394
|
+
contentType,
|
|
1395
|
+
entryDocumentId: entryDocumentId ?? null,
|
|
1396
|
+
locale: locale ?? null
|
|
1397
|
+
}
|
|
1301
1398
|
}
|
|
1302
1399
|
}
|
|
1303
1400
|
});
|
|
@@ -1385,43 +1482,50 @@ const releaseController = {
|
|
|
1385
1482
|
};
|
|
1386
1483
|
ctx.body = { data };
|
|
1387
1484
|
},
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1485
|
+
async mapEntriesToReleases(ctx) {
|
|
1486
|
+
const { contentTypeUid, documentIds, locale } = ctx.query;
|
|
1487
|
+
if (!contentTypeUid || !documentIds) {
|
|
1488
|
+
throw new errors.ValidationError("Missing required query parameters");
|
|
1489
|
+
}
|
|
1490
|
+
const releaseService = getService("release", { strapi });
|
|
1491
|
+
const releasesWithActions = await releaseService.findMany({
|
|
1492
|
+
where: {
|
|
1493
|
+
releasedAt: null,
|
|
1494
|
+
actions: {
|
|
1495
|
+
contentType: contentTypeUid,
|
|
1496
|
+
entryDocumentId: {
|
|
1497
|
+
$in: documentIds
|
|
1498
|
+
},
|
|
1499
|
+
locale
|
|
1500
|
+
}
|
|
1501
|
+
},
|
|
1502
|
+
populate: {
|
|
1503
|
+
actions: true
|
|
1394
1504
|
}
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
ctx.body = {
|
|
1421
|
-
data: mappedEntriesInReleases,
|
|
1422
|
-
};
|
|
1423
|
-
},
|
|
1424
|
-
*/
|
|
1505
|
+
});
|
|
1506
|
+
const mappedEntriesInReleases = releasesWithActions.reduce(
|
|
1507
|
+
(acc, release2) => {
|
|
1508
|
+
release2.actions.forEach((action) => {
|
|
1509
|
+
if (action.contentType !== contentTypeUid) {
|
|
1510
|
+
return;
|
|
1511
|
+
}
|
|
1512
|
+
if (locale && action.locale !== locale) {
|
|
1513
|
+
return;
|
|
1514
|
+
}
|
|
1515
|
+
if (!acc[action.entryDocumentId]) {
|
|
1516
|
+
acc[action.entryDocumentId] = [{ id: release2.id, name: release2.name }];
|
|
1517
|
+
} else {
|
|
1518
|
+
acc[action.entryDocumentId].push({ id: release2.id, name: release2.name });
|
|
1519
|
+
}
|
|
1520
|
+
});
|
|
1521
|
+
return acc;
|
|
1522
|
+
},
|
|
1523
|
+
{}
|
|
1524
|
+
);
|
|
1525
|
+
ctx.body = {
|
|
1526
|
+
data: mappedEntriesInReleases
|
|
1527
|
+
};
|
|
1528
|
+
},
|
|
1425
1529
|
async create(ctx) {
|
|
1426
1530
|
const user = ctx.state.user;
|
|
1427
1531
|
const releaseArgs = ctx.request.body;
|
|
@@ -1514,22 +1618,23 @@ const releaseActionController = {
|
|
|
1514
1618
|
data: releaseAction2
|
|
1515
1619
|
});
|
|
1516
1620
|
},
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
const
|
|
1520
|
-
const releaseActionsArgs = ctx.request.body as CreateManyReleaseActions.Request['body'];
|
|
1621
|
+
async createMany(ctx) {
|
|
1622
|
+
const releaseId = ctx.params.releaseId;
|
|
1623
|
+
const releaseActionsArgs = ctx.request.body;
|
|
1521
1624
|
await Promise.all(
|
|
1522
1625
|
releaseActionsArgs.map((releaseActionArgs) => validateReleaseAction(releaseActionArgs))
|
|
1523
1626
|
);
|
|
1524
|
-
const releaseActionService = getService(
|
|
1627
|
+
const releaseActionService = getService("release-action", { strapi });
|
|
1628
|
+
const releaseService = getService("release", { strapi });
|
|
1525
1629
|
const releaseActions = await strapi.db.transaction(async () => {
|
|
1526
|
-
const
|
|
1630
|
+
const releaseActions2 = await Promise.all(
|
|
1527
1631
|
releaseActionsArgs.map(async (releaseActionArgs) => {
|
|
1528
1632
|
try {
|
|
1529
|
-
const action = await releaseActionService.create(releaseId, releaseActionArgs
|
|
1633
|
+
const action = await releaseActionService.create(releaseId, releaseActionArgs, {
|
|
1634
|
+
disableUpdateReleaseStatus: true
|
|
1635
|
+
});
|
|
1530
1636
|
return action;
|
|
1531
1637
|
} catch (error) {
|
|
1532
|
-
// If the entry is already in the release, we don't want to throw an error, so we catch and ignore it
|
|
1533
1638
|
if (error instanceof AlreadyOnReleaseError) {
|
|
1534
1639
|
return null;
|
|
1535
1640
|
}
|
|
@@ -1537,18 +1642,20 @@ const releaseActionController = {
|
|
|
1537
1642
|
}
|
|
1538
1643
|
})
|
|
1539
1644
|
);
|
|
1540
|
-
return
|
|
1645
|
+
return releaseActions2;
|
|
1541
1646
|
});
|
|
1542
1647
|
const newReleaseActions = releaseActions.filter((action) => action !== null);
|
|
1648
|
+
if (newReleaseActions.length > 0) {
|
|
1649
|
+
releaseService.updateReleaseStatus(releaseId);
|
|
1650
|
+
}
|
|
1543
1651
|
ctx.created({
|
|
1544
1652
|
data: newReleaseActions,
|
|
1545
1653
|
meta: {
|
|
1546
1654
|
entriesAlreadyInRelease: releaseActions.length - newReleaseActions.length,
|
|
1547
|
-
totalEntries: releaseActions.length
|
|
1548
|
-
}
|
|
1655
|
+
totalEntries: releaseActions.length
|
|
1656
|
+
}
|
|
1549
1657
|
});
|
|
1550
1658
|
},
|
|
1551
|
-
*/
|
|
1552
1659
|
async findMany(ctx) {
|
|
1553
1660
|
const releaseId = ctx.params.releaseId;
|
|
1554
1661
|
const permissionsManager = strapi.service("admin::permission").createPermissionsManager({
|
|
@@ -1584,7 +1691,7 @@ const releaseActionController = {
|
|
|
1584
1691
|
entry: action.entry ? await contentTypeOutputSanitizers[action.contentType](action.entry) : {}
|
|
1585
1692
|
}));
|
|
1586
1693
|
const groupedData = await releaseActionService.groupActions(sanitizedResults, query.sort);
|
|
1587
|
-
const contentTypes2 = releaseActionService.getContentTypeModelsFromActions(results);
|
|
1694
|
+
const contentTypes2 = await releaseActionService.getContentTypeModelsFromActions(results);
|
|
1588
1695
|
const releaseService = getService("release", { strapi });
|
|
1589
1696
|
const components = await releaseService.getAllComponents();
|
|
1590
1697
|
ctx.body = {
|
|
@@ -1647,24 +1754,22 @@ const controllers = {
|
|
|
1647
1754
|
const release = {
|
|
1648
1755
|
type: "admin",
|
|
1649
1756
|
routes: [
|
|
1650
|
-
/*
|
|
1651
1757
|
{
|
|
1652
|
-
method:
|
|
1653
|
-
path:
|
|
1654
|
-
handler:
|
|
1758
|
+
method: "GET",
|
|
1759
|
+
path: "/mapEntriesToReleases",
|
|
1760
|
+
handler: "release.mapEntriesToReleases",
|
|
1655
1761
|
config: {
|
|
1656
1762
|
policies: [
|
|
1657
|
-
|
|
1763
|
+
"admin::isAuthenticatedAdmin",
|
|
1658
1764
|
{
|
|
1659
|
-
name:
|
|
1765
|
+
name: "admin::hasPermissions",
|
|
1660
1766
|
config: {
|
|
1661
|
-
actions: [
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
]
|
|
1665
|
-
}
|
|
1767
|
+
actions: ["plugin::content-releases.read"]
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
]
|
|
1771
|
+
}
|
|
1666
1772
|
},
|
|
1667
|
-
*/
|
|
1668
1773
|
{
|
|
1669
1774
|
method: "GET",
|
|
1670
1775
|
path: "/getByDocumentAttached",
|
|
@@ -1798,24 +1903,22 @@ const releaseAction = {
|
|
|
1798
1903
|
]
|
|
1799
1904
|
}
|
|
1800
1905
|
},
|
|
1801
|
-
/*
|
|
1802
1906
|
{
|
|
1803
|
-
method:
|
|
1804
|
-
path:
|
|
1805
|
-
handler:
|
|
1907
|
+
method: "POST",
|
|
1908
|
+
path: "/:releaseId/actions/bulk",
|
|
1909
|
+
handler: "release-action.createMany",
|
|
1806
1910
|
config: {
|
|
1807
1911
|
policies: [
|
|
1808
|
-
|
|
1912
|
+
"admin::isAuthenticatedAdmin",
|
|
1809
1913
|
{
|
|
1810
|
-
name:
|
|
1914
|
+
name: "admin::hasPermissions",
|
|
1811
1915
|
config: {
|
|
1812
|
-
actions: [
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
]
|
|
1816
|
-
}
|
|
1916
|
+
actions: ["plugin::content-releases.create-action"]
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
]
|
|
1920
|
+
}
|
|
1817
1921
|
},
|
|
1818
|
-
*/
|
|
1819
1922
|
{
|
|
1820
1923
|
method: "GET",
|
|
1821
1924
|
path: "/:releaseId/actions",
|