@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.js
CHANGED
|
@@ -111,6 +111,13 @@ const isEntryValid = async (contentTypeUid, entry, { strapi: strapi2 }) => {
|
|
|
111
111
|
// @ts-expect-error - FIXME: entity here is unnecessary
|
|
112
112
|
entry
|
|
113
113
|
);
|
|
114
|
+
const workflowsService = strapi2.plugin("review-workflows").service("workflows");
|
|
115
|
+
const workflow = await workflowsService.getAssignedWorkflow(contentTypeUid, {
|
|
116
|
+
populate: "stageRequiredToPublish"
|
|
117
|
+
});
|
|
118
|
+
if (workflow?.stageRequiredToPublish) {
|
|
119
|
+
return entry.strapi_stage.id === workflow.stageRequiredToPublish.id;
|
|
120
|
+
}
|
|
114
121
|
return true;
|
|
115
122
|
} catch {
|
|
116
123
|
return false;
|
|
@@ -124,7 +131,11 @@ const getEntry = async ({
|
|
|
124
131
|
status = "draft"
|
|
125
132
|
}, { strapi: strapi2 }) => {
|
|
126
133
|
if (documentId) {
|
|
127
|
-
|
|
134
|
+
const entry = await strapi2.documents(contentType).findOne({ documentId, locale, populate, status });
|
|
135
|
+
if (status === "published" && !entry) {
|
|
136
|
+
return strapi2.documents(contentType).findOne({ documentId, locale, populate, status: "draft" });
|
|
137
|
+
}
|
|
138
|
+
return entry;
|
|
128
139
|
}
|
|
129
140
|
return strapi2.documents(contentType).findFirst({ locale, populate, status });
|
|
130
141
|
};
|
|
@@ -329,6 +340,10 @@ async function enableContentTypeLocalized({ oldContentTypes, contentTypes: conte
|
|
|
329
340
|
const addEntryDocumentToReleaseActions = {
|
|
330
341
|
name: "content-releases::5.0.0-add-entry-document-id-to-release-actions",
|
|
331
342
|
async up(trx, db) {
|
|
343
|
+
const hasTable = await trx.schema.hasTable("strapi_release_actions");
|
|
344
|
+
if (!hasTable) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
332
347
|
const hasPolymorphicColumn = await trx.schema.hasColumn("strapi_release_actions", "target_id");
|
|
333
348
|
if (hasPolymorphicColumn) {
|
|
334
349
|
const hasEntryDocumentIdColumn = await trx.schema.hasColumn(
|
|
@@ -370,6 +385,7 @@ const register = async ({ strapi: strapi2 }) => {
|
|
|
370
385
|
const updateActionsStatusAndUpdateReleaseStatus = async (contentType, entry) => {
|
|
371
386
|
const releases = await strapi.db.query(RELEASE_MODEL_UID).findMany({
|
|
372
387
|
where: {
|
|
388
|
+
releasedAt: null,
|
|
373
389
|
actions: {
|
|
374
390
|
contentType,
|
|
375
391
|
entryDocumentId: entry.documentId,
|
|
@@ -378,7 +394,7 @@ const updateActionsStatusAndUpdateReleaseStatus = async (contentType, entry) =>
|
|
|
378
394
|
}
|
|
379
395
|
});
|
|
380
396
|
const entryStatus = await isEntryValid(contentType, entry, { strapi });
|
|
381
|
-
await strapi.db.query(RELEASE_ACTION_MODEL_UID).
|
|
397
|
+
await strapi.db.query(RELEASE_ACTION_MODEL_UID).updateMany({
|
|
382
398
|
where: {
|
|
383
399
|
contentType,
|
|
384
400
|
entryDocumentId: entry.documentId,
|
|
@@ -482,8 +498,8 @@ const bootstrap = async ({ strapi: strapi2 }) => {
|
|
|
482
498
|
const { where } = event.params;
|
|
483
499
|
deleteReleasesActionsAndUpdateReleaseStatus({
|
|
484
500
|
contentType: model.uid,
|
|
485
|
-
locale: where
|
|
486
|
-
...where
|
|
501
|
+
locale: where?.locale ?? null,
|
|
502
|
+
...where?.documentId && { entryDocumentId: where.documentId }
|
|
487
503
|
});
|
|
488
504
|
}
|
|
489
505
|
} catch (error) {
|
|
@@ -929,7 +945,7 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
929
945
|
return contentTypesData;
|
|
930
946
|
};
|
|
931
947
|
return {
|
|
932
|
-
async create(releaseId, action) {
|
|
948
|
+
async create(releaseId, action, { disableUpdateReleaseStatus = false } = {}) {
|
|
933
949
|
const { validateEntryData, validateUniqueEntry } = getService("release-validation", {
|
|
934
950
|
strapi: strapi2
|
|
935
951
|
});
|
|
@@ -937,6 +953,14 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
937
953
|
validateEntryData(action.contentType, action.entryDocumentId),
|
|
938
954
|
validateUniqueEntry(releaseId, action)
|
|
939
955
|
]);
|
|
956
|
+
const model = strapi2.contentType(action.contentType);
|
|
957
|
+
if (model.kind === "singleType") {
|
|
958
|
+
const document = await strapi2.db.query(model.uid).findOne({ select: ["documentId"] });
|
|
959
|
+
if (!document) {
|
|
960
|
+
throw new utils.errors.NotFoundError(`No entry found for contentType ${action.contentType}`);
|
|
961
|
+
}
|
|
962
|
+
action.entryDocumentId = document.documentId;
|
|
963
|
+
}
|
|
940
964
|
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({ where: { id: releaseId } });
|
|
941
965
|
if (!release2) {
|
|
942
966
|
throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
@@ -962,7 +986,9 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
962
986
|
},
|
|
963
987
|
populate: { release: { select: ["id"] } }
|
|
964
988
|
});
|
|
965
|
-
|
|
989
|
+
if (!disableUpdateReleaseStatus) {
|
|
990
|
+
getService("release", { strapi: strapi2 }).updateReleaseStatus(release2.id);
|
|
991
|
+
}
|
|
966
992
|
return releaseAction2;
|
|
967
993
|
},
|
|
968
994
|
async findPage(releaseId, query) {
|
|
@@ -1028,16 +1054,26 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
1028
1054
|
const groupName = getGroupName(groupBy);
|
|
1029
1055
|
return ___default.default.groupBy(groupName)(formattedData);
|
|
1030
1056
|
},
|
|
1031
|
-
getContentTypeModelsFromActions(actions) {
|
|
1057
|
+
async getContentTypeModelsFromActions(actions) {
|
|
1032
1058
|
const contentTypeUids = actions.reduce((acc, action) => {
|
|
1033
1059
|
if (!acc.includes(action.contentType)) {
|
|
1034
1060
|
acc.push(action.contentType);
|
|
1035
1061
|
}
|
|
1036
1062
|
return acc;
|
|
1037
1063
|
}, []);
|
|
1038
|
-
const
|
|
1039
|
-
|
|
1040
|
-
|
|
1064
|
+
const workflowsService = strapi2.plugin("review-workflows").service("workflows");
|
|
1065
|
+
const contentTypeModelsMap = await utils.async.reduce(contentTypeUids)(
|
|
1066
|
+
async (accPromise, contentTypeUid) => {
|
|
1067
|
+
const acc = await accPromise;
|
|
1068
|
+
const contentTypeModel = strapi2.getModel(contentTypeUid);
|
|
1069
|
+
const workflow = await workflowsService.getAssignedWorkflow(contentTypeUid, {
|
|
1070
|
+
populate: "stageRequiredToPublish"
|
|
1071
|
+
});
|
|
1072
|
+
acc[contentTypeUid] = {
|
|
1073
|
+
...contentTypeModel,
|
|
1074
|
+
hasReviewWorkflow: !!workflow,
|
|
1075
|
+
stageRequiredToPublish: workflow?.stageRequiredToPublish
|
|
1076
|
+
};
|
|
1041
1077
|
return acc;
|
|
1042
1078
|
},
|
|
1043
1079
|
{}
|
|
@@ -1065,7 +1101,7 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
1065
1101
|
`Action with id ${actionId} not found in release with id ${releaseId} or it is already published`
|
|
1066
1102
|
);
|
|
1067
1103
|
}
|
|
1068
|
-
const actionStatus = update.type === "publish" ? getDraftEntryValidStatus(
|
|
1104
|
+
const actionStatus = update.type === "publish" ? await getDraftEntryValidStatus(
|
|
1069
1105
|
{
|
|
1070
1106
|
contentType: action.contentType,
|
|
1071
1107
|
documentId: action.entryDocumentId,
|
|
@@ -1112,6 +1148,54 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
1112
1148
|
}
|
|
1113
1149
|
getService("release", { strapi: strapi2 }).updateReleaseStatus(releaseId);
|
|
1114
1150
|
return deletedAction;
|
|
1151
|
+
},
|
|
1152
|
+
async validateActionsByContentTypes(contentTypeUids) {
|
|
1153
|
+
const actions = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).findMany({
|
|
1154
|
+
where: {
|
|
1155
|
+
contentType: {
|
|
1156
|
+
$in: contentTypeUids
|
|
1157
|
+
},
|
|
1158
|
+
// We only want to validate actions that are going to be published
|
|
1159
|
+
type: "publish",
|
|
1160
|
+
release: {
|
|
1161
|
+
releasedAt: {
|
|
1162
|
+
$null: true
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
},
|
|
1166
|
+
populate: { release: true }
|
|
1167
|
+
});
|
|
1168
|
+
const releasesUpdated = [];
|
|
1169
|
+
await utils.async.map(actions, async (action) => {
|
|
1170
|
+
const isValid = await getDraftEntryValidStatus(
|
|
1171
|
+
{
|
|
1172
|
+
contentType: action.contentType,
|
|
1173
|
+
documentId: action.entryDocumentId,
|
|
1174
|
+
locale: action.locale
|
|
1175
|
+
},
|
|
1176
|
+
{ strapi: strapi2 }
|
|
1177
|
+
);
|
|
1178
|
+
await strapi2.db.query(RELEASE_ACTION_MODEL_UID).update({
|
|
1179
|
+
where: {
|
|
1180
|
+
id: action.id
|
|
1181
|
+
},
|
|
1182
|
+
data: {
|
|
1183
|
+
isEntryValid: isValid
|
|
1184
|
+
}
|
|
1185
|
+
});
|
|
1186
|
+
if (!releasesUpdated.includes(action.release.id)) {
|
|
1187
|
+
releasesUpdated.push(action.release.id);
|
|
1188
|
+
}
|
|
1189
|
+
return {
|
|
1190
|
+
id: action.id,
|
|
1191
|
+
isEntryValid: isValid
|
|
1192
|
+
};
|
|
1193
|
+
});
|
|
1194
|
+
if (releasesUpdated.length > 0) {
|
|
1195
|
+
await utils.async.map(releasesUpdated, async (releaseId) => {
|
|
1196
|
+
await getService("release", { strapi: strapi2 }).updateReleaseStatus(releaseId);
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1115
1199
|
}
|
|
1116
1200
|
};
|
|
1117
1201
|
};
|
|
@@ -1135,11 +1219,11 @@ const createReleaseValidationService = ({ strapi: strapi2 }) => ({
|
|
|
1135
1219
|
throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
1136
1220
|
}
|
|
1137
1221
|
const isEntryInRelease = release2.actions.some(
|
|
1138
|
-
(action) =>
|
|
1222
|
+
(action) => action.entryDocumentId === releaseActionArgs.entryDocumentId && action.contentType === releaseActionArgs.contentType && (releaseActionArgs.locale ? action.locale === releaseActionArgs.locale : true)
|
|
1139
1223
|
);
|
|
1140
1224
|
if (isEntryInRelease) {
|
|
1141
1225
|
throw new AlreadyOnReleaseError(
|
|
1142
|
-
`Entry with documentId ${releaseActionArgs.entryDocumentId}
|
|
1226
|
+
`Entry with documentId ${releaseActionArgs.entryDocumentId}${releaseActionArgs.locale ? `( ${releaseActionArgs.locale})` : ""} and contentType ${releaseActionArgs.contentType} already exists in release with id ${releaseId}`
|
|
1143
1227
|
);
|
|
1144
1228
|
}
|
|
1145
1229
|
},
|
|
@@ -1306,7 +1390,15 @@ const releaseController = {
|
|
|
1306
1390
|
const releaseService = getService("release", { strapi });
|
|
1307
1391
|
const query = await permissionsManager.sanitizeQuery(ctx.query);
|
|
1308
1392
|
await validatefindByDocumentAttachedParams(query);
|
|
1309
|
-
const
|
|
1393
|
+
const model = strapi.getModel(query.contentType);
|
|
1394
|
+
if (model.kind && model.kind === "singleType") {
|
|
1395
|
+
const document = await strapi.db.query(model.uid).findOne({ select: ["documentId"] });
|
|
1396
|
+
if (!document) {
|
|
1397
|
+
throw new utils.errors.NotFoundError(`No entry found for contentType ${query.contentType}`);
|
|
1398
|
+
}
|
|
1399
|
+
query.entryDocumentId = document.documentId;
|
|
1400
|
+
}
|
|
1401
|
+
const { contentType, hasEntryAttached, entryDocumentId, locale } = query;
|
|
1310
1402
|
const isEntryAttached = typeof hasEntryAttached === "string" ? Boolean(JSON.parse(hasEntryAttached)) : false;
|
|
1311
1403
|
if (isEntryAttached) {
|
|
1312
1404
|
const releases = await releaseService.findMany({
|
|
@@ -1320,7 +1412,12 @@ const releaseController = {
|
|
|
1320
1412
|
},
|
|
1321
1413
|
populate: {
|
|
1322
1414
|
actions: {
|
|
1323
|
-
fields: ["type"]
|
|
1415
|
+
fields: ["type"],
|
|
1416
|
+
filters: {
|
|
1417
|
+
contentType,
|
|
1418
|
+
entryDocumentId: entryDocumentId ?? null,
|
|
1419
|
+
locale: locale ?? null
|
|
1420
|
+
}
|
|
1324
1421
|
}
|
|
1325
1422
|
}
|
|
1326
1423
|
});
|
|
@@ -1408,43 +1505,50 @@ const releaseController = {
|
|
|
1408
1505
|
};
|
|
1409
1506
|
ctx.body = { data };
|
|
1410
1507
|
},
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1508
|
+
async mapEntriesToReleases(ctx) {
|
|
1509
|
+
const { contentTypeUid, documentIds, locale } = ctx.query;
|
|
1510
|
+
if (!contentTypeUid || !documentIds) {
|
|
1511
|
+
throw new utils.errors.ValidationError("Missing required query parameters");
|
|
1512
|
+
}
|
|
1513
|
+
const releaseService = getService("release", { strapi });
|
|
1514
|
+
const releasesWithActions = await releaseService.findMany({
|
|
1515
|
+
where: {
|
|
1516
|
+
releasedAt: null,
|
|
1517
|
+
actions: {
|
|
1518
|
+
contentType: contentTypeUid,
|
|
1519
|
+
entryDocumentId: {
|
|
1520
|
+
$in: documentIds
|
|
1521
|
+
},
|
|
1522
|
+
locale
|
|
1523
|
+
}
|
|
1524
|
+
},
|
|
1525
|
+
populate: {
|
|
1526
|
+
actions: true
|
|
1417
1527
|
}
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
ctx.body = {
|
|
1444
|
-
data: mappedEntriesInReleases,
|
|
1445
|
-
};
|
|
1446
|
-
},
|
|
1447
|
-
*/
|
|
1528
|
+
});
|
|
1529
|
+
const mappedEntriesInReleases = releasesWithActions.reduce(
|
|
1530
|
+
(acc, release2) => {
|
|
1531
|
+
release2.actions.forEach((action) => {
|
|
1532
|
+
if (action.contentType !== contentTypeUid) {
|
|
1533
|
+
return;
|
|
1534
|
+
}
|
|
1535
|
+
if (locale && action.locale !== locale) {
|
|
1536
|
+
return;
|
|
1537
|
+
}
|
|
1538
|
+
if (!acc[action.entryDocumentId]) {
|
|
1539
|
+
acc[action.entryDocumentId] = [{ id: release2.id, name: release2.name }];
|
|
1540
|
+
} else {
|
|
1541
|
+
acc[action.entryDocumentId].push({ id: release2.id, name: release2.name });
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
return acc;
|
|
1545
|
+
},
|
|
1546
|
+
{}
|
|
1547
|
+
);
|
|
1548
|
+
ctx.body = {
|
|
1549
|
+
data: mappedEntriesInReleases
|
|
1550
|
+
};
|
|
1551
|
+
},
|
|
1448
1552
|
async create(ctx) {
|
|
1449
1553
|
const user = ctx.state.user;
|
|
1450
1554
|
const releaseArgs = ctx.request.body;
|
|
@@ -1537,22 +1641,23 @@ const releaseActionController = {
|
|
|
1537
1641
|
data: releaseAction2
|
|
1538
1642
|
});
|
|
1539
1643
|
},
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
const
|
|
1543
|
-
const releaseActionsArgs = ctx.request.body as CreateManyReleaseActions.Request['body'];
|
|
1644
|
+
async createMany(ctx) {
|
|
1645
|
+
const releaseId = ctx.params.releaseId;
|
|
1646
|
+
const releaseActionsArgs = ctx.request.body;
|
|
1544
1647
|
await Promise.all(
|
|
1545
1648
|
releaseActionsArgs.map((releaseActionArgs) => validateReleaseAction(releaseActionArgs))
|
|
1546
1649
|
);
|
|
1547
|
-
const releaseActionService = getService(
|
|
1650
|
+
const releaseActionService = getService("release-action", { strapi });
|
|
1651
|
+
const releaseService = getService("release", { strapi });
|
|
1548
1652
|
const releaseActions = await strapi.db.transaction(async () => {
|
|
1549
|
-
const
|
|
1653
|
+
const releaseActions2 = await Promise.all(
|
|
1550
1654
|
releaseActionsArgs.map(async (releaseActionArgs) => {
|
|
1551
1655
|
try {
|
|
1552
|
-
const action = await releaseActionService.create(releaseId, releaseActionArgs
|
|
1656
|
+
const action = await releaseActionService.create(releaseId, releaseActionArgs, {
|
|
1657
|
+
disableUpdateReleaseStatus: true
|
|
1658
|
+
});
|
|
1553
1659
|
return action;
|
|
1554
1660
|
} catch (error) {
|
|
1555
|
-
// If the entry is already in the release, we don't want to throw an error, so we catch and ignore it
|
|
1556
1661
|
if (error instanceof AlreadyOnReleaseError) {
|
|
1557
1662
|
return null;
|
|
1558
1663
|
}
|
|
@@ -1560,18 +1665,20 @@ const releaseActionController = {
|
|
|
1560
1665
|
}
|
|
1561
1666
|
})
|
|
1562
1667
|
);
|
|
1563
|
-
return
|
|
1668
|
+
return releaseActions2;
|
|
1564
1669
|
});
|
|
1565
1670
|
const newReleaseActions = releaseActions.filter((action) => action !== null);
|
|
1671
|
+
if (newReleaseActions.length > 0) {
|
|
1672
|
+
releaseService.updateReleaseStatus(releaseId);
|
|
1673
|
+
}
|
|
1566
1674
|
ctx.created({
|
|
1567
1675
|
data: newReleaseActions,
|
|
1568
1676
|
meta: {
|
|
1569
1677
|
entriesAlreadyInRelease: releaseActions.length - newReleaseActions.length,
|
|
1570
|
-
totalEntries: releaseActions.length
|
|
1571
|
-
}
|
|
1678
|
+
totalEntries: releaseActions.length
|
|
1679
|
+
}
|
|
1572
1680
|
});
|
|
1573
1681
|
},
|
|
1574
|
-
*/
|
|
1575
1682
|
async findMany(ctx) {
|
|
1576
1683
|
const releaseId = ctx.params.releaseId;
|
|
1577
1684
|
const permissionsManager = strapi.service("admin::permission").createPermissionsManager({
|
|
@@ -1607,7 +1714,7 @@ const releaseActionController = {
|
|
|
1607
1714
|
entry: action.entry ? await contentTypeOutputSanitizers[action.contentType](action.entry) : {}
|
|
1608
1715
|
}));
|
|
1609
1716
|
const groupedData = await releaseActionService.groupActions(sanitizedResults, query.sort);
|
|
1610
|
-
const contentTypes2 = releaseActionService.getContentTypeModelsFromActions(results);
|
|
1717
|
+
const contentTypes2 = await releaseActionService.getContentTypeModelsFromActions(results);
|
|
1611
1718
|
const releaseService = getService("release", { strapi });
|
|
1612
1719
|
const components = await releaseService.getAllComponents();
|
|
1613
1720
|
ctx.body = {
|
|
@@ -1670,24 +1777,22 @@ const controllers = {
|
|
|
1670
1777
|
const release = {
|
|
1671
1778
|
type: "admin",
|
|
1672
1779
|
routes: [
|
|
1673
|
-
/*
|
|
1674
1780
|
{
|
|
1675
|
-
method:
|
|
1676
|
-
path:
|
|
1677
|
-
handler:
|
|
1781
|
+
method: "GET",
|
|
1782
|
+
path: "/mapEntriesToReleases",
|
|
1783
|
+
handler: "release.mapEntriesToReleases",
|
|
1678
1784
|
config: {
|
|
1679
1785
|
policies: [
|
|
1680
|
-
|
|
1786
|
+
"admin::isAuthenticatedAdmin",
|
|
1681
1787
|
{
|
|
1682
|
-
name:
|
|
1788
|
+
name: "admin::hasPermissions",
|
|
1683
1789
|
config: {
|
|
1684
|
-
actions: [
|
|
1685
|
-
}
|
|
1686
|
-
}
|
|
1687
|
-
]
|
|
1688
|
-
}
|
|
1790
|
+
actions: ["plugin::content-releases.read"]
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
]
|
|
1794
|
+
}
|
|
1689
1795
|
},
|
|
1690
|
-
*/
|
|
1691
1796
|
{
|
|
1692
1797
|
method: "GET",
|
|
1693
1798
|
path: "/getByDocumentAttached",
|
|
@@ -1821,24 +1926,22 @@ const releaseAction = {
|
|
|
1821
1926
|
]
|
|
1822
1927
|
}
|
|
1823
1928
|
},
|
|
1824
|
-
/*
|
|
1825
1929
|
{
|
|
1826
|
-
method:
|
|
1827
|
-
path:
|
|
1828
|
-
handler:
|
|
1930
|
+
method: "POST",
|
|
1931
|
+
path: "/:releaseId/actions/bulk",
|
|
1932
|
+
handler: "release-action.createMany",
|
|
1829
1933
|
config: {
|
|
1830
1934
|
policies: [
|
|
1831
|
-
|
|
1935
|
+
"admin::isAuthenticatedAdmin",
|
|
1832
1936
|
{
|
|
1833
|
-
name:
|
|
1937
|
+
name: "admin::hasPermissions",
|
|
1834
1938
|
config: {
|
|
1835
|
-
actions: [
|
|
1836
|
-
}
|
|
1837
|
-
}
|
|
1838
|
-
]
|
|
1839
|
-
}
|
|
1939
|
+
actions: ["plugin::content-releases.create-action"]
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
]
|
|
1943
|
+
}
|
|
1840
1944
|
},
|
|
1841
|
-
*/
|
|
1842
1945
|
{
|
|
1843
1946
|
method: "GET",
|
|
1844
1947
|
path: "/:releaseId/actions",
|