@strapi/content-releases 0.0.0-next.e6eaa3d0563c85f80fd88b258df70a55c057096e → 0.0.0-next.ee56af7ae29770097422de95c0d5500908dce15c
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/LICENSE +17 -1
- package/dist/_chunks/App-BKB1esYS.js +1395 -0
- package/dist/_chunks/App-BKB1esYS.js.map +1 -0
- package/dist/_chunks/App-Cne--1Z8.mjs +1374 -0
- package/dist/_chunks/App-Cne--1Z8.mjs.map +1 -0
- package/dist/_chunks/{PurchaseContentReleases-YhAPgpG9.js → PurchaseContentReleases-Be3acS2L.js} +8 -7
- package/dist/_chunks/PurchaseContentReleases-Be3acS2L.js.map +1 -0
- package/dist/_chunks/{PurchaseContentReleases-Clm0iACO.mjs → PurchaseContentReleases-_MxP6-Dt.mjs} +9 -8
- package/dist/_chunks/PurchaseContentReleases-_MxP6-Dt.mjs.map +1 -0
- package/dist/_chunks/ReleasesSettingsPage-C1WwGWIH.mjs +178 -0
- package/dist/_chunks/ReleasesSettingsPage-C1WwGWIH.mjs.map +1 -0
- package/dist/_chunks/ReleasesSettingsPage-kuXIwpWp.js +178 -0
- package/dist/_chunks/ReleasesSettingsPage-kuXIwpWp.js.map +1 -0
- package/dist/_chunks/{en-faJDuv3q.js → en-CmYoEnA7.js} +19 -3
- package/dist/_chunks/en-CmYoEnA7.js.map +1 -0
- package/dist/_chunks/{en-RdapH-9X.mjs → en-D0yVZFqf.mjs} +19 -3
- package/dist/_chunks/en-D0yVZFqf.mjs.map +1 -0
- package/dist/_chunks/index-5Odi61vw.js +1381 -0
- package/dist/_chunks/index-5Odi61vw.js.map +1 -0
- package/dist/_chunks/index-Cy7qwpaU.mjs +1362 -0
- package/dist/_chunks/index-Cy7qwpaU.mjs.map +1 -0
- package/dist/_chunks/schemas-BE1LxE9J.js +62 -0
- package/dist/_chunks/schemas-BE1LxE9J.js.map +1 -0
- package/dist/_chunks/schemas-DdA2ic2U.mjs +44 -0
- package/dist/_chunks/schemas-DdA2ic2U.mjs.map +1 -0
- package/dist/admin/index.js +1 -15
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +2 -16
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/src/components/RelativeTime.d.ts +28 -0
- package/dist/admin/src/components/ReleaseAction.d.ts +3 -0
- package/dist/admin/src/components/ReleaseActionMenu.d.ts +26 -0
- package/dist/admin/src/components/ReleaseActionModal.d.ts +24 -0
- package/dist/admin/src/components/ReleaseActionOptions.d.ts +9 -0
- package/dist/admin/src/components/ReleaseListCell.d.ts +28 -0
- package/dist/admin/src/components/ReleaseModal.d.ts +17 -0
- package/dist/admin/src/components/ReleasesPanel.d.ts +3 -0
- package/dist/admin/src/constants.d.ts +76 -0
- package/dist/admin/src/index.d.ts +3 -0
- package/dist/admin/src/modules/hooks.d.ts +7 -0
- package/dist/admin/src/pages/App.d.ts +1 -0
- package/dist/admin/src/pages/PurchaseContentReleases.d.ts +2 -0
- package/dist/admin/src/pages/ReleaseDetailsPage.d.ts +2 -0
- package/dist/admin/src/pages/ReleasesPage.d.ts +8 -0
- package/dist/admin/src/pages/ReleasesSettingsPage.d.ts +1 -0
- package/dist/admin/src/pages/tests/mockReleaseDetailsPageData.d.ts +181 -0
- package/dist/admin/src/pages/tests/mockReleasesPageData.d.ts +39 -0
- package/dist/admin/src/pluginId.d.ts +1 -0
- package/dist/admin/src/services/release.d.ts +112 -0
- package/dist/admin/src/store/hooks.d.ts +7 -0
- package/dist/admin/src/utils/api.d.ts +6 -0
- package/dist/admin/src/utils/prefixPluginTranslations.d.ts +3 -0
- package/dist/admin/src/utils/time.d.ts +10 -0
- package/dist/admin/src/validation/schemas.d.ts +6 -0
- package/dist/server/index.js +882 -617
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +883 -617
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts +5 -0
- package/dist/server/src/bootstrap.d.ts.map +1 -0
- package/dist/server/src/constants.d.ts +21 -0
- package/dist/server/src/constants.d.ts.map +1 -0
- package/dist/server/src/content-types/index.d.ts +97 -0
- package/dist/server/src/content-types/index.d.ts.map +1 -0
- package/dist/server/src/content-types/release/index.d.ts +48 -0
- package/dist/server/src/content-types/release/index.d.ts.map +1 -0
- package/dist/server/src/content-types/release/schema.d.ts +47 -0
- package/dist/server/src/content-types/release/schema.d.ts.map +1 -0
- package/dist/server/src/content-types/release-action/index.d.ts +48 -0
- package/dist/server/src/content-types/release-action/index.d.ts.map +1 -0
- package/dist/server/src/content-types/release-action/schema.d.ts +47 -0
- package/dist/server/src/content-types/release-action/schema.d.ts.map +1 -0
- package/dist/server/src/controllers/index.d.ts +25 -0
- package/dist/server/src/controllers/index.d.ts.map +1 -0
- package/dist/server/src/controllers/release-action.d.ts +10 -0
- package/dist/server/src/controllers/release-action.d.ts.map +1 -0
- package/dist/server/src/controllers/release.d.ts +18 -0
- package/dist/server/src/controllers/release.d.ts.map +1 -0
- package/dist/server/src/controllers/settings.d.ts +11 -0
- package/dist/server/src/controllers/settings.d.ts.map +1 -0
- package/dist/server/src/controllers/validation/release-action.d.ts +14 -0
- package/dist/server/src/controllers/validation/release-action.d.ts.map +1 -0
- package/dist/server/src/controllers/validation/release.d.ts +4 -0
- package/dist/server/src/controllers/validation/release.d.ts.map +1 -0
- package/dist/server/src/controllers/validation/settings.d.ts +3 -0
- package/dist/server/src/controllers/validation/settings.d.ts.map +1 -0
- package/dist/server/src/destroy.d.ts +5 -0
- package/dist/server/src/destroy.d.ts.map +1 -0
- package/dist/server/src/index.d.ts +2115 -0
- package/dist/server/src/index.d.ts.map +1 -0
- package/dist/server/src/middlewares/documents.d.ts +6 -0
- package/dist/server/src/middlewares/documents.d.ts.map +1 -0
- package/dist/server/src/migrations/database/5.0.0-document-id-in-actions.d.ts +9 -0
- package/dist/server/src/migrations/database/5.0.0-document-id-in-actions.d.ts.map +1 -0
- package/dist/server/src/migrations/index.d.ts +13 -0
- package/dist/server/src/migrations/index.d.ts.map +1 -0
- package/dist/server/src/register.d.ts +5 -0
- package/dist/server/src/register.d.ts.map +1 -0
- package/dist/server/src/routes/index.d.ts +51 -0
- package/dist/server/src/routes/index.d.ts.map +1 -0
- package/dist/server/src/routes/release-action.d.ts +18 -0
- package/dist/server/src/routes/release-action.d.ts.map +1 -0
- package/dist/server/src/routes/release.d.ts +18 -0
- package/dist/server/src/routes/release.d.ts.map +1 -0
- package/dist/server/src/routes/settings.d.ts +18 -0
- package/dist/server/src/routes/settings.d.ts.map +1 -0
- package/dist/server/src/services/index.d.ts +1828 -0
- package/dist/server/src/services/index.d.ts.map +1 -0
- package/dist/server/src/services/release-action.d.ts +38 -0
- package/dist/server/src/services/release-action.d.ts.map +1 -0
- package/dist/server/src/services/release.d.ts +31 -0
- package/dist/server/src/services/release.d.ts.map +1 -0
- package/dist/server/src/services/scheduling.d.ts +18 -0
- package/dist/server/src/services/scheduling.d.ts.map +1 -0
- package/dist/server/src/services/settings.d.ts +13 -0
- package/dist/server/src/services/settings.d.ts.map +1 -0
- package/dist/server/src/services/validation.d.ts +18 -0
- package/dist/server/src/services/validation.d.ts.map +1 -0
- package/dist/server/src/utils/index.d.ts +35 -0
- package/dist/server/src/utils/index.d.ts.map +1 -0
- package/dist/shared/contracts/release-actions.d.ts +130 -0
- package/dist/shared/contracts/release-actions.d.ts.map +1 -0
- package/dist/shared/contracts/releases.d.ts +184 -0
- package/dist/shared/contracts/releases.d.ts.map +1 -0
- package/dist/shared/contracts/settings.d.ts +39 -0
- package/dist/shared/contracts/settings.d.ts.map +1 -0
- package/dist/shared/types.d.ts +24 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/package.json +34 -39
- package/dist/_chunks/App-R-kksTW7.mjs +0 -1308
- package/dist/_chunks/App-R-kksTW7.mjs.map +0 -1
- package/dist/_chunks/App-WZHc_d3m.js +0 -1331
- package/dist/_chunks/App-WZHc_d3m.js.map +0 -1
- package/dist/_chunks/PurchaseContentReleases-Clm0iACO.mjs.map +0 -1
- package/dist/_chunks/PurchaseContentReleases-YhAPgpG9.js.map +0 -1
- package/dist/_chunks/en-RdapH-9X.mjs.map +0 -1
- package/dist/_chunks/en-faJDuv3q.js.map +0 -1
- package/dist/_chunks/index-k6fw6RYi.js +0 -1033
- package/dist/_chunks/index-k6fw6RYi.js.map +0 -1
- package/dist/_chunks/index-vpSczx8v.mjs +0 -1012
- package/dist/_chunks/index-vpSczx8v.mjs.map +0 -1
- package/strapi-server.js +0 -3
|
@@ -0,0 +1,1395 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const strapiAdmin = require("@strapi/admin/strapi-admin");
|
|
5
|
+
const reactRouterDom = require("react-router-dom");
|
|
6
|
+
const index = require("./index-5Odi61vw.js");
|
|
7
|
+
const React = require("react");
|
|
8
|
+
const strapiAdmin$1 = require("@strapi/content-manager/strapi-admin");
|
|
9
|
+
const designSystem = require("@strapi/design-system");
|
|
10
|
+
const icons = require("@strapi/icons");
|
|
11
|
+
const symbols = require("@strapi/icons/symbols");
|
|
12
|
+
const format = require("date-fns/format");
|
|
13
|
+
const dateFnsTz = require("date-fns-tz");
|
|
14
|
+
const reactIntl = require("react-intl");
|
|
15
|
+
const styledComponents = require("styled-components");
|
|
16
|
+
const dateFns = require("date-fns");
|
|
17
|
+
const formik = require("formik");
|
|
18
|
+
const schemas = require("./schemas-BE1LxE9J.js");
|
|
19
|
+
const reactRedux = require("react-redux");
|
|
20
|
+
const ee = require("@strapi/admin/strapi-admin/ee");
|
|
21
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
22
|
+
function _interopNamespace(e) {
|
|
23
|
+
if (e && e.__esModule)
|
|
24
|
+
return e;
|
|
25
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
26
|
+
if (e) {
|
|
27
|
+
for (const k in e) {
|
|
28
|
+
if (k !== "default") {
|
|
29
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
30
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: () => e[k]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
n.default = e;
|
|
38
|
+
return Object.freeze(n);
|
|
39
|
+
}
|
|
40
|
+
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
|
41
|
+
const format__default = /* @__PURE__ */ _interopDefault(format);
|
|
42
|
+
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
|
43
|
+
const RelativeTime$1 = React__namespace.forwardRef(
|
|
44
|
+
({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {
|
|
45
|
+
const { formatRelativeTime, formatDate, formatTime } = reactIntl.useIntl();
|
|
46
|
+
const interval = dateFns.intervalToDuration({
|
|
47
|
+
start: timestamp,
|
|
48
|
+
end: Date.now()
|
|
49
|
+
// see https://github.com/date-fns/date-fns/issues/2891 – No idea why it's all partial it returns it every time.
|
|
50
|
+
});
|
|
51
|
+
const unit = intervals.find((intervalUnit) => {
|
|
52
|
+
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
|
|
53
|
+
});
|
|
54
|
+
const relativeTime = dateFns.isPast(timestamp) ? -interval[unit] : interval[unit];
|
|
55
|
+
const customInterval = customIntervals.find(
|
|
56
|
+
(custom) => interval[custom.unit] < custom.threshold
|
|
57
|
+
);
|
|
58
|
+
const displayText = customInterval ? customInterval.text : formatRelativeTime(relativeTime, unit, { numeric: "auto" });
|
|
59
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
60
|
+
"time",
|
|
61
|
+
{
|
|
62
|
+
ref: forwardedRef,
|
|
63
|
+
dateTime: timestamp.toISOString(),
|
|
64
|
+
role: "time",
|
|
65
|
+
title: `${formatDate(timestamp)} ${formatTime(timestamp)}`,
|
|
66
|
+
...restProps,
|
|
67
|
+
children: displayText
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
const ReleaseModal = ({
|
|
73
|
+
handleClose,
|
|
74
|
+
open,
|
|
75
|
+
handleSubmit,
|
|
76
|
+
initialValues,
|
|
77
|
+
isLoading = false
|
|
78
|
+
}) => {
|
|
79
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
80
|
+
const { pathname } = reactRouterDom.useLocation();
|
|
81
|
+
const isCreatingRelease = pathname === `/plugins/${index.pluginId}`;
|
|
82
|
+
const { timezoneList, systemTimezone = { value: "UTC+00:00-Africa/Abidjan " } } = index.getTimezones(
|
|
83
|
+
initialValues.scheduledAt ? new Date(initialValues.scheduledAt) : /* @__PURE__ */ new Date()
|
|
84
|
+
);
|
|
85
|
+
const getScheduledTimestamp = (values) => {
|
|
86
|
+
const { date, time, timezone } = values;
|
|
87
|
+
if (!date || !time || !timezone)
|
|
88
|
+
return null;
|
|
89
|
+
const timezoneWithoutOffset = timezone.split("&")[1];
|
|
90
|
+
return dateFnsTz.zonedTimeToUtc(`${date} ${time}`, timezoneWithoutOffset);
|
|
91
|
+
};
|
|
92
|
+
const getTimezoneWithOffset = () => {
|
|
93
|
+
const currentTimezone = timezoneList.find(
|
|
94
|
+
(timezone) => timezone.value.split("&")[1] === initialValues.timezone
|
|
95
|
+
);
|
|
96
|
+
return currentTimezone?.value || systemTimezone.value;
|
|
97
|
+
};
|
|
98
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
|
|
99
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: formatMessage(
|
|
100
|
+
{
|
|
101
|
+
id: "content-releases.modal.title",
|
|
102
|
+
defaultMessage: "{isCreatingRelease, select, true {New release} other {Edit release}}"
|
|
103
|
+
},
|
|
104
|
+
{ isCreatingRelease }
|
|
105
|
+
) }) }),
|
|
106
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
107
|
+
formik.Formik,
|
|
108
|
+
{
|
|
109
|
+
onSubmit: (values) => {
|
|
110
|
+
handleSubmit({
|
|
111
|
+
...values,
|
|
112
|
+
timezone: values.timezone ? values.timezone.split("&")[1] : null,
|
|
113
|
+
scheduledAt: values.isScheduled ? getScheduledTimestamp(values) : null
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
initialValues: {
|
|
117
|
+
...initialValues,
|
|
118
|
+
timezone: initialValues.timezone ? getTimezoneWithOffset() : systemTimezone.value
|
|
119
|
+
},
|
|
120
|
+
validationSchema: schemas.RELEASE_SCHEMA,
|
|
121
|
+
validateOnChange: false,
|
|
122
|
+
children: ({ values, errors, handleChange, setFieldValue }) => {
|
|
123
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(formik.Form, { children: [
|
|
124
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
125
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
126
|
+
designSystem.Field.Root,
|
|
127
|
+
{
|
|
128
|
+
name: "name",
|
|
129
|
+
error: errors.name && formatMessage({ id: errors.name, defaultMessage: errors.name }),
|
|
130
|
+
required: true,
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
|
|
133
|
+
id: "content-releases.modal.form.input.label.release-name",
|
|
134
|
+
defaultMessage: "Name"
|
|
135
|
+
}) }),
|
|
136
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.TextInput, { value: values.name, onChange: handleChange }),
|
|
137
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { width: "max-content", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
142
|
+
designSystem.Checkbox,
|
|
143
|
+
{
|
|
144
|
+
name: "isScheduled",
|
|
145
|
+
checked: values.isScheduled,
|
|
146
|
+
onCheckedChange: (checked) => {
|
|
147
|
+
setFieldValue("isScheduled", checked);
|
|
148
|
+
if (!checked) {
|
|
149
|
+
setFieldValue("date", null);
|
|
150
|
+
setFieldValue("time", "");
|
|
151
|
+
setFieldValue("timezone", null);
|
|
152
|
+
} else {
|
|
153
|
+
setFieldValue("date", initialValues.date);
|
|
154
|
+
setFieldValue("time", initialValues.time);
|
|
155
|
+
setFieldValue(
|
|
156
|
+
"timezone",
|
|
157
|
+
initialValues.timezone ?? systemTimezone?.value
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
162
|
+
designSystem.Typography,
|
|
163
|
+
{
|
|
164
|
+
textColor: values.isScheduled ? "primary600" : "neutral800",
|
|
165
|
+
fontWeight: values.isScheduled ? "semiBold" : "regular",
|
|
166
|
+
children: formatMessage({
|
|
167
|
+
id: "modal.form.input.label.schedule-release",
|
|
168
|
+
defaultMessage: "Schedule release"
|
|
169
|
+
})
|
|
170
|
+
}
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
) }),
|
|
174
|
+
values.isScheduled && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
175
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, alignItems: "start", children: [
|
|
176
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { width: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
177
|
+
designSystem.Field.Root,
|
|
178
|
+
{
|
|
179
|
+
name: "date",
|
|
180
|
+
error: errors.date && formatMessage({ id: errors.date, defaultMessage: errors.date }),
|
|
181
|
+
required: true,
|
|
182
|
+
children: [
|
|
183
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
|
|
184
|
+
id: "content-releases.modal.form.input.label.date",
|
|
185
|
+
defaultMessage: "Date"
|
|
186
|
+
}) }),
|
|
187
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
188
|
+
designSystem.DatePicker,
|
|
189
|
+
{
|
|
190
|
+
onChange: (date) => {
|
|
191
|
+
const isoFormatDate = date ? dateFns.formatISO(date, { representation: "date" }) : null;
|
|
192
|
+
setFieldValue("date", isoFormatDate);
|
|
193
|
+
},
|
|
194
|
+
clearLabel: formatMessage({
|
|
195
|
+
id: "content-releases.modal.form.input.clearLabel",
|
|
196
|
+
defaultMessage: "Clear"
|
|
197
|
+
}),
|
|
198
|
+
onClear: () => {
|
|
199
|
+
setFieldValue("date", null);
|
|
200
|
+
},
|
|
201
|
+
value: values.date ? new Date(values.date) : /* @__PURE__ */ new Date(),
|
|
202
|
+
minDate: dateFnsTz.utcToZonedTime(/* @__PURE__ */ new Date(), values.timezone.split("&")[1])
|
|
203
|
+
}
|
|
204
|
+
),
|
|
205
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
) }),
|
|
209
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { width: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
210
|
+
designSystem.Field.Root,
|
|
211
|
+
{
|
|
212
|
+
name: "time",
|
|
213
|
+
error: errors.time && formatMessage({ id: errors.time, defaultMessage: errors.time }),
|
|
214
|
+
required: true,
|
|
215
|
+
children: [
|
|
216
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
|
|
217
|
+
id: "content-releases.modal.form.input.label.time",
|
|
218
|
+
defaultMessage: "Time"
|
|
219
|
+
}) }),
|
|
220
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
221
|
+
designSystem.TimePicker,
|
|
222
|
+
{
|
|
223
|
+
onChange: (time) => {
|
|
224
|
+
setFieldValue("time", time);
|
|
225
|
+
},
|
|
226
|
+
clearLabel: formatMessage({
|
|
227
|
+
id: "content-releases.modal.form.input.clearLabel",
|
|
228
|
+
defaultMessage: "Clear"
|
|
229
|
+
}),
|
|
230
|
+
onClear: () => {
|
|
231
|
+
setFieldValue("time", "");
|
|
232
|
+
},
|
|
233
|
+
value: values.time || void 0
|
|
234
|
+
}
|
|
235
|
+
),
|
|
236
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
) })
|
|
240
|
+
] }),
|
|
241
|
+
/* @__PURE__ */ jsxRuntime.jsx(TimezoneComponent, { timezoneOptions: timezoneList })
|
|
242
|
+
] })
|
|
243
|
+
] }) }),
|
|
244
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
|
245
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", name: "cancel", children: formatMessage({ id: "cancel", defaultMessage: "Cancel" }) }) }),
|
|
246
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { name: "submit", loading: isLoading, type: "submit", children: formatMessage(
|
|
247
|
+
{
|
|
248
|
+
id: "content-releases.modal.form.button.submit",
|
|
249
|
+
defaultMessage: "{isCreatingRelease, select, true {Continue} other {Save}}"
|
|
250
|
+
},
|
|
251
|
+
{ isCreatingRelease }
|
|
252
|
+
) })
|
|
253
|
+
] })
|
|
254
|
+
] });
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
)
|
|
258
|
+
] }) });
|
|
259
|
+
};
|
|
260
|
+
const TimezoneComponent = ({ timezoneOptions }) => {
|
|
261
|
+
const { values, errors, setFieldValue } = formik.useFormikContext();
|
|
262
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
263
|
+
const [timezoneList, setTimezoneList] = React__namespace.useState(timezoneOptions);
|
|
264
|
+
React__namespace.useEffect(() => {
|
|
265
|
+
if (values.date) {
|
|
266
|
+
const { timezoneList: timezoneList2 } = index.getTimezones(new Date(values.date));
|
|
267
|
+
setTimezoneList(timezoneList2);
|
|
268
|
+
const updatedTimezone = values.timezone && timezoneList2.find((tz) => tz.value.split("&")[1] === values.timezone.split("&")[1]);
|
|
269
|
+
if (updatedTimezone) {
|
|
270
|
+
setFieldValue("timezone", updatedTimezone.value);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}, [setFieldValue, values.date, values.timezone]);
|
|
274
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
275
|
+
designSystem.Field.Root,
|
|
276
|
+
{
|
|
277
|
+
name: "timezone",
|
|
278
|
+
error: errors.timezone && formatMessage({ id: errors.timezone, defaultMessage: errors.timezone }),
|
|
279
|
+
required: true,
|
|
280
|
+
children: [
|
|
281
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
|
|
282
|
+
id: "content-releases.modal.form.input.label.timezone",
|
|
283
|
+
defaultMessage: "Timezone"
|
|
284
|
+
}) }),
|
|
285
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
286
|
+
designSystem.Combobox,
|
|
287
|
+
{
|
|
288
|
+
autocomplete: { type: "list", filter: "contains" },
|
|
289
|
+
value: values.timezone || void 0,
|
|
290
|
+
textValue: values.timezone ? values.timezone.replace(/&/, " ") : void 0,
|
|
291
|
+
onChange: (timezone) => {
|
|
292
|
+
setFieldValue("timezone", timezone);
|
|
293
|
+
},
|
|
294
|
+
onTextValueChange: (timezone) => {
|
|
295
|
+
setFieldValue("timezone", timezone);
|
|
296
|
+
},
|
|
297
|
+
onClear: () => {
|
|
298
|
+
setFieldValue("timezone", "");
|
|
299
|
+
},
|
|
300
|
+
children: timezoneList.map((timezone) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.ComboboxOption, { value: timezone.value, children: timezone.value.replace(/&/, " ") }, timezone.value))
|
|
301
|
+
}
|
|
302
|
+
),
|
|
303
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
|
|
304
|
+
]
|
|
305
|
+
}
|
|
306
|
+
);
|
|
307
|
+
};
|
|
308
|
+
const useTypedDispatch = reactRedux.useDispatch;
|
|
309
|
+
const isBaseQueryError = (error) => {
|
|
310
|
+
return typeof error !== "undefined" && error.name !== void 0;
|
|
311
|
+
};
|
|
312
|
+
const LinkCard = styledComponents.styled(designSystem.Link)`
|
|
313
|
+
display: block;
|
|
314
|
+
`;
|
|
315
|
+
const RelativeTime = styledComponents.styled(RelativeTime$1)`
|
|
316
|
+
display: inline-block;
|
|
317
|
+
&::first-letter {
|
|
318
|
+
text-transform: uppercase;
|
|
319
|
+
}
|
|
320
|
+
`;
|
|
321
|
+
const getBadgeProps = (status) => {
|
|
322
|
+
let color;
|
|
323
|
+
switch (status) {
|
|
324
|
+
case "ready":
|
|
325
|
+
color = "success";
|
|
326
|
+
break;
|
|
327
|
+
case "blocked":
|
|
328
|
+
color = "warning";
|
|
329
|
+
break;
|
|
330
|
+
case "failed":
|
|
331
|
+
color = "danger";
|
|
332
|
+
break;
|
|
333
|
+
case "done":
|
|
334
|
+
color = "primary";
|
|
335
|
+
break;
|
|
336
|
+
case "empty":
|
|
337
|
+
default:
|
|
338
|
+
color = "neutral";
|
|
339
|
+
}
|
|
340
|
+
return {
|
|
341
|
+
textColor: `${color}600`,
|
|
342
|
+
backgroundColor: `${color}100`,
|
|
343
|
+
borderColor: `${color}200`
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
const ReleasesGrid = ({ sectionTitle, releases = [], isError = false }) => {
|
|
347
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
348
|
+
if (isError) {
|
|
349
|
+
return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Error, {});
|
|
350
|
+
}
|
|
351
|
+
if (releases?.length === 0) {
|
|
352
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
353
|
+
designSystem.EmptyStateLayout,
|
|
354
|
+
{
|
|
355
|
+
content: formatMessage(
|
|
356
|
+
{
|
|
357
|
+
id: "content-releases.page.Releases.tab.emptyEntries",
|
|
358
|
+
defaultMessage: "No releases"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
target: sectionTitle
|
|
362
|
+
}
|
|
363
|
+
),
|
|
364
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem" })
|
|
365
|
+
}
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: releases.map(({ id, name, scheduledAt, status }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 3, s: 6, xs: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(LinkCard, { tag: reactRouterDom.NavLink, to: `${id}`, isExternal: false, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
369
|
+
designSystem.Flex,
|
|
370
|
+
{
|
|
371
|
+
direction: "column",
|
|
372
|
+
justifyContent: "space-between",
|
|
373
|
+
padding: 4,
|
|
374
|
+
hasRadius: true,
|
|
375
|
+
background: "neutral0",
|
|
376
|
+
shadow: "tableShadow",
|
|
377
|
+
height: "100%",
|
|
378
|
+
width: "100%",
|
|
379
|
+
alignItems: "start",
|
|
380
|
+
gap: 4,
|
|
381
|
+
children: [
|
|
382
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "start", gap: 1, children: [
|
|
383
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", tag: "h3", variant: "delta", fontWeight: "bold", children: name }),
|
|
384
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: scheduledAt ? /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(scheduledAt) }) : formatMessage({
|
|
385
|
+
id: "content-releases.pages.Releases.not-scheduled",
|
|
386
|
+
defaultMessage: "Not scheduled"
|
|
387
|
+
}) })
|
|
388
|
+
] }),
|
|
389
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { ...getBadgeProps(status), children: status })
|
|
390
|
+
]
|
|
391
|
+
}
|
|
392
|
+
) }) }, id)) });
|
|
393
|
+
};
|
|
394
|
+
const StyledAlert = styledComponents.styled(designSystem.Alert)`
|
|
395
|
+
button {
|
|
396
|
+
display: none;
|
|
397
|
+
}
|
|
398
|
+
p + div {
|
|
399
|
+
margin-left: auto;
|
|
400
|
+
}
|
|
401
|
+
`;
|
|
402
|
+
const INITIAL_FORM_VALUES = {
|
|
403
|
+
name: "",
|
|
404
|
+
date: dateFns.format(/* @__PURE__ */ new Date(), "yyyy-MM-dd"),
|
|
405
|
+
time: "",
|
|
406
|
+
isScheduled: true,
|
|
407
|
+
scheduledAt: null,
|
|
408
|
+
timezone: null
|
|
409
|
+
};
|
|
410
|
+
const ReleasesPage = () => {
|
|
411
|
+
const location = reactRouterDom.useLocation();
|
|
412
|
+
const [releaseModalShown, setReleaseModalShown] = React__namespace.useState(false);
|
|
413
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
|
414
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
415
|
+
const navigate = reactRouterDom.useNavigate();
|
|
416
|
+
const { formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
|
417
|
+
const [{ query }, setQuery] = strapiAdmin.useQueryParams();
|
|
418
|
+
const response = index.useGetReleasesQuery(query);
|
|
419
|
+
const { data, isLoading: isLoadingSettings } = index.useGetReleaseSettingsQuery();
|
|
420
|
+
const [createRelease, { isLoading: isSubmittingForm }] = index.useCreateReleaseMutation();
|
|
421
|
+
const { getFeature } = ee.useLicenseLimits();
|
|
422
|
+
const { maximumReleases = 3 } = getFeature("cms-content-releases");
|
|
423
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
|
424
|
+
const {
|
|
425
|
+
allowedActions: { canCreate }
|
|
426
|
+
} = strapiAdmin.useRBAC(index.PERMISSIONS);
|
|
427
|
+
const { isLoading: isLoadingReleases, isSuccess, isError } = response;
|
|
428
|
+
const activeTab = response?.currentData?.meta?.activeTab || "pending";
|
|
429
|
+
React__namespace.useEffect(() => {
|
|
430
|
+
if (location?.state?.errors) {
|
|
431
|
+
toggleNotification({
|
|
432
|
+
type: "danger",
|
|
433
|
+
title: formatMessage({
|
|
434
|
+
id: "content-releases.pages.Releases.notification.error.title",
|
|
435
|
+
defaultMessage: "Your request could not be processed."
|
|
436
|
+
}),
|
|
437
|
+
message: formatMessage({
|
|
438
|
+
id: "content-releases.pages.Releases.notification.error.message",
|
|
439
|
+
defaultMessage: "Please try again or open another release."
|
|
440
|
+
})
|
|
441
|
+
});
|
|
442
|
+
navigate("", { replace: true, state: null });
|
|
443
|
+
}
|
|
444
|
+
}, [formatMessage, location?.state?.errors, navigate, toggleNotification]);
|
|
445
|
+
const toggleAddReleaseModal = () => {
|
|
446
|
+
setReleaseModalShown((prev) => !prev);
|
|
447
|
+
};
|
|
448
|
+
if (isLoadingReleases || isLoadingSettings) {
|
|
449
|
+
return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Loading, {});
|
|
450
|
+
}
|
|
451
|
+
const totalPendingReleases = isSuccess && response.currentData?.meta?.pendingReleasesCount || 0;
|
|
452
|
+
const hasReachedMaximumPendingReleases = totalPendingReleases >= maximumReleases;
|
|
453
|
+
const handleTabChange = (tabValue) => {
|
|
454
|
+
setQuery({
|
|
455
|
+
...query,
|
|
456
|
+
page: 1,
|
|
457
|
+
pageSize: response?.currentData?.meta?.pagination?.pageSize || 16,
|
|
458
|
+
filters: {
|
|
459
|
+
releasedAt: {
|
|
460
|
+
$notNull: tabValue !== "pending"
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
};
|
|
465
|
+
const handleAddRelease = async ({ name, scheduledAt, timezone }) => {
|
|
466
|
+
const response2 = await createRelease({
|
|
467
|
+
name,
|
|
468
|
+
scheduledAt,
|
|
469
|
+
timezone
|
|
470
|
+
});
|
|
471
|
+
if ("data" in response2) {
|
|
472
|
+
toggleNotification({
|
|
473
|
+
type: "success",
|
|
474
|
+
message: formatMessage({
|
|
475
|
+
id: "content-releases.modal.release-created-notification-success",
|
|
476
|
+
defaultMessage: "Release created."
|
|
477
|
+
})
|
|
478
|
+
});
|
|
479
|
+
trackUsage("didCreateRelease");
|
|
480
|
+
navigate(response2.data.data.id.toString());
|
|
481
|
+
} else if (strapiAdmin.isFetchError(response2.error)) {
|
|
482
|
+
toggleNotification({
|
|
483
|
+
type: "danger",
|
|
484
|
+
message: formatAPIError(response2.error)
|
|
485
|
+
});
|
|
486
|
+
} else {
|
|
487
|
+
toggleNotification({
|
|
488
|
+
type: "danger",
|
|
489
|
+
message: formatMessage({ id: "notification.error", defaultMessage: "An error occurred" })
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { "aria-busy": isLoadingReleases || isLoadingSettings, children: [
|
|
494
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
495
|
+
strapiAdmin.Layouts.Header,
|
|
496
|
+
{
|
|
497
|
+
title: formatMessage({
|
|
498
|
+
id: "content-releases.pages.Releases.title",
|
|
499
|
+
defaultMessage: "Releases"
|
|
500
|
+
}),
|
|
501
|
+
subtitle: formatMessage({
|
|
502
|
+
id: "content-releases.pages.Releases.header-subtitle",
|
|
503
|
+
defaultMessage: "Create and manage content updates"
|
|
504
|
+
}),
|
|
505
|
+
primaryAction: canCreate ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
506
|
+
designSystem.Button,
|
|
507
|
+
{
|
|
508
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}),
|
|
509
|
+
onClick: toggleAddReleaseModal,
|
|
510
|
+
disabled: hasReachedMaximumPendingReleases,
|
|
511
|
+
children: formatMessage({
|
|
512
|
+
id: "content-releases.header.actions.add-release",
|
|
513
|
+
defaultMessage: "New release"
|
|
514
|
+
})
|
|
515
|
+
}
|
|
516
|
+
) : null
|
|
517
|
+
}
|
|
518
|
+
),
|
|
519
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
520
|
+
hasReachedMaximumPendingReleases && /* @__PURE__ */ jsxRuntime.jsx(
|
|
521
|
+
StyledAlert,
|
|
522
|
+
{
|
|
523
|
+
marginBottom: 6,
|
|
524
|
+
action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Link, { href: "https://strapi.io/pricing-cloud", isExternal: true, children: formatMessage({
|
|
525
|
+
id: "content-releases.pages.Releases.max-limit-reached.action",
|
|
526
|
+
defaultMessage: "Explore plans"
|
|
527
|
+
}) }),
|
|
528
|
+
title: formatMessage(
|
|
529
|
+
{
|
|
530
|
+
id: "content-releases.pages.Releases.max-limit-reached.title",
|
|
531
|
+
defaultMessage: "You have reached the {number} pending {number, plural, one {release} other {releases}} limit."
|
|
532
|
+
},
|
|
533
|
+
{ number: maximumReleases }
|
|
534
|
+
),
|
|
535
|
+
onClose: () => {
|
|
536
|
+
},
|
|
537
|
+
closeLabel: "",
|
|
538
|
+
children: formatMessage({
|
|
539
|
+
id: "content-releases.pages.Releases.max-limit-reached.message",
|
|
540
|
+
defaultMessage: "Upgrade to manage an unlimited number of releases."
|
|
541
|
+
})
|
|
542
|
+
}
|
|
543
|
+
),
|
|
544
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tabs.Root, { variant: "simple", onValueChange: handleTabChange, value: activeTab, children: [
|
|
545
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { paddingBottom: 8, children: [
|
|
546
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
547
|
+
designSystem.Tabs.List,
|
|
548
|
+
{
|
|
549
|
+
"aria-label": formatMessage({
|
|
550
|
+
id: "content-releases.pages.Releases.tab-group.label",
|
|
551
|
+
defaultMessage: "Releases list"
|
|
552
|
+
}),
|
|
553
|
+
children: [
|
|
554
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Trigger, { value: "pending", children: formatMessage(
|
|
555
|
+
{
|
|
556
|
+
id: "content-releases.pages.Releases.tab.pending",
|
|
557
|
+
defaultMessage: "Pending ({count})"
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
count: totalPendingReleases
|
|
561
|
+
}
|
|
562
|
+
) }),
|
|
563
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Trigger, { value: "done", children: formatMessage({
|
|
564
|
+
id: "content-releases.pages.Releases.tab.done",
|
|
565
|
+
defaultMessage: "Done"
|
|
566
|
+
}) })
|
|
567
|
+
]
|
|
568
|
+
}
|
|
569
|
+
),
|
|
570
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {})
|
|
571
|
+
] }),
|
|
572
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "pending", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
573
|
+
ReleasesGrid,
|
|
574
|
+
{
|
|
575
|
+
sectionTitle: "pending",
|
|
576
|
+
releases: response?.currentData?.data,
|
|
577
|
+
isError
|
|
578
|
+
}
|
|
579
|
+
) }),
|
|
580
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "done", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
581
|
+
ReleasesGrid,
|
|
582
|
+
{
|
|
583
|
+
sectionTitle: "done",
|
|
584
|
+
releases: response?.currentData?.data,
|
|
585
|
+
isError
|
|
586
|
+
}
|
|
587
|
+
) })
|
|
588
|
+
] }),
|
|
589
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
590
|
+
strapiAdmin.Pagination.Root,
|
|
591
|
+
{
|
|
592
|
+
...response?.currentData?.meta?.pagination,
|
|
593
|
+
defaultPageSize: response?.currentData?.meta?.pagination?.pageSize,
|
|
594
|
+
children: [
|
|
595
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Pagination.PageSize, { options: ["8", "16", "32", "64"] }),
|
|
596
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Pagination.Links, {})
|
|
597
|
+
]
|
|
598
|
+
}
|
|
599
|
+
)
|
|
600
|
+
] }) }),
|
|
601
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
602
|
+
ReleaseModal,
|
|
603
|
+
{
|
|
604
|
+
open: releaseModalShown,
|
|
605
|
+
handleClose: toggleAddReleaseModal,
|
|
606
|
+
handleSubmit: handleAddRelease,
|
|
607
|
+
isLoading: isSubmittingForm,
|
|
608
|
+
initialValues: {
|
|
609
|
+
...INITIAL_FORM_VALUES,
|
|
610
|
+
timezone: data?.data.defaultTimezone ? data.data.defaultTimezone.split("&")[1] : null
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
)
|
|
614
|
+
] });
|
|
615
|
+
};
|
|
616
|
+
const ReleaseInfoWrapper = styledComponents.styled(designSystem.Flex)`
|
|
617
|
+
align-self: stretch;
|
|
618
|
+
border-bottom-right-radius: ${({ theme }) => theme.borderRadius};
|
|
619
|
+
border-bottom-left-radius: ${({ theme }) => theme.borderRadius};
|
|
620
|
+
border-top: 1px solid ${({ theme }) => theme.colors.neutral150};
|
|
621
|
+
`;
|
|
622
|
+
const StyledMenuItem = styledComponents.styled(designSystem.MenuItem)`
|
|
623
|
+
svg path {
|
|
624
|
+
fill: ${({ theme, disabled }) => disabled && theme.colors.neutral500};
|
|
625
|
+
}
|
|
626
|
+
span {
|
|
627
|
+
color: ${({ theme, disabled }) => disabled && theme.colors.neutral500};
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
&:hover {
|
|
631
|
+
background: ${({ theme, $variant = "neutral" }) => theme.colors[`${$variant}100`]};
|
|
632
|
+
}
|
|
633
|
+
`;
|
|
634
|
+
const PencilIcon = styledComponents.styled(icons.Pencil)`
|
|
635
|
+
width: ${({ theme }) => theme.spaces[4]};
|
|
636
|
+
height: ${({ theme }) => theme.spaces[4]};
|
|
637
|
+
path {
|
|
638
|
+
fill: ${({ theme }) => theme.colors.neutral600};
|
|
639
|
+
}
|
|
640
|
+
`;
|
|
641
|
+
const TrashIcon = styledComponents.styled(icons.Trash)`
|
|
642
|
+
width: ${({ theme }) => theme.spaces[4]};
|
|
643
|
+
height: ${({ theme }) => theme.spaces[4]};
|
|
644
|
+
path {
|
|
645
|
+
fill: ${({ theme }) => theme.colors.danger600};
|
|
646
|
+
}
|
|
647
|
+
`;
|
|
648
|
+
const TypographyMaxWidth = styledComponents.styled(designSystem.Typography)`
|
|
649
|
+
max-width: 300px;
|
|
650
|
+
`;
|
|
651
|
+
const EntryValidationText = ({ action, schema, entry, status }) => {
|
|
652
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
653
|
+
const { validate, isLoading } = strapiAdmin$1.unstable_useDocument(
|
|
654
|
+
{
|
|
655
|
+
collectionType: schema?.kind ?? "",
|
|
656
|
+
model: schema?.uid ?? ""
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
// useDocument makes a request to get more data about the entry, but we only want to have the validation function so we skip the request
|
|
660
|
+
skip: true
|
|
661
|
+
}
|
|
662
|
+
);
|
|
663
|
+
const errorsToString = (errors2, prefix = "") => {
|
|
664
|
+
if (Object.keys(errors2).length === 0) {
|
|
665
|
+
return "";
|
|
666
|
+
}
|
|
667
|
+
return Object.entries(errors2).map(([key, value]) => {
|
|
668
|
+
if (value === void 0 || value === null) {
|
|
669
|
+
return "";
|
|
670
|
+
}
|
|
671
|
+
if (typeof value === "string") {
|
|
672
|
+
return formatMessage(
|
|
673
|
+
{ id: value, defaultMessage: value },
|
|
674
|
+
{ field: prefix ? `${prefix}.${key}` : key }
|
|
675
|
+
);
|
|
676
|
+
}
|
|
677
|
+
if (typeof value === "object" && value !== null && "id" in value && "defaultMessage" in value) {
|
|
678
|
+
return formatMessage(
|
|
679
|
+
// @ts-expect-error – TODO: default message will be a string
|
|
680
|
+
{ id: `${value.id}.withField`, defaultMessage: value.defaultMessage },
|
|
681
|
+
{ field: prefix ? `${prefix}.${key}` : key }
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
return errorsToString(value, key);
|
|
685
|
+
}).join(" ");
|
|
686
|
+
};
|
|
687
|
+
if (isLoading) {
|
|
688
|
+
return null;
|
|
689
|
+
}
|
|
690
|
+
const errors = validate(entry) ?? {};
|
|
691
|
+
if (action === "publish") {
|
|
692
|
+
if (Object.keys(errors).length > 0) {
|
|
693
|
+
const validationErrorsMessages = errorsToString(errors);
|
|
694
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
|
695
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.CrossCircle, { fill: "danger600" }),
|
|
696
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { description: validationErrorsMessages, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
697
|
+
TypographyMaxWidth,
|
|
698
|
+
{
|
|
699
|
+
textColor: "danger600",
|
|
700
|
+
variant: "omega",
|
|
701
|
+
fontWeight: "semiBold",
|
|
702
|
+
ellipsis: true,
|
|
703
|
+
children: validationErrorsMessages
|
|
704
|
+
}
|
|
705
|
+
) })
|
|
706
|
+
] });
|
|
707
|
+
}
|
|
708
|
+
if (status === "draft") {
|
|
709
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
|
710
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
|
711
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
|
|
712
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.ready-to-publish",
|
|
713
|
+
defaultMessage: "Ready to publish"
|
|
714
|
+
}) })
|
|
715
|
+
] });
|
|
716
|
+
}
|
|
717
|
+
if (status === "modified") {
|
|
718
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
|
719
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowsCounterClockwise, { fill: "alternative600" }),
|
|
720
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
|
|
721
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.modified",
|
|
722
|
+
defaultMessage: "Ready to publish changes"
|
|
723
|
+
}) })
|
|
724
|
+
] });
|
|
725
|
+
}
|
|
726
|
+
if (status === "published") {
|
|
727
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
|
728
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
|
729
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
|
|
730
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.already-published",
|
|
731
|
+
defaultMessage: "Already published"
|
|
732
|
+
}) })
|
|
733
|
+
] });
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
|
737
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
|
738
|
+
!entry.publishedAt ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "success600", fontWeight: "bold", children: formatMessage({
|
|
739
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.already-unpublished",
|
|
740
|
+
defaultMessage: "Already unpublished"
|
|
741
|
+
}) }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
|
|
742
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.ready-to-unpublish",
|
|
743
|
+
defaultMessage: "Ready to unpublish"
|
|
744
|
+
}) })
|
|
745
|
+
] });
|
|
746
|
+
};
|
|
747
|
+
const ReleaseDetailsLayout = ({
|
|
748
|
+
toggleEditReleaseModal,
|
|
749
|
+
toggleWarningSubmit,
|
|
750
|
+
children
|
|
751
|
+
}) => {
|
|
752
|
+
const { formatMessage, formatDate, formatTime } = reactIntl.useIntl();
|
|
753
|
+
const { releaseId } = reactRouterDom.useParams();
|
|
754
|
+
const {
|
|
755
|
+
data,
|
|
756
|
+
isLoading: isLoadingDetails,
|
|
757
|
+
error
|
|
758
|
+
} = index.useGetReleaseQuery(
|
|
759
|
+
{ id: releaseId },
|
|
760
|
+
{
|
|
761
|
+
skip: !releaseId
|
|
762
|
+
}
|
|
763
|
+
);
|
|
764
|
+
const [publishRelease, { isLoading: isPublishing }] = index.usePublishReleaseMutation();
|
|
765
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
|
766
|
+
const { formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
|
767
|
+
const { allowedActions } = strapiAdmin.useRBAC(index.PERMISSIONS);
|
|
768
|
+
const { canUpdate, canDelete, canPublish } = allowedActions;
|
|
769
|
+
const dispatch = useTypedDispatch();
|
|
770
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
|
771
|
+
const release = data?.data;
|
|
772
|
+
const handlePublishRelease = (id) => async () => {
|
|
773
|
+
const response = await publishRelease({ id });
|
|
774
|
+
if ("data" in response) {
|
|
775
|
+
toggleNotification({
|
|
776
|
+
type: "success",
|
|
777
|
+
message: formatMessage({
|
|
778
|
+
id: "content-releases.pages.ReleaseDetails.publish-notification-success",
|
|
779
|
+
defaultMessage: "Release was published successfully."
|
|
780
|
+
})
|
|
781
|
+
});
|
|
782
|
+
const { totalEntries: totalEntries2, totalPublishedEntries, totalUnpublishedEntries } = response.data.meta;
|
|
783
|
+
trackUsage("didPublishRelease", {
|
|
784
|
+
totalEntries: totalEntries2,
|
|
785
|
+
totalPublishedEntries,
|
|
786
|
+
totalUnpublishedEntries
|
|
787
|
+
});
|
|
788
|
+
} else if (strapiAdmin.isFetchError(response.error)) {
|
|
789
|
+
toggleNotification({
|
|
790
|
+
type: "danger",
|
|
791
|
+
message: formatAPIError(response.error)
|
|
792
|
+
});
|
|
793
|
+
} else {
|
|
794
|
+
toggleNotification({
|
|
795
|
+
type: "danger",
|
|
796
|
+
message: formatMessage({ id: "notification.error", defaultMessage: "An error occurred" })
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
const handleRefresh = () => {
|
|
801
|
+
dispatch(
|
|
802
|
+
index.releaseApi.util.invalidateTags([
|
|
803
|
+
{ type: "ReleaseAction", id: "LIST" },
|
|
804
|
+
{ type: "Release", id: releaseId }
|
|
805
|
+
])
|
|
806
|
+
);
|
|
807
|
+
};
|
|
808
|
+
const getCreatedByUser = () => {
|
|
809
|
+
if (!release?.createdBy) {
|
|
810
|
+
return null;
|
|
811
|
+
}
|
|
812
|
+
if (release.createdBy.username) {
|
|
813
|
+
return release.createdBy.username;
|
|
814
|
+
}
|
|
815
|
+
if (release.createdBy.firstname) {
|
|
816
|
+
return `${release.createdBy.firstname} ${release.createdBy.lastname || ""}`.trim();
|
|
817
|
+
}
|
|
818
|
+
return release.createdBy.email;
|
|
819
|
+
};
|
|
820
|
+
if (isLoadingDetails) {
|
|
821
|
+
return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Loading, {});
|
|
822
|
+
}
|
|
823
|
+
if (isBaseQueryError(error) && "code" in error || !release) {
|
|
824
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
825
|
+
reactRouterDom.Navigate,
|
|
826
|
+
{
|
|
827
|
+
to: "..",
|
|
828
|
+
state: {
|
|
829
|
+
errors: [
|
|
830
|
+
{
|
|
831
|
+
// @ts-expect-error – TODO: fix this weird error flow
|
|
832
|
+
code: error?.code
|
|
833
|
+
}
|
|
834
|
+
]
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
);
|
|
838
|
+
}
|
|
839
|
+
const totalEntries = release.actions.meta.count || 0;
|
|
840
|
+
const hasCreatedByUser = Boolean(getCreatedByUser());
|
|
841
|
+
const isScheduled = release.scheduledAt && release.timezone;
|
|
842
|
+
const numberOfEntriesText = formatMessage(
|
|
843
|
+
{
|
|
844
|
+
id: "content-releases.pages.Details.header-subtitle",
|
|
845
|
+
defaultMessage: "{number, plural, =0 {No entries} one {# entry} other {# entries}}"
|
|
846
|
+
},
|
|
847
|
+
{ number: totalEntries }
|
|
848
|
+
);
|
|
849
|
+
const scheduledText = isScheduled ? formatMessage(
|
|
850
|
+
{
|
|
851
|
+
id: "content-releases.pages.ReleaseDetails.header-subtitle.scheduled",
|
|
852
|
+
defaultMessage: "Scheduled for {date} at {time} ({offset})"
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
date: formatDate(new Date(release.scheduledAt), {
|
|
856
|
+
weekday: "long",
|
|
857
|
+
day: "numeric",
|
|
858
|
+
month: "long",
|
|
859
|
+
year: "numeric",
|
|
860
|
+
timeZone: release.timezone
|
|
861
|
+
}),
|
|
862
|
+
time: formatTime(new Date(release.scheduledAt), {
|
|
863
|
+
timeZone: release.timezone,
|
|
864
|
+
hourCycle: "h23"
|
|
865
|
+
}),
|
|
866
|
+
offset: index.getTimezoneOffset(release.timezone, new Date(release.scheduledAt))
|
|
867
|
+
}
|
|
868
|
+
) : "";
|
|
869
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { "aria-busy": isLoadingDetails, children: [
|
|
870
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
871
|
+
strapiAdmin.Layouts.Header,
|
|
872
|
+
{
|
|
873
|
+
title: release.name,
|
|
874
|
+
subtitle: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, lineHeight: 6, children: [
|
|
875
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", variant: "epsilon", children: numberOfEntriesText + (isScheduled ? ` - ${scheduledText}` : "") }),
|
|
876
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { ...getBadgeProps(release.status), children: release.status })
|
|
877
|
+
] }),
|
|
878
|
+
navigationAction: /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.BackButton, {}),
|
|
879
|
+
primaryAction: !release.releasedAt && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
|
880
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
881
|
+
SimpleMenuButton,
|
|
882
|
+
{
|
|
883
|
+
label: /* @__PURE__ */ jsxRuntime.jsx(icons.More, {}),
|
|
884
|
+
variant: "tertiary",
|
|
885
|
+
endIcon: null,
|
|
886
|
+
paddingLeft: "7px",
|
|
887
|
+
paddingRight: "7px",
|
|
888
|
+
"aria-label": formatMessage({
|
|
889
|
+
id: "content-releases.header.actions.open-release-actions",
|
|
890
|
+
defaultMessage: "Release edit and delete menu"
|
|
891
|
+
}),
|
|
892
|
+
popoverPlacement: "bottom-end",
|
|
893
|
+
children: [
|
|
894
|
+
/* @__PURE__ */ jsxRuntime.jsx(StyledMenuItem, { disabled: !canUpdate, onSelect: toggleEditReleaseModal, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", gap: 2, hasRadius: true, width: "100%", children: [
|
|
895
|
+
/* @__PURE__ */ jsxRuntime.jsx(PencilIcon, {}),
|
|
896
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { ellipsis: true, children: formatMessage({
|
|
897
|
+
id: "content-releases.header.actions.edit",
|
|
898
|
+
defaultMessage: "Edit"
|
|
899
|
+
}) })
|
|
900
|
+
] }) }),
|
|
901
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
902
|
+
StyledMenuItem,
|
|
903
|
+
{
|
|
904
|
+
disabled: !canDelete,
|
|
905
|
+
onSelect: toggleWarningSubmit,
|
|
906
|
+
$variant: "danger",
|
|
907
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", gap: 2, hasRadius: true, width: "100%", children: [
|
|
908
|
+
/* @__PURE__ */ jsxRuntime.jsx(TrashIcon, {}),
|
|
909
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { ellipsis: true, textColor: "danger600", children: formatMessage({
|
|
910
|
+
id: "content-releases.header.actions.delete",
|
|
911
|
+
defaultMessage: "Delete"
|
|
912
|
+
}) })
|
|
913
|
+
] })
|
|
914
|
+
}
|
|
915
|
+
),
|
|
916
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
917
|
+
ReleaseInfoWrapper,
|
|
918
|
+
{
|
|
919
|
+
direction: "column",
|
|
920
|
+
justifyContent: "center",
|
|
921
|
+
alignItems: "flex-start",
|
|
922
|
+
gap: 1,
|
|
923
|
+
padding: 4,
|
|
924
|
+
children: [
|
|
925
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", children: formatMessage({
|
|
926
|
+
id: "content-releases.header.actions.created",
|
|
927
|
+
defaultMessage: "Created"
|
|
928
|
+
}) }),
|
|
929
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", color: "neutral300", children: [
|
|
930
|
+
/* @__PURE__ */ jsxRuntime.jsx(RelativeTime$1, { timestamp: new Date(release.createdAt) }),
|
|
931
|
+
formatMessage(
|
|
932
|
+
{
|
|
933
|
+
id: "content-releases.header.actions.created.description",
|
|
934
|
+
defaultMessage: "{hasCreatedByUser, select, true { by {createdBy}} other { by deleted user}}"
|
|
935
|
+
},
|
|
936
|
+
{ createdBy: getCreatedByUser(), hasCreatedByUser }
|
|
937
|
+
)
|
|
938
|
+
] })
|
|
939
|
+
]
|
|
940
|
+
}
|
|
941
|
+
)
|
|
942
|
+
]
|
|
943
|
+
}
|
|
944
|
+
),
|
|
945
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "tertiary", onClick: handleRefresh, children: formatMessage({
|
|
946
|
+
id: "content-releases.header.actions.refresh",
|
|
947
|
+
defaultMessage: "Refresh"
|
|
948
|
+
}) }),
|
|
949
|
+
canPublish ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
950
|
+
designSystem.Button,
|
|
951
|
+
{
|
|
952
|
+
size: "S",
|
|
953
|
+
variant: "default",
|
|
954
|
+
onClick: handlePublishRelease(release.id.toString()),
|
|
955
|
+
loading: isPublishing,
|
|
956
|
+
disabled: release.actions.meta.count === 0,
|
|
957
|
+
children: formatMessage({
|
|
958
|
+
id: "content-releases.header.actions.publish",
|
|
959
|
+
defaultMessage: "Publish"
|
|
960
|
+
})
|
|
961
|
+
}
|
|
962
|
+
) : null
|
|
963
|
+
] })
|
|
964
|
+
}
|
|
965
|
+
),
|
|
966
|
+
children
|
|
967
|
+
] });
|
|
968
|
+
};
|
|
969
|
+
const SimpleMenuButton = styledComponents.styled(designSystem.SimpleMenu)`
|
|
970
|
+
& > span {
|
|
971
|
+
display: flex;
|
|
972
|
+
}
|
|
973
|
+
`;
|
|
974
|
+
const GROUP_BY_OPTIONS = ["contentType", "locale", "action"];
|
|
975
|
+
const GROUP_BY_OPTIONS_NO_LOCALE = ["contentType", "action"];
|
|
976
|
+
const getGroupByOptionLabel = (value) => {
|
|
977
|
+
if (value === "locale") {
|
|
978
|
+
return {
|
|
979
|
+
id: "content-releases.pages.ReleaseDetails.groupBy.option.locales",
|
|
980
|
+
defaultMessage: "Locales"
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
if (value === "action") {
|
|
984
|
+
return {
|
|
985
|
+
id: "content-releases.pages.ReleaseDetails.groupBy.option.actions",
|
|
986
|
+
defaultMessage: "Actions"
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
return {
|
|
990
|
+
id: "content-releases.pages.ReleaseDetails.groupBy.option.content-type",
|
|
991
|
+
defaultMessage: "Content-Types"
|
|
992
|
+
};
|
|
993
|
+
};
|
|
994
|
+
const ReleaseDetailsBody = ({ releaseId }) => {
|
|
995
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
996
|
+
const [{ query }, setQuery] = strapiAdmin.useQueryParams();
|
|
997
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
|
998
|
+
const { formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
|
999
|
+
const {
|
|
1000
|
+
data: releaseData,
|
|
1001
|
+
isLoading: isReleaseLoading,
|
|
1002
|
+
error: releaseError
|
|
1003
|
+
} = index.useGetReleaseQuery({ id: releaseId });
|
|
1004
|
+
const {
|
|
1005
|
+
allowedActions: { canUpdate }
|
|
1006
|
+
} = strapiAdmin.useRBAC(index.PERMISSIONS);
|
|
1007
|
+
const runHookWaterfall = strapiAdmin.useStrapiApp("ReleaseDetailsPage", (state) => state.runHookWaterfall);
|
|
1008
|
+
const { displayedHeaders, hasI18nEnabled } = runHookWaterfall("ContentReleases/pages/ReleaseDetails/add-locale-in-releases", {
|
|
1009
|
+
displayedHeaders: [
|
|
1010
|
+
{
|
|
1011
|
+
label: {
|
|
1012
|
+
id: "content-releases.page.ReleaseDetails.table.header.label.name",
|
|
1013
|
+
defaultMessage: "name"
|
|
1014
|
+
},
|
|
1015
|
+
name: "name"
|
|
1016
|
+
}
|
|
1017
|
+
],
|
|
1018
|
+
hasI18nEnabled: false
|
|
1019
|
+
});
|
|
1020
|
+
const release = releaseData?.data;
|
|
1021
|
+
const selectedGroupBy = query?.groupBy || "contentType";
|
|
1022
|
+
const {
|
|
1023
|
+
isLoading,
|
|
1024
|
+
isFetching,
|
|
1025
|
+
isError,
|
|
1026
|
+
data,
|
|
1027
|
+
error: releaseActionsError
|
|
1028
|
+
} = index.useGetReleaseActionsQuery({
|
|
1029
|
+
...query,
|
|
1030
|
+
releaseId
|
|
1031
|
+
});
|
|
1032
|
+
const [updateReleaseAction] = index.useUpdateReleaseActionMutation();
|
|
1033
|
+
const handleChangeType = async (e, actionId, actionPath) => {
|
|
1034
|
+
const response = await updateReleaseAction({
|
|
1035
|
+
params: {
|
|
1036
|
+
releaseId,
|
|
1037
|
+
actionId
|
|
1038
|
+
},
|
|
1039
|
+
body: {
|
|
1040
|
+
type: e.target.value
|
|
1041
|
+
},
|
|
1042
|
+
query,
|
|
1043
|
+
// We are passing the query params to make optimistic updates
|
|
1044
|
+
actionPath
|
|
1045
|
+
// We are passing the action path to found the position in the cache of the action for optimistic updates
|
|
1046
|
+
});
|
|
1047
|
+
if ("error" in response) {
|
|
1048
|
+
if (strapiAdmin.isFetchError(response.error)) {
|
|
1049
|
+
toggleNotification({
|
|
1050
|
+
type: "danger",
|
|
1051
|
+
message: formatAPIError(response.error)
|
|
1052
|
+
});
|
|
1053
|
+
} else {
|
|
1054
|
+
toggleNotification({
|
|
1055
|
+
type: "danger",
|
|
1056
|
+
message: formatMessage({ id: "notification.error", defaultMessage: "An error occurred" })
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
if (isLoading || isReleaseLoading) {
|
|
1062
|
+
return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Loading, {});
|
|
1063
|
+
}
|
|
1064
|
+
const releaseActions = data?.data;
|
|
1065
|
+
const releaseMeta = data?.meta;
|
|
1066
|
+
const contentTypes = releaseMeta?.contentTypes || {};
|
|
1067
|
+
const components = releaseMeta?.components || {};
|
|
1068
|
+
if (isBaseQueryError(releaseError) || !release) {
|
|
1069
|
+
const errorsArray = [];
|
|
1070
|
+
if (releaseError && "code" in releaseError) {
|
|
1071
|
+
errorsArray.push({
|
|
1072
|
+
code: releaseError.code
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
if (releaseActionsError && "code" in releaseActionsError) {
|
|
1076
|
+
errorsArray.push({
|
|
1077
|
+
code: releaseActionsError.code
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1081
|
+
reactRouterDom.Navigate,
|
|
1082
|
+
{
|
|
1083
|
+
to: "..",
|
|
1084
|
+
state: {
|
|
1085
|
+
errors: errorsArray
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
);
|
|
1089
|
+
}
|
|
1090
|
+
if (isError || !releaseActions) {
|
|
1091
|
+
return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Error, {});
|
|
1092
|
+
}
|
|
1093
|
+
if (Object.keys(releaseActions).length === 0) {
|
|
1094
|
+
return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1095
|
+
designSystem.EmptyStateLayout,
|
|
1096
|
+
{
|
|
1097
|
+
action: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1098
|
+
designSystem.LinkButton,
|
|
1099
|
+
{
|
|
1100
|
+
tag: reactRouterDom.Link,
|
|
1101
|
+
to: {
|
|
1102
|
+
pathname: "/content-manager"
|
|
1103
|
+
},
|
|
1104
|
+
style: { textDecoration: "none" },
|
|
1105
|
+
variant: "secondary",
|
|
1106
|
+
children: formatMessage({
|
|
1107
|
+
id: "content-releases.page.Details.button.openContentManager",
|
|
1108
|
+
defaultMessage: "Open the Content Manager"
|
|
1109
|
+
})
|
|
1110
|
+
}
|
|
1111
|
+
),
|
|
1112
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem" }),
|
|
1113
|
+
content: formatMessage({
|
|
1114
|
+
id: "content-releases.pages.Details.tab.emptyEntries",
|
|
1115
|
+
defaultMessage: "This release is empty. Open the Content Manager, select an entry and add it to the release."
|
|
1116
|
+
})
|
|
1117
|
+
}
|
|
1118
|
+
) });
|
|
1119
|
+
}
|
|
1120
|
+
const groupByLabel = formatMessage({
|
|
1121
|
+
id: "content-releases.pages.ReleaseDetails.groupBy.aria-label",
|
|
1122
|
+
defaultMessage: "Group by"
|
|
1123
|
+
});
|
|
1124
|
+
const headers = [
|
|
1125
|
+
...displayedHeaders,
|
|
1126
|
+
{
|
|
1127
|
+
label: {
|
|
1128
|
+
id: "content-releases.page.ReleaseDetails.table.header.label.content-type",
|
|
1129
|
+
defaultMessage: "content-type"
|
|
1130
|
+
},
|
|
1131
|
+
name: "content-type"
|
|
1132
|
+
},
|
|
1133
|
+
{
|
|
1134
|
+
label: {
|
|
1135
|
+
id: "content-releases.page.ReleaseDetails.table.header.label.action",
|
|
1136
|
+
defaultMessage: "action"
|
|
1137
|
+
},
|
|
1138
|
+
name: "action"
|
|
1139
|
+
},
|
|
1140
|
+
...!release.releasedAt ? [
|
|
1141
|
+
{
|
|
1142
|
+
label: {
|
|
1143
|
+
id: "content-releases.page.ReleaseDetails.table.header.label.status",
|
|
1144
|
+
defaultMessage: "status"
|
|
1145
|
+
},
|
|
1146
|
+
name: "status"
|
|
1147
|
+
}
|
|
1148
|
+
] : []
|
|
1149
|
+
];
|
|
1150
|
+
const options = hasI18nEnabled ? GROUP_BY_OPTIONS : GROUP_BY_OPTIONS_NO_LOCALE;
|
|
1151
|
+
return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 8, direction: "column", alignItems: "stretch", children: [
|
|
1152
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1153
|
+
designSystem.SingleSelect,
|
|
1154
|
+
{
|
|
1155
|
+
placeholder: groupByLabel,
|
|
1156
|
+
"aria-label": groupByLabel,
|
|
1157
|
+
customizeContent: (value) => formatMessage(
|
|
1158
|
+
{
|
|
1159
|
+
id: `content-releases.pages.ReleaseDetails.groupBy.label`,
|
|
1160
|
+
defaultMessage: `Group by {groupBy}`
|
|
1161
|
+
},
|
|
1162
|
+
{
|
|
1163
|
+
groupBy: value
|
|
1164
|
+
}
|
|
1165
|
+
),
|
|
1166
|
+
value: formatMessage(getGroupByOptionLabel(selectedGroupBy)),
|
|
1167
|
+
onChange: (value) => setQuery({ groupBy: value }),
|
|
1168
|
+
children: options.map((option) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: option, children: formatMessage(getGroupByOptionLabel(option)) }, option))
|
|
1169
|
+
}
|
|
1170
|
+
) }),
|
|
1171
|
+
Object.keys(releaseActions).map((key) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, direction: "column", alignItems: "stretch", children: [
|
|
1172
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { role: "separator", "aria-label": key, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { children: key }) }),
|
|
1173
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1174
|
+
strapiAdmin.Table.Root,
|
|
1175
|
+
{
|
|
1176
|
+
rows: releaseActions[key].map((item) => ({
|
|
1177
|
+
...item,
|
|
1178
|
+
id: Number(item.entry.id)
|
|
1179
|
+
})),
|
|
1180
|
+
headers,
|
|
1181
|
+
isLoading: isLoading || isFetching,
|
|
1182
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Content, { children: [
|
|
1183
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Head, { children: headers.map(({ label, name }) => /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.HeaderCell, { label: formatMessage(label), name }, name)) }),
|
|
1184
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Loading, {}),
|
|
1185
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Body, { children: releaseActions[key].map(
|
|
1186
|
+
({ id, contentType, locale, type, entry, status }, actionIndex) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
1187
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { width: "25%", maxWidth: "200px", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { ellipsis: true, children: `${contentType.mainFieldValue || entry.id}` }) }),
|
|
1188
|
+
hasI18nEnabled && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { width: "10%", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: `${locale?.name ? locale.name : "-"}` }) }),
|
|
1189
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { width: "10%", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: contentType.displayName || "" }) }),
|
|
1190
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { width: "20%", children: release.releasedAt ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage(
|
|
1191
|
+
{
|
|
1192
|
+
id: "content-releases.page.ReleaseDetails.table.action-published",
|
|
1193
|
+
defaultMessage: "This entry was <b>{isPublish, select, true {published} other {unpublished}}</b>."
|
|
1194
|
+
},
|
|
1195
|
+
{
|
|
1196
|
+
isPublish: type === "publish",
|
|
1197
|
+
b: (children) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children })
|
|
1198
|
+
}
|
|
1199
|
+
) }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1200
|
+
index.ReleaseActionOptions,
|
|
1201
|
+
{
|
|
1202
|
+
selected: type,
|
|
1203
|
+
handleChange: (e) => handleChangeType(e, id, [key, actionIndex]),
|
|
1204
|
+
name: `release-action-${id}-type`,
|
|
1205
|
+
disabled: !canUpdate
|
|
1206
|
+
}
|
|
1207
|
+
) }),
|
|
1208
|
+
!release.releasedAt && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1209
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { width: "20%", minWidth: "200px", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1210
|
+
EntryValidationText,
|
|
1211
|
+
{
|
|
1212
|
+
action: type,
|
|
1213
|
+
schema: contentTypes?.[contentType.uid],
|
|
1214
|
+
components,
|
|
1215
|
+
entry,
|
|
1216
|
+
status
|
|
1217
|
+
}
|
|
1218
|
+
) }),
|
|
1219
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsxs(index.ReleaseActionMenu.Root, { children: [
|
|
1220
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1221
|
+
index.ReleaseActionMenu.ReleaseActionEntryLinkItem,
|
|
1222
|
+
{
|
|
1223
|
+
contentTypeUid: contentType.uid,
|
|
1224
|
+
documentId: entry.documentId,
|
|
1225
|
+
locale: locale?.code
|
|
1226
|
+
}
|
|
1227
|
+
),
|
|
1228
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1229
|
+
index.ReleaseActionMenu.DeleteReleaseActionItem,
|
|
1230
|
+
{
|
|
1231
|
+
releaseId: release.id,
|
|
1232
|
+
actionId: id
|
|
1233
|
+
}
|
|
1234
|
+
)
|
|
1235
|
+
] }) }) })
|
|
1236
|
+
] })
|
|
1237
|
+
] }, id)
|
|
1238
|
+
) })
|
|
1239
|
+
] })
|
|
1240
|
+
}
|
|
1241
|
+
)
|
|
1242
|
+
] }, `releases-group-${key}`)),
|
|
1243
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1244
|
+
strapiAdmin.Pagination.Root,
|
|
1245
|
+
{
|
|
1246
|
+
...releaseMeta?.pagination,
|
|
1247
|
+
defaultPageSize: releaseMeta?.pagination?.pageSize,
|
|
1248
|
+
children: [
|
|
1249
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Pagination.PageSize, {}),
|
|
1250
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Pagination.Links, {})
|
|
1251
|
+
]
|
|
1252
|
+
}
|
|
1253
|
+
)
|
|
1254
|
+
] }) });
|
|
1255
|
+
};
|
|
1256
|
+
const ReleaseDetailsPage = () => {
|
|
1257
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
1258
|
+
const { releaseId } = reactRouterDom.useParams();
|
|
1259
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
|
1260
|
+
const { formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
|
1261
|
+
const navigate = reactRouterDom.useNavigate();
|
|
1262
|
+
const [releaseModalShown, setReleaseModalShown] = React__namespace.useState(false);
|
|
1263
|
+
const [showWarningSubmit, setWarningSubmit] = React__namespace.useState(false);
|
|
1264
|
+
const {
|
|
1265
|
+
isLoading: isLoadingDetails,
|
|
1266
|
+
data,
|
|
1267
|
+
isSuccess: isSuccessDetails
|
|
1268
|
+
} = index.useGetReleaseQuery(
|
|
1269
|
+
{ id: releaseId },
|
|
1270
|
+
{
|
|
1271
|
+
skip: !releaseId
|
|
1272
|
+
}
|
|
1273
|
+
);
|
|
1274
|
+
const { data: dataTimezone, isLoading: isLoadingTimezone } = index.useGetReleaseSettingsQuery();
|
|
1275
|
+
const [updateRelease, { isLoading: isSubmittingForm }] = index.useUpdateReleaseMutation();
|
|
1276
|
+
const [deleteRelease] = index.useDeleteReleaseMutation();
|
|
1277
|
+
const toggleEditReleaseModal = () => {
|
|
1278
|
+
setReleaseModalShown((prev) => !prev);
|
|
1279
|
+
};
|
|
1280
|
+
const getTimezoneValue = () => {
|
|
1281
|
+
if (releaseData?.timezone) {
|
|
1282
|
+
return releaseData.timezone;
|
|
1283
|
+
} else {
|
|
1284
|
+
if (dataTimezone?.data.defaultTimezone) {
|
|
1285
|
+
return dataTimezone.data.defaultTimezone;
|
|
1286
|
+
}
|
|
1287
|
+
return null;
|
|
1288
|
+
}
|
|
1289
|
+
};
|
|
1290
|
+
const toggleWarningSubmit = () => setWarningSubmit((prevState) => !prevState);
|
|
1291
|
+
if (isLoadingDetails || isLoadingTimezone) {
|
|
1292
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1293
|
+
ReleaseDetailsLayout,
|
|
1294
|
+
{
|
|
1295
|
+
toggleEditReleaseModal,
|
|
1296
|
+
toggleWarningSubmit,
|
|
1297
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Loading, {})
|
|
1298
|
+
}
|
|
1299
|
+
);
|
|
1300
|
+
}
|
|
1301
|
+
if (!releaseId) {
|
|
1302
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: ".." });
|
|
1303
|
+
}
|
|
1304
|
+
const releaseData = isSuccessDetails && data?.data || null;
|
|
1305
|
+
const title = releaseData?.name || "";
|
|
1306
|
+
const timezone = getTimezoneValue();
|
|
1307
|
+
const scheduledAt = releaseData?.scheduledAt && timezone ? dateFnsTz.utcToZonedTime(releaseData.scheduledAt, timezone) : null;
|
|
1308
|
+
const date = scheduledAt ? format__default.default(scheduledAt, "yyyy-MM-dd") : void 0;
|
|
1309
|
+
const time = scheduledAt ? format__default.default(scheduledAt, "HH:mm") : "";
|
|
1310
|
+
const handleEditRelease = async (values) => {
|
|
1311
|
+
const response = await updateRelease({
|
|
1312
|
+
id: releaseId,
|
|
1313
|
+
name: values.name,
|
|
1314
|
+
scheduledAt: values.scheduledAt,
|
|
1315
|
+
timezone: values.timezone
|
|
1316
|
+
});
|
|
1317
|
+
if ("data" in response) {
|
|
1318
|
+
toggleNotification({
|
|
1319
|
+
type: "success",
|
|
1320
|
+
message: formatMessage({
|
|
1321
|
+
id: "content-releases.modal.release-updated-notification-success",
|
|
1322
|
+
defaultMessage: "Release updated."
|
|
1323
|
+
})
|
|
1324
|
+
});
|
|
1325
|
+
toggleEditReleaseModal();
|
|
1326
|
+
} else if (strapiAdmin.isFetchError(response.error)) {
|
|
1327
|
+
toggleNotification({
|
|
1328
|
+
type: "danger",
|
|
1329
|
+
message: formatAPIError(response.error)
|
|
1330
|
+
});
|
|
1331
|
+
} else {
|
|
1332
|
+
toggleNotification({
|
|
1333
|
+
type: "danger",
|
|
1334
|
+
message: formatMessage({ id: "notification.error", defaultMessage: "An error occurred" })
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
};
|
|
1338
|
+
const handleDeleteRelease = async () => {
|
|
1339
|
+
const response = await deleteRelease({
|
|
1340
|
+
id: releaseId
|
|
1341
|
+
});
|
|
1342
|
+
if ("data" in response) {
|
|
1343
|
+
navigate("..");
|
|
1344
|
+
} else if (strapiAdmin.isFetchError(response.error)) {
|
|
1345
|
+
toggleNotification({
|
|
1346
|
+
type: "danger",
|
|
1347
|
+
message: formatAPIError(response.error)
|
|
1348
|
+
});
|
|
1349
|
+
} else {
|
|
1350
|
+
toggleNotification({
|
|
1351
|
+
type: "danger",
|
|
1352
|
+
message: formatMessage({ id: "notification.error", defaultMessage: "An error occurred" })
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
};
|
|
1356
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1357
|
+
ReleaseDetailsLayout,
|
|
1358
|
+
{
|
|
1359
|
+
toggleEditReleaseModal,
|
|
1360
|
+
toggleWarningSubmit,
|
|
1361
|
+
children: [
|
|
1362
|
+
/* @__PURE__ */ jsxRuntime.jsx(ReleaseDetailsBody, { releaseId }),
|
|
1363
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1364
|
+
ReleaseModal,
|
|
1365
|
+
{
|
|
1366
|
+
open: releaseModalShown,
|
|
1367
|
+
handleClose: toggleEditReleaseModal,
|
|
1368
|
+
handleSubmit: handleEditRelease,
|
|
1369
|
+
isLoading: isLoadingDetails || isSubmittingForm,
|
|
1370
|
+
initialValues: {
|
|
1371
|
+
name: title || "",
|
|
1372
|
+
scheduledAt,
|
|
1373
|
+
date,
|
|
1374
|
+
time,
|
|
1375
|
+
isScheduled: Boolean(scheduledAt),
|
|
1376
|
+
timezone
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
),
|
|
1380
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: showWarningSubmit, onOpenChange: toggleWarningSubmit, children: /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.ConfirmDialog, { onConfirm: handleDeleteRelease, children: formatMessage({
|
|
1381
|
+
id: "content-releases.dialog.confirmation-message",
|
|
1382
|
+
defaultMessage: "Are you sure you want to delete this release?"
|
|
1383
|
+
}) }) })
|
|
1384
|
+
]
|
|
1385
|
+
}
|
|
1386
|
+
);
|
|
1387
|
+
};
|
|
1388
|
+
const App = () => {
|
|
1389
|
+
return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Protect, { permissions: index.PERMISSIONS.main, children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
|
|
1390
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { index: true, element: /* @__PURE__ */ jsxRuntime.jsx(ReleasesPage, {}) }),
|
|
1391
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: ":releaseId", element: /* @__PURE__ */ jsxRuntime.jsx(ReleaseDetailsPage, {}) })
|
|
1392
|
+
] }) });
|
|
1393
|
+
};
|
|
1394
|
+
exports.App = App;
|
|
1395
|
+
//# sourceMappingURL=App-BKB1esYS.js.map
|