@strapi/content-releases 0.0.0-experimental.fd379e4937e431407d784eaa5fe7f93cf2a53386 → 0.0.0-experimental.fdacf4285d1cada9d94ab4dcd756c5362cba1b54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{App-Cne--1Z8.mjs → App-B7XAvv8M.mjs} +283 -112
- package/dist/_chunks/App-B7XAvv8M.mjs.map +1 -0
- package/dist/_chunks/{App-BKB1esYS.js → App-bh0od5o7.js} +323 -152
- package/dist/_chunks/App-bh0od5o7.js.map +1 -0
- package/dist/_chunks/{ReleasesSettingsPage-C1WwGWIH.mjs → ReleasesSettingsPage-DI0i3yzr.mjs} +2 -2
- package/dist/_chunks/{ReleasesSettingsPage-C1WwGWIH.mjs.map → ReleasesSettingsPage-DI0i3yzr.mjs.map} +1 -1
- package/dist/_chunks/{ReleasesSettingsPage-kuXIwpWp.js → ReleasesSettingsPage-DegTeuSf.js} +2 -2
- package/dist/_chunks/{ReleasesSettingsPage-kuXIwpWp.js.map → ReleasesSettingsPage-DegTeuSf.js.map} +1 -1
- package/dist/_chunks/{en-CmYoEnA7.js → en-BWPPsSH-.js} +11 -2
- package/dist/_chunks/en-BWPPsSH-.js.map +1 -0
- package/dist/_chunks/{en-D0yVZFqf.mjs → en-D9Q4YW03.mjs} +11 -2
- package/dist/_chunks/en-D9Q4YW03.mjs.map +1 -0
- package/dist/_chunks/{index-5Odi61vw.js → index-B7aCK4-q.js} +7 -4
- package/dist/_chunks/{index-5Odi61vw.js.map → index-B7aCK4-q.js.map} +1 -1
- package/dist/_chunks/{index-Cy7qwpaU.mjs → index-ok-2phdF.mjs} +7 -4
- package/dist/_chunks/{index-Cy7qwpaU.mjs.map → index-ok-2phdF.mjs.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/EntryValidationPopover.d.ts +12 -0
- package/dist/server/index.js +14 -9
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +14 -9
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/index.d.ts +1 -6
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/migrations/database/5.0.0-document-id-in-actions.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +1 -6
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/release-action.d.ts +2 -7
- package/dist/server/src/services/release-action.d.ts.map +1 -1
- package/dist/shared/contracts/release-actions.d.ts +7 -1
- package/dist/shared/contracts/release-actions.d.ts.map +1 -1
- package/package.json +12 -11
- package/dist/_chunks/App-BKB1esYS.js.map +0 -1
- package/dist/_chunks/App-Cne--1Z8.mjs.map +0 -1
- package/dist/_chunks/en-CmYoEnA7.js.map +0 -1
- package/dist/_chunks/en-D0yVZFqf.mjs.map +0 -1
|
@@ -1,21 +1,292 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useNotification, useAPIErrorHandler, useQueryParams, useTracking, useRBAC, Page, Layouts, Pagination, isFetchError, ConfirmDialog, BackButton, useStrapiApp, Table } from "@strapi/admin/strapi-admin";
|
|
3
|
-
import { useLocation, useNavigate, NavLink, useParams, Navigate,
|
|
4
|
-
import { g as getTimezones, p as pluginId, u as useGetReleasesQuery, a as useGetReleaseSettingsQuery, b as useCreateReleaseMutation, P as PERMISSIONS, c as useGetReleaseQuery, d as useUpdateReleaseMutation, e as useDeleteReleaseMutation, f as usePublishReleaseMutation, h as getTimezoneOffset, i as useGetReleaseActionsQuery, j as useUpdateReleaseActionMutation, R as ReleaseActionOptions, k as ReleaseActionMenu, r as releaseApi } from "./index-
|
|
3
|
+
import { Link, useLocation, useNavigate, NavLink, useParams, Navigate, Routes, Route } from "react-router-dom";
|
|
4
|
+
import { g as getTimezones, p as pluginId, u as useGetReleasesQuery, a as useGetReleaseSettingsQuery, b as useCreateReleaseMutation, P as PERMISSIONS, c as useGetReleaseQuery, d as useUpdateReleaseMutation, e as useDeleteReleaseMutation, f as usePublishReleaseMutation, h as getTimezoneOffset, i as useGetReleaseActionsQuery, j as useUpdateReleaseActionMutation, R as ReleaseActionOptions, k as ReleaseActionMenu, r as releaseApi } from "./index-ok-2phdF.mjs";
|
|
5
5
|
import * as React from "react";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { Plus, Pencil, Trash, More, CrossCircle, CheckCircle, ArrowsCounterClockwise } from "@strapi/icons";
|
|
6
|
+
import { Flex, Popover, Button, Typography, LinkButton, Modal, Field, TextInput, Box, Checkbox, DatePicker, TimePicker, Combobox, ComboboxOption, Link as Link$1, Alert, Main, Tabs, Divider, EmptyStateLayout, Grid, Badge, MenuItem, SimpleMenu, Dialog, SingleSelect, SingleSelectOption, Tr, Td } from "@strapi/design-system";
|
|
7
|
+
import { CrossCircle, CaretDown, CheckCircle, ArrowsCounterClockwise, Plus, Pencil, Trash, More } from "@strapi/icons";
|
|
9
8
|
import { EmptyDocuments } from "@strapi/icons/symbols";
|
|
10
9
|
import format$1 from "date-fns/format";
|
|
11
10
|
import { utcToZonedTime, zonedTimeToUtc } from "date-fns-tz";
|
|
12
11
|
import { useIntl } from "react-intl";
|
|
13
12
|
import { styled } from "styled-components";
|
|
13
|
+
import { unstable_useDocument } from "@strapi/content-manager/strapi-admin";
|
|
14
|
+
import { stringify } from "qs";
|
|
14
15
|
import { intervalToDuration, isPast, formatISO, format } from "date-fns";
|
|
15
16
|
import { Formik, Form, useFormikContext } from "formik";
|
|
16
17
|
import { R as RELEASE_SCHEMA } from "./schemas-DdA2ic2U.mjs";
|
|
17
18
|
import { useDispatch } from "react-redux";
|
|
18
19
|
import { useLicenseLimits } from "@strapi/admin/strapi-admin/ee";
|
|
20
|
+
const StyledPopoverFlex = styled(Flex)`
|
|
21
|
+
width: 100%;
|
|
22
|
+
max-width: 256px;
|
|
23
|
+
|
|
24
|
+
& > * {
|
|
25
|
+
border-bottom: 1px solid ${({ theme }) => theme.colors.neutral150};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
& > *:last-child {
|
|
29
|
+
border-bottom: none;
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
const EntryStatusTrigger = ({
|
|
33
|
+
action,
|
|
34
|
+
status,
|
|
35
|
+
hasErrors,
|
|
36
|
+
requiredStage,
|
|
37
|
+
entryStage
|
|
38
|
+
}) => {
|
|
39
|
+
const { formatMessage } = useIntl();
|
|
40
|
+
if (action === "publish") {
|
|
41
|
+
if (hasErrors || requiredStage && requiredStage.id !== entryStage?.id) {
|
|
42
|
+
return /* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(
|
|
43
|
+
Button,
|
|
44
|
+
{
|
|
45
|
+
variant: "ghost",
|
|
46
|
+
startIcon: /* @__PURE__ */ jsx(CrossCircle, { fill: "danger600" }),
|
|
47
|
+
endIcon: /* @__PURE__ */ jsx(CaretDown, {}),
|
|
48
|
+
children: /* @__PURE__ */ jsx(Typography, { textColor: "danger600", variant: "omega", fontWeight: "bold", children: formatMessage({
|
|
49
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.not-ready",
|
|
50
|
+
defaultMessage: "Not ready to publish"
|
|
51
|
+
}) })
|
|
52
|
+
}
|
|
53
|
+
) });
|
|
54
|
+
}
|
|
55
|
+
if (status === "draft") {
|
|
56
|
+
return /* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(
|
|
57
|
+
Button,
|
|
58
|
+
{
|
|
59
|
+
variant: "ghost",
|
|
60
|
+
startIcon: /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
|
61
|
+
endIcon: /* @__PURE__ */ jsx(CaretDown, {}),
|
|
62
|
+
children: /* @__PURE__ */ jsx(Typography, { textColor: "success600", variant: "omega", fontWeight: "bold", children: formatMessage({
|
|
63
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.ready-to-publish",
|
|
64
|
+
defaultMessage: "Ready to publish"
|
|
65
|
+
}) })
|
|
66
|
+
}
|
|
67
|
+
) });
|
|
68
|
+
}
|
|
69
|
+
if (status === "modified") {
|
|
70
|
+
return /* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(
|
|
71
|
+
Button,
|
|
72
|
+
{
|
|
73
|
+
variant: "ghost",
|
|
74
|
+
startIcon: /* @__PURE__ */ jsx(ArrowsCounterClockwise, { fill: "alternative600" }),
|
|
75
|
+
endIcon: /* @__PURE__ */ jsx(CaretDown, {}),
|
|
76
|
+
children: /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "alternative600", children: formatMessage({
|
|
77
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.modified",
|
|
78
|
+
defaultMessage: "Ready to publish changes"
|
|
79
|
+
}) })
|
|
80
|
+
}
|
|
81
|
+
) });
|
|
82
|
+
}
|
|
83
|
+
return /* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(
|
|
84
|
+
Button,
|
|
85
|
+
{
|
|
86
|
+
variant: "ghost",
|
|
87
|
+
startIcon: /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
|
88
|
+
endIcon: /* @__PURE__ */ jsx(CaretDown, {}),
|
|
89
|
+
children: /* @__PURE__ */ jsx(Typography, { textColor: "success600", variant: "omega", fontWeight: "bold", children: formatMessage({
|
|
90
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.already-published",
|
|
91
|
+
defaultMessage: "Already published"
|
|
92
|
+
}) })
|
|
93
|
+
}
|
|
94
|
+
) });
|
|
95
|
+
}
|
|
96
|
+
return /* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(Button, { variant: "ghost", startIcon: /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }), endIcon: /* @__PURE__ */ jsx(CaretDown, {}), children: /* @__PURE__ */ jsx(Typography, { textColor: "success600", variant: "omega", fontWeight: "bold", children: formatMessage({
|
|
97
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.already-unpublished",
|
|
98
|
+
defaultMessage: "Already unpublished"
|
|
99
|
+
}) }) }) });
|
|
100
|
+
};
|
|
101
|
+
const FieldsValidation = ({
|
|
102
|
+
hasErrors,
|
|
103
|
+
errors,
|
|
104
|
+
kind,
|
|
105
|
+
contentTypeUid,
|
|
106
|
+
documentId,
|
|
107
|
+
locale
|
|
108
|
+
}) => {
|
|
109
|
+
const { formatMessage } = useIntl();
|
|
110
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, width: "100%", padding: 5, children: [
|
|
111
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, width: "100%", children: [
|
|
112
|
+
/* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: formatMessage({
|
|
113
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.fields",
|
|
114
|
+
defaultMessage: "Fields"
|
|
115
|
+
}) }),
|
|
116
|
+
hasErrors ? /* @__PURE__ */ jsx(CrossCircle, { fill: "danger600" }) : /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" })
|
|
117
|
+
] }),
|
|
118
|
+
/* @__PURE__ */ jsx(Typography, { width: "100%", textColor: "neutral600", children: hasErrors ? formatMessage(
|
|
119
|
+
{
|
|
120
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.fields.error",
|
|
121
|
+
defaultMessage: "{errors} errors on fields."
|
|
122
|
+
},
|
|
123
|
+
{ errors: errors ? Object.keys(errors).length : 0 }
|
|
124
|
+
) : formatMessage({
|
|
125
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.fields.success",
|
|
126
|
+
defaultMessage: "All fields are filled correctly."
|
|
127
|
+
}) }),
|
|
128
|
+
hasErrors && /* @__PURE__ */ jsx(
|
|
129
|
+
LinkButton,
|
|
130
|
+
{
|
|
131
|
+
tag: Link,
|
|
132
|
+
to: {
|
|
133
|
+
pathname: `/content-manager/${kind === "collectionType" ? "collection-types" : "single-types"}/${contentTypeUid}/${documentId}`,
|
|
134
|
+
search: locale ? stringify({
|
|
135
|
+
plugins: {
|
|
136
|
+
i18n: {
|
|
137
|
+
locale
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}) : ""
|
|
141
|
+
},
|
|
142
|
+
variant: "secondary",
|
|
143
|
+
fullWidth: true,
|
|
144
|
+
state: { forceValidation: true },
|
|
145
|
+
children: formatMessage({
|
|
146
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.fields.see-errors",
|
|
147
|
+
defaultMessage: "See errors"
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
] });
|
|
152
|
+
};
|
|
153
|
+
const getReviewStageIcon = ({
|
|
154
|
+
contentTypeHasReviewWorkflow,
|
|
155
|
+
requiredStage,
|
|
156
|
+
entryStage
|
|
157
|
+
}) => {
|
|
158
|
+
if (!contentTypeHasReviewWorkflow) {
|
|
159
|
+
return /* @__PURE__ */ jsx(CheckCircle, { fill: "neutral200" });
|
|
160
|
+
}
|
|
161
|
+
if (requiredStage && requiredStage.id !== entryStage?.id) {
|
|
162
|
+
return /* @__PURE__ */ jsx(CrossCircle, { fill: "danger600" });
|
|
163
|
+
}
|
|
164
|
+
return /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" });
|
|
165
|
+
};
|
|
166
|
+
const getReviewStageMessage = ({
|
|
167
|
+
contentTypeHasReviewWorkflow,
|
|
168
|
+
requiredStage,
|
|
169
|
+
entryStage,
|
|
170
|
+
formatMessage
|
|
171
|
+
}) => {
|
|
172
|
+
if (!contentTypeHasReviewWorkflow) {
|
|
173
|
+
return formatMessage({
|
|
174
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.review-stage.not-enabled",
|
|
175
|
+
defaultMessage: "This entry is not associated to any workflow."
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (requiredStage && requiredStage.id !== entryStage?.id) {
|
|
179
|
+
return formatMessage(
|
|
180
|
+
{
|
|
181
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.review-stage.not-ready",
|
|
182
|
+
defaultMessage: "This entry is not at the required stage for publishing. ({stageName})"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
stageName: requiredStage?.name ?? ""
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
if (requiredStage && requiredStage.id === entryStage?.id) {
|
|
190
|
+
return formatMessage(
|
|
191
|
+
{
|
|
192
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.review-stage.ready",
|
|
193
|
+
defaultMessage: "This entry is at the required stage for publishing. ({stageName})"
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
stageName: requiredStage?.name ?? ""
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
return formatMessage({
|
|
201
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.review-stage.stage-not-required",
|
|
202
|
+
defaultMessage: "No required stage for publication"
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
const ReviewStageValidation = ({
|
|
206
|
+
contentTypeHasReviewWorkflow,
|
|
207
|
+
requiredStage,
|
|
208
|
+
entryStage
|
|
209
|
+
}) => {
|
|
210
|
+
const { formatMessage } = useIntl();
|
|
211
|
+
const Icon = getReviewStageIcon({
|
|
212
|
+
contentTypeHasReviewWorkflow,
|
|
213
|
+
requiredStage,
|
|
214
|
+
entryStage
|
|
215
|
+
});
|
|
216
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, width: "100%", padding: 5, children: [
|
|
217
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, width: "100%", children: [
|
|
218
|
+
/* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: formatMessage({
|
|
219
|
+
id: "content-releases.pages.ReleaseDetails.entry-validation.review-stage",
|
|
220
|
+
defaultMessage: "Review stage"
|
|
221
|
+
}) }),
|
|
222
|
+
Icon
|
|
223
|
+
] }),
|
|
224
|
+
/* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: getReviewStageMessage({
|
|
225
|
+
contentTypeHasReviewWorkflow,
|
|
226
|
+
requiredStage,
|
|
227
|
+
entryStage,
|
|
228
|
+
formatMessage
|
|
229
|
+
}) })
|
|
230
|
+
] });
|
|
231
|
+
};
|
|
232
|
+
const EntryValidationPopover = ({
|
|
233
|
+
action,
|
|
234
|
+
schema,
|
|
235
|
+
entry,
|
|
236
|
+
status
|
|
237
|
+
}) => {
|
|
238
|
+
const { validate, isLoading } = unstable_useDocument(
|
|
239
|
+
{
|
|
240
|
+
collectionType: schema?.kind ?? "",
|
|
241
|
+
model: schema?.uid ?? ""
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
// 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
|
|
245
|
+
skip: true
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
const errors = isLoading ? null : validate(entry);
|
|
249
|
+
const hasErrors = errors ? Object.keys(errors).length > 0 : false;
|
|
250
|
+
const contentTypeHasReviewWorkflow = schema?.options?.reviewWorkflows ?? false;
|
|
251
|
+
const requiredStage = schema?.stageRequiredToPublish;
|
|
252
|
+
const entryStage = entry.strapi_stage;
|
|
253
|
+
if (isLoading) {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
return /* @__PURE__ */ jsxs(Popover.Root, { children: [
|
|
257
|
+
/* @__PURE__ */ jsx(
|
|
258
|
+
EntryStatusTrigger,
|
|
259
|
+
{
|
|
260
|
+
action,
|
|
261
|
+
status,
|
|
262
|
+
hasErrors,
|
|
263
|
+
requiredStage,
|
|
264
|
+
entryStage
|
|
265
|
+
}
|
|
266
|
+
),
|
|
267
|
+
/* @__PURE__ */ jsx(Popover.Content, { children: /* @__PURE__ */ jsxs(StyledPopoverFlex, { direction: "column", children: [
|
|
268
|
+
/* @__PURE__ */ jsx(
|
|
269
|
+
FieldsValidation,
|
|
270
|
+
{
|
|
271
|
+
hasErrors,
|
|
272
|
+
errors,
|
|
273
|
+
contentTypeUid: schema?.uid,
|
|
274
|
+
kind: schema?.kind,
|
|
275
|
+
documentId: entry.documentId,
|
|
276
|
+
locale: entry.locale
|
|
277
|
+
}
|
|
278
|
+
),
|
|
279
|
+
/* @__PURE__ */ jsx(
|
|
280
|
+
ReviewStageValidation,
|
|
281
|
+
{
|
|
282
|
+
contentTypeHasReviewWorkflow,
|
|
283
|
+
requiredStage,
|
|
284
|
+
entryStage
|
|
285
|
+
}
|
|
286
|
+
)
|
|
287
|
+
] }) })
|
|
288
|
+
] });
|
|
289
|
+
};
|
|
19
290
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
|
20
291
|
const RelativeTime$1 = React.forwardRef(
|
|
21
292
|
({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {
|
|
@@ -286,7 +557,7 @@ const useTypedDispatch = useDispatch;
|
|
|
286
557
|
const isBaseQueryError = (error) => {
|
|
287
558
|
return typeof error !== "undefined" && error.name !== void 0;
|
|
288
559
|
};
|
|
289
|
-
const LinkCard = styled(Link)`
|
|
560
|
+
const LinkCard = styled(Link$1)`
|
|
290
561
|
display: block;
|
|
291
562
|
`;
|
|
292
563
|
const RelativeTime = styled(RelativeTime$1)`
|
|
@@ -498,7 +769,7 @@ const ReleasesPage = () => {
|
|
|
498
769
|
StyledAlert,
|
|
499
770
|
{
|
|
500
771
|
marginBottom: 6,
|
|
501
|
-
action: /* @__PURE__ */ jsx(Link, { href: "https://strapi.io/pricing-cloud", isExternal: true, children: formatMessage({
|
|
772
|
+
action: /* @__PURE__ */ jsx(Link$1, { href: "https://strapi.io/pricing-cloud", isExternal: true, children: formatMessage({
|
|
502
773
|
id: "content-releases.pages.Releases.max-limit-reached.action",
|
|
503
774
|
defaultMessage: "Explore plans"
|
|
504
775
|
}) }),
|
|
@@ -622,105 +893,6 @@ const TrashIcon = styled(Trash)`
|
|
|
622
893
|
fill: ${({ theme }) => theme.colors.danger600};
|
|
623
894
|
}
|
|
624
895
|
`;
|
|
625
|
-
const TypographyMaxWidth = styled(Typography)`
|
|
626
|
-
max-width: 300px;
|
|
627
|
-
`;
|
|
628
|
-
const EntryValidationText = ({ action, schema, entry, status }) => {
|
|
629
|
-
const { formatMessage } = useIntl();
|
|
630
|
-
const { validate, isLoading } = unstable_useDocument(
|
|
631
|
-
{
|
|
632
|
-
collectionType: schema?.kind ?? "",
|
|
633
|
-
model: schema?.uid ?? ""
|
|
634
|
-
},
|
|
635
|
-
{
|
|
636
|
-
// 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
|
|
637
|
-
skip: true
|
|
638
|
-
}
|
|
639
|
-
);
|
|
640
|
-
const errorsToString = (errors2, prefix = "") => {
|
|
641
|
-
if (Object.keys(errors2).length === 0) {
|
|
642
|
-
return "";
|
|
643
|
-
}
|
|
644
|
-
return Object.entries(errors2).map(([key, value]) => {
|
|
645
|
-
if (value === void 0 || value === null) {
|
|
646
|
-
return "";
|
|
647
|
-
}
|
|
648
|
-
if (typeof value === "string") {
|
|
649
|
-
return formatMessage(
|
|
650
|
-
{ id: value, defaultMessage: value },
|
|
651
|
-
{ field: prefix ? `${prefix}.${key}` : key }
|
|
652
|
-
);
|
|
653
|
-
}
|
|
654
|
-
if (typeof value === "object" && value !== null && "id" in value && "defaultMessage" in value) {
|
|
655
|
-
return formatMessage(
|
|
656
|
-
// @ts-expect-error – TODO: default message will be a string
|
|
657
|
-
{ id: `${value.id}.withField`, defaultMessage: value.defaultMessage },
|
|
658
|
-
{ field: prefix ? `${prefix}.${key}` : key }
|
|
659
|
-
);
|
|
660
|
-
}
|
|
661
|
-
return errorsToString(value, key);
|
|
662
|
-
}).join(" ");
|
|
663
|
-
};
|
|
664
|
-
if (isLoading) {
|
|
665
|
-
return null;
|
|
666
|
-
}
|
|
667
|
-
const errors = validate(entry) ?? {};
|
|
668
|
-
if (action === "publish") {
|
|
669
|
-
if (Object.keys(errors).length > 0) {
|
|
670
|
-
const validationErrorsMessages = errorsToString(errors);
|
|
671
|
-
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
672
|
-
/* @__PURE__ */ jsx(CrossCircle, { fill: "danger600" }),
|
|
673
|
-
/* @__PURE__ */ jsx(Tooltip, { description: validationErrorsMessages, children: /* @__PURE__ */ jsx(
|
|
674
|
-
TypographyMaxWidth,
|
|
675
|
-
{
|
|
676
|
-
textColor: "danger600",
|
|
677
|
-
variant: "omega",
|
|
678
|
-
fontWeight: "semiBold",
|
|
679
|
-
ellipsis: true,
|
|
680
|
-
children: validationErrorsMessages
|
|
681
|
-
}
|
|
682
|
-
) })
|
|
683
|
-
] });
|
|
684
|
-
}
|
|
685
|
-
if (status === "draft") {
|
|
686
|
-
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
687
|
-
/* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
|
688
|
-
/* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
|
689
|
-
id: "content-releases.pages.ReleaseDetails.entry-validation.ready-to-publish",
|
|
690
|
-
defaultMessage: "Ready to publish"
|
|
691
|
-
}) })
|
|
692
|
-
] });
|
|
693
|
-
}
|
|
694
|
-
if (status === "modified") {
|
|
695
|
-
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
696
|
-
/* @__PURE__ */ jsx(ArrowsCounterClockwise, { fill: "alternative600" }),
|
|
697
|
-
/* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
|
698
|
-
id: "content-releases.pages.ReleaseDetails.entry-validation.modified",
|
|
699
|
-
defaultMessage: "Ready to publish changes"
|
|
700
|
-
}) })
|
|
701
|
-
] });
|
|
702
|
-
}
|
|
703
|
-
if (status === "published") {
|
|
704
|
-
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
705
|
-
/* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
|
706
|
-
/* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
|
707
|
-
id: "content-releases.pages.ReleaseDetails.entry-validation.already-published",
|
|
708
|
-
defaultMessage: "Already published"
|
|
709
|
-
}) })
|
|
710
|
-
] });
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
714
|
-
/* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
|
715
|
-
!entry.publishedAt ? /* @__PURE__ */ jsx(Typography, { textColor: "success600", fontWeight: "bold", children: formatMessage({
|
|
716
|
-
id: "content-releases.pages.ReleaseDetails.entry-validation.already-unpublished",
|
|
717
|
-
defaultMessage: "Already unpublished"
|
|
718
|
-
}) }) : /* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
|
719
|
-
id: "content-releases.pages.ReleaseDetails.entry-validation.ready-to-unpublish",
|
|
720
|
-
defaultMessage: "Ready to unpublish"
|
|
721
|
-
}) })
|
|
722
|
-
] });
|
|
723
|
-
};
|
|
724
896
|
const ReleaseDetailsLayout = ({
|
|
725
897
|
toggleEditReleaseModal,
|
|
726
898
|
toggleWarningSubmit,
|
|
@@ -1041,7 +1213,7 @@ const ReleaseDetailsBody = ({ releaseId }) => {
|
|
|
1041
1213
|
const releaseActions = data?.data;
|
|
1042
1214
|
const releaseMeta = data?.meta;
|
|
1043
1215
|
const contentTypes = releaseMeta?.contentTypes || {};
|
|
1044
|
-
|
|
1216
|
+
releaseMeta?.components || {};
|
|
1045
1217
|
if (isBaseQueryError(releaseError) || !release) {
|
|
1046
1218
|
const errorsArray = [];
|
|
1047
1219
|
if (releaseError && "code" in releaseError) {
|
|
@@ -1074,7 +1246,7 @@ const ReleaseDetailsBody = ({ releaseId }) => {
|
|
|
1074
1246
|
action: /* @__PURE__ */ jsx(
|
|
1075
1247
|
LinkButton,
|
|
1076
1248
|
{
|
|
1077
|
-
tag: Link
|
|
1249
|
+
tag: Link,
|
|
1078
1250
|
to: {
|
|
1079
1251
|
pathname: "/content-manager"
|
|
1080
1252
|
},
|
|
@@ -1184,11 +1356,10 @@ const ReleaseDetailsBody = ({ releaseId }) => {
|
|
|
1184
1356
|
) }),
|
|
1185
1357
|
!release.releasedAt && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1186
1358
|
/* @__PURE__ */ jsx(Td, { width: "20%", minWidth: "200px", children: /* @__PURE__ */ jsx(
|
|
1187
|
-
|
|
1359
|
+
EntryValidationPopover,
|
|
1188
1360
|
{
|
|
1189
1361
|
action: type,
|
|
1190
1362
|
schema: contentTypes?.[contentType.uid],
|
|
1191
|
-
components,
|
|
1192
1363
|
entry,
|
|
1193
1364
|
status
|
|
1194
1365
|
}
|
|
@@ -1371,4 +1542,4 @@ const App = () => {
|
|
|
1371
1542
|
export {
|
|
1372
1543
|
App
|
|
1373
1544
|
};
|
|
1374
|
-
//# sourceMappingURL=App-
|
|
1545
|
+
//# sourceMappingURL=App-B7XAvv8M.mjs.map
|