@strapi/content-releases 0.0.0-next.6d59515520a3850456f256fb0e4c54b75054ddf4 → 0.0.0-next.734763e5757af27ff96ad1c9662161f3f677052a
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-_20W9dYa.js → App-c5uGEz9O.js} +744 -446
- package/dist/_chunks/App-c5uGEz9O.js.map +1 -0
- package/dist/_chunks/{App-L1jSxCiL.mjs → App-xQ5ljY7-.mjs} +752 -455
- package/dist/_chunks/App-xQ5ljY7-.mjs.map +1 -0
- package/dist/_chunks/PurchaseContentReleases-3tRbmbY3.mjs +51 -0
- package/dist/_chunks/PurchaseContentReleases-3tRbmbY3.mjs.map +1 -0
- package/dist/_chunks/PurchaseContentReleases-bpIYXOfu.js +51 -0
- package/dist/_chunks/PurchaseContentReleases-bpIYXOfu.js.map +1 -0
- package/dist/_chunks/{en-gYDqKYFd.js → en-3SGjiVyR.js} +29 -7
- package/dist/_chunks/en-3SGjiVyR.js.map +1 -0
- package/dist/_chunks/{en-MyLPoISH.mjs → en-bpHsnU0n.mjs} +29 -7
- package/dist/_chunks/en-bpHsnU0n.mjs.map +1 -0
- package/dist/_chunks/{index-KJa1Rb5F.js → index-4U0Q_Fgd.js} +350 -34
- package/dist/_chunks/index-4U0Q_Fgd.js.map +1 -0
- package/dist/_chunks/{index-c4zRX_sg.mjs → index-ifoPtgmH.mjs} +363 -47
- package/dist/_chunks/index-ifoPtgmH.mjs.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/server/index.js +998 -399
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +997 -399
- package/dist/server/index.mjs.map +1 -1
- package/package.json +14 -11
- package/dist/_chunks/App-L1jSxCiL.mjs.map +0 -1
- package/dist/_chunks/App-_20W9dYa.js.map +0 -1
- package/dist/_chunks/en-MyLPoISH.mjs.map +0 -1
- package/dist/_chunks/en-gYDqKYFd.js.map +0 -1
- package/dist/_chunks/index-KJa1Rb5F.js.map +0 -1
- package/dist/_chunks/index-c4zRX_sg.mjs.map +0 -1
|
@@ -274,6 +274,19 @@ const releaseApi = react.createApi({
|
|
|
274
274
|
{ type: "ReleaseAction", id: "LIST" }
|
|
275
275
|
]
|
|
276
276
|
}),
|
|
277
|
+
createManyReleaseActions: build.mutation({
|
|
278
|
+
query({ body, params }) {
|
|
279
|
+
return {
|
|
280
|
+
url: `/content-releases/${params.releaseId}/actions/bulk`,
|
|
281
|
+
method: "POST",
|
|
282
|
+
data: body
|
|
283
|
+
};
|
|
284
|
+
},
|
|
285
|
+
invalidatesTags: [
|
|
286
|
+
{ type: "Release", id: "LIST" },
|
|
287
|
+
{ type: "ReleaseAction", id: "LIST" }
|
|
288
|
+
]
|
|
289
|
+
}),
|
|
277
290
|
updateReleaseAction: build.mutation({
|
|
278
291
|
query({ body, params }) {
|
|
279
292
|
return {
|
|
@@ -282,7 +295,27 @@ const releaseApi = react.createApi({
|
|
|
282
295
|
data: body
|
|
283
296
|
};
|
|
284
297
|
},
|
|
285
|
-
invalidatesTags: () => [{ type: "ReleaseAction", id: "LIST" }]
|
|
298
|
+
invalidatesTags: () => [{ type: "ReleaseAction", id: "LIST" }],
|
|
299
|
+
async onQueryStarted({ body, params, query: query2, actionPath }, { dispatch, queryFulfilled }) {
|
|
300
|
+
const paramsWithoutActionId = {
|
|
301
|
+
releaseId: params.releaseId,
|
|
302
|
+
...query2
|
|
303
|
+
};
|
|
304
|
+
const patchResult = dispatch(
|
|
305
|
+
releaseApi.util.updateQueryData("getReleaseActions", paramsWithoutActionId, (draft) => {
|
|
306
|
+
const [key, index] = actionPath;
|
|
307
|
+
const action = draft.data[key][index];
|
|
308
|
+
if (action) {
|
|
309
|
+
action.type = body.type;
|
|
310
|
+
}
|
|
311
|
+
})
|
|
312
|
+
);
|
|
313
|
+
try {
|
|
314
|
+
await queryFulfilled;
|
|
315
|
+
} catch {
|
|
316
|
+
patchResult.undo();
|
|
317
|
+
}
|
|
318
|
+
}
|
|
286
319
|
}),
|
|
287
320
|
deleteReleaseAction: build.mutation({
|
|
288
321
|
query({ params }) {
|
|
@@ -291,8 +324,9 @@ const releaseApi = react.createApi({
|
|
|
291
324
|
method: "DELETE"
|
|
292
325
|
};
|
|
293
326
|
},
|
|
294
|
-
invalidatesTags: [
|
|
327
|
+
invalidatesTags: (result, error, arg) => [
|
|
295
328
|
{ type: "Release", id: "LIST" },
|
|
329
|
+
{ type: "Release", id: arg.params.releaseId },
|
|
296
330
|
{ type: "ReleaseAction", id: "LIST" }
|
|
297
331
|
]
|
|
298
332
|
}),
|
|
@@ -312,7 +346,7 @@ const releaseApi = react.createApi({
|
|
|
312
346
|
method: "DELETE"
|
|
313
347
|
};
|
|
314
348
|
},
|
|
315
|
-
invalidatesTags: (
|
|
349
|
+
invalidatesTags: () => [{ type: "Release", id: "LIST" }]
|
|
316
350
|
})
|
|
317
351
|
};
|
|
318
352
|
}
|
|
@@ -324,12 +358,29 @@ const {
|
|
|
324
358
|
useGetReleaseActionsQuery,
|
|
325
359
|
useCreateReleaseMutation,
|
|
326
360
|
useCreateReleaseActionMutation,
|
|
361
|
+
useCreateManyReleaseActionsMutation,
|
|
327
362
|
useUpdateReleaseMutation,
|
|
328
363
|
useUpdateReleaseActionMutation,
|
|
329
364
|
usePublishReleaseMutation,
|
|
330
365
|
useDeleteReleaseActionMutation,
|
|
331
366
|
useDeleteReleaseMutation
|
|
332
367
|
} = releaseApi;
|
|
368
|
+
const getTimezoneOffset = (timezone, date) => {
|
|
369
|
+
try {
|
|
370
|
+
const offsetPart = new Intl.DateTimeFormat("en", {
|
|
371
|
+
timeZone: timezone,
|
|
372
|
+
timeZoneName: "longOffset"
|
|
373
|
+
}).formatToParts(date).find((part) => part.type === "timeZoneName");
|
|
374
|
+
const offset = offsetPart ? offsetPart.value : "";
|
|
375
|
+
let utcOffset = offset.replace("GMT", "UTC");
|
|
376
|
+
if (!utcOffset.includes("+") && !utcOffset.includes("-")) {
|
|
377
|
+
utcOffset = `${utcOffset}+00:00`;
|
|
378
|
+
}
|
|
379
|
+
return utcOffset;
|
|
380
|
+
} catch (error) {
|
|
381
|
+
return "";
|
|
382
|
+
}
|
|
383
|
+
};
|
|
333
384
|
const useTypedDispatch = reactRedux.useDispatch;
|
|
334
385
|
const useTypedSelector = reactRedux.useSelector;
|
|
335
386
|
const StyledMenuItem = styled__default.default(v2.Menu.Item)`
|
|
@@ -400,7 +451,7 @@ const DeleteReleaseActionItem = ({ releaseId, actionId }) => {
|
|
|
400
451
|
}
|
|
401
452
|
};
|
|
402
453
|
return /* @__PURE__ */ jsxRuntime.jsx(helperPlugin.CheckPermissions, { permissions: PERMISSIONS.deleteAction, children: /* @__PURE__ */ jsxRuntime.jsx(StyledMenuItem, { variant: "danger", onSelect: handleDeleteAction, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
|
403
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Icon, { as: icons.Cross,
|
|
454
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Icon, { as: icons.Cross, width: 3, height: 3 }),
|
|
404
455
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", variant: "omega", children: formatMessage({
|
|
405
456
|
id: "content-releases.content-manager-edit-view.remove-from-release",
|
|
406
457
|
defaultMessage: "Remove from release"
|
|
@@ -439,7 +490,7 @@ const ReleaseActionEntryLinkItem = ({
|
|
|
439
490
|
pathname: `/content-manager/collection-types/${contentTypeUid}/${entryId}`,
|
|
440
491
|
search: locale && `?plugins[i18n][locale]=${locale}`
|
|
441
492
|
},
|
|
442
|
-
startIcon: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Icon, { as: icons.Pencil,
|
|
493
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Icon, { as: icons.Pencil, width: 3, height: 3 }),
|
|
443
494
|
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: formatMessage({
|
|
444
495
|
id: "content-releases.content-manager-edit-view.edit-entry",
|
|
445
496
|
defaultMessage: "Edit entry"
|
|
@@ -449,6 +500,21 @@ const ReleaseActionEntryLinkItem = ({
|
|
|
449
500
|
}
|
|
450
501
|
);
|
|
451
502
|
};
|
|
503
|
+
const EditReleaseItem = ({ releaseId }) => {
|
|
504
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
505
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StyledMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
506
|
+
v2.Link,
|
|
507
|
+
{
|
|
508
|
+
href: `/admin/plugins/content-releases/${releaseId}`,
|
|
509
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Icon, { as: icons.Pencil, width: 3, height: 3 }),
|
|
510
|
+
isExternal: false,
|
|
511
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: formatMessage({
|
|
512
|
+
id: "content-releases.content-manager-edit-view.edit-release",
|
|
513
|
+
defaultMessage: "Edit release"
|
|
514
|
+
}) })
|
|
515
|
+
}
|
|
516
|
+
) });
|
|
517
|
+
};
|
|
452
518
|
const Root = ({ children, hasTriggerBorder = false }) => {
|
|
453
519
|
const { formatMessage } = reactIntl.useIntl();
|
|
454
520
|
return (
|
|
@@ -473,6 +539,7 @@ const Root = ({ children, hasTriggerBorder = false }) => {
|
|
|
473
539
|
};
|
|
474
540
|
const ReleaseActionMenu = {
|
|
475
541
|
Root,
|
|
542
|
+
EditReleaseItem,
|
|
476
543
|
DeleteReleaseActionItem,
|
|
477
544
|
ReleaseActionEntryLinkItem
|
|
478
545
|
};
|
|
@@ -496,19 +563,40 @@ const FieldWrapper = styled__default.default(designSystem.Field)`
|
|
|
496
563
|
text-transform: capitalize;
|
|
497
564
|
}
|
|
498
565
|
|
|
499
|
-
&:active,
|
|
500
566
|
&[data-checked='true'] {
|
|
501
|
-
color: ${({ theme }) => theme.colors.primary700};
|
|
502
|
-
background-color: ${({ theme }) => theme.colors.primary100};
|
|
503
|
-
border-color: ${({ theme }) => theme.colors.primary700};
|
|
567
|
+
color: ${({ theme, actionType }) => actionType === "publish" ? theme.colors.primary700 : theme.colors.danger600};
|
|
568
|
+
background-color: ${({ theme, actionType }) => actionType === "publish" ? theme.colors.primary100 : theme.colors.danger100};
|
|
569
|
+
border-color: ${({ theme, actionType }) => actionType === "publish" ? theme.colors.primary700 : theme.colors.danger600};
|
|
504
570
|
}
|
|
505
571
|
|
|
506
572
|
&[data-checked='false'] {
|
|
507
573
|
border-left: ${({ actionType }) => actionType === "unpublish" && "none"};
|
|
508
574
|
border-right: ${({ actionType }) => actionType === "publish" && "none"};
|
|
509
575
|
}
|
|
576
|
+
|
|
577
|
+
&[data-checked='false'][data-disabled='false']:hover {
|
|
578
|
+
color: ${({ theme }) => theme.colors.neutral700};
|
|
579
|
+
background-color: ${({ theme }) => theme.colors.neutral100};
|
|
580
|
+
border-color: ${({ theme }) => theme.colors.neutral200};
|
|
581
|
+
|
|
582
|
+
& > label {
|
|
583
|
+
cursor: pointer;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
&[data-disabled='true'] {
|
|
588
|
+
color: ${({ theme }) => theme.colors.neutral600};
|
|
589
|
+
background-color: ${({ theme }) => theme.colors.neutral150};
|
|
590
|
+
border-color: ${({ theme }) => theme.colors.neutral300};
|
|
591
|
+
}
|
|
510
592
|
`;
|
|
511
|
-
const ActionOption = ({
|
|
593
|
+
const ActionOption = ({
|
|
594
|
+
selected,
|
|
595
|
+
actionType,
|
|
596
|
+
handleChange,
|
|
597
|
+
name,
|
|
598
|
+
disabled = false
|
|
599
|
+
}) => {
|
|
512
600
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
513
601
|
FieldWrapper,
|
|
514
602
|
{
|
|
@@ -519,6 +607,7 @@ const ActionOption = ({ selected, actionType, handleChange, name }) => {
|
|
|
519
607
|
position: "relative",
|
|
520
608
|
cursor: "pointer",
|
|
521
609
|
"data-checked": selected === actionType,
|
|
610
|
+
"data-disabled": disabled && selected !== actionType,
|
|
522
611
|
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.FieldLabel, { htmlFor: `${name}-${actionType}`, children: [
|
|
523
612
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
524
613
|
designSystem.FieldInput,
|
|
@@ -528,7 +617,8 @@ const ActionOption = ({ selected, actionType, handleChange, name }) => {
|
|
|
528
617
|
name,
|
|
529
618
|
checked: selected === actionType,
|
|
530
619
|
onChange: handleChange,
|
|
531
|
-
value: actionType
|
|
620
|
+
value: actionType,
|
|
621
|
+
disabled
|
|
532
622
|
}
|
|
533
623
|
) }),
|
|
534
624
|
actionType
|
|
@@ -536,7 +626,12 @@ const ActionOption = ({ selected, actionType, handleChange, name }) => {
|
|
|
536
626
|
}
|
|
537
627
|
);
|
|
538
628
|
};
|
|
539
|
-
const ReleaseActionOptions = ({
|
|
629
|
+
const ReleaseActionOptions = ({
|
|
630
|
+
selected,
|
|
631
|
+
handleChange,
|
|
632
|
+
name,
|
|
633
|
+
disabled = false
|
|
634
|
+
}) => {
|
|
540
635
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
|
|
541
636
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
542
637
|
ActionOption,
|
|
@@ -544,7 +639,8 @@ const ReleaseActionOptions = ({ selected, handleChange, name }) => {
|
|
|
544
639
|
actionType: "publish",
|
|
545
640
|
selected,
|
|
546
641
|
handleChange,
|
|
547
|
-
name
|
|
642
|
+
name,
|
|
643
|
+
disabled
|
|
548
644
|
}
|
|
549
645
|
),
|
|
550
646
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -553,7 +649,8 @@ const ReleaseActionOptions = ({ selected, handleChange, name }) => {
|
|
|
553
649
|
actionType: "unpublish",
|
|
554
650
|
selected,
|
|
555
651
|
handleChange,
|
|
556
|
-
name
|
|
652
|
+
name,
|
|
653
|
+
disabled
|
|
557
654
|
}
|
|
558
655
|
)
|
|
559
656
|
] });
|
|
@@ -597,6 +694,7 @@ const AddActionToReleaseModal = ({
|
|
|
597
694
|
contentTypeUid,
|
|
598
695
|
entryId
|
|
599
696
|
}) => {
|
|
697
|
+
const releaseHeaderId = React__namespace.useId();
|
|
600
698
|
const { formatMessage } = reactIntl.useIntl();
|
|
601
699
|
const toggleNotification = helperPlugin.useNotification();
|
|
602
700
|
const { formatAPIError } = helperPlugin.useAPIErrorHandler();
|
|
@@ -644,8 +742,8 @@ const AddActionToReleaseModal = ({
|
|
|
644
742
|
}
|
|
645
743
|
}
|
|
646
744
|
};
|
|
647
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.ModalLayout, { onClose: handleClose, labelledBy:
|
|
648
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id:
|
|
745
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.ModalLayout, { onClose: handleClose, labelledBy: releaseHeaderId, children: [
|
|
746
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: releaseHeaderId, fontWeight: "bold", textColor: "neutral800", children: formatMessage({
|
|
649
747
|
id: "content-releases.content-manager-edit-view.add-to-release",
|
|
650
748
|
defaultMessage: "Add to release"
|
|
651
749
|
}) }) }),
|
|
@@ -715,16 +813,18 @@ const AddActionToReleaseModal = ({
|
|
|
715
813
|
};
|
|
716
814
|
const CMReleasesContainer = () => {
|
|
717
815
|
const [isModalOpen, setIsModalOpen] = React__namespace.useState(false);
|
|
718
|
-
const { formatMessage } = reactIntl.useIntl();
|
|
816
|
+
const { formatMessage, formatDate, formatTime } = reactIntl.useIntl();
|
|
719
817
|
const {
|
|
720
818
|
isCreatingEntry,
|
|
721
|
-
|
|
819
|
+
hasDraftAndPublish,
|
|
820
|
+
initialData: { id: entryId },
|
|
821
|
+
slug
|
|
722
822
|
} = helperPlugin.useCMEditViewDataManager();
|
|
723
|
-
const
|
|
724
|
-
const canFetch =
|
|
823
|
+
const contentTypeUid = slug;
|
|
824
|
+
const canFetch = entryId != null && contentTypeUid != null;
|
|
725
825
|
const fetchParams = canFetch ? {
|
|
726
|
-
contentTypeUid
|
|
727
|
-
entryId
|
|
826
|
+
contentTypeUid,
|
|
827
|
+
entryId,
|
|
728
828
|
hasEntryAttached: true
|
|
729
829
|
} : query.skipToken;
|
|
730
830
|
const response = useGetReleasesForEntryQuery(fetchParams);
|
|
@@ -732,7 +832,7 @@ const CMReleasesContainer = () => {
|
|
|
732
832
|
if (!canFetch) {
|
|
733
833
|
return null;
|
|
734
834
|
}
|
|
735
|
-
if (isCreatingEntry || !
|
|
835
|
+
if (isCreatingEntry || !hasDraftAndPublish) {
|
|
736
836
|
return null;
|
|
737
837
|
}
|
|
738
838
|
const toggleModal = () => setIsModalOpen((prev) => !prev);
|
|
@@ -799,15 +899,40 @@ const CMReleasesContainer = () => {
|
|
|
799
899
|
)
|
|
800
900
|
}
|
|
801
901
|
),
|
|
802
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { padding: 4, direction: "column", gap:
|
|
902
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { padding: 4, direction: "column", gap: 2, width: "100%", alignItems: "flex-start", children: [
|
|
803
903
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontSize: 2, fontWeight: "bold", variant: "omega", textColor: "neutral700", children: release.name }),
|
|
804
|
-
|
|
805
|
-
|
|
904
|
+
release.scheduledAt && release.timezone && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: formatMessage(
|
|
905
|
+
{
|
|
906
|
+
id: "content-releases.content-manager-edit-view.scheduled.date",
|
|
907
|
+
defaultMessage: "{date} at {time} ({offset})"
|
|
908
|
+
},
|
|
806
909
|
{
|
|
807
|
-
|
|
808
|
-
|
|
910
|
+
date: formatDate(new Date(release.scheduledAt), {
|
|
911
|
+
day: "2-digit",
|
|
912
|
+
month: "2-digit",
|
|
913
|
+
year: "numeric",
|
|
914
|
+
timeZone: release.timezone
|
|
915
|
+
}),
|
|
916
|
+
time: formatTime(new Date(release.scheduledAt), {
|
|
917
|
+
hourCycle: "h23",
|
|
918
|
+
timeZone: release.timezone
|
|
919
|
+
}),
|
|
920
|
+
offset: getTimezoneOffset(
|
|
921
|
+
release.timezone,
|
|
922
|
+
new Date(release.scheduledAt)
|
|
923
|
+
)
|
|
809
924
|
}
|
|
810
|
-
) })
|
|
925
|
+
) }),
|
|
926
|
+
/* @__PURE__ */ jsxRuntime.jsx(helperPlugin.CheckPermissions, { permissions: PERMISSIONS.deleteAction, children: /* @__PURE__ */ jsxRuntime.jsxs(ReleaseActionMenu.Root, { hasTriggerBorder: true, children: [
|
|
927
|
+
/* @__PURE__ */ jsxRuntime.jsx(ReleaseActionMenu.EditReleaseItem, { releaseId: release.id }),
|
|
928
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
929
|
+
ReleaseActionMenu.DeleteReleaseActionItem,
|
|
930
|
+
{
|
|
931
|
+
releaseId: release.id,
|
|
932
|
+
actionId: release.action.id
|
|
933
|
+
}
|
|
934
|
+
)
|
|
935
|
+
] }) })
|
|
811
936
|
] })
|
|
812
937
|
]
|
|
813
938
|
},
|
|
@@ -835,14 +960,185 @@ const CMReleasesContainer = () => {
|
|
|
835
960
|
AddActionToReleaseModal,
|
|
836
961
|
{
|
|
837
962
|
handleClose: toggleModal,
|
|
838
|
-
contentTypeUid
|
|
839
|
-
entryId
|
|
963
|
+
contentTypeUid,
|
|
964
|
+
entryId
|
|
840
965
|
}
|
|
841
966
|
)
|
|
842
967
|
]
|
|
843
968
|
}
|
|
844
969
|
) });
|
|
845
970
|
};
|
|
971
|
+
const getContentPermissions = (subject) => {
|
|
972
|
+
const permissions = {
|
|
973
|
+
publish: [
|
|
974
|
+
{
|
|
975
|
+
action: "plugin::content-manager.explorer.publish",
|
|
976
|
+
subject,
|
|
977
|
+
id: "",
|
|
978
|
+
actionParameters: {},
|
|
979
|
+
properties: {},
|
|
980
|
+
conditions: []
|
|
981
|
+
}
|
|
982
|
+
]
|
|
983
|
+
};
|
|
984
|
+
return permissions;
|
|
985
|
+
};
|
|
986
|
+
const ReleaseAction = ({ ids, model }) => {
|
|
987
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
988
|
+
const toggleNotification = helperPlugin.useNotification();
|
|
989
|
+
const { formatAPIError } = helperPlugin.useAPIErrorHandler();
|
|
990
|
+
const { modifiedData } = helperPlugin.useCMEditViewDataManager();
|
|
991
|
+
const contentPermissions = getContentPermissions(model);
|
|
992
|
+
const {
|
|
993
|
+
allowedActions: { canPublish }
|
|
994
|
+
} = helperPlugin.useRBAC(contentPermissions);
|
|
995
|
+
const {
|
|
996
|
+
allowedActions: { canCreate }
|
|
997
|
+
} = helperPlugin.useRBAC(PERMISSIONS);
|
|
998
|
+
const response = useGetReleasesQuery();
|
|
999
|
+
const releases = response.data?.data;
|
|
1000
|
+
const [createManyReleaseActions, { isLoading }] = useCreateManyReleaseActionsMutation();
|
|
1001
|
+
const handleSubmit = async (values) => {
|
|
1002
|
+
const locale = modifiedData.locale;
|
|
1003
|
+
const releaseActionEntries = ids.map((id) => ({
|
|
1004
|
+
type: values.type,
|
|
1005
|
+
entry: {
|
|
1006
|
+
contentType: model,
|
|
1007
|
+
id,
|
|
1008
|
+
locale
|
|
1009
|
+
}
|
|
1010
|
+
}));
|
|
1011
|
+
const response2 = await createManyReleaseActions({
|
|
1012
|
+
body: releaseActionEntries,
|
|
1013
|
+
params: { releaseId: values.releaseId }
|
|
1014
|
+
});
|
|
1015
|
+
if ("data" in response2) {
|
|
1016
|
+
const notificationMessage = formatMessage(
|
|
1017
|
+
{
|
|
1018
|
+
id: "content-releases.content-manager-list-view.add-to-release.notification.success.message",
|
|
1019
|
+
defaultMessage: "{entriesAlreadyInRelease} out of {totalEntries} entries were already in the release."
|
|
1020
|
+
},
|
|
1021
|
+
{
|
|
1022
|
+
entriesAlreadyInRelease: response2.data.meta.entriesAlreadyInRelease,
|
|
1023
|
+
totalEntries: response2.data.meta.totalEntries
|
|
1024
|
+
}
|
|
1025
|
+
);
|
|
1026
|
+
const notification = {
|
|
1027
|
+
type: "success",
|
|
1028
|
+
title: formatMessage(
|
|
1029
|
+
{
|
|
1030
|
+
id: "content-releases.content-manager-list-view.add-to-release.notification.success.title",
|
|
1031
|
+
defaultMessage: "Successfully added to release."
|
|
1032
|
+
},
|
|
1033
|
+
{
|
|
1034
|
+
entriesAlreadyInRelease: response2.data.meta.entriesAlreadyInRelease,
|
|
1035
|
+
totalEntries: response2.data.meta.totalEntries
|
|
1036
|
+
}
|
|
1037
|
+
),
|
|
1038
|
+
message: response2.data.meta.entriesAlreadyInRelease ? notificationMessage : ""
|
|
1039
|
+
};
|
|
1040
|
+
toggleNotification(notification);
|
|
1041
|
+
return true;
|
|
1042
|
+
}
|
|
1043
|
+
if ("error" in response2) {
|
|
1044
|
+
if (axios.isAxiosError(response2.error)) {
|
|
1045
|
+
toggleNotification({
|
|
1046
|
+
type: "warning",
|
|
1047
|
+
message: formatAPIError(response2.error)
|
|
1048
|
+
});
|
|
1049
|
+
} else {
|
|
1050
|
+
toggleNotification({
|
|
1051
|
+
type: "warning",
|
|
1052
|
+
message: formatMessage({ id: "notification.error", defaultMessage: "An error occurred" })
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
1057
|
+
if (!canCreate || !canPublish)
|
|
1058
|
+
return null;
|
|
1059
|
+
return {
|
|
1060
|
+
actionType: "release",
|
|
1061
|
+
variant: "tertiary",
|
|
1062
|
+
label: formatMessage({
|
|
1063
|
+
id: "content-manager-list-view.add-to-release",
|
|
1064
|
+
defaultMessage: "Add to Release"
|
|
1065
|
+
}),
|
|
1066
|
+
dialog: {
|
|
1067
|
+
type: "modal",
|
|
1068
|
+
title: formatMessage({
|
|
1069
|
+
id: "content-manager-list-view.add-to-release",
|
|
1070
|
+
defaultMessage: "Add to Release"
|
|
1071
|
+
}),
|
|
1072
|
+
content: ({ onClose }) => {
|
|
1073
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1074
|
+
formik.Formik,
|
|
1075
|
+
{
|
|
1076
|
+
onSubmit: async (values) => {
|
|
1077
|
+
const data = await handleSubmit(values);
|
|
1078
|
+
if (data) {
|
|
1079
|
+
return onClose();
|
|
1080
|
+
}
|
|
1081
|
+
},
|
|
1082
|
+
validationSchema: RELEASE_ACTION_FORM_SCHEMA,
|
|
1083
|
+
initialValues: INITIAL_VALUES,
|
|
1084
|
+
children: ({ values, setFieldValue }) => /* @__PURE__ */ jsxRuntime.jsxs(formik.Form, { children: [
|
|
1085
|
+
releases?.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(NoReleases, {}) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalBody, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
1086
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1087
|
+
designSystem.SingleSelect,
|
|
1088
|
+
{
|
|
1089
|
+
required: true,
|
|
1090
|
+
label: formatMessage({
|
|
1091
|
+
id: "content-releases.content-manager-list-view.add-to-release.select-label",
|
|
1092
|
+
defaultMessage: "Select a release"
|
|
1093
|
+
}),
|
|
1094
|
+
placeholder: formatMessage({
|
|
1095
|
+
id: "content-releases.content-manager-list-view.add-to-release.select-placeholder",
|
|
1096
|
+
defaultMessage: "Select"
|
|
1097
|
+
}),
|
|
1098
|
+
onChange: (value) => setFieldValue("releaseId", value),
|
|
1099
|
+
value: values.releaseId,
|
|
1100
|
+
children: releases?.map((release) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: release.id, children: release.name }, release.id))
|
|
1101
|
+
}
|
|
1102
|
+
) }),
|
|
1103
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldLabel, { children: formatMessage({
|
|
1104
|
+
id: "content-releases.content-manager-list-view.add-to-release.action-type-label",
|
|
1105
|
+
defaultMessage: "What do you want to do with these entries?"
|
|
1106
|
+
}) }),
|
|
1107
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1108
|
+
ReleaseActionOptions,
|
|
1109
|
+
{
|
|
1110
|
+
selected: values.type,
|
|
1111
|
+
handleChange: (e) => setFieldValue("type", e.target.value),
|
|
1112
|
+
name: "type"
|
|
1113
|
+
}
|
|
1114
|
+
)
|
|
1115
|
+
] }) }),
|
|
1116
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1117
|
+
designSystem.ModalFooter,
|
|
1118
|
+
{
|
|
1119
|
+
startActions: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", name: "cancel", children: formatMessage({
|
|
1120
|
+
id: "content-releases.content-manager-list-view.add-to-release.cancel-button",
|
|
1121
|
+
defaultMessage: "Cancel"
|
|
1122
|
+
}) }),
|
|
1123
|
+
endActions: (
|
|
1124
|
+
/**
|
|
1125
|
+
* TODO: Ideally we would use isValid from Formik to disable the button, however currently it always returns true
|
|
1126
|
+
* for yup.string().required(), even when the value is falsy (including empty string)
|
|
1127
|
+
*/
|
|
1128
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { type: "submit", disabled: !values.releaseId, loading: isLoading, children: formatMessage({
|
|
1129
|
+
id: "content-releases.content-manager-list-view.add-to-release.continue-button",
|
|
1130
|
+
defaultMessage: "Continue"
|
|
1131
|
+
}) })
|
|
1132
|
+
)
|
|
1133
|
+
}
|
|
1134
|
+
)
|
|
1135
|
+
] })
|
|
1136
|
+
}
|
|
1137
|
+
);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
};
|
|
846
1142
|
const admin = {
|
|
847
1143
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
848
1144
|
register(app) {
|
|
@@ -855,7 +1151,7 @@ const admin = {
|
|
|
855
1151
|
defaultMessage: "Releases"
|
|
856
1152
|
},
|
|
857
1153
|
async Component() {
|
|
858
|
-
const { App } = await Promise.resolve().then(() => require("./App-
|
|
1154
|
+
const { App } = await Promise.resolve().then(() => require("./App-c5uGEz9O.js"));
|
|
859
1155
|
return App;
|
|
860
1156
|
},
|
|
861
1157
|
permissions: PERMISSIONS.main
|
|
@@ -868,12 +1164,31 @@ const admin = {
|
|
|
868
1164
|
name: `${pluginId}-link`,
|
|
869
1165
|
Component: CMReleasesContainer
|
|
870
1166
|
});
|
|
1167
|
+
app.plugins["content-manager"].apis.addBulkAction((actions) => {
|
|
1168
|
+
const deleteActionIndex = actions.findIndex((action) => action.name === "DeleteAction");
|
|
1169
|
+
actions.splice(deleteActionIndex, 0, ReleaseAction);
|
|
1170
|
+
return actions;
|
|
1171
|
+
});
|
|
1172
|
+
} else if (!window.strapi.features.isEnabled("cms-content-releases") && window.strapi?.flags?.promoteEE) {
|
|
1173
|
+
app.addMenuLink({
|
|
1174
|
+
to: `/plugins/purchase-content-releases`,
|
|
1175
|
+
icon: icons.PaperPlane,
|
|
1176
|
+
intlLabel: {
|
|
1177
|
+
id: `${pluginId}.plugin.name`,
|
|
1178
|
+
defaultMessage: "Releases"
|
|
1179
|
+
},
|
|
1180
|
+
async Component() {
|
|
1181
|
+
const { PurchaseContentReleases } = await Promise.resolve().then(() => require("./PurchaseContentReleases-bpIYXOfu.js"));
|
|
1182
|
+
return PurchaseContentReleases;
|
|
1183
|
+
},
|
|
1184
|
+
lockIcon: true
|
|
1185
|
+
});
|
|
871
1186
|
}
|
|
872
1187
|
},
|
|
873
1188
|
async registerTrads({ locales }) {
|
|
874
1189
|
const importedTrads = await Promise.all(
|
|
875
1190
|
locales.map((locale) => {
|
|
876
|
-
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("./en-
|
|
1191
|
+
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("./en-3SGjiVyR.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
|
|
877
1192
|
return {
|
|
878
1193
|
data: helperPlugin.prefixPluginTranslations(data, "content-releases"),
|
|
879
1194
|
locale
|
|
@@ -893,6 +1208,7 @@ exports.PERMISSIONS = PERMISSIONS;
|
|
|
893
1208
|
exports.ReleaseActionMenu = ReleaseActionMenu;
|
|
894
1209
|
exports.ReleaseActionOptions = ReleaseActionOptions;
|
|
895
1210
|
exports.admin = admin;
|
|
1211
|
+
exports.getTimezoneOffset = getTimezoneOffset;
|
|
896
1212
|
exports.isAxiosError = isAxiosError;
|
|
897
1213
|
exports.pluginId = pluginId;
|
|
898
1214
|
exports.releaseApi = releaseApi;
|
|
@@ -905,4 +1221,4 @@ exports.usePublishReleaseMutation = usePublishReleaseMutation;
|
|
|
905
1221
|
exports.useTypedDispatch = useTypedDispatch;
|
|
906
1222
|
exports.useUpdateReleaseActionMutation = useUpdateReleaseActionMutation;
|
|
907
1223
|
exports.useUpdateReleaseMutation = useUpdateReleaseMutation;
|
|
908
|
-
//# sourceMappingURL=index-
|
|
1224
|
+
//# sourceMappingURL=index-4U0Q_Fgd.js.map
|