@strapi/content-releases 0.0.0-experimental.ec089c69ff953942fb39de032c12daafaf7176e6 → 0.0.0-experimental.f75e3c6d67cc47c64ab37479efdbb7b43be50b78

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.
Files changed (110) hide show
  1. package/dist/_chunks/{App-HjWtUYmc.js → App-DUmziQ17.js} +401 -388
  2. package/dist/_chunks/App-DUmziQ17.js.map +1 -0
  3. package/dist/_chunks/{App-gu1aiP6i.mjs → App-D_6Y9N2F.mjs} +378 -364
  4. package/dist/_chunks/App-D_6Y9N2F.mjs.map +1 -0
  5. package/dist/_chunks/{PurchaseContentReleases-bpIYXOfu.js → PurchaseContentReleases-Be3acS2L.js} +7 -6
  6. package/dist/_chunks/PurchaseContentReleases-Be3acS2L.js.map +1 -0
  7. package/dist/_chunks/{PurchaseContentReleases-3tRbmbY3.mjs → PurchaseContentReleases-_MxP6-Dt.mjs} +8 -7
  8. package/dist/_chunks/PurchaseContentReleases-_MxP6-Dt.mjs.map +1 -0
  9. package/dist/_chunks/{en-ltT1TlKQ.mjs → en-B9Ur3VsE.mjs} +1 -1
  10. package/dist/_chunks/en-B9Ur3VsE.mjs.map +1 -0
  11. package/dist/_chunks/{en-HrREghh3.js → en-DtFJ5ViE.js} +1 -1
  12. package/dist/_chunks/en-DtFJ5ViE.js.map +1 -0
  13. package/dist/_chunks/{index-mvj9PSKd.mjs → index-BomF0-yY.mjs} +180 -476
  14. package/dist/_chunks/index-BomF0-yY.mjs.map +1 -0
  15. package/dist/_chunks/{index-ZNwxYN8H.js → index-C5Hc767q.js} +177 -475
  16. package/dist/_chunks/index-C5Hc767q.js.map +1 -0
  17. package/dist/admin/index.js +1 -15
  18. package/dist/admin/index.js.map +1 -1
  19. package/dist/admin/index.mjs +2 -16
  20. package/dist/admin/index.mjs.map +1 -1
  21. package/dist/admin/src/components/CMReleasesContainer.d.ts +22 -0
  22. package/dist/admin/src/components/RelativeTime.d.ts +28 -0
  23. package/dist/admin/src/components/ReleaseAction.d.ts +3 -0
  24. package/dist/admin/src/components/ReleaseActionMenu.d.ts +26 -0
  25. package/dist/admin/src/components/ReleaseActionOptions.d.ts +9 -0
  26. package/dist/admin/src/components/ReleaseListCell.d.ts +0 -0
  27. package/dist/admin/src/components/ReleaseModal.d.ts +16 -0
  28. package/dist/admin/src/constants.d.ts +58 -0
  29. package/dist/admin/src/index.d.ts +3 -0
  30. package/dist/admin/src/pages/App.d.ts +1 -0
  31. package/dist/admin/src/pages/PurchaseContentReleases.d.ts +2 -0
  32. package/dist/admin/src/pages/ReleaseDetailsPage.d.ts +2 -0
  33. package/dist/admin/src/pages/ReleasesPage.d.ts +8 -0
  34. package/dist/admin/src/pages/tests/mockReleaseDetailsPageData.d.ts +181 -0
  35. package/dist/admin/src/pages/tests/mockReleasesPageData.d.ts +39 -0
  36. package/dist/admin/src/pluginId.d.ts +1 -0
  37. package/dist/admin/src/services/release.d.ts +105 -0
  38. package/dist/admin/src/store/hooks.d.ts +7 -0
  39. package/dist/admin/src/utils/api.d.ts +6 -0
  40. package/dist/admin/src/utils/prefixPluginTranslations.d.ts +3 -0
  41. package/dist/admin/src/utils/time.d.ts +1 -0
  42. package/dist/server/index.js +83 -86
  43. package/dist/server/index.js.map +1 -1
  44. package/dist/server/index.mjs +84 -86
  45. package/dist/server/index.mjs.map +1 -1
  46. package/dist/server/src/bootstrap.d.ts +5 -0
  47. package/dist/server/src/bootstrap.d.ts.map +1 -0
  48. package/dist/server/src/constants.d.ts +12 -0
  49. package/dist/server/src/constants.d.ts.map +1 -0
  50. package/dist/server/src/content-types/index.d.ts +99 -0
  51. package/dist/server/src/content-types/index.d.ts.map +1 -0
  52. package/dist/server/src/content-types/release/index.d.ts +48 -0
  53. package/dist/server/src/content-types/release/index.d.ts.map +1 -0
  54. package/dist/server/src/content-types/release/schema.d.ts +47 -0
  55. package/dist/server/src/content-types/release/schema.d.ts.map +1 -0
  56. package/dist/server/src/content-types/release-action/index.d.ts +50 -0
  57. package/dist/server/src/content-types/release-action/index.d.ts.map +1 -0
  58. package/dist/server/src/content-types/release-action/schema.d.ts +49 -0
  59. package/dist/server/src/content-types/release-action/schema.d.ts.map +1 -0
  60. package/dist/server/src/controllers/index.d.ts +20 -0
  61. package/dist/server/src/controllers/index.d.ts.map +1 -0
  62. package/dist/server/src/controllers/release-action.d.ts +10 -0
  63. package/dist/server/src/controllers/release-action.d.ts.map +1 -0
  64. package/dist/server/src/controllers/release.d.ts +12 -0
  65. package/dist/server/src/controllers/release.d.ts.map +1 -0
  66. package/dist/server/src/controllers/validation/release-action.d.ts +8 -0
  67. package/dist/server/src/controllers/validation/release-action.d.ts.map +1 -0
  68. package/dist/server/src/controllers/validation/release.d.ts +2 -0
  69. package/dist/server/src/controllers/validation/release.d.ts.map +1 -0
  70. package/dist/server/src/destroy.d.ts +5 -0
  71. package/dist/server/src/destroy.d.ts.map +1 -0
  72. package/dist/server/src/index.d.ts +2096 -0
  73. package/dist/server/src/index.d.ts.map +1 -0
  74. package/dist/server/src/migrations/index.d.ts +13 -0
  75. package/dist/server/src/migrations/index.d.ts.map +1 -0
  76. package/dist/server/src/register.d.ts +5 -0
  77. package/dist/server/src/register.d.ts.map +1 -0
  78. package/dist/server/src/routes/index.d.ts +35 -0
  79. package/dist/server/src/routes/index.d.ts.map +1 -0
  80. package/dist/server/src/routes/release-action.d.ts +18 -0
  81. package/dist/server/src/routes/release-action.d.ts.map +1 -0
  82. package/dist/server/src/routes/release.d.ts +18 -0
  83. package/dist/server/src/routes/release.d.ts.map +1 -0
  84. package/dist/server/src/services/index.d.ts +1826 -0
  85. package/dist/server/src/services/index.d.ts.map +1 -0
  86. package/dist/server/src/services/release.d.ts +66 -0
  87. package/dist/server/src/services/release.d.ts.map +1 -0
  88. package/dist/server/src/services/scheduling.d.ts +18 -0
  89. package/dist/server/src/services/scheduling.d.ts.map +1 -0
  90. package/dist/server/src/services/validation.d.ts +18 -0
  91. package/dist/server/src/services/validation.d.ts.map +1 -0
  92. package/dist/server/src/utils/index.d.ts +14 -0
  93. package/dist/server/src/utils/index.d.ts.map +1 -0
  94. package/dist/shared/contracts/release-actions.d.ts +131 -0
  95. package/dist/shared/contracts/release-actions.d.ts.map +1 -0
  96. package/dist/shared/contracts/releases.d.ts +182 -0
  97. package/dist/shared/contracts/releases.d.ts.map +1 -0
  98. package/dist/shared/types.d.ts +24 -0
  99. package/dist/shared/types.d.ts.map +1 -0
  100. package/dist/shared/validation-schemas.d.ts +2 -0
  101. package/dist/shared/validation-schemas.d.ts.map +1 -0
  102. package/package.json +29 -36
  103. package/dist/_chunks/App-HjWtUYmc.js.map +0 -1
  104. package/dist/_chunks/App-gu1aiP6i.mjs.map +0 -1
  105. package/dist/_chunks/PurchaseContentReleases-3tRbmbY3.mjs.map +0 -1
  106. package/dist/_chunks/PurchaseContentReleases-bpIYXOfu.js.map +0 -1
  107. package/dist/_chunks/en-HrREghh3.js.map +0 -1
  108. package/dist/_chunks/en-ltT1TlKQ.mjs.map +0 -1
  109. package/dist/_chunks/index-ZNwxYN8H.js.map +0 -1
  110. package/dist/_chunks/index-mvj9PSKd.mjs.map +0 -1
@@ -1,20 +1,17 @@
1
1
  "use strict";
2
- const helperPlugin = require("@strapi/helper-plugin");
3
2
  const icons = require("@strapi/icons");
4
3
  const jsxRuntime = require("react/jsx-runtime");
5
4
  const React = require("react");
6
5
  const query = require("@reduxjs/toolkit/query");
6
+ const strapiAdmin = require("@strapi/admin/strapi-admin");
7
+ const strapiAdmin$1 = require("@strapi/content-manager/strapi-admin");
7
8
  const designSystem = require("@strapi/design-system");
8
- const v2 = require("@strapi/design-system/v2");
9
- const axios = require("axios");
9
+ const symbols = require("@strapi/icons/symbols");
10
10
  const formik = require("formik");
11
11
  const reactIntl = require("react-intl");
12
12
  const reactRouterDom = require("react-router-dom");
13
13
  const yup = require("yup");
14
- const react = require("@reduxjs/toolkit/query/react");
15
- const styled = require("styled-components");
16
- const reactRedux = require("react-redux");
17
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
14
+ const styledComponents = require("styled-components");
18
15
  function _interopNamespace(e) {
19
16
  if (e && e.__esModule)
20
17
  return e;
@@ -35,7 +32,6 @@ function _interopNamespace(e) {
35
32
  }
36
33
  const React__namespace = /* @__PURE__ */ _interopNamespace(React);
37
34
  const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
38
- const styled__default = /* @__PURE__ */ _interopDefault(styled);
39
35
  const __variableDynamicImportRuntimeHelper = (glob, path) => {
40
36
  const v = glob[path];
41
37
  if (v) {
@@ -117,49 +113,9 @@ const PERMISSIONS = {
117
113
  }
118
114
  ]
119
115
  };
120
- const pluginId = "content-releases";
121
- const axiosBaseQuery = async ({
122
- url,
123
- method,
124
- data,
125
- config
126
- }) => {
127
- try {
128
- const { get, post, del, put } = helperPlugin.getFetchClient();
129
- if (method === "POST") {
130
- const result2 = await post(url, data, config);
131
- return { data: result2.data };
132
- }
133
- if (method === "DELETE") {
134
- const result2 = await del(url, config);
135
- return { data: result2.data };
136
- }
137
- if (method === "PUT") {
138
- const result2 = await put(url, data, config);
139
- return { data: result2.data };
140
- }
141
- const result = await get(url, config);
142
- return { data: result.data };
143
- } catch (error) {
144
- const err = error;
145
- return {
146
- error: {
147
- status: err.response?.status,
148
- code: err.code,
149
- response: {
150
- data: err.response?.data
151
- }
152
- }
153
- };
154
- }
155
- };
156
- const isAxiosError = (err) => {
157
- return typeof err === "object" && err !== null && "response" in err && typeof err.response === "object" && err.response !== null && "data" in err.response;
158
- };
159
- const releaseApi = react.createApi({
160
- reducerPath: pluginId,
161
- baseQuery: axiosBaseQuery,
162
- tagTypes: ["Release", "ReleaseAction", "EntriesInRelease"],
116
+ const releaseApi = strapiAdmin.adminApi.enhanceEndpoints({
117
+ addTagTypes: ["Release", "ReleaseAction", "EntriesInRelease"]
118
+ }).injectEndpoints({
163
119
  endpoints: (build) => {
164
120
  return {
165
121
  getReleasesForEntry: build.query({
@@ -303,13 +259,17 @@ const releaseApi = react.createApi({
303
259
  ...query2
304
260
  };
305
261
  const patchResult = dispatch(
306
- releaseApi.util.updateQueryData("getReleaseActions", paramsWithoutActionId, (draft) => {
307
- const [key, index] = actionPath;
308
- const action = draft.data[key][index];
309
- if (action) {
310
- action.type = body.type;
262
+ releaseApi.util.updateQueryData(
263
+ "getReleaseActions",
264
+ paramsWithoutActionId,
265
+ (draft) => {
266
+ const [key, index] = actionPath;
267
+ const action = draft.data[key][index];
268
+ if (action) {
269
+ action.type = body.type;
270
+ }
311
271
  }
312
- })
272
+ )
313
273
  );
314
274
  try {
315
275
  await queryFulfilled;
@@ -399,16 +359,12 @@ const getTimezoneOffset = (timezone, date) => {
399
359
  return "";
400
360
  }
401
361
  };
402
- const useTypedDispatch = reactRedux.useDispatch;
403
- const useTypedSelector = reactRedux.useSelector;
404
- const StyledMenuItem = styled__default.default(v2.Menu.Item)`
362
+ const StyledMenuItem = styledComponents.styled(designSystem.Menu.Item)`
405
363
  &:hover {
406
- background: ${({ theme, variant = "neutral" }) => theme.colors[`${variant}100`]};
364
+ background: ${({ theme, $variant = "neutral" }) => theme.colors[`${$variant}100`]};
407
365
 
408
366
  svg {
409
- path {
410
- fill: ${({ theme, variant = "neutral" }) => theme.colors[`${variant}600`]};
411
- }
367
+ fill: ${({ theme, $variant = "neutral" }) => theme.colors[`${$variant}600`]};
412
368
  }
413
369
 
414
370
  a {
@@ -417,9 +373,7 @@ const StyledMenuItem = styled__default.default(v2.Menu.Item)`
417
373
  }
418
374
 
419
375
  svg {
420
- path {
421
- fill: ${({ theme, variant = "neutral" }) => theme.colors[`${variant}600`]};
422
- }
376
+ fill: ${({ theme, $variant = "neutral" }) => theme.colors[`${$variant}600`]};
423
377
  }
424
378
 
425
379
  a {
@@ -431,15 +385,14 @@ const StyledMenuItem = styled__default.default(v2.Menu.Item)`
431
385
  width: 100%;
432
386
  }
433
387
  `;
434
- const StyledIconButton = styled__default.default(designSystem.IconButton)`
435
- /* Setting this style inline with borderColor will not apply the style */
436
- border: ${({ theme }) => `1px solid ${theme.colors.neutral200}`};
437
- `;
438
388
  const DeleteReleaseActionItem = ({ releaseId, actionId }) => {
439
389
  const { formatMessage } = reactIntl.useIntl();
440
- const toggleNotification = helperPlugin.useNotification();
441
- const { formatAPIError } = helperPlugin.useAPIErrorHandler();
390
+ const { toggleNotification } = strapiAdmin.useNotification();
391
+ const { formatAPIError } = strapiAdmin.useAPIErrorHandler();
442
392
  const [deleteReleaseAction] = useDeleteReleaseActionMutation();
393
+ const {
394
+ allowedActions: { canDeleteAction }
395
+ } = strapiAdmin.useRBAC(PERMISSIONS);
443
396
  const handleDeleteAction = async () => {
444
397
  const response = await deleteReleaseAction({
445
398
  params: { releaseId, actionId }
@@ -455,26 +408,29 @@ const DeleteReleaseActionItem = ({ releaseId, actionId }) => {
455
408
  return;
456
409
  }
457
410
  if ("error" in response) {
458
- if (axios.isAxiosError(response.error)) {
411
+ if (strapiAdmin.isFetchError(response.error)) {
459
412
  toggleNotification({
460
- type: "warning",
413
+ type: "danger",
461
414
  message: formatAPIError(response.error)
462
415
  });
463
416
  } else {
464
417
  toggleNotification({
465
- type: "warning",
418
+ type: "danger",
466
419
  message: formatMessage({ id: "notification.error", defaultMessage: "An error occurred" })
467
420
  });
468
421
  }
469
422
  }
470
423
  };
471
- 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: [
472
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Icon, { as: icons.Cross, width: 3, height: 3 }),
424
+ if (!canDeleteAction) {
425
+ return null;
426
+ }
427
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledMenuItem, { $variant: "danger", onSelect: handleDeleteAction, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
428
+ /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, { width: "1.6rem", height: "1.6rem" }),
473
429
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", variant: "omega", children: formatMessage({
474
430
  id: "content-releases.content-manager-edit-view.remove-from-release",
475
431
  defaultMessage: "Remove from release"
476
432
  }) })
477
- ] }) }) });
433
+ ] }) });
478
434
  };
479
435
  const ReleaseActionEntryLinkItem = ({
480
436
  contentTypeUid,
@@ -482,77 +438,79 @@ const ReleaseActionEntryLinkItem = ({
482
438
  locale
483
439
  }) => {
484
440
  const { formatMessage } = reactIntl.useIntl();
485
- const collectionTypePermissions = useTypedSelector(
486
- (state) => state.rbacProvider.collectionTypesRelatedPermissions
487
- );
488
- const updatePermissions = contentTypeUid ? collectionTypePermissions[contentTypeUid]?.["plugin::content-manager.explorer.update"] : [];
489
- const canUpdateEntryForLocale = Boolean(
490
- !locale || updatePermissions?.find(
491
- (permission) => permission.properties?.locales?.includes(locale)
492
- )
493
- );
441
+ const userPermissions = strapiAdmin.useAuth("ReleaseActionEntryLinkItem", (state) => state.permissions);
442
+ const canUpdateEntryForLocale = React__namespace.useMemo(() => {
443
+ const updatePermissions = userPermissions.find(
444
+ (permission) => permission.subject === contentTypeUid && permission.action === "plugin::content-manager.explorer.update"
445
+ );
446
+ if (!updatePermissions) {
447
+ return false;
448
+ }
449
+ return Boolean(!locale || updatePermissions.properties?.locales?.includes(locale));
450
+ }, [contentTypeUid, locale, userPermissions]);
451
+ const {
452
+ allowedActions: { canUpdate: canUpdateContentType }
453
+ } = strapiAdmin.useRBAC({
454
+ updateContentType: [
455
+ {
456
+ action: "plugin::content-manager.explorer.update",
457
+ subject: contentTypeUid
458
+ }
459
+ ]
460
+ });
461
+ if (!canUpdateContentType || !canUpdateEntryForLocale) {
462
+ return null;
463
+ }
494
464
  return /* @__PURE__ */ jsxRuntime.jsx(
495
- helperPlugin.CheckPermissions,
465
+ StyledMenuItem,
496
466
  {
497
- permissions: [
498
- {
499
- action: "plugin::content-manager.explorer.update",
500
- subject: contentTypeUid
501
- }
502
- ],
503
- children: canUpdateEntryForLocale && /* @__PURE__ */ jsxRuntime.jsx(StyledMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsx(
504
- v2.Link,
505
- {
506
- as: reactRouterDom.NavLink,
507
- to: {
508
- pathname: `/content-manager/collection-types/${contentTypeUid}/${entryId}`,
509
- search: locale && `?plugins[i18n][locale]=${locale}`
510
- },
511
- startIcon: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Icon, { as: icons.Pencil, width: 3, height: 3 }),
512
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: formatMessage({
513
- id: "content-releases.content-manager-edit-view.edit-entry",
514
- defaultMessage: "Edit entry"
515
- }) })
516
- }
517
- ) })
467
+ tag: reactRouterDom.Link,
468
+ isLink: true,
469
+ to: {
470
+ pathname: `/content-manager/collection-types/${contentTypeUid}/${entryId}`,
471
+ search: locale && `?plugins[i18n][locale]=${locale}`
472
+ },
473
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
474
+ /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, { width: "1.6rem", height: "1.6rem" }),
475
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: formatMessage({
476
+ id: "content-releases.content-manager-edit-view.edit-entry",
477
+ defaultMessage: "Edit entry"
478
+ }) })
479
+ ] })
518
480
  }
519
481
  );
520
482
  };
521
483
  const EditReleaseItem = ({ releaseId }) => {
522
484
  const { formatMessage } = reactIntl.useIntl();
523
- return /* @__PURE__ */ jsxRuntime.jsx(StyledMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsx(
524
- v2.Link,
525
- {
526
- href: `/admin/plugins/content-releases/${releaseId}`,
527
- startIcon: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Icon, { as: icons.Pencil, width: 3, height: 3 }),
528
- isExternal: false,
529
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: formatMessage({
485
+ return (
486
+ /* @ts-expect-error inference isn't working in DS */
487
+ /* @__PURE__ */ jsxRuntime.jsx(StyledMenuItem, { tag: reactRouterDom.Link, isLink: true, to: `/plugins/content-releases/${releaseId}`, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
488
+ /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, { width: "1.6rem", height: "1.6rem" }),
489
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: formatMessage({
530
490
  id: "content-releases.content-manager-edit-view.edit-release",
531
491
  defaultMessage: "Edit release"
532
492
  }) })
533
- }
534
- ) });
493
+ ] }) })
494
+ );
535
495
  };
536
- const Root = ({ children, hasTriggerBorder = false }) => {
496
+ const Root = ({ children }) => {
537
497
  const { formatMessage } = reactIntl.useIntl();
498
+ const { allowedActions } = strapiAdmin.useRBAC(PERMISSIONS);
538
499
  return (
539
500
  // A user can access the dropdown if they have permissions to delete a release-action OR update a release
540
- /* @__PURE__ */ jsxRuntime.jsx(helperPlugin.CheckPermissions, { permissions: [...PERMISSIONS.deleteAction, ...PERMISSIONS.update], children: /* @__PURE__ */ jsxRuntime.jsxs(v2.Menu.Root, { children: [
541
- /* @__PURE__ */ jsxRuntime.jsx(
542
- v2.Menu.Trigger,
501
+ allowedActions.canDeleteAction || allowedActions.canUpdate ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { children: [
502
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Trigger, { paddingLeft: 2, paddingRight: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
503
+ designSystem.AccessibleIcon,
543
504
  {
544
- as: hasTriggerBorder ? StyledIconButton : designSystem.IconButton,
545
- paddingLeft: 2,
546
- paddingRight: 2,
547
- "aria-label": formatMessage({
505
+ label: formatMessage({
548
506
  id: "content-releases.content-manager-edit-view.release-action-menu",
549
507
  defaultMessage: "Release action options"
550
508
  }),
551
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.More, {})
509
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.More, {})
552
510
  }
553
- ),
554
- /* @__PURE__ */ jsxRuntime.jsx(v2.Menu.Content, { top: 1, popoverPlacement: "bottom-end", children })
555
- ] }) })
511
+ ) }),
512
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Content, { top: 1, popoverPlacement: "bottom-end", children })
513
+ ] }) : null
556
514
  );
557
515
  };
558
516
  const ReleaseActionMenu = {
@@ -567,11 +525,11 @@ const getBorderLeftRadiusValue = (actionType) => {
567
525
  const getBorderRightRadiusValue = (actionType) => {
568
526
  return actionType === "publish" ? 0 : 1;
569
527
  };
570
- const FieldWrapper = styled__default.default(designSystem.Field)`
571
- border-top-left-radius: ${({ actionType, theme }) => theme.spaces[getBorderLeftRadiusValue(actionType)]};
572
- border-bottom-left-radius: ${({ actionType, theme }) => theme.spaces[getBorderLeftRadiusValue(actionType)]};
573
- border-top-right-radius: ${({ actionType, theme }) => theme.spaces[getBorderRightRadiusValue(actionType)]};
574
- border-bottom-right-radius: ${({ actionType, theme }) => theme.spaces[getBorderRightRadiusValue(actionType)]};
528
+ const FieldWrapper = styledComponents.styled(designSystem.Field.Root)`
529
+ border-top-left-radius: ${({ $actionType, theme }) => theme.spaces[getBorderLeftRadiusValue($actionType)]};
530
+ border-bottom-left-radius: ${({ $actionType, theme }) => theme.spaces[getBorderLeftRadiusValue($actionType)]};
531
+ border-top-right-radius: ${({ $actionType, theme }) => theme.spaces[getBorderRightRadiusValue($actionType)]};
532
+ border-bottom-right-radius: ${({ $actionType, theme }) => theme.spaces[getBorderRightRadiusValue($actionType)]};
575
533
 
576
534
  > label {
577
535
  color: inherit;
@@ -582,14 +540,14 @@ const FieldWrapper = styled__default.default(designSystem.Field)`
582
540
  }
583
541
 
584
542
  &[data-checked='true'] {
585
- color: ${({ theme, actionType }) => actionType === "publish" ? theme.colors.primary700 : theme.colors.danger600};
586
- background-color: ${({ theme, actionType }) => actionType === "publish" ? theme.colors.primary100 : theme.colors.danger100};
587
- border-color: ${({ theme, actionType }) => actionType === "publish" ? theme.colors.primary700 : theme.colors.danger600};
543
+ color: ${({ theme, $actionType }) => $actionType === "publish" ? theme.colors.primary700 : theme.colors.danger600};
544
+ background-color: ${({ theme, $actionType }) => $actionType === "publish" ? theme.colors.primary100 : theme.colors.danger100};
545
+ border-color: ${({ theme, $actionType }) => $actionType === "publish" ? theme.colors.primary700 : theme.colors.danger600};
588
546
  }
589
547
 
590
548
  &[data-checked='false'] {
591
- border-left: ${({ actionType }) => actionType === "unpublish" && "none"};
592
- border-right: ${({ actionType }) => actionType === "publish" && "none"};
549
+ border-left: ${({ $actionType }) => $actionType === "unpublish" && "none"};
550
+ border-right: ${({ $actionType }) => $actionType === "publish" && "none"};
593
551
  }
594
552
 
595
553
  &[data-checked='false'][data-disabled='false']:hover {
@@ -618,7 +576,7 @@ const ActionOption = ({
618
576
  return /* @__PURE__ */ jsxRuntime.jsx(
619
577
  FieldWrapper,
620
578
  {
621
- actionType,
579
+ $actionType: actionType,
622
580
  background: "primary0",
623
581
  borderColor: "neutral200",
624
582
  color: selected === actionType ? "primary600" : "neutral600",
@@ -626,12 +584,11 @@ const ActionOption = ({
626
584
  cursor: "pointer",
627
585
  "data-checked": selected === actionType,
628
586
  "data-disabled": disabled && selected !== actionType,
629
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.FieldLabel, { htmlFor: `${name}-${actionType}`, children: [
587
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { children: [
630
588
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: /* @__PURE__ */ jsxRuntime.jsx(
631
- designSystem.FieldInput,
589
+ designSystem.Field.Input,
632
590
  {
633
591
  type: "radio",
634
- id: `${name}-${actionType}`,
635
592
  name,
636
593
  checked: selected === actionType,
637
594
  onChange: handleChange,
@@ -684,19 +641,20 @@ const INITIAL_VALUES = {
684
641
  const NoReleases = () => {
685
642
  const { formatMessage } = reactIntl.useIntl();
686
643
  return /* @__PURE__ */ jsxRuntime.jsx(
687
- helperPlugin.NoContent,
644
+ designSystem.EmptyStateLayout,
688
645
  {
689
- content: {
646
+ icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem" }),
647
+ content: formatMessage({
690
648
  id: "content-releases.content-manager-edit-view.add-to-release.no-releases-message",
691
649
  defaultMessage: "No available releases. Open the list of releases and create a new one from there."
692
- },
650
+ }),
693
651
  action: /* @__PURE__ */ jsxRuntime.jsx(
694
- v2.LinkButton,
652
+ designSystem.LinkButton,
695
653
  {
696
654
  to: {
697
655
  pathname: "/plugins/content-releases"
698
656
  },
699
- as: reactRouterDom.Link,
657
+ tag: reactRouterDom.Link,
700
658
  variant: "secondary",
701
659
  children: formatMessage({
702
660
  id: "content-releases.content-manager-edit-view.add-to-release.redirect-button",
@@ -714,9 +672,10 @@ const AddActionToReleaseModal = ({
714
672
  }) => {
715
673
  const releaseHeaderId = React__namespace.useId();
716
674
  const { formatMessage } = reactIntl.useIntl();
717
- const toggleNotification = helperPlugin.useNotification();
718
- const { formatAPIError } = helperPlugin.useAPIErrorHandler();
719
- const { modifiedData } = helperPlugin.useCMEditViewDataManager();
675
+ const { toggleNotification } = strapiAdmin.useNotification();
676
+ const { formatAPIError } = strapiAdmin.useAPIErrorHandler();
677
+ const [{ query: query2 }] = strapiAdmin.useQueryParams();
678
+ const locale = query2.plugins?.i18n?.locale;
720
679
  const response = useGetReleasesForEntryQuery({
721
680
  contentTypeUid,
722
681
  entryId,
@@ -725,7 +684,6 @@ const AddActionToReleaseModal = ({
725
684
  const releases = response.data?.data;
726
685
  const [createReleaseAction, { isLoading }] = useCreateReleaseActionMutation();
727
686
  const handleSubmit = async (values) => {
728
- const locale = modifiedData.locale;
729
687
  const releaseActionEntry = {
730
688
  contentType: contentTypeUid,
731
689
  id: entryId,
@@ -747,14 +705,14 @@ const AddActionToReleaseModal = ({
747
705
  return;
748
706
  }
749
707
  if ("error" in response2) {
750
- if (axios.isAxiosError(response2.error)) {
708
+ if (strapiAdmin.isFetchError(response2.error)) {
751
709
  toggleNotification({
752
- type: "warning",
710
+ type: "danger",
753
711
  message: formatAPIError(response2.error)
754
712
  });
755
713
  } else {
756
714
  toggleNotification({
757
- type: "warning",
715
+ type: "danger",
758
716
  message: formatMessage({ id: "notification.error", defaultMessage: "An error occurred" })
759
717
  });
760
718
  }
@@ -774,24 +732,25 @@ const AddActionToReleaseModal = ({
774
732
  children: ({ values, setFieldValue }) => {
775
733
  return /* @__PURE__ */ jsxRuntime.jsxs(formik.Form, { children: [
776
734
  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: [
777
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
778
- designSystem.SingleSelect,
779
- {
780
- required: true,
781
- label: formatMessage({
782
- id: "content-releases.content-manager-edit-view.add-to-release.select-label",
783
- defaultMessage: "Select a release"
784
- }),
785
- placeholder: formatMessage({
786
- id: "content-releases.content-manager-edit-view.add-to-release.select-placeholder",
787
- defaultMessage: "Select"
788
- }),
789
- onChange: (value) => setFieldValue("releaseId", value),
790
- value: values.releaseId,
791
- children: releases?.map((release) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: release.id, children: release.name }, release.id))
792
- }
793
- ) }),
794
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldLabel, { children: formatMessage({
735
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 6, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { required: true, children: [
736
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
737
+ id: "content-releases.content-manager-edit-view.add-to-release.select-label",
738
+ defaultMessage: "Select a release"
739
+ }) }),
740
+ /* @__PURE__ */ jsxRuntime.jsx(
741
+ designSystem.SingleSelect,
742
+ {
743
+ placeholder: formatMessage({
744
+ id: "content-releases.content-manager-edit-view.add-to-release.select-placeholder",
745
+ defaultMessage: "Select"
746
+ }),
747
+ onChange: (value) => setFieldValue("releaseId", value),
748
+ value: values.releaseId,
749
+ children: releases?.map((release) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: release.id, children: release.name }, release.id))
750
+ }
751
+ )
752
+ ] }) }),
753
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
795
754
  id: "content-releases.content-manager-edit-view.add-to-release.action-type-label",
796
755
  defaultMessage: "What do you want to do with this entry?"
797
756
  }) }),
@@ -832,14 +791,18 @@ const AddActionToReleaseModal = ({
832
791
  const CMReleasesContainer = () => {
833
792
  const [isModalOpen, setIsModalOpen] = React__namespace.useState(false);
834
793
  const { formatMessage, formatDate, formatTime } = reactIntl.useIntl();
835
- const {
836
- isCreatingEntry,
837
- hasDraftAndPublish,
838
- initialData: { id: entryId },
839
- slug
840
- } = helperPlugin.useCMEditViewDataManager();
794
+ const { id, slug, collectionType } = reactRouterDom.useParams();
795
+ const isCreatingEntry = id === "create";
796
+ const entryId = parseInt(id, 10);
797
+ const { allowedActions } = strapiAdmin.useRBAC(PERMISSIONS);
798
+ const { canCreateAction, canRead: canMain, canDeleteAction } = allowedActions;
799
+ const { schema } = strapiAdmin$1.unstable_useDocument({
800
+ collectionType,
801
+ model: slug
802
+ });
803
+ const hasDraftAndPublish = schema?.options?.draftAndPublish;
841
804
  const contentTypeUid = slug;
842
- const canFetch = entryId != null && contentTypeUid != null;
805
+ const canFetch = id != null && contentTypeUid != null;
843
806
  const fetchParams = canFetch ? {
844
807
  contentTypeUid,
845
808
  entryId,
@@ -860,10 +823,13 @@ const CMReleasesContainer = () => {
860
823
  }
861
824
  return `success${shade}`;
862
825
  };
863
- return /* @__PURE__ */ jsxRuntime.jsx(helperPlugin.CheckPermissions, { permissions: PERMISSIONS.main, children: /* @__PURE__ */ jsxRuntime.jsxs(
826
+ if (!canMain) {
827
+ return null;
828
+ }
829
+ return /* @__PURE__ */ jsxRuntime.jsxs(
864
830
  designSystem.Box,
865
831
  {
866
- as: "aside",
832
+ tag: "aside",
867
833
  "aria-label": formatMessage({
868
834
  id: "content-releases.plugin.name",
869
835
  defaultMessage: "Releases"
@@ -917,7 +883,7 @@ const CMReleasesContainer = () => {
917
883
  )
918
884
  }
919
885
  ),
920
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { padding: 4, direction: "column", gap: 2, width: "100%", alignItems: "flex-start", children: [
886
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { padding: 4, direction: "column", gap: 2, width: "100%", alignItems: "flex-start", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { padding: 4, direction: "column", gap: 2, width: "100%", alignItems: "flex-start", children: [
921
887
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontSize: 2, fontWeight: "bold", variant: "omega", textColor: "neutral700", children: release.name }),
922
888
  release.scheduledAt && release.timezone && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: formatMessage(
923
889
  {
@@ -941,7 +907,7 @@ const CMReleasesContainer = () => {
941
907
  )
942
908
  }
943
909
  ) }),
944
- /* @__PURE__ */ jsxRuntime.jsx(helperPlugin.CheckPermissions, { permissions: PERMISSIONS.deleteAction, children: /* @__PURE__ */ jsxRuntime.jsxs(ReleaseActionMenu.Root, { hasTriggerBorder: true, children: [
910
+ canDeleteAction ? /* @__PURE__ */ jsxRuntime.jsxs(ReleaseActionMenu.Root, { hasTriggerBorder: true, children: [
945
911
  /* @__PURE__ */ jsxRuntime.jsx(ReleaseActionMenu.EditReleaseItem, { releaseId: release.id }),
946
912
  /* @__PURE__ */ jsxRuntime.jsx(
947
913
  ReleaseActionMenu.DeleteReleaseActionItem,
@@ -950,14 +916,14 @@ const CMReleasesContainer = () => {
950
916
  actionId: release.actions[0].id
951
917
  }
952
918
  )
953
- ] }) })
954
- ] })
919
+ ] }) : null
920
+ ] }) })
955
921
  ]
956
922
  },
957
923
  release.id
958
924
  );
959
925
  }),
960
- /* @__PURE__ */ jsxRuntime.jsx(helperPlugin.CheckPermissions, { permissions: PERMISSIONS.createAction, children: /* @__PURE__ */ jsxRuntime.jsx(
926
+ canCreateAction ? /* @__PURE__ */ jsxRuntime.jsx(
961
927
  designSystem.Button,
962
928
  {
963
929
  justifyContent: "center",
@@ -972,7 +938,7 @@ const CMReleasesContainer = () => {
972
938
  defaultMessage: "Add to release"
973
939
  })
974
940
  }
975
- ) })
941
+ ) : null
976
942
  ] }),
977
943
  isModalOpen && /* @__PURE__ */ jsxRuntime.jsx(
978
944
  AddActionToReleaseModal,
@@ -984,269 +950,17 @@ const CMReleasesContainer = () => {
984
950
  )
985
951
  ]
986
952
  }
987
- ) });
988
- };
989
- const getContentPermissions = (subject) => {
990
- const permissions = {
991
- publish: [
992
- {
993
- action: "plugin::content-manager.explorer.publish",
994
- subject,
995
- id: "",
996
- actionParameters: {},
997
- properties: {},
998
- conditions: []
999
- }
1000
- ]
1001
- };
1002
- return permissions;
1003
- };
1004
- const ReleaseAction = ({ ids, model }) => {
1005
- const { formatMessage } = reactIntl.useIntl();
1006
- const toggleNotification = helperPlugin.useNotification();
1007
- const { formatAPIError } = helperPlugin.useAPIErrorHandler();
1008
- const { modifiedData } = helperPlugin.useCMEditViewDataManager();
1009
- const contentPermissions = getContentPermissions(model);
1010
- const {
1011
- allowedActions: { canPublish }
1012
- } = helperPlugin.useRBAC(contentPermissions);
1013
- const {
1014
- allowedActions: { canCreate }
1015
- } = helperPlugin.useRBAC(PERMISSIONS);
1016
- const response = useGetReleasesQuery();
1017
- const releases = response.data?.data;
1018
- const [createManyReleaseActions, { isLoading }] = useCreateManyReleaseActionsMutation();
1019
- const handleSubmit = async (values) => {
1020
- const locale = modifiedData.locale;
1021
- const releaseActionEntries = ids.map((id) => ({
1022
- type: values.type,
1023
- entry: {
1024
- contentType: model,
1025
- id,
1026
- locale
1027
- }
1028
- }));
1029
- const response2 = await createManyReleaseActions({
1030
- body: releaseActionEntries,
1031
- params: { releaseId: values.releaseId }
1032
- });
1033
- if ("data" in response2) {
1034
- const notificationMessage = formatMessage(
1035
- {
1036
- id: "content-releases.content-manager-list-view.add-to-release.notification.success.message",
1037
- defaultMessage: "{entriesAlreadyInRelease} out of {totalEntries} entries were already in the release."
1038
- },
1039
- {
1040
- entriesAlreadyInRelease: response2.data.meta.entriesAlreadyInRelease,
1041
- totalEntries: response2.data.meta.totalEntries
1042
- }
1043
- );
1044
- const notification = {
1045
- type: "success",
1046
- title: formatMessage(
1047
- {
1048
- id: "content-releases.content-manager-list-view.add-to-release.notification.success.title",
1049
- defaultMessage: "Successfully added to release."
1050
- },
1051
- {
1052
- entriesAlreadyInRelease: response2.data.meta.entriesAlreadyInRelease,
1053
- totalEntries: response2.data.meta.totalEntries
1054
- }
1055
- ),
1056
- message: response2.data.meta.entriesAlreadyInRelease ? notificationMessage : ""
1057
- };
1058
- toggleNotification(notification);
1059
- return true;
1060
- }
1061
- if ("error" in response2) {
1062
- if (axios.isAxiosError(response2.error)) {
1063
- toggleNotification({
1064
- type: "warning",
1065
- message: formatAPIError(response2.error)
1066
- });
1067
- } else {
1068
- toggleNotification({
1069
- type: "warning",
1070
- message: formatMessage({ id: "notification.error", defaultMessage: "An error occurred" })
1071
- });
1072
- }
1073
- }
1074
- };
1075
- if (!canCreate || !canPublish)
1076
- return null;
1077
- return {
1078
- actionType: "release",
1079
- variant: "tertiary",
1080
- label: formatMessage({
1081
- id: "content-manager-list-view.add-to-release",
1082
- defaultMessage: "Add to Release"
1083
- }),
1084
- dialog: {
1085
- type: "modal",
1086
- title: formatMessage({
1087
- id: "content-manager-list-view.add-to-release",
1088
- defaultMessage: "Add to Release"
1089
- }),
1090
- content: ({ onClose }) => {
1091
- return /* @__PURE__ */ jsxRuntime.jsx(
1092
- formik.Formik,
1093
- {
1094
- onSubmit: async (values) => {
1095
- const data = await handleSubmit(values);
1096
- if (data) {
1097
- return onClose();
1098
- }
1099
- },
1100
- validationSchema: RELEASE_ACTION_FORM_SCHEMA,
1101
- initialValues: INITIAL_VALUES,
1102
- children: ({ values, setFieldValue }) => /* @__PURE__ */ jsxRuntime.jsxs(formik.Form, { children: [
1103
- 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: [
1104
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
1105
- designSystem.SingleSelect,
1106
- {
1107
- required: true,
1108
- label: formatMessage({
1109
- id: "content-releases.content-manager-list-view.add-to-release.select-label",
1110
- defaultMessage: "Select a release"
1111
- }),
1112
- placeholder: formatMessage({
1113
- id: "content-releases.content-manager-list-view.add-to-release.select-placeholder",
1114
- defaultMessage: "Select"
1115
- }),
1116
- onChange: (value) => setFieldValue("releaseId", value),
1117
- value: values.releaseId,
1118
- children: releases?.map((release) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: release.id, children: release.name }, release.id))
1119
- }
1120
- ) }),
1121
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldLabel, { children: formatMessage({
1122
- id: "content-releases.content-manager-list-view.add-to-release.action-type-label",
1123
- defaultMessage: "What do you want to do with these entries?"
1124
- }) }),
1125
- /* @__PURE__ */ jsxRuntime.jsx(
1126
- ReleaseActionOptions,
1127
- {
1128
- selected: values.type,
1129
- handleChange: (e) => setFieldValue("type", e.target.value),
1130
- name: "type"
1131
- }
1132
- )
1133
- ] }) }),
1134
- /* @__PURE__ */ jsxRuntime.jsx(
1135
- designSystem.ModalFooter,
1136
- {
1137
- startActions: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", name: "cancel", children: formatMessage({
1138
- id: "content-releases.content-manager-list-view.add-to-release.cancel-button",
1139
- defaultMessage: "Cancel"
1140
- }) }),
1141
- endActions: (
1142
- /**
1143
- * TODO: Ideally we would use isValid from Formik to disable the button, however currently it always returns true
1144
- * for yup.string().required(), even when the value is falsy (including empty string)
1145
- */
1146
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { type: "submit", disabled: !values.releaseId, loading: isLoading, children: formatMessage({
1147
- id: "content-releases.content-manager-list-view.add-to-release.continue-button",
1148
- defaultMessage: "Continue"
1149
- }) })
1150
- )
1151
- }
1152
- )
1153
- ] })
1154
- }
1155
- );
1156
- }
1157
- }
1158
- };
1159
- };
1160
- const Button = styled__default.default.button`
1161
- svg {
1162
- > g,
1163
- path {
1164
- fill: ${({ theme }) => theme.colors.neutral500};
1165
- }
1166
- }
1167
- &:hover {
1168
- svg {
1169
- > g,
1170
- path {
1171
- fill: ${({ theme }) => theme.colors.neutral600};
1172
- }
1173
- }
1174
- }
1175
- &:active {
1176
- svg {
1177
- > g,
1178
- path {
1179
- fill: ${({ theme }) => theme.colors.neutral400};
1180
- }
1181
- }
1182
- }
1183
- `;
1184
- const ActionWrapper = styled__default.default(designSystem.Flex)`
1185
- svg {
1186
- height: ${4 / 16}rem;
1187
- }
1188
- `;
1189
- const useReleasesList = (entryId) => {
1190
- const { uid: contentTypeUid } = useTypedSelector(
1191
- (state) => state["content-manager_listView"].contentType
1192
953
  );
1193
- const listViewData = useTypedSelector((state) => state["content-manager_listView"].data);
1194
- const entriesIds = listViewData.map((entry) => entry.id);
1195
- const response = useGetMappedEntriesInReleasesQuery(
1196
- { contentTypeUid, entriesIds },
1197
- { skip: !entriesIds || !contentTypeUid || entriesIds.length === 0 }
1198
- );
1199
- const mappedEntriesInReleases = response.data || {};
1200
- return mappedEntriesInReleases?.[entryId] || [];
1201
954
  };
1202
- const addColumnToTableHook = ({ displayedHeaders, layout }) => {
1203
- const { contentType } = layout;
1204
- if (!contentType.options?.draftAndPublish) {
1205
- return { displayedHeaders, layout };
955
+ const pluginId = "content-releases";
956
+ const prefixPluginTranslations = (trad, pluginId2) => {
957
+ if (!pluginId2) {
958
+ throw new TypeError("pluginId can't be empty");
1206
959
  }
1207
- return {
1208
- displayedHeaders: [
1209
- ...displayedHeaders,
1210
- {
1211
- key: "__release_key__",
1212
- fieldSchema: { type: "string" },
1213
- metadatas: { label: "To be released in", searchable: true, sortable: false },
1214
- name: "releasedAt",
1215
- cellFormatter: (props) => /* @__PURE__ */ jsxRuntime.jsx(ReleaseListCell, { ...props })
1216
- }
1217
- ],
1218
- layout
1219
- };
1220
- };
1221
- const ReleaseListCell = ({ id }) => {
1222
- const releases = useReleasesList(id);
1223
- const [visible, setVisible] = React__namespace.useState(false);
1224
- const buttonRef = React__namespace.useRef(null);
1225
- const { formatMessage } = reactIntl.useIntl();
1226
- const handleTogglePopover = () => setVisible((prev) => !prev);
1227
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", onClick: handleTogglePopover, ref: buttonRef, children: /* @__PURE__ */ jsxRuntime.jsxs(ActionWrapper, { height: "2rem", width: "2rem", children: [
1228
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { style: { maxWidth: "252px", cursor: "pointer" }, textColor: "neutral800", children: releases.length > 0 ? formatMessage(
1229
- {
1230
- id: "content-releases.content-manager.list-view.releases-number",
1231
- defaultMessage: "{number} {number, plural, one {release} other {releases}}"
1232
- },
1233
- {
1234
- number: releases.length
1235
- }
1236
- ) : "-" }),
1237
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
1238
- releases.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(helperPlugin.SortIcon, {}),
1239
- visible && /* @__PURE__ */ jsxRuntime.jsx(
1240
- designSystem.Popover,
1241
- {
1242
- onDismiss: handleTogglePopover,
1243
- source: buttonRef,
1244
- spacing: 16,
1245
- children: /* @__PURE__ */ jsxRuntime.jsx("ul", { children: releases.map(({ id: id2, name }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 3, as: "li", children: /* @__PURE__ */ jsxRuntime.jsx(v2.Link, { href: `/admin/plugins/content-releases/${id2}`, isExternal: false, children: name }) }, id2)) })
1246
- }
1247
- )
1248
- ] })
1249
- ] }) }) });
960
+ return Object.keys(trad).reduce((acc, current) => {
961
+ acc[`${pluginId2}.${current}`] = trad[current];
962
+ return acc;
963
+ }, {});
1250
964
  };
1251
965
  const admin = {
1252
966
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1254,32 +968,20 @@ const admin = {
1254
968
  app.createHook("ContentReleases/pages/ReleaseDetails/add-locale-in-releases");
1255
969
  if (window.strapi.features.isEnabled("cms-content-releases")) {
1256
970
  app.addMenuLink({
1257
- to: `/plugins/${pluginId}`,
971
+ to: `plugins/${pluginId}`,
1258
972
  icon: icons.PaperPlane,
1259
973
  intlLabel: {
1260
974
  id: `${pluginId}.plugin.name`,
1261
975
  defaultMessage: "Releases"
1262
976
  },
1263
- async Component() {
1264
- const { App } = await Promise.resolve().then(() => require("./App-HjWtUYmc.js"));
1265
- return App;
1266
- },
1267
- permissions: PERMISSIONS.main
977
+ Component: () => Promise.resolve().then(() => require("./App-DUmziQ17.js")).then((mod) => ({ default: mod.App })),
978
+ permissions: PERMISSIONS.main,
979
+ position: 2
1268
980
  });
1269
- app.addMiddlewares([() => releaseApi.middleware]);
1270
- app.addReducers({
1271
- [releaseApi.reducerPath]: releaseApi.reducer
1272
- });
1273
- app.injectContentManagerComponent("editView", "right-links", {
981
+ app.getPlugin("content-manager").injectComponent("editView", "right-links", {
1274
982
  name: `${pluginId}-link`,
1275
983
  Component: CMReleasesContainer
1276
984
  });
1277
- app.plugins["content-manager"].apis.addBulkAction((actions) => {
1278
- const deleteActionIndex = actions.findIndex((action) => action.name === "DeleteAction");
1279
- actions.splice(deleteActionIndex, 0, ReleaseAction);
1280
- return actions;
1281
- });
1282
- app.registerHook("Admin/CM/pages/ListView/inject-column-in-table", addColumnToTableHook);
1283
985
  } else if (!window.strapi.features.isEnabled("cms-content-releases") && window.strapi?.flags?.promoteEE) {
1284
986
  app.addMenuLink({
1285
987
  to: `/plugins/purchase-content-releases`,
@@ -1288,20 +990,22 @@ const admin = {
1288
990
  id: `${pluginId}.plugin.name`,
1289
991
  defaultMessage: "Releases"
1290
992
  },
993
+ permissions: [],
1291
994
  async Component() {
1292
- const { PurchaseContentReleases } = await Promise.resolve().then(() => require("./PurchaseContentReleases-bpIYXOfu.js"));
1293
- return PurchaseContentReleases;
995
+ const { PurchaseContentReleases } = await Promise.resolve().then(() => require("./PurchaseContentReleases-Be3acS2L.js"));
996
+ return { default: PurchaseContentReleases };
1294
997
  },
1295
- lockIcon: true
998
+ lockIcon: true,
999
+ position: 2
1296
1000
  });
1297
1001
  }
1298
1002
  },
1299
1003
  async registerTrads({ locales }) {
1300
1004
  const importedTrads = await Promise.all(
1301
1005
  locales.map((locale) => {
1302
- return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("./en-HrREghh3.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
1006
+ return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("./en-DtFJ5ViE.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
1303
1007
  return {
1304
- data: helperPlugin.prefixPluginTranslations(data, "content-releases"),
1008
+ data: prefixPluginTranslations(data, "content-releases"),
1305
1009
  locale
1306
1010
  };
1307
1011
  }).catch(() => {
@@ -1320,7 +1024,6 @@ exports.ReleaseActionMenu = ReleaseActionMenu;
1320
1024
  exports.ReleaseActionOptions = ReleaseActionOptions;
1321
1025
  exports.admin = admin;
1322
1026
  exports.getTimezoneOffset = getTimezoneOffset;
1323
- exports.isAxiosError = isAxiosError;
1324
1027
  exports.pluginId = pluginId;
1325
1028
  exports.releaseApi = releaseApi;
1326
1029
  exports.useCreateReleaseMutation = useCreateReleaseMutation;
@@ -1329,7 +1032,6 @@ exports.useGetReleaseActionsQuery = useGetReleaseActionsQuery;
1329
1032
  exports.useGetReleaseQuery = useGetReleaseQuery;
1330
1033
  exports.useGetReleasesQuery = useGetReleasesQuery;
1331
1034
  exports.usePublishReleaseMutation = usePublishReleaseMutation;
1332
- exports.useTypedDispatch = useTypedDispatch;
1333
1035
  exports.useUpdateReleaseActionMutation = useUpdateReleaseActionMutation;
1334
1036
  exports.useUpdateReleaseMutation = useUpdateReleaseMutation;
1335
- //# sourceMappingURL=index-ZNwxYN8H.js.map
1037
+ //# sourceMappingURL=index-C5Hc767q.js.map