@strapi/content-manager 5.12.3 → 5.12.5
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/admin/components/Widgets.js +161 -0
- package/dist/admin/components/Widgets.js.map +1 -0
- package/dist/admin/components/Widgets.mjs +158 -0
- package/dist/admin/components/Widgets.mjs.map +1 -0
- package/dist/admin/content-manager.js.map +1 -1
- package/dist/admin/content-manager.mjs.map +1 -1
- package/dist/admin/history/pages/History.js +1 -9
- package/dist/admin/history/pages/History.js.map +1 -1
- package/dist/admin/history/pages/History.mjs +1 -9
- package/dist/admin/history/pages/History.mjs.map +1 -1
- package/dist/admin/hooks/useDocumentActions.js +8 -1
- package/dist/admin/hooks/useDocumentActions.js.map +1 -1
- package/dist/admin/hooks/useDocumentActions.mjs +8 -1
- package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
- package/dist/admin/hooks/useDocumentContext.js +57 -0
- package/dist/admin/hooks/useDocumentContext.js.map +1 -0
- package/dist/admin/hooks/useDocumentContext.mjs +36 -0
- package/dist/admin/hooks/useDocumentContext.mjs.map +1 -0
- package/dist/admin/index.js +41 -2
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +42 -3
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/pages/EditView/EditViewPage.js +85 -93
- package/dist/admin/pages/EditView/EditViewPage.js.map +1 -1
- package/dist/admin/pages/EditView/EditViewPage.mjs +86 -94
- package/dist/admin/pages/EditView/EditViewPage.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.js +28 -32
- package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.mjs +32 -36
- package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Input.js +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/Component/Input.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Input.mjs +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/Component/Input.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +5 -16
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +5 -16
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js +2 -3
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs +2 -3
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +432 -344
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +432 -346
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +55 -37
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +57 -39
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/UID.js +7 -7
- package/dist/admin/pages/EditView/components/FormInputs/UID.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/UID.mjs +7 -7
- package/dist/admin/pages/EditView/components/FormInputs/UID.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.js +3 -10
- package/dist/admin/pages/EditView/components/InputRenderer.js.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.mjs +3 -10
- package/dist/admin/pages/EditView/components/InputRenderer.mjs.map +1 -1
- package/dist/admin/preview/components/PreviewHeader.js +2 -5
- package/dist/admin/preview/components/PreviewHeader.js.map +1 -1
- package/dist/admin/preview/components/PreviewHeader.mjs +2 -5
- package/dist/admin/preview/components/PreviewHeader.mjs.map +1 -1
- package/dist/admin/preview/pages/Preview.js +94 -102
- package/dist/admin/preview/pages/Preview.js.map +1 -1
- package/dist/admin/preview/pages/Preview.mjs +94 -102
- package/dist/admin/preview/pages/Preview.mjs.map +1 -1
- package/dist/admin/services/homepage.js +26 -0
- package/dist/admin/services/homepage.js.map +1 -0
- package/dist/admin/services/homepage.mjs +24 -0
- package/dist/admin/services/homepage.mjs.map +1 -0
- package/dist/admin/src/components/Widgets.d.ts +3 -0
- package/dist/admin/src/content-manager.d.ts +0 -3
- package/dist/admin/src/features/DocumentRBAC.d.ts +1 -1
- package/dist/admin/src/history/pages/History.d.ts +1 -1
- package/dist/admin/src/hooks/useDocumentContext.d.ts +30 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/ComponentContext.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +50 -5
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations/Relations.d.ts +1 -0
- package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +1 -1
- package/dist/admin/src/preview/pages/Preview.d.ts +2 -1
- package/dist/admin/src/services/homepage.d.ts +5 -0
- package/dist/server/src/services/homepage.d.ts +11 -0
- package/dist/server/src/services/homepage.d.ts.map +1 -0
- package/dist/shared/contracts/homepage.d.ts +25 -0
- package/dist/shared/contracts/homepage.d.ts.map +1 -0
- package/package.json +8 -8
- package/dist/admin/features/DocumentContext.js +0 -71
- package/dist/admin/features/DocumentContext.js.map +0 -1
- package/dist/admin/features/DocumentContext.mjs +0 -49
- package/dist/admin/features/DocumentContext.mjs.map +0 -1
- package/dist/admin/src/features/DocumentContext.d.ts +0 -53
@@ -7,7 +7,6 @@ import { useIntl } from 'react-intl';
|
|
7
7
|
import { useParams, useLocation } from 'react-router-dom';
|
8
8
|
import { styled } from 'styled-components';
|
9
9
|
import { COLLECTION_TYPES } from '../../constants/collections.mjs';
|
10
|
-
import { DocumentContextProvider } from '../../features/DocumentContext.mjs';
|
11
10
|
import { DocumentRBAC } from '../../features/DocumentRBAC.mjs';
|
12
11
|
import { useDocument } from '../../hooks/useDocument.mjs';
|
13
12
|
import { useDocumentLayout } from '../../hooks/useDocumentLayout.mjs';
|
@@ -102,109 +101,102 @@ const PreviewPage = ()=>{
|
|
102
101
|
contentType: documentTitle
|
103
102
|
})
|
104
103
|
}),
|
105
|
-
/*#__PURE__*/ jsx(
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
104
|
+
/*#__PURE__*/ jsx(PreviewProvider, {
|
105
|
+
url: previewUrl,
|
106
|
+
document: documentResponse.document,
|
107
|
+
title: documentTitle,
|
108
|
+
meta: documentResponse.meta,
|
109
|
+
schema: documentResponse.schema,
|
110
|
+
layout: documentLayoutResponse.edit,
|
111
111
|
onPreview: onPreview,
|
112
|
-
children: /*#__PURE__*/ jsx(
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
paddingLeft: isSideEditorOpen ? 6 : 0,
|
157
|
-
paddingRight: isSideEditorOpen ? 6 : 0,
|
158
|
-
transition: "all 0.2s ease-in-out",
|
159
|
-
children: /*#__PURE__*/ jsx(FormLayout, {
|
160
|
-
layout: documentLayoutResponse.edit.layout,
|
161
|
-
document: documentResponse,
|
162
|
-
hasBackground: false
|
163
|
-
})
|
164
|
-
}),
|
165
|
-
/*#__PURE__*/ jsxs(Box, {
|
166
|
-
position: "relative",
|
167
|
-
flex: 1,
|
168
|
-
height: "100%",
|
169
|
-
overflow: "hidden",
|
170
|
-
children: [
|
171
|
-
/*#__PURE__*/ jsx(Box, {
|
172
|
-
"data-testid": "preview-iframe",
|
173
|
-
ref: iframeRef,
|
174
|
-
src: previewUrl,
|
175
|
-
title: formatMessage({
|
176
|
-
id: 'content-manager.preview.panel.title',
|
177
|
-
defaultMessage: 'Preview'
|
178
|
-
}),
|
179
|
-
width: "100%",
|
180
|
-
height: "100%",
|
181
|
-
borderWidth: 0,
|
182
|
-
tag: "iframe"
|
183
|
-
}, previewUrl),
|
184
|
-
hasAdvancedPreview && /*#__PURE__*/ jsx(IconButton, {
|
185
|
-
variant: "tertiary",
|
186
|
-
label: formatMessage(isSideEditorOpen ? {
|
187
|
-
id: 'content-manager.preview.content.close-editor',
|
188
|
-
defaultMessage: 'Close editor'
|
189
|
-
} : {
|
190
|
-
id: 'content-manager.preview.content.open-editor',
|
191
|
-
defaultMessage: 'Open editor'
|
192
|
-
}),
|
193
|
-
onClick: ()=>setIsSideEditorOpen((prev)=>!prev),
|
194
|
-
position: "absolute",
|
195
|
-
top: 2,
|
196
|
-
left: 2,
|
197
|
-
children: /*#__PURE__*/ jsx(AnimatedArrow, {
|
198
|
-
isSideEditorOpen: isSideEditorOpen
|
199
|
-
})
|
200
|
-
})
|
201
|
-
]
|
112
|
+
children: /*#__PURE__*/ jsx(Form, {
|
113
|
+
method: "PUT",
|
114
|
+
disabled: query.status === 'published' && documentResponse && documentResponse.document.status !== 'draft',
|
115
|
+
initialValues: documentResponse.getInitialFormValues(),
|
116
|
+
initialErrors: location?.state?.forceValidation ? validateSync(initialValues, {}) : {},
|
117
|
+
height: "100%",
|
118
|
+
validate: (values, options)=>{
|
119
|
+
const yupSchema = createYupSchema(documentResponse.schema?.attributes, documentResponse.components, {
|
120
|
+
status: documentResponse.document?.status,
|
121
|
+
...options
|
122
|
+
});
|
123
|
+
return yupSchema.validate(values, {
|
124
|
+
abortEarly: false
|
125
|
+
});
|
126
|
+
},
|
127
|
+
children: ({ resetForm })=>/*#__PURE__*/ jsxs(Flex, {
|
128
|
+
direction: "column",
|
129
|
+
height: "100%",
|
130
|
+
alignItems: "stretch",
|
131
|
+
children: [
|
132
|
+
/*#__PURE__*/ jsx(Blocker, {
|
133
|
+
onProceed: resetForm
|
134
|
+
}),
|
135
|
+
/*#__PURE__*/ jsx(PreviewHeader, {}),
|
136
|
+
/*#__PURE__*/ jsxs(Flex, {
|
137
|
+
flex: 1,
|
138
|
+
overflow: "auto",
|
139
|
+
alignItems: "stretch",
|
140
|
+
children: [
|
141
|
+
hasAdvancedPreview && /*#__PURE__*/ jsx(Box, {
|
142
|
+
overflow: "auto",
|
143
|
+
width: isSideEditorOpen ? '50%' : 0,
|
144
|
+
borderWidth: "0 1px 0 0",
|
145
|
+
borderColor: "neutral150",
|
146
|
+
paddingTop: 6,
|
147
|
+
paddingBottom: 6,
|
148
|
+
// Remove horizontal padding when the editor is closed or it won't fully disappear
|
149
|
+
paddingLeft: isSideEditorOpen ? 6 : 0,
|
150
|
+
paddingRight: isSideEditorOpen ? 6 : 0,
|
151
|
+
transition: "all 0.2s ease-in-out",
|
152
|
+
children: /*#__PURE__*/ jsx(FormLayout, {
|
153
|
+
layout: documentLayoutResponse.edit.layout,
|
154
|
+
document: documentResponse,
|
155
|
+
hasBackground: false
|
202
156
|
})
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
157
|
+
}),
|
158
|
+
/*#__PURE__*/ jsxs(Box, {
|
159
|
+
position: "relative",
|
160
|
+
flex: 1,
|
161
|
+
height: "100%",
|
162
|
+
overflow: "hidden",
|
163
|
+
children: [
|
164
|
+
/*#__PURE__*/ jsx(Box, {
|
165
|
+
"data-testid": "preview-iframe",
|
166
|
+
ref: iframeRef,
|
167
|
+
src: previewUrl,
|
168
|
+
title: formatMessage({
|
169
|
+
id: 'content-manager.preview.panel.title',
|
170
|
+
defaultMessage: 'Preview'
|
171
|
+
}),
|
172
|
+
width: "100%",
|
173
|
+
height: "100%",
|
174
|
+
borderWidth: 0,
|
175
|
+
tag: "iframe"
|
176
|
+
}, previewUrl),
|
177
|
+
hasAdvancedPreview && /*#__PURE__*/ jsx(IconButton, {
|
178
|
+
variant: "tertiary",
|
179
|
+
label: formatMessage(isSideEditorOpen ? {
|
180
|
+
id: 'content-manager.preview.content.close-editor',
|
181
|
+
defaultMessage: 'Close editor'
|
182
|
+
} : {
|
183
|
+
id: 'content-manager.preview.content.open-editor',
|
184
|
+
defaultMessage: 'Open editor'
|
185
|
+
}),
|
186
|
+
onClick: ()=>setIsSideEditorOpen((prev)=>!prev),
|
187
|
+
position: "absolute",
|
188
|
+
top: 2,
|
189
|
+
left: 2,
|
190
|
+
children: /*#__PURE__*/ jsx(AnimatedArrow, {
|
191
|
+
isSideEditorOpen: isSideEditorOpen
|
192
|
+
})
|
193
|
+
})
|
194
|
+
]
|
195
|
+
})
|
196
|
+
]
|
197
|
+
})
|
198
|
+
]
|
199
|
+
})
|
208
200
|
})
|
209
201
|
})
|
210
202
|
]
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Preview.mjs","sources":["../../../../admin/src/preview/pages/Preview.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Page,\n useQueryParams,\n useRBAC,\n createContext,\n Form as FormContext,\n Blocker,\n} from '@strapi/admin/strapi-admin';\nimport { Box, Flex, FocusTrap, IconButton, Portal } from '@strapi/design-system';\nimport { ArrowLineLeft } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\nimport { useLocation, useParams } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { GetPreviewUrl } from '../../../../shared/contracts/preview';\nimport { COLLECTION_TYPES } from '../../constants/collections';\nimport { DocumentContextProvider } from '../../features/DocumentContext';\nimport { DocumentRBAC } from '../../features/DocumentRBAC';\nimport { type UseDocument, useDocument } from '../../hooks/useDocument';\nimport { type EditLayout, useDocumentLayout } from '../../hooks/useDocumentLayout';\nimport { FormLayout } from '../../pages/EditView/components/FormLayout';\nimport { buildValidParams } from '../../utils/api';\nimport { createYupSchema } from '../../utils/validation';\nimport { PreviewHeader } from '../components/PreviewHeader';\nimport { useGetPreviewUrlQuery } from '../services/preview';\n\nimport type { UID } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * PreviewProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface PreviewContextValue {\n url: string;\n title: string;\n document: NonNullable<ReturnType<UseDocument>['document']>;\n meta: NonNullable<ReturnType<UseDocument>['meta']>;\n schema: NonNullable<ReturnType<UseDocument>['schema']>;\n layout: EditLayout;\n}\n\nconst [PreviewProvider, usePreviewContext] = createContext<PreviewContextValue>('PreviewPage');\n\n/* -------------------------------------------------------------------------------------------------\n * PreviewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst AnimatedArrow = styled(ArrowLineLeft)<{ isSideEditorOpen: boolean }>`\n will-change: transform;\n rotate: ${(props) => (props.isSideEditorOpen ? '0deg' : '180deg')};\n transition: rotate 0.2s ease-in-out;\n`;\n\nconst PreviewPage = () => {\n const location = useLocation();\n const { formatMessage } = useIntl();\n\n const iframeRef = React.useRef<HTMLIFrameElement>(null);\n const [isSideEditorOpen, setIsSideEditorOpen] = React.useState(true);\n\n // Read all the necessary data from the URL to find the right preview URL\n const {\n slug: model,\n id: documentId,\n collectionType,\n } = useParams<{\n slug: UID.ContentType;\n id: string;\n collectionType: string;\n }>();\n const [{ query }] = useQueryParams<{\n plugins?: Record<string, unknown>;\n status?: string;\n }>();\n\n const params = React.useMemo(() => buildValidParams(query), [query]);\n\n if (!collectionType) {\n throw new Error('Could not find collectionType in url params');\n }\n\n if (!model) {\n throw new Error('Could not find model in url params');\n }\n\n // Only collection types must have a documentId\n if (collectionType === COLLECTION_TYPES && !documentId) {\n throw new Error('Could not find documentId in url params');\n }\n\n const previewUrlResponse = useGetPreviewUrlQuery({\n params: {\n contentType: model,\n },\n query: {\n documentId,\n locale: params.locale,\n status: params.status as GetPreviewUrl.Request['query']['status'],\n },\n });\n const documentResponse = useDocument({\n model,\n collectionType,\n documentId,\n params,\n });\n const documentLayoutResponse = useDocumentLayout(model);\n\n const isLoading =\n previewUrlResponse.isLoading || documentLayoutResponse.isLoading || documentResponse.isLoading;\n if (isLoading && !documentResponse.document?.documentId) {\n return <Page.Loading />;\n }\n\n const initialValues = documentResponse.getInitialFormValues();\n\n if (\n previewUrlResponse.error ||\n documentLayoutResponse.error ||\n !documentResponse.document ||\n !documentResponse.meta ||\n !documentResponse.schema ||\n !initialValues\n ) {\n return <Page.Error />;\n }\n\n if (!previewUrlResponse.data?.data?.url) {\n return <Page.NoData />;\n }\n\n const documentTitle = documentResponse.getTitle(documentLayoutResponse.edit.settings.mainField);\n\n const validateSync = (values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(\n documentResponse.schema?.attributes,\n documentResponse.components,\n {\n status: documentResponse.document?.status,\n ...options,\n }\n );\n\n return yupSchema.validateSync(values, { abortEarly: false });\n };\n\n const previewUrl = previewUrlResponse.data.data.url;\n\n const onPreview = () => {\n iframeRef?.current?.contentWindow?.postMessage(\n { type: 'strapiUpdate' },\n // The iframe origin is safe to use since it must be provided through the allowedOrigins config\n new URL(iframeRef.current.src).origin\n );\n };\n\n const hasAdvancedPreview = window.strapi.features.isEnabled('cms-advanced-preview');\n\n return (\n <>\n <Page.Title>\n {formatMessage(\n {\n id: 'content-manager.preview.page-title',\n defaultMessage: '{contentType} preview',\n },\n {\n contentType: documentTitle,\n }\n )}\n </Page.Title>\n <DocumentContextProvider\n initialDocument={{\n documentId: documentId || '',\n model,\n collectionType,\n }}\n onPreview={onPreview}\n >\n <PreviewProvider\n url={previewUrl}\n document={documentResponse.document}\n title={documentTitle}\n meta={documentResponse.meta}\n schema={documentResponse.schema}\n layout={documentLayoutResponse.edit}\n >\n <FormContext\n method=\"PUT\"\n disabled={\n query.status === 'published' &&\n documentResponse &&\n documentResponse.document.status === 'published'\n }\n initialValues={documentResponse.getInitialFormValues()}\n initialErrors={location?.state?.forceValidation ? validateSync(initialValues, {}) : {}}\n height=\"100%\"\n validate={(values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(\n documentResponse.schema?.attributes,\n documentResponse.components,\n {\n status: documentResponse.document?.status,\n ...options,\n }\n );\n\n return yupSchema.validate(values, { abortEarly: false });\n }}\n >\n {({ resetForm }) => (\n <Flex direction=\"column\" height=\"100%\" alignItems=\"stretch\">\n <Blocker onProceed={resetForm} />\n <PreviewHeader />\n <Flex flex={1} overflow=\"auto\" alignItems=\"stretch\">\n {hasAdvancedPreview && (\n <Box\n overflow=\"auto\"\n width={isSideEditorOpen ? '50%' : 0}\n borderWidth=\"0 1px 0 0\"\n borderColor=\"neutral150\"\n paddingTop={6}\n paddingBottom={6}\n // Remove horizontal padding when the editor is closed or it won't fully disappear\n paddingLeft={isSideEditorOpen ? 6 : 0}\n paddingRight={isSideEditorOpen ? 6 : 0}\n transition=\"all 0.2s ease-in-out\"\n >\n <FormLayout\n layout={documentLayoutResponse.edit.layout}\n document={documentResponse}\n hasBackground={false}\n />\n </Box>\n )}\n\n <Box position=\"relative\" flex={1} height=\"100%\" overflow=\"hidden\">\n <Box\n data-testid=\"preview-iframe\"\n ref={iframeRef}\n src={previewUrl}\n /**\n * For some reason, changing an iframe's src tag causes the browser to add a new item in the\n * history stack. This is an issue for us as it means clicking the back button will not let us\n * go back to the edit view. To fix it, we need to trick the browser into thinking this is a\n * different iframe when the preview URL changes. So we set a key prop to force React\n * to mount a different node when the src changes.\n */\n key={previewUrl}\n title={formatMessage({\n id: 'content-manager.preview.panel.title',\n defaultMessage: 'Preview',\n })}\n width=\"100%\"\n height=\"100%\"\n borderWidth={0}\n tag=\"iframe\"\n />\n {hasAdvancedPreview && (\n <IconButton\n variant=\"tertiary\"\n label={formatMessage(\n isSideEditorOpen\n ? {\n id: 'content-manager.preview.content.close-editor',\n defaultMessage: 'Close editor',\n }\n : {\n id: 'content-manager.preview.content.open-editor',\n defaultMessage: 'Open editor',\n }\n )}\n onClick={() => setIsSideEditorOpen((prev) => !prev)}\n position=\"absolute\"\n top={2}\n left={2}\n >\n <AnimatedArrow isSideEditorOpen={isSideEditorOpen} />\n </IconButton>\n )}\n </Box>\n </Flex>\n </Flex>\n )}\n </FormContext>\n </PreviewProvider>\n </DocumentContextProvider>\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ProtectedPreviewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedPreviewPageImpl = () => {\n const { slug: model } = useParams<{\n slug: string;\n }>();\n const {\n permissions = [],\n isLoading,\n error,\n } = useRBAC([\n { action: 'plugin::content-manager.explorer.read', subject: model },\n { action: 'plugin::content-manager.explorer.update', subject: model },\n { action: 'plugin::content-manager.explorer.publish', subject: model },\n ]);\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || !model) {\n return (\n <Box\n height=\"100vh\"\n width=\"100vw\"\n position=\"fixed\"\n top={0}\n left={0}\n zIndex={2}\n background=\"neutral0\"\n >\n <Page.Error />\n </Box>\n );\n }\n\n return (\n <Box\n height=\"100vh\"\n width=\"100vw\"\n position=\"fixed\"\n top={0}\n left={0}\n zIndex={2}\n background=\"neutral0\"\n >\n <Page.Protect\n permissions={permissions.filter((permission) =>\n permission.action.includes('explorer.read')\n )}\n >\n <DocumentRBAC permissions={permissions}>\n <PreviewPage />\n </DocumentRBAC>\n </Page.Protect>\n </Box>\n );\n};\n\nconst ProtectedPreviewPage = () => {\n return (\n <Portal>\n <FocusTrap>\n <ProtectedPreviewPageImpl />\n </FocusTrap>\n </Portal>\n );\n};\n\nexport { ProtectedPreviewPage, usePreviewContext };\n"],"names":["PreviewProvider","usePreviewContext","createContext","AnimatedArrow","styled","ArrowLineLeft","props","isSideEditorOpen","PreviewPage","location","useLocation","formatMessage","useIntl","iframeRef","React","useRef","setIsSideEditorOpen","useState","slug","model","id","documentId","collectionType","useParams","query","useQueryParams","params","useMemo","buildValidParams","Error","COLLECTION_TYPES","previewUrlResponse","useGetPreviewUrlQuery","contentType","locale","status","documentResponse","useDocument","documentLayoutResponse","useDocumentLayout","isLoading","document","_jsx","Page","Loading","initialValues","getInitialFormValues","error","meta","schema","data","url","NoData","documentTitle","getTitle","edit","settings","mainField","validateSync","values","options","yupSchema","createYupSchema","attributes","components","abortEarly","previewUrl","onPreview","current","contentWindow","postMessage","type","URL","src","origin","hasAdvancedPreview","window","strapi","features","isEnabled","_jsxs","_Fragment","Title","defaultMessage","DocumentContextProvider","initialDocument","title","layout","FormContext","method","disabled","initialErrors","state","forceValidation","height","validate","resetForm","Flex","direction","alignItems","Blocker","onProceed","PreviewHeader","flex","overflow","Box","width","borderWidth","borderColor","paddingTop","paddingBottom","paddingLeft","paddingRight","transition","FormLayout","hasBackground","position","data-testid","ref","tag","IconButton","variant","label","onClick","prev","top","left","ProtectedPreviewPageImpl","permissions","useRBAC","action","subject","zIndex","background","Protect","filter","permission","includes","DocumentRBAC","Pro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M,EAAA,OAAA;YACNU,QAAS,EAAA,OAAA;YACTS,GAAK,EAAA,CAAA;YACLC,IAAM,EAAA,CAAA;YACNM,MAAQ,EAAA,CAAA;YACRC,UAAW,EAAA,UAAA;oCAEX3F,GAAA,CAACC,KAAKd,KAAK,EAAA,EAAA;;AAGjB;AAEA,IAAA,qBACEa,GAAC+D,CAAAA,GAAAA,EAAAA;QACCX,MAAO,EAAA,OAAA;QACPY,KAAM,EAAA,OAAA;QACNU,QAAS,EAAA,OAAA;QACTS,GAAK,EAAA,CAAA;QACLC,IAAM,EAAA,CAAA;QACNM,MAAQ,EAAA,CAAA;QACRC,UAAW,EAAA,UAAA;gCAEX3F,GAAA,CAACC,KAAK2F,OAAO,EAAA;YACXN,WAAaA,EAAAA,WAAAA,CAAYO,MAAM,CAAC,CAACC,aAC/BA,UAAWN,CAAAA,MAAM,CAACO,QAAQ,CAAC,eAAA,CAAA,CAAA;AAG7B,YAAA,QAAA,gBAAA/F,GAACgG,CAAAA,YAAAA,EAAAA;gBAAaV,WAAaA,EAAAA,WAAAA;AACzB,gBAAA,QAAA,gBAAAtF,GAAClC,CAAAA,WAAAA,EAAAA,EAAAA;;;;AAKX,CAAA;AAEA,MAAMmI,oBAAuB,GAAA,IAAA;AAC3B,IAAA,qBACEjG,GAACkG,CAAAA,MAAAA,EAAAA;AACC,QAAA,QAAA,gBAAAlG,GAACmG,CAAAA,SAAAA,EAAAA;AACC,YAAA,QAAA,gBAAAnG,GAACqF,CAAAA,wBAAAA,EAAAA,EAAAA;;;AAIT;;;;"}
|
1
|
+
{"version":3,"file":"Preview.mjs","sources":["../../../../admin/src/preview/pages/Preview.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Page,\n useQueryParams,\n useRBAC,\n createContext,\n Form as FormContext,\n Blocker,\n} from '@strapi/admin/strapi-admin';\nimport { Box, Flex, FocusTrap, IconButton, Portal } from '@strapi/design-system';\nimport { ArrowLineLeft } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\nimport { useLocation, useParams } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { GetPreviewUrl } from '../../../../shared/contracts/preview';\nimport { COLLECTION_TYPES } from '../../constants/collections';\nimport { DocumentRBAC } from '../../features/DocumentRBAC';\nimport { type UseDocument, useDocument } from '../../hooks/useDocument';\nimport { type EditLayout, useDocumentLayout } from '../../hooks/useDocumentLayout';\nimport { FormLayout } from '../../pages/EditView/components/FormLayout';\nimport { buildValidParams } from '../../utils/api';\nimport { createYupSchema } from '../../utils/validation';\nimport { PreviewHeader } from '../components/PreviewHeader';\nimport { useGetPreviewUrlQuery } from '../services/preview';\n\nimport type { UID } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * PreviewProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface PreviewContextValue {\n url: string;\n title: string;\n document: NonNullable<ReturnType<UseDocument>['document']>;\n meta: NonNullable<ReturnType<UseDocument>['meta']>;\n schema: NonNullable<ReturnType<UseDocument>['schema']>;\n layout: EditLayout;\n onPreview: () => void;\n}\n\nconst [PreviewProvider, usePreviewContext] = createContext<PreviewContextValue>('PreviewPage');\n\n/* -------------------------------------------------------------------------------------------------\n * PreviewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst AnimatedArrow = styled(ArrowLineLeft)<{ isSideEditorOpen: boolean }>`\n will-change: transform;\n rotate: ${(props) => (props.isSideEditorOpen ? '0deg' : '180deg')};\n transition: rotate 0.2s ease-in-out;\n`;\n\nconst PreviewPage = () => {\n const location = useLocation();\n const { formatMessage } = useIntl();\n\n const iframeRef = React.useRef<HTMLIFrameElement>(null);\n const [isSideEditorOpen, setIsSideEditorOpen] = React.useState(true);\n\n // Read all the necessary data from the URL to find the right preview URL\n const {\n slug: model,\n id: documentId,\n collectionType,\n } = useParams<{\n slug: UID.ContentType;\n id: string;\n collectionType: string;\n }>();\n const [{ query }] = useQueryParams<{\n plugins?: Record<string, unknown>;\n status?: string;\n }>();\n\n const params = React.useMemo(() => buildValidParams(query), [query]);\n\n if (!collectionType) {\n throw new Error('Could not find collectionType in url params');\n }\n\n if (!model) {\n throw new Error('Could not find model in url params');\n }\n\n // Only collection types must have a documentId\n if (collectionType === COLLECTION_TYPES && !documentId) {\n throw new Error('Could not find documentId in url params');\n }\n\n const previewUrlResponse = useGetPreviewUrlQuery({\n params: {\n contentType: model,\n },\n query: {\n documentId,\n locale: params.locale,\n status: params.status as GetPreviewUrl.Request['query']['status'],\n },\n });\n const documentResponse = useDocument({\n model,\n collectionType,\n documentId,\n params,\n });\n const documentLayoutResponse = useDocumentLayout(model);\n\n const isLoading =\n previewUrlResponse.isLoading || documentLayoutResponse.isLoading || documentResponse.isLoading;\n if (isLoading && !documentResponse.document?.documentId) {\n return <Page.Loading />;\n }\n\n const initialValues = documentResponse.getInitialFormValues();\n\n if (\n previewUrlResponse.error ||\n documentLayoutResponse.error ||\n !documentResponse.document ||\n !documentResponse.meta ||\n !documentResponse.schema ||\n !initialValues\n ) {\n return <Page.Error />;\n }\n\n if (!previewUrlResponse.data?.data?.url) {\n return <Page.NoData />;\n }\n\n const documentTitle = documentResponse.getTitle(documentLayoutResponse.edit.settings.mainField);\n\n const validateSync = (values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(\n documentResponse.schema?.attributes,\n documentResponse.components,\n {\n status: documentResponse.document?.status,\n ...options,\n }\n );\n\n return yupSchema.validateSync(values, { abortEarly: false });\n };\n\n const previewUrl = previewUrlResponse.data.data.url;\n\n const onPreview = () => {\n iframeRef?.current?.contentWindow?.postMessage(\n { type: 'strapiUpdate' },\n // The iframe origin is safe to use since it must be provided through the allowedOrigins config\n new URL(iframeRef.current.src).origin\n );\n };\n\n const hasAdvancedPreview = window.strapi.features.isEnabled('cms-advanced-preview');\n\n return (\n <>\n <Page.Title>\n {formatMessage(\n {\n id: 'content-manager.preview.page-title',\n defaultMessage: '{contentType} preview',\n },\n {\n contentType: documentTitle,\n }\n )}\n </Page.Title>\n <PreviewProvider\n url={previewUrl}\n document={documentResponse.document}\n title={documentTitle}\n meta={documentResponse.meta}\n schema={documentResponse.schema}\n layout={documentLayoutResponse.edit}\n onPreview={onPreview}\n >\n <FormContext\n method=\"PUT\"\n disabled={\n query.status === 'published' &&\n documentResponse &&\n documentResponse.document.status !== 'draft'\n }\n initialValues={documentResponse.getInitialFormValues()}\n initialErrors={location?.state?.forceValidation ? validateSync(initialValues, {}) : {}}\n height=\"100%\"\n validate={(values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(\n documentResponse.schema?.attributes,\n documentResponse.components,\n {\n status: documentResponse.document?.status,\n ...options,\n }\n );\n\n return yupSchema.validate(values, { abortEarly: false });\n }}\n >\n {({ resetForm }) => (\n <Flex direction=\"column\" height=\"100%\" alignItems=\"stretch\">\n <Blocker onProceed={resetForm} />\n <PreviewHeader />\n <Flex flex={1} overflow=\"auto\" alignItems=\"stretch\">\n {hasAdvancedPreview && (\n <Box\n overflow=\"auto\"\n width={isSideEditorOpen ? '50%' : 0}\n borderWidth=\"0 1px 0 0\"\n borderColor=\"neutral150\"\n paddingTop={6}\n paddingBottom={6}\n // Remove horizontal padding when the editor is closed or it won't fully disappear\n paddingLeft={isSideEditorOpen ? 6 : 0}\n paddingRight={isSideEditorOpen ? 6 : 0}\n transition=\"all 0.2s ease-in-out\"\n >\n <FormLayout\n layout={documentLayoutResponse.edit.layout}\n document={documentResponse}\n hasBackground={false}\n />\n </Box>\n )}\n\n <Box position=\"relative\" flex={1} height=\"100%\" overflow=\"hidden\">\n <Box\n data-testid=\"preview-iframe\"\n ref={iframeRef}\n src={previewUrl}\n /**\n * For some reason, changing an iframe's src tag causes the browser to add a new item in the\n * history stack. This is an issue for us as it means clicking the back button will not let us\n * go back to the edit view. To fix it, we need to trick the browser into thinking this is a\n * different iframe when the preview URL changes. So we set a key prop to force React\n * to mount a different node when the src changes.\n */\n key={previewUrl}\n title={formatMessage({\n id: 'content-manager.preview.panel.title',\n defaultMessage: 'Preview',\n })}\n width=\"100%\"\n height=\"100%\"\n borderWidth={0}\n tag=\"iframe\"\n />\n {hasAdvancedPreview && (\n <IconButton\n variant=\"tertiary\"\n label={formatMessage(\n isSideEditorOpen\n ? {\n id: 'content-manager.preview.content.close-editor',\n defaultMessage: 'Close editor',\n }\n : {\n id: 'content-manager.preview.content.open-editor',\n defaultMessage: 'Open editor',\n }\n )}\n onClick={() => setIsSideEditorOpen((prev) => !prev)}\n position=\"absolute\"\n top={2}\n left={2}\n >\n <AnimatedArrow isSideEditorOpen={isSideEditorOpen} />\n </IconButton>\n )}\n </Box>\n </Flex>\n </Flex>\n )}\n </FormContext>\n </PreviewProvider>\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ProtectedPreviewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedPreviewPageImpl = () => {\n const { slug: model } = useParams<{\n slug: string;\n }>();\n const {\n permissions = [],\n isLoading,\n error,\n } = useRBAC([\n { action: 'plugin::content-manager.explorer.read', subject: model },\n { action: 'plugin::content-manager.explorer.update', subject: model },\n { action: 'plugin::content-manager.explorer.publish', subject: model },\n ]);\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || !model) {\n return (\n <Box\n height=\"100vh\"\n width=\"100vw\"\n position=\"fixed\"\n top={0}\n left={0}\n zIndex={2}\n background=\"neutral0\"\n >\n <Page.Error />\n </Box>\n );\n }\n\n return (\n <Box\n height=\"100vh\"\n width=\"100vw\"\n position=\"fixed\"\n top={0}\n left={0}\n zIndex={2}\n background=\"neutral0\"\n >\n <Page.Protect\n permissions={permissions.filter((permission) =>\n permission.action.includes('explorer.read')\n )}\n >\n <DocumentRBAC permissions={permissions}>\n <PreviewPage />\n </DocumentRBAC>\n </Page.Protect>\n </Box>\n );\n};\n\nconst ProtectedPreviewPage = () => {\n return (\n <Portal>\n <FocusTrap>\n <ProtectedPreviewPageImpl />\n </FocusTrap>\n </Portal>\n );\n};\n\nexport { ProtectedPreviewPage, usePreviewContext };\n"],"names":["PreviewProvider","usePreviewContext","createContext","AnimatedArrow","styled","ArrowLineLeft","props","isSideEditorOpen","PreviewPage","location","useLocation","formatMessage","useIntl","iframeRef","React","useRef","setIsSideEditorOpen","useState","slug","model","id","documentId","collectionType","useParams","query","useQueryParams","params","useMemo","buildValidParams","Error","COLLECTION_TYPES","previewUrlResponse","useGetPreviewUrlQuery","contentType","locale","status","documentResponse","useDocument","documentLayoutResponse","useDocumentLayout","isLoading","document","_jsx","Page","Loading","initialValues","getInitialFormValues","error","meta","schema","data","url","NoData","documentTitle","getTitle","edit","settings","mainField","validateSync","values","options","yupSchema","createYupSchema","attributes","components","abortEarly","previewUrl","onPreview","current","contentWindow","postMessage","type","URL","src","origin","hasAdvancedPreview","window","strapi","features","isEnabled","_jsxs","_Fragment","Title","defaultMessage","title","layout","FormContext","method","disabled","initialErrors","state","forceValidation","height","validate","resetForm","Flex","direction","alignItems","Blocker","onProceed","PreviewHeader","flex","overflow","Box","width","borderWidth","borderColor","paddingTop","paddingBottom","paddingLeft","paddingRight","transition","FormLayout","hasBackground","position","data-testid","ref","tag","IconButton","variant","label","onClick","prev","top","left","ProtectedPreviewPageImpl","permissions","useRBAC","action","subject","zIndex","background","Protect","filter","permission","includes","DocumentRBAC","ProtectedPreviewPage","Portal","FocusTrap"],"mappings":";;;;;;;;;;;;;;;;;;AA2CA,MAAM,CAACA,eAAAA,EAAiBC,iBAAkB,CAAA,GAAGC,aAAmC,CAAA,aAAA;AAEhF;;AAEkG,qGAElG,MAAMC,aAAAA,GAAgBC,MAAOC,CAAAA,aAAAA,CAA6C;;AAEhE,UAAA,EAAE,CAACC,KAAWA,GAAAA,KAAAA,CAAMC,gBAAgB,GAAG,SAAS,QAAU,CAAA;;AAEpE,CAAC;AAED,MAAMC,WAAc,GAAA,IAAA;AAClB,IAAA,MAAMC,QAAWC,GAAAA,WAAAA,EAAAA;IACjB,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;IAE1B,MAAMC,SAAAA,GAAYC,K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EAAAA,WAAAA;AACzB,gBAAA,QAAA,gBAAApF,GAAClC,CAAAA,WAAAA,EAAAA,EAAAA;;;;AAKX,CAAA;AAEA,MAAMiI,oBAAuB,GAAA,IAAA;AAC3B,IAAA,qBACE/F,GAACgG,CAAAA,MAAAA,EAAAA;AACC,QAAA,QAAA,gBAAAhG,GAACiG,CAAAA,SAAAA,EAAAA;AACC,YAAA,QAAA,gBAAAjG,GAACmF,CAAAA,wBAAAA,EAAAA,EAAAA;;;AAIT;;;;"}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var api = require('./api.js');
|
4
|
+
|
5
|
+
const homepageService = api.contentManagerApi.injectEndpoints({
|
6
|
+
/**
|
7
|
+
* TODO: Remove overrideExisting when we remove the future flag
|
8
|
+
* and delete the old homepage service in the admin
|
9
|
+
*/ overrideExisting: true,
|
10
|
+
endpoints: (builder)=>({
|
11
|
+
getRecentDocuments: builder.query({
|
12
|
+
query: (params)=>`/admin/homepage/recent-documents?action=${params.action}`,
|
13
|
+
transformResponse: (response)=>response.data,
|
14
|
+
providesTags: (res, _err, { action })=>[
|
15
|
+
{
|
16
|
+
type: 'RecentDocumentList',
|
17
|
+
id: action
|
18
|
+
}
|
19
|
+
]
|
20
|
+
})
|
21
|
+
})
|
22
|
+
});
|
23
|
+
const { useGetRecentDocumentsQuery } = homepageService;
|
24
|
+
|
25
|
+
exports.useGetRecentDocumentsQuery = useGetRecentDocumentsQuery;
|
26
|
+
//# sourceMappingURL=homepage.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"homepage.js","sources":["../../../admin/src/services/homepage.ts"],"sourcesContent":["import * as Homepage from '../../../shared/contracts/homepage';\n\nimport { contentManagerApi } from './api';\n\nconst homepageService = contentManagerApi.injectEndpoints({\n /**\n * TODO: Remove overrideExisting when we remove the future flag\n * and delete the old homepage service in the admin\n */\n overrideExisting: true,\n endpoints: (builder) => ({\n getRecentDocuments: builder.query<\n Homepage.GetRecentDocuments.Response['data'],\n Homepage.GetRecentDocuments.Request['query']\n >({\n query: (params) => `/admin/homepage/recent-documents?action=${params.action}`,\n transformResponse: (response: Homepage.GetRecentDocuments.Response) => response.data,\n providesTags: (res, _err, { action }) => [\n { type: 'RecentDocumentList' as const, id: action },\n ],\n }),\n }),\n});\n\nconst { useGetRecentDocumentsQuery } = homepageService;\n\nexport { useGetRecentDocumentsQuery };\n"],"names":["homepageService","contentManagerApi","injectEndpoints","overrideExisting","endpoints","builder","getRecentDocuments","query","params","action","transformResponse","response","data","providesTags","res","_err","type","id","useGetRecentDocumentsQuery"],"mappings":";;;;AAIA,MAAMA,eAAAA,GAAkBC,qBAAkBC,CAAAA,eAAe,CAAC;AACxD;;;AAGC,MACDC,gBAAkB,EAAA,IAAA;IAClBC,SAAW,EAAA,CAACC,WAAa;YACvBC,kBAAoBD,EAAAA,OAAAA,CAAQE,KAAK,CAG/B;gBACAA,KAAO,EAAA,CAACC,SAAW,CAAC,wCAAwC,EAAEA,MAAOC,CAAAA,MAAM,CAAC,CAAC;gBAC7EC,iBAAmB,EAAA,CAACC,QAAmDA,GAAAA,QAAAA,CAASC,IAAI;AACpFC,gBAAAA,YAAAA,EAAc,CAACC,GAAKC,EAAAA,IAAAA,EAAM,EAAEN,MAAM,EAAE,GAAK;AACvC,wBAAA;4BAAEO,IAAM,EAAA,oBAAA;4BAA+BC,EAAIR,EAAAA;AAAO;AACnD;AACH,aAAA;SACF;AACF,CAAA,CAAA;AAEM,MAAA,EAAES,0BAA0B,EAAE,GAAGlB;;;;"}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { contentManagerApi } from './api.mjs';
|
2
|
+
|
3
|
+
const homepageService = contentManagerApi.injectEndpoints({
|
4
|
+
/**
|
5
|
+
* TODO: Remove overrideExisting when we remove the future flag
|
6
|
+
* and delete the old homepage service in the admin
|
7
|
+
*/ overrideExisting: true,
|
8
|
+
endpoints: (builder)=>({
|
9
|
+
getRecentDocuments: builder.query({
|
10
|
+
query: (params)=>`/admin/homepage/recent-documents?action=${params.action}`,
|
11
|
+
transformResponse: (response)=>response.data,
|
12
|
+
providesTags: (res, _err, { action })=>[
|
13
|
+
{
|
14
|
+
type: 'RecentDocumentList',
|
15
|
+
id: action
|
16
|
+
}
|
17
|
+
]
|
18
|
+
})
|
19
|
+
})
|
20
|
+
});
|
21
|
+
const { useGetRecentDocumentsQuery } = homepageService;
|
22
|
+
|
23
|
+
export { useGetRecentDocumentsQuery };
|
24
|
+
//# sourceMappingURL=homepage.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"homepage.mjs","sources":["../../../admin/src/services/homepage.ts"],"sourcesContent":["import * as Homepage from '../../../shared/contracts/homepage';\n\nimport { contentManagerApi } from './api';\n\nconst homepageService = contentManagerApi.injectEndpoints({\n /**\n * TODO: Remove overrideExisting when we remove the future flag\n * and delete the old homepage service in the admin\n */\n overrideExisting: true,\n endpoints: (builder) => ({\n getRecentDocuments: builder.query<\n Homepage.GetRecentDocuments.Response['data'],\n Homepage.GetRecentDocuments.Request['query']\n >({\n query: (params) => `/admin/homepage/recent-documents?action=${params.action}`,\n transformResponse: (response: Homepage.GetRecentDocuments.Response) => response.data,\n providesTags: (res, _err, { action }) => [\n { type: 'RecentDocumentList' as const, id: action },\n ],\n }),\n }),\n});\n\nconst { useGetRecentDocumentsQuery } = homepageService;\n\nexport { useGetRecentDocumentsQuery };\n"],"names":["homepageService","contentManagerApi","injectEndpoints","overrideExisting","endpoints","builder","getRecentDocuments","query","params","action","transformResponse","response","data","providesTags","res","_err","type","id","useGetRecentDocumentsQuery"],"mappings":";;AAIA,MAAMA,eAAAA,GAAkBC,iBAAkBC,CAAAA,eAAe,CAAC;AACxD;;;AAGC,MACDC,gBAAkB,EAAA,IAAA;IAClBC,SAAW,EAAA,CAACC,WAAa;YACvBC,kBAAoBD,EAAAA,OAAAA,CAAQE,KAAK,CAG/B;gBACAA,KAAO,EAAA,CAACC,SAAW,CAAC,wCAAwC,EAAEA,MAAOC,CAAAA,MAAM,CAAC,CAAC;gBAC7EC,iBAAmB,EAAA,CAACC,QAAmDA,GAAAA,QAAAA,CAASC,IAAI;AACpFC,gBAAAA,YAAAA,EAAc,CAACC,GAAKC,EAAAA,IAAAA,EAAM,EAAEN,MAAM,EAAE,GAAK;AACvC,wBAAA;4BAAEO,IAAM,EAAA,oBAAA;4BAA+BC,EAAIR,EAAAA;AAAO;AACnD;AACH,aAAA;SACF;AACF,CAAA,CAAA;AAEM,MAAA,EAAES,0BAA0B,EAAE,GAAGlB;;;;"}
|
@@ -57,9 +57,6 @@ interface PanelComponent extends DescriptionComponent<PanelComponentProps, Panel
|
|
57
57
|
type?: 'actions' | 'releases';
|
58
58
|
}
|
59
59
|
interface DocumentActionProps extends EditViewContext {
|
60
|
-
onPreview?: () => void;
|
61
|
-
fromPreview?: boolean;
|
62
|
-
fromRelationModal?: boolean;
|
63
60
|
}
|
64
61
|
interface DocumentActionComponent extends DescriptionComponent<DocumentActionProps, DocumentActionDescription> {
|
65
62
|
type?: 'clone' | 'configure-the-view' | 'delete' | 'discard' | 'edit' | 'edit-the-model' | 'history' | 'publish' | 'unpublish' | 'update';
|
@@ -19,7 +19,7 @@ interface DocumentRBACContextValue {
|
|
19
19
|
canUserAction: (fieldName: string, fieldsUserCanAction: string[], fieldType: Schema.Attribute.Kind) => boolean;
|
20
20
|
isLoading: boolean;
|
21
21
|
}
|
22
|
-
declare const useDocumentRBAC: <Selected>(consumerName: string, selector: (value: DocumentRBACContextValue) => Selected) => Selected;
|
22
|
+
declare const useDocumentRBAC: <Selected, ShouldThrow extends boolean = true>(consumerName: string, selector: (value: DocumentRBACContextValue) => Selected, shouldThrowOnMissingContext?: ShouldThrow | undefined) => ShouldThrow extends true ? Selected : Selected | undefined;
|
23
23
|
interface DocumentRBACProps {
|
24
24
|
children: React.ReactNode;
|
25
25
|
permissions: Permission[] | null;
|
@@ -21,7 +21,7 @@ declare const HistoryProvider: {
|
|
21
21
|
children: React.ReactNode;
|
22
22
|
}): import("react/jsx-runtime").JSX.Element;
|
23
23
|
displayName: string;
|
24
|
-
}, useHistoryContext: <Selected>(consumerName: string, selector: (value: HistoryContextValue) => Selected) => Selected;
|
24
|
+
}, useHistoryContext: <Selected, ShouldThrow extends boolean = true>(consumerName: string, selector: (value: HistoryContextValue) => Selected, shouldThrowOnMissingContext?: ShouldThrow | undefined) => ShouldThrow extends true ? Selected : Selected | undefined;
|
25
25
|
declare const ProtectedHistoryPage: () => import("react/jsx-runtime").JSX.Element;
|
26
26
|
export { ProtectedHistoryPage, HistoryProvider, useHistoryContext };
|
27
27
|
export type { HistoryContextValue };
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { type UseDocument } from '../hooks/useDocument';
|
2
|
+
interface DocumentMeta {
|
3
|
+
/**
|
4
|
+
* The equivalent of the ":id" url param value
|
5
|
+
* i.e. gus5a67jcboa3o2zjnz39mb1
|
6
|
+
*/
|
7
|
+
documentId: string;
|
8
|
+
/**
|
9
|
+
* The equivalent of the url ":slug" param value
|
10
|
+
* i.e. api::articles.article
|
11
|
+
*/
|
12
|
+
model: string;
|
13
|
+
/**
|
14
|
+
* The equivalent of the url ":collectionType" param value
|
15
|
+
* i.e. collection-types or single-types
|
16
|
+
*/
|
17
|
+
collectionType: string;
|
18
|
+
/**
|
19
|
+
* Query params object
|
20
|
+
* i.e. { locale: 'fr' }
|
21
|
+
*/
|
22
|
+
params?: Record<string, string | string[] | null>;
|
23
|
+
}
|
24
|
+
interface DocumentContextValue {
|
25
|
+
currentDocumentMeta: DocumentMeta;
|
26
|
+
currentDocument: ReturnType<UseDocument>;
|
27
|
+
}
|
28
|
+
declare function useDocumentContext(consumerName: string): DocumentContextValue;
|
29
|
+
export { useDocumentContext };
|
30
|
+
export type { DocumentMeta };
|
@@ -38,5 +38,5 @@ declare const ComponentProvider: {
|
|
38
38
|
children: import("react").ReactNode;
|
39
39
|
}): import("react/jsx-runtime").JSX.Element;
|
40
40
|
displayName: string;
|
41
|
-
}, useComponent: <Selected>(consumerName: string, selector: (value: ComponentContextValue) => Selected) => Selected;
|
41
|
+
}, useComponent: <Selected, ShouldThrow extends boolean = true>(consumerName: string, selector: (value: ComponentContextValue) => Selected, shouldThrowOnMissingContext?: ShouldThrow | undefined) => ShouldThrow extends true ? Selected : Selected | undefined;
|
42
42
|
export { ComponentProvider, useComponent };
|
@@ -6,7 +6,7 @@ import type { InputRendererProps } from '../../InputRenderer';
|
|
6
6
|
interface DynamicZoneContextValue {
|
7
7
|
isInDynamicZone: boolean;
|
8
8
|
}
|
9
|
-
declare const useDynamicZone: <Selected>(consumerName: string, selector: (value: DynamicZoneContextValue) => Selected) => Selected;
|
9
|
+
declare const useDynamicZone: <Selected, ShouldThrow extends boolean = true>(consumerName: string, selector: (value: DynamicZoneContextValue) => Selected, shouldThrowOnMissingContext?: ShouldThrow | undefined) => ShouldThrow extends true ? Selected : Selected | undefined;
|
10
10
|
interface DynamicZoneProps extends Omit<Extract<EditFieldLayout, {
|
11
11
|
type: 'dynamiczone';
|
12
12
|
}>, 'size' | 'hint'>, Pick<InputProps, 'hint'>, Pick<DynamicZoneLabelProps, 'labelAction'> {
|
@@ -1,8 +1,53 @@
|
|
1
|
-
import
|
1
|
+
import * as React from 'react';
|
2
|
+
import { type UseDocument } from '../../../../../hooks/useDocument';
|
3
|
+
import { type DocumentMeta } from '../../../../../hooks/useDocumentContext';
|
4
|
+
export declare function getCollectionType(url: string): string | undefined;
|
5
|
+
interface State {
|
6
|
+
documentHistory: DocumentMeta[];
|
7
|
+
confirmDialogIntent: null | 'close' | 'back' | 'navigate' | DocumentMeta;
|
8
|
+
isModalOpen: boolean;
|
9
|
+
hasUnsavedChanges: boolean;
|
10
|
+
}
|
11
|
+
type Action = {
|
12
|
+
type: 'GO_TO_RELATION';
|
13
|
+
payload: {
|
14
|
+
document: DocumentMeta;
|
15
|
+
shouldBypassConfirmation: boolean;
|
16
|
+
};
|
17
|
+
} | {
|
18
|
+
type: 'GO_BACK';
|
19
|
+
payload: {
|
20
|
+
shouldBypassConfirmation: boolean;
|
21
|
+
};
|
22
|
+
} | {
|
23
|
+
type: 'GO_FULL_PAGE';
|
24
|
+
} | {
|
25
|
+
type: 'CANCEL_CONFIRM_DIALOG';
|
26
|
+
} | {
|
27
|
+
type: 'CLOSE_MODAL';
|
28
|
+
payload: {
|
29
|
+
shouldBypassConfirmation: boolean;
|
30
|
+
};
|
31
|
+
} | {
|
32
|
+
type: 'SET_HAS_UNSAVED_CHANGES';
|
33
|
+
payload: {
|
34
|
+
hasUnsavedChanges: boolean;
|
35
|
+
};
|
36
|
+
};
|
37
|
+
declare function reducer(state: State, action: Action): State;
|
38
|
+
interface RelationModalContextValue {
|
39
|
+
state: State;
|
40
|
+
dispatch: React.Dispatch<Action>;
|
41
|
+
rootDocumentMeta: DocumentMeta;
|
42
|
+
currentDocumentMeta: DocumentMeta;
|
43
|
+
currentDocument: ReturnType<UseDocument>;
|
44
|
+
onPreview?: () => void;
|
45
|
+
}
|
46
|
+
declare const useRelationModal: <Selected, ShouldThrow extends boolean = true>(consumerName: string, selector: (value: RelationModalContextValue) => Selected, shouldThrowOnMissingContext?: ShouldThrow | undefined) => ShouldThrow extends true ? Selected : Selected | undefined;
|
2
47
|
interface RelationModalProps {
|
3
|
-
|
48
|
+
children: React.ReactNode;
|
4
49
|
relation: DocumentMeta;
|
5
50
|
}
|
6
|
-
|
7
|
-
|
8
|
-
export {
|
51
|
+
declare const RelationModal: React.MemoExoticComponent<({ relation, children }: RelationModalProps) => import("react/jsx-runtime").JSX.Element>;
|
52
|
+
export { RelationModal, reducer, useRelationModal };
|
53
|
+
export type { State, Action };
|
@@ -22,6 +22,7 @@ interface Relation extends Pick<RelationResult, 'documentId' | 'id' | 'locale' |
|
|
22
22
|
id: RelationResult['id'];
|
23
23
|
locale?: RelationResult['locale'];
|
24
24
|
position: RelationPosition;
|
25
|
+
isTemporary?: boolean;
|
25
26
|
};
|
26
27
|
}
|
27
28
|
interface RelationsFieldProps extends Omit<Extract<EditFieldLayout, {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import { UseDocument } from '../../../hooks/useDocument';
|
2
|
+
import { type UseDocument } from '../../../hooks/useDocument';
|
3
3
|
import type { EditFieldLayout } from '../../../hooks/useDocumentLayout';
|
4
4
|
import type { Schema } from '@strapi/types';
|
5
5
|
import type { DistributiveOmit } from 'react-redux';
|
@@ -7,7 +7,8 @@ interface PreviewContextValue {
|
|
7
7
|
meta: NonNullable<ReturnType<UseDocument>['meta']>;
|
8
8
|
schema: NonNullable<ReturnType<UseDocument>['schema']>;
|
9
9
|
layout: EditLayout;
|
10
|
+
onPreview: () => void;
|
10
11
|
}
|
11
|
-
declare const usePreviewContext: <Selected>(consumerName: string, selector: (value: PreviewContextValue) => Selected) => Selected;
|
12
|
+
declare const usePreviewContext: <Selected, ShouldThrow extends boolean = true>(consumerName: string, selector: (value: PreviewContextValue) => Selected, shouldThrowOnMissingContext?: ShouldThrow | undefined) => ShouldThrow extends true ? Selected : Selected | undefined;
|
12
13
|
declare const ProtectedPreviewPage: () => import("react/jsx-runtime").JSX.Element;
|
13
14
|
export { ProtectedPreviewPage, usePreviewContext };
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import * as Homepage from '../../../shared/contracts/homepage';
|
2
|
+
declare const useGetRecentDocumentsQuery: import("@reduxjs/toolkit/dist/query/react/buildHooks").UseQuery<import("@reduxjs/toolkit/query").QueryDefinition<{
|
3
|
+
action: "update" | "publish";
|
4
|
+
}, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@strapi/admin/strapi-admin").QueryArguments, unknown, import("@strapi/admin/strapi-admin").BaseQueryError, {}, {}>, "ComponentConfiguration" | "ContentTypesConfiguration" | "ContentTypeSettings" | "Document" | "InitialData" | "HistoryVersion" | "Relations" | "UidAvailability" | "RecentDocumentList", Homepage.RecentDocument[], "adminApi">>;
|
5
|
+
export { useGetRecentDocumentsQuery };
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import type { Core } from '@strapi/types';
|
3
|
+
import type { GetRecentDocuments } from '../../../shared/contracts/homepage';
|
4
|
+
declare const createHomepageService: ({ strapi }: {
|
5
|
+
strapi: Core.Strapi;
|
6
|
+
}) => {
|
7
|
+
getRecentlyPublishedDocuments(): Promise<GetRecentDocuments.Response['data']>;
|
8
|
+
getRecentlyUpdatedDocuments(): Promise<GetRecentDocuments.Response['data']>;
|
9
|
+
};
|
10
|
+
export { createHomepageService };
|
11
|
+
//# sourceMappingURL=homepage.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"homepage.d.ts","sourceRoot":"","sources":["../../../../server/src/services/homepage.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,IAAI,EAAmB,MAAM,eAAe,CAAC;AAG3D,OAAO,KAAK,EAAE,kBAAkB,EAAkB,MAAM,oCAAoC,CAAC;AAE7F,QAAA,MAAM,qBAAqB,eAAgB;IAAE,MAAM,EAAE,KAAK,MAAM,CAAA;CAAE;qCAiJvB,QAAQ,2BAA2B,CAAC,MAAM,CAAC,CAAC;mCAoC9C,QAAQ,2BAA2B,CAAC,MAAM,CAAC,CAAC;CA+BpF,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|