@strapi/content-manager 0.0.0-experimental.cffeb3f30bb8beaa0d2a247ba56da461781c6690 → 0.0.0-experimental.d1602f22dc638a4c3c5084965fd6126fff5e9d4f
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/chunks/{ComponentConfigurationPage-CM3vQxyp.js → ComponentConfigurationPage-DXwOtpq1.js} +3 -3
- package/dist/admin/chunks/{ComponentConfigurationPage-CM3vQxyp.js.map → ComponentConfigurationPage-DXwOtpq1.js.map} +1 -1
- package/dist/admin/chunks/{ComponentConfigurationPage-BqW-t7Lr.js → ComponentConfigurationPage-DhYZp4nN.js} +3 -3
- package/dist/admin/chunks/{ComponentConfigurationPage-BqW-t7Lr.js.map → ComponentConfigurationPage-DhYZp4nN.js.map} +1 -1
- package/dist/admin/chunks/{EditConfigurationPage-CIKO27N8.js → EditConfigurationPage-D0Ng758X.js} +3 -3
- package/dist/admin/chunks/{EditConfigurationPage-CIKO27N8.js.map → EditConfigurationPage-D0Ng758X.js.map} +1 -1
- package/dist/admin/chunks/{EditConfigurationPage-CYQ6mJWy.js → EditConfigurationPage-DDuPch5d.js} +3 -3
- package/dist/admin/chunks/{EditConfigurationPage-CYQ6mJWy.js.map → EditConfigurationPage-DDuPch5d.js.map} +1 -1
- package/dist/admin/chunks/{EditViewPage-DaY9aMeu.js → EditViewPage-jCZnUuCR.js} +6 -55
- package/dist/admin/chunks/{EditViewPage-DaY9aMeu.js.map → EditViewPage-jCZnUuCR.js.map} +1 -1
- package/dist/admin/chunks/{EditViewPage-CRu2G4OS.js → EditViewPage-zSnDwLz3.js} +6 -55
- package/dist/admin/chunks/{EditViewPage-CRu2G4OS.js.map → EditViewPage-zSnDwLz3.js.map} +1 -1
- package/dist/admin/chunks/{Form--7s-Wsw1.js → Form-BEqiuSvQ.js} +2 -2
- package/dist/admin/chunks/{Form--7s-Wsw1.js.map → Form-BEqiuSvQ.js.map} +1 -1
- package/dist/admin/chunks/{Form-CX_f1AUZ.js → Form-CZmB6JIg.js} +2 -2
- package/dist/admin/chunks/{Form-CX_f1AUZ.js.map → Form-CZmB6JIg.js.map} +1 -1
- package/dist/admin/chunks/{History-SRih7tGq.js → History-BlLKDZSw.js} +6 -55
- package/dist/admin/chunks/{History-SRih7tGq.js.map → History-BlLKDZSw.js.map} +1 -1
- package/dist/admin/chunks/{History-VVVFEAnd.js → History-CPYXgxkS.js} +6 -55
- package/dist/admin/chunks/{History-VVVFEAnd.js.map → History-CPYXgxkS.js.map} +1 -1
- package/dist/admin/chunks/{Input-B3wbR0pJ.js → Input-CLX3C5DI.js} +10 -53
- package/dist/admin/chunks/Input-CLX3C5DI.js.map +1 -0
- package/dist/admin/chunks/{Input-BIRb1gP2.js → Input-DiR2Xfa7.js} +11 -54
- package/dist/admin/chunks/Input-DiR2Xfa7.js.map +1 -0
- package/dist/admin/chunks/{ListConfigurationPage-BMBxgLtZ.js → ListConfigurationPage-CNvotSqe.js} +2 -2
- package/dist/admin/chunks/{ListConfigurationPage-BMBxgLtZ.js.map → ListConfigurationPage-CNvotSqe.js.map} +1 -1
- package/dist/admin/chunks/{ListConfigurationPage-DBWZlkHs.js → ListConfigurationPage-DdTp-HxB.js} +2 -2
- package/dist/admin/chunks/{ListConfigurationPage-DBWZlkHs.js.map → ListConfigurationPage-DdTp-HxB.js.map} +1 -1
- package/dist/admin/chunks/{ListViewPage-9jad22KO.js → ListViewPage-BtXYjEYz.js} +5 -5
- package/dist/admin/chunks/{ListViewPage-9jad22KO.js.map → ListViewPage-BtXYjEYz.js.map} +1 -1
- package/dist/admin/chunks/{ListViewPage-Dq2zuPYL.js → ListViewPage-MJNfQTp-.js} +4 -4
- package/dist/admin/chunks/{ListViewPage-Dq2zuPYL.js.map → ListViewPage-MJNfQTp-.js.map} +1 -1
- package/dist/admin/chunks/{NoContentTypePage-BtpSxTZs.js → NoContentTypePage-BJrZvYPY.js} +2 -2
- package/dist/admin/chunks/{NoContentTypePage-BtpSxTZs.js.map → NoContentTypePage-BJrZvYPY.js.map} +1 -1
- package/dist/admin/chunks/{NoContentTypePage-B5xX6Br5.js → NoContentTypePage-CVvVpwj4.js} +2 -2
- package/dist/admin/chunks/{NoContentTypePage-B5xX6Br5.js.map → NoContentTypePage-CVvVpwj4.js.map} +1 -1
- package/dist/admin/chunks/{NoPermissionsPage-HnOCsRtG.js → NoPermissionsPage-BulvG4hB.js} +2 -2
- package/dist/admin/chunks/{NoPermissionsPage-HnOCsRtG.js.map → NoPermissionsPage-BulvG4hB.js.map} +1 -1
- package/dist/admin/chunks/{NoPermissionsPage-CRS0hARz.js → NoPermissionsPage-C5yWg70d.js} +2 -2
- package/dist/admin/chunks/{NoPermissionsPage-CRS0hARz.js.map → NoPermissionsPage-C5yWg70d.js.map} +1 -1
- package/dist/admin/chunks/{Preview-BcggSPwn.js → Preview-DEuQgQg2.js} +111 -64
- package/dist/admin/chunks/Preview-DEuQgQg2.js.map +1 -0
- package/dist/admin/chunks/{Preview-DRtWRrYn.js → Preview-H74FQ9Cq.js} +109 -62
- package/dist/admin/chunks/Preview-H74FQ9Cq.js.map +1 -0
- package/dist/admin/chunks/{Relations-B1i77Jba.js → Relations-C8jbZPVK.js} +6 -5
- package/dist/admin/chunks/Relations-C8jbZPVK.js.map +1 -0
- package/dist/admin/chunks/{Relations-BDe2e0a7.js → Relations-mxOUS7TJ.js} +6 -5
- package/dist/admin/chunks/Relations-mxOUS7TJ.js.map +1 -0
- package/dist/admin/chunks/{en-1xHet_GV.js → en-C1CjdAtC.js} +2 -1
- package/dist/admin/chunks/{en-1xHet_GV.js.map → en-C1CjdAtC.js.map} +1 -1
- package/dist/admin/chunks/{en-DB7sPJVj.js → en-LfhocNG2.js} +2 -1
- package/dist/admin/chunks/{en-DB7sPJVj.js.map → en-LfhocNG2.js.map} +1 -1
- package/dist/admin/chunks/{fr-Dm1xiZI5.js → fr-CFdRaRVj.js} +4 -1
- package/dist/admin/chunks/{fr-Dm1xiZI5.js.map → fr-CFdRaRVj.js.map} +1 -1
- package/dist/admin/chunks/{fr-CqAyDOmo.js → fr-gQSilC7w.js} +4 -1
- package/dist/admin/chunks/{fr-CqAyDOmo.js.map → fr-gQSilC7w.js.map} +1 -1
- package/dist/admin/chunks/{index-DfEfFmQC.js → index-BRlRBRLb.js} +130 -53
- package/dist/admin/chunks/index-BRlRBRLb.js.map +1 -0
- package/dist/admin/chunks/{index-CKZHZ3ir.js → index-ZIwOPk6p.js} +128 -51
- package/dist/admin/chunks/index-ZIwOPk6p.js.map +1 -0
- package/dist/admin/chunks/{layout-BN6DSZ4t.js → layout-B3-guCPG.js} +4 -4
- package/dist/admin/chunks/{layout-BN6DSZ4t.js.map → layout-B3-guCPG.js.map} +1 -1
- package/dist/admin/chunks/{layout-CX-A0s3P.js → layout-ameRNiAM.js} +4 -4
- package/dist/admin/chunks/{layout-CX-A0s3P.js.map → layout-ameRNiAM.js.map} +1 -1
- package/dist/admin/chunks/{relations-CuPmv-zR.js → relations-CmoFVrKj.js} +20 -2
- package/dist/admin/chunks/relations-CmoFVrKj.js.map +1 -0
- package/dist/admin/chunks/{relations-xwSNlsdc.js → relations-DYQAaXwZ.js} +20 -3
- package/dist/admin/chunks/relations-DYQAaXwZ.js.map +1 -0
- package/dist/admin/chunks/usePrev-Bjw2dhmq.js +18 -0
- package/dist/admin/chunks/usePrev-Bjw2dhmq.js.map +1 -0
- package/dist/admin/chunks/{usePrev-CwGzb4ed.js → usePrev-DIYl-IAL.js} +1 -18
- package/dist/admin/chunks/usePrev-DIYl-IAL.js.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +0 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +0 -49
- package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -1
- package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -1
- package/package.json +5 -5
- package/dist/admin/chunks/Input-B3wbR0pJ.js.map +0 -1
- package/dist/admin/chunks/Input-BIRb1gP2.js.map +0 -1
- package/dist/admin/chunks/Preview-BcggSPwn.js.map +0 -1
- package/dist/admin/chunks/Preview-DRtWRrYn.js.map +0 -1
- package/dist/admin/chunks/Relations-B1i77Jba.js.map +0 -1
- package/dist/admin/chunks/Relations-BDe2e0a7.js.map +0 -1
- package/dist/admin/chunks/index-CKZHZ3ir.js.map +0 -1
- package/dist/admin/chunks/index-DfEfFmQC.js.map +0 -1
- package/dist/admin/chunks/relations-CuPmv-zR.js.map +0 -1
- package/dist/admin/chunks/relations-xwSNlsdc.js.map +0 -1
- package/dist/admin/chunks/usePrev-CwGzb4ed.js.map +0 -1
- package/dist/admin/chunks/usePrev-tlgK0qPG.js +0 -34
- package/dist/admin/chunks/usePrev-tlgK0qPG.js.map +0 -1
@@ -5,8 +5,8 @@ var React = require('react');
|
|
5
5
|
var strapiAdmin = require('@strapi/admin/strapi-admin');
|
6
6
|
var reactIntl = require('react-intl');
|
7
7
|
var reactRouterDom = require('react-router-dom');
|
8
|
-
var Form = require('./Form
|
9
|
-
var index = require('./index-
|
8
|
+
var Form = require('./Form-BEqiuSvQ.js');
|
9
|
+
var index = require('./index-ZIwOPk6p.js');
|
10
10
|
var hooks = require('./hooks-D-sOYd1s.js');
|
11
11
|
var objects = require('./objects-C3EebVVe.js');
|
12
12
|
require('@strapi/design-system');
|
@@ -295,4 +295,4 @@ const { useGetComponentConfigurationQuery, useUpdateComponentConfigurationMutati
|
|
295
295
|
|
296
296
|
exports.ComponentConfigurationPage = ComponentConfigurationPage;
|
297
297
|
exports.ProtectedComponentConfigurationPage = ProtectedComponentConfigurationPage;
|
298
|
-
//# sourceMappingURL=ComponentConfigurationPage-
|
298
|
+
//# sourceMappingURL=ComponentConfigurationPage-DXwOtpq1.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ComponentConfigurationPage-CM3vQxyp.js","sources":["../../../admin/src/services/components.ts","../../../admin/src/pages/ComponentConfigurationPage.tsx"],"sourcesContent":["import { contentManagerApi } from './api';\n\nimport type {\n FindComponentConfiguration,\n UpdateComponentConfiguration,\n} from '../../../shared/contracts/components';\n\nconst componentsApi = contentManagerApi.injectEndpoints({\n endpoints: (builder) => ({\n getComponentConfiguration: builder.query<\n FindComponentConfiguration.Response['data'],\n FindComponentConfiguration.Params['uid']\n >({\n query: (uid) => `/content-manager/components/${uid}/configuration`,\n transformResponse: (response: FindComponentConfiguration.Response) => response.data,\n providesTags: (_result, _error, uid) => [{ type: 'ComponentConfiguration', id: uid }],\n }),\n updateComponentConfiguration: builder.mutation({\n query: ({ uid, ...body }) => ({\n url: `/content-manager/components/${uid}/configuration`,\n method: 'PUT',\n data: body,\n }),\n transformResponse: (response: UpdateComponentConfiguration.Response) => response.data,\n invalidatesTags: (_result, _error, { uid }) => [\n { type: 'ComponentConfiguration', id: uid },\n // otherwise layouts already fetched will have stale component configuration data.\n { type: 'ContentTypeSettings', id: 'LIST' },\n ],\n }),\n }),\n});\n\nconst { useGetComponentConfigurationQuery, useUpdateComponentConfigurationMutation } =\n componentsApi;\n\nexport { useGetComponentConfigurationQuery, useUpdateComponentConfigurationMutation };\n","import * as React from 'react';\n\nimport { Page, useNotification, useAPIErrorHandler } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\nimport { useParams } from 'react-router-dom';\n\nimport { TEMP_FIELD_NAME } from '../components/ConfigurationForm/Fields';\nimport { ConfigurationForm, ConfigurationFormProps } from '../components/ConfigurationForm/Form';\nimport { ComponentsDictionary, extractContentTypeComponents } from '../hooks/useContentTypeSchema';\nimport {\n DEFAULT_SETTINGS,\n EditLayout,\n convertEditLayoutToFieldLayouts,\n} from '../hooks/useDocumentLayout';\nimport { useTypedSelector } from '../modules/hooks';\nimport {\n useGetComponentConfigurationQuery,\n useUpdateComponentConfigurationMutation,\n} from '../services/components';\nimport { useGetInitialDataQuery } from '../services/init';\nimport { setIn } from '../utils/objects';\n\nimport type { Component, FindComponentConfiguration } from '../../../shared/contracts/components';\nimport type { Metadatas } from '../../../shared/contracts/content-types';\n\n/* -------------------------------------------------------------------------------------------------\n * ComponentConfigurationPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ComponentConfigurationPage = () => {\n /**\n * useDocumentLayout only works for documents, not components,\n * it feels weird to make that hook work for both when this is SUCH\n * a unique use case and we only do it here, so in short, we essentially\n * just extracted the logic to make an edit view layout and reproduced it here.\n */\n const { slug: model } = useParams<{ slug: string }>();\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n\n const {\n components,\n fieldSizes,\n schema,\n error: errorSchema,\n isLoading: isLoadingSchema,\n isFetching: isFetchingSchema,\n } = useGetInitialDataQuery(undefined, {\n selectFromResult: (res) => {\n const schema = res.data?.components.find((ct) => ct.uid === model);\n\n const componentsByKey = res.data?.components.reduce<ComponentsDictionary>(\n (acc, component) => {\n acc[component.uid] = component;\n\n return acc;\n },\n {}\n );\n\n const components = extractContentTypeComponents(schema?.attributes, componentsByKey);\n\n const fieldSizes = Object.entries(res.data?.fieldSizes ?? {}).reduce<\n ConfigurationFormProps['fieldSizes']\n >((acc, [attributeName, { default: size }]) => {\n acc[attributeName] = size;\n\n return acc;\n }, {});\n\n return {\n isFetching: res.isFetching,\n isLoading: res.isLoading,\n error: res.error,\n components,\n schema,\n fieldSizes,\n };\n },\n });\n\n React.useEffect(() => {\n if (errorSchema) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(errorSchema),\n });\n }\n }, [errorSchema, formatAPIError, toggleNotification]);\n\n const {\n data,\n isLoading: isLoadingConfig,\n isFetching: isFetchingConfig,\n error,\n } = useGetComponentConfigurationQuery(model ?? '');\n\n React.useEffect(() => {\n if (error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(error),\n });\n }\n }, [error, formatAPIError, toggleNotification]);\n\n /**\n * you **must** check if we're loading or fetching in case the component gets new props\n * but nothing was unmounted, it then becomes a fetch, not a load.\n */\n const isLoading = isLoadingConfig || isLoadingSchema || isFetchingConfig || isFetchingSchema;\n\n const editLayout = React.useMemo(\n () =>\n data && !isLoading\n ? formatEditLayout(data, { schema, components })\n : ({\n layout: [],\n components: {},\n metadatas: {},\n options: {},\n settings: DEFAULT_SETTINGS,\n } as EditLayout),\n [data, isLoading, schema, components]\n );\n\n const [updateConfiguration] = useUpdateComponentConfigurationMutation();\n const handleSubmit: ConfigurationFormProps['onSubmit'] = async (formData) => {\n try {\n /**\n * We reconstruct the metadatas object by taking the existing list metadatas\n * and re-merging that by attribute name with the current list metadatas, whilst overwriting\n * the data from the form we've built.\n */\n const meta = Object.entries(data?.component.metadatas ?? {}).reduce<Metadatas>(\n (acc, [name, { edit, list }]) => {\n const {\n __temp_key__,\n size: _size,\n name: _name,\n ...editedMetadata\n } = formData.layout.flatMap((row) => row.children).find((field) => field.name === name) ??\n {};\n\n acc[name] = {\n edit: {\n ...edit,\n ...editedMetadata,\n },\n list,\n };\n\n return acc;\n },\n {}\n );\n\n const res = await updateConfiguration({\n layouts: {\n edit: formData.layout.map((row) =>\n row.children.reduce<Array<{ name: string; size: number }>>((acc, { name, size }) => {\n if (name !== TEMP_FIELD_NAME) {\n return [...acc, { name, size }];\n }\n\n return acc;\n }, [])\n ),\n list: data?.component.layouts.list,\n },\n settings: setIn(formData.settings, 'displayName', undefined),\n metadatas: meta,\n uid: model,\n });\n\n if ('data' in res) {\n toggleNotification({\n type: 'success',\n message: formatMessage({ id: 'notification.success.saved', defaultMessage: 'Saved' }),\n });\n } else {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(res.error),\n });\n }\n } catch {\n toggleNotification({\n type: 'danger',\n message: formatMessage({ id: 'notification.error', defaultMessage: 'An error occurred' }),\n });\n }\n };\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || errorSchema || !schema) {\n return <Page.Error />;\n }\n\n return (\n <>\n <Page.Title>{`Configure ${editLayout.settings.displayName} Edit View`}</Page.Title>\n <ConfigurationForm\n onSubmit={handleSubmit}\n attributes={schema.attributes}\n fieldSizes={fieldSizes}\n layout={editLayout}\n />\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\nconst formatEditLayout = (\n data: FindComponentConfiguration.Response['data'],\n { schema, components }: { schema?: Component; components: ComponentsDictionary }\n) => {\n const editAttributes = convertEditLayoutToFieldLayouts(\n data.component.layouts.edit,\n schema?.attributes,\n data.component.metadatas,\n { configurations: data.components, schemas: components }\n );\n\n const componentEditAttributes = Object.entries(data.components).reduce<EditLayout['components']>(\n (acc, [uid, configuration]) => {\n acc[uid] = {\n layout: convertEditLayoutToFieldLayouts(\n configuration.layouts.edit,\n components[uid].attributes,\n configuration.metadatas\n ),\n settings: {\n ...configuration.settings,\n icon: components[uid].info.icon,\n displayName: components[uid].info.displayName,\n },\n };\n return acc;\n },\n {}\n );\n\n const editMetadatas = Object.entries(data.component.metadatas).reduce<EditLayout['metadatas']>(\n (acc, [attribute, metadata]) => {\n return {\n ...acc,\n [attribute]: metadata.edit,\n };\n },\n {}\n );\n\n return {\n layout: [editAttributes],\n components: componentEditAttributes,\n metadatas: editMetadatas,\n options: {\n ...schema?.options,\n ...schema?.pluginOptions,\n },\n settings: {\n ...data.component.settings,\n displayName: schema?.info.displayName,\n },\n };\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedComponentConfigurationPage = () => {\n const permissions = useTypedSelector(\n (state) => state.admin_app.permissions.contentManager?.componentsConfigurations\n );\n\n return (\n <Page.Protect permissions={permissions}>\n <ComponentConfigurationPage />\n </Page.Protect>\n );\n};\n\nexport { ComponentConfigurationPage, ProtectedComponentConfigurationPage };\n"],"names":["componentsApi","contentManagerApi","injectEndpoints","endpoints","builder","getComponentConfiguration","query","uid","transformResponse","response","data","providesTags","_result","_error","type","id","updateComponentConfiguration","mutation","body","url","method","invalidatesTags","useGetComponentConfigurationQuery","useUpdateComponentConfigurationMutation","ComponentConfigurationPage","slug","model","useParams","toggleNotification","useNotification","formatMessage","useIntl","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","components","fieldSizes","schema","error","errorSchema","isLoading","isLoadingSchema","isFetching","isFetchingSchema","useGetInitialDataQuery","undefined","selectFromResult","res","find","ct","componentsByKey","reduce","acc","component","extractContentTypeComponents","attributes","Object","entries","attributeName","default","size","React","useEffect","message","isLoadingConfig","isFetchingConfig","editLayout","useMemo","formatEditLayout","layout","metadatas","options","settings","DEFAULT_SETTINGS","updateConfiguration","handleSubmit","formData","meta","name","edit","list","__temp_key__","_size","_name","editedMetadata","flatMap","row","children","field","layouts","map","TEMP_FIELD_NAME","setIn","defaultMessage","_jsx","Page","Loading","Error","_jsxs","_Fragment","Title","displayName","ConfigurationForm","onSubmit","editAttributes","convertEditLayoutToFieldLayouts","configurations","schemas","componentEditAttributes","configuration","icon","info","editMetadatas","attribute","metadata","pluginOptions","ProtectedComponentConfigurationPage","permissions","useTypedSelector","state","admin_app","contentManager","componentsConfigurations","Protect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAMA,aAAAA,GAAgBC,uBAAkBC,CAAAA,eAAe,CAAC;IACtDC,SAAW,EAAA,CAACC,WAAa;YACvBC,yBAA2BD,EAAAA,OAAAA,CAAQE,KAAK,CAGtC;AACAA,gBAAAA,KAAAA,EAAO,CAACC,GAAQ,GAAA,CAAC,4BAA4B,EAAEA,GAAAA,CAAI,cAAc,CAAC;gBAClEC,iBAAmB,EAAA,CAACC,QAAkDA,GAAAA,QAAAA,CAASC,IAAI;gBACnFC,YAAc,EAAA,CAACC,OAASC,EAAAA,MAAAA,EAAQN,GAAQ,GAAA;AAAC,wBAAA;4BAAEO,IAAM,EAAA,wBAAA;4BAA0BC,EAAIR,EAAAA;AAAI;AAAE;AACvF,aAAA,CAAA;YACAS,4BAA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AAAA,CAASnC;AACxB,SAAA;AACF,KAAA,EACA,EAAC,CAAA;IAGH,OAAO;QACLV,MAAQ,EAAA;AAACmC,YAAAA;AAAe,SAAA;QACxBrE,UAAYyE,EAAAA,uBAAAA;QACZtC,SAAW0C,EAAAA,aAAAA;QACXzC,OAAS,EAAA;AACP,YAAA,GAAGlC,QAAQkC,OAAO;AAClB,YAAA,GAAGlC,QAAQ8E;AACb,SAAA;QACA3C,QAAU,EAAA;YACR,GAAG9D,IAAAA,CAAK2C,SAAS,CAACmB,QAAQ;AAC1B6B,YAAAA,WAAAA,EAAahE,QAAQ0E,IAAKV,CAAAA;AAC5B;AACF,KAAA;AACF,CAAA;AAEA;;AAEkG,2GAE5Fe,mCAAsC,GAAA,IAAA;IAC1C,MAAMC,WAAAA,GAAcC,sBAClB,CAAA,CAACC,KAAUA,GAAAA,KAAAA,CAAMC,SAAS,CAACH,WAAW,CAACI,cAAc,EAAEC,wBAAAA,CAAAA;IAGzD,qBACE5B,cAAA,CAACC,iBAAK4B,OAAO,EAAA;QAACN,WAAaA,EAAAA,WAAAA;AACzB,QAAA,QAAA,gBAAAvB,cAACtE,CAAAA,0BAAAA,EAAAA,EAAAA;;AAGP;;;;;"}
|
1
|
+
{"version":3,"file":"ComponentConfigurationPage-DXwOtpq1.js","sources":["../../../admin/src/services/components.ts","../../../admin/src/pages/ComponentConfigurationPage.tsx"],"sourcesContent":["import { contentManagerApi } from './api';\n\nimport type {\n FindComponentConfiguration,\n UpdateComponentConfiguration,\n} from '../../../shared/contracts/components';\n\nconst componentsApi = contentManagerApi.injectEndpoints({\n endpoints: (builder) => ({\n getComponentConfiguration: builder.query<\n FindComponentConfiguration.Response['data'],\n FindComponentConfiguration.Params['uid']\n >({\n query: (uid) => `/content-manager/components/${uid}/configuration`,\n transformResponse: (response: FindComponentConfiguration.Response) => response.data,\n providesTags: (_result, _error, uid) => [{ type: 'ComponentConfiguration', id: uid }],\n }),\n updateComponentConfiguration: builder.mutation({\n query: ({ uid, ...body }) => ({\n url: `/content-manager/components/${uid}/configuration`,\n method: 'PUT',\n data: body,\n }),\n transformResponse: (response: UpdateComponentConfiguration.Response) => response.data,\n invalidatesTags: (_result, _error, { uid }) => [\n { type: 'ComponentConfiguration', id: uid },\n // otherwise layouts already fetched will have stale component configuration data.\n { type: 'ContentTypeSettings', id: 'LIST' },\n ],\n }),\n }),\n});\n\nconst { useGetComponentConfigurationQuery, useUpdateComponentConfigurationMutation } =\n componentsApi;\n\nexport { useGetComponentConfigurationQuery, useUpdateComponentConfigurationMutation };\n","import * as React from 'react';\n\nimport { Page, useNotification, useAPIErrorHandler } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\nimport { useParams } from 'react-router-dom';\n\nimport { TEMP_FIELD_NAME } from '../components/ConfigurationForm/Fields';\nimport { ConfigurationForm, ConfigurationFormProps } from '../components/ConfigurationForm/Form';\nimport { ComponentsDictionary, extractContentTypeComponents } from '../hooks/useContentTypeSchema';\nimport {\n DEFAULT_SETTINGS,\n EditLayout,\n convertEditLayoutToFieldLayouts,\n} from '../hooks/useDocumentLayout';\nimport { useTypedSelector } from '../modules/hooks';\nimport {\n useGetComponentConfigurationQuery,\n useUpdateComponentConfigurationMutation,\n} from '../services/components';\nimport { useGetInitialDataQuery } from '../services/init';\nimport { setIn } from '../utils/objects';\n\nimport type { Component, FindComponentConfiguration } from '../../../shared/contracts/components';\nimport type { Metadatas } from '../../../shared/contracts/content-types';\n\n/* -------------------------------------------------------------------------------------------------\n * ComponentConfigurationPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ComponentConfigurationPage = () => {\n /**\n * useDocumentLayout only works for documents, not components,\n * it feels weird to make that hook work for both when this is SUCH\n * a unique use case and we only do it here, so in short, we essentially\n * just extracted the logic to make an edit view layout and reproduced it here.\n */\n const { slug: model } = useParams<{ slug: string }>();\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n\n const {\n components,\n fieldSizes,\n schema,\n error: errorSchema,\n isLoading: isLoadingSchema,\n isFetching: isFetchingSchema,\n } = useGetInitialDataQuery(undefined, {\n selectFromResult: (res) => {\n const schema = res.data?.components.find((ct) => ct.uid === model);\n\n const componentsByKey = res.data?.components.reduce<ComponentsDictionary>(\n (acc, component) => {\n acc[component.uid] = component;\n\n return acc;\n },\n {}\n );\n\n const components = extractContentTypeComponents(schema?.attributes, componentsByKey);\n\n const fieldSizes = Object.entries(res.data?.fieldSizes ?? {}).reduce<\n ConfigurationFormProps['fieldSizes']\n >((acc, [attributeName, { default: size }]) => {\n acc[attributeName] = size;\n\n return acc;\n }, {});\n\n return {\n isFetching: res.isFetching,\n isLoading: res.isLoading,\n error: res.error,\n components,\n schema,\n fieldSizes,\n };\n },\n });\n\n React.useEffect(() => {\n if (errorSchema) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(errorSchema),\n });\n }\n }, [errorSchema, formatAPIError, toggleNotification]);\n\n const {\n data,\n isLoading: isLoadingConfig,\n isFetching: isFetchingConfig,\n error,\n } = useGetComponentConfigurationQuery(model ?? '');\n\n React.useEffect(() => {\n if (error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(error),\n });\n }\n }, [error, formatAPIError, toggleNotification]);\n\n /**\n * you **must** check if we're loading or fetching in case the component gets new props\n * but nothing was unmounted, it then becomes a fetch, not a load.\n */\n const isLoading = isLoadingConfig || isLoadingSchema || isFetchingConfig || isFetchingSchema;\n\n const editLayout = React.useMemo(\n () =>\n data && !isLoading\n ? formatEditLayout(data, { schema, components })\n : ({\n layout: [],\n components: {},\n metadatas: {},\n options: {},\n settings: DEFAULT_SETTINGS,\n } as EditLayout),\n [data, isLoading, schema, components]\n );\n\n const [updateConfiguration] = useUpdateComponentConfigurationMutation();\n const handleSubmit: ConfigurationFormProps['onSubmit'] = async (formData) => {\n try {\n /**\n * We reconstruct the metadatas object by taking the existing list metadatas\n * and re-merging that by attribute name with the current list metadatas, whilst overwriting\n * the data from the form we've built.\n */\n const meta = Object.entries(data?.component.metadatas ?? {}).reduce<Metadatas>(\n (acc, [name, { edit, list }]) => {\n const {\n __temp_key__,\n size: _size,\n name: _name,\n ...editedMetadata\n } = formData.layout.flatMap((row) => row.children).find((field) => field.name === name) ??\n {};\n\n acc[name] = {\n edit: {\n ...edit,\n ...editedMetadata,\n },\n list,\n };\n\n return acc;\n },\n {}\n );\n\n const res = await updateConfiguration({\n layouts: {\n edit: formData.layout.map((row) =>\n row.children.reduce<Array<{ name: string; size: number }>>((acc, { name, size }) => {\n if (name !== TEMP_FIELD_NAME) {\n return [...acc, { name, size }];\n }\n\n return acc;\n }, [])\n ),\n list: data?.component.layouts.list,\n },\n settings: setIn(formData.settings, 'displayName', undefined),\n metadatas: meta,\n uid: model,\n });\n\n if ('data' in res) {\n toggleNotification({\n type: 'success',\n message: formatMessage({ id: 'notification.success.saved', defaultMessage: 'Saved' }),\n });\n } else {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(res.error),\n });\n }\n } catch {\n toggleNotification({\n type: 'danger',\n message: formatMessage({ id: 'notification.error', defaultMessage: 'An error occurred' }),\n });\n }\n };\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || errorSchema || !schema) {\n return <Page.Error />;\n }\n\n return (\n <>\n <Page.Title>{`Configure ${editLayout.settings.displayName} Edit View`}</Page.Title>\n <ConfigurationForm\n onSubmit={handleSubmit}\n attributes={schema.attributes}\n fieldSizes={fieldSizes}\n layout={editLayout}\n />\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\nconst formatEditLayout = (\n data: FindComponentConfiguration.Response['data'],\n { schema, components }: { schema?: Component; components: ComponentsDictionary }\n) => {\n const editAttributes = convertEditLayoutToFieldLayouts(\n data.component.layouts.edit,\n schema?.attributes,\n data.component.metadatas,\n { configurations: data.components, schemas: components }\n );\n\n const componentEditAttributes = Object.entries(data.components).reduce<EditLayout['components']>(\n (acc, [uid, configuration]) => {\n acc[uid] = {\n layout: convertEditLayoutToFieldLayouts(\n configuration.layouts.edit,\n components[uid].attributes,\n configuration.metadatas\n ),\n settings: {\n ...configuration.settings,\n icon: components[uid].info.icon,\n displayName: components[uid].info.displayName,\n },\n };\n return acc;\n },\n {}\n );\n\n const editMetadatas = Object.entries(data.component.metadatas).reduce<EditLayout['metadatas']>(\n (acc, [attribute, metadata]) => {\n return {\n ...acc,\n [attribute]: metadata.edit,\n };\n },\n {}\n );\n\n return {\n layout: [editAttributes],\n components: componentEditAttributes,\n metadatas: editMetadatas,\n options: {\n ...schema?.options,\n ...schema?.pluginOptions,\n },\n settings: {\n ...data.component.settings,\n displayName: schema?.info.displayName,\n },\n };\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedComponentConfigurationPage = () => {\n const permissions = useTypedSelector(\n (state) => state.admin_app.permissions.contentManager?.componentsConfigurations\n );\n\n return (\n <Page.Protect permissions={permissions}>\n <ComponentConfigurationPage />\n </Page.Protect>\n );\n};\n\nexport { ComponentConfigurationPage, ProtectedComponentConfigurationPage };\n"],"names":["componentsApi","contentManagerApi","injectEndpoints","endpoints","builder","getComponentConfiguration","query","uid","transformResponse","response","data","providesTags","_result","_error","type","id","updateComponentConfiguration","mutation","body","url","method","invalidatesTags","useGetComponentConfigurationQuery","useUpdateComponentConfigurationMutation","ComponentConfigurationPage","slug","model","useParams","toggleNotification","useNotification","formatMessage","useIntl","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","components","fieldSizes","schema","error","errorSchema","isLoading","isLoadingSchema","isFetching","isFetchingSchema","useGetInitialDataQuery","undefined","selectFromResult","res","find","ct","componentsByKey","reduce","acc","component","extractContentTypeComponents","attributes","Object","entries","attributeName","default","size","React","useEffect","message","isLoadingConfig","isFetchingConfig","editLayout","useMemo","formatEditLayout","layout","metadatas","options","settings","DEFAULT_SETTINGS","updateConfiguration","handleSubmit","formData","meta","name","edit","list","__temp_key__","_size","_name","editedMetadata","flatMap","row","children","field","layouts","map","TEMP_FIELD_NAME","setIn","defaultMessage","_jsx","Page","Loading","Error","_jsxs","_Fragment","Title","displayName","ConfigurationForm","onSubmit","editAttributes","convertEditLayoutToFieldLayouts","configurations","schemas","componentEditAttributes","configuration","icon","info","editMetadatas","attribute","metadata","pluginOptions","ProtectedComponentConfigurationPage","permissions","useTypedSelector","state","admin_app","contentManager","componentsConfigurations","Protect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAMA,aAAAA,GAAgBC,uBAAkBC,CAAAA,eAAe,CAAC;IACtDC,SAAW,EAAA,CAACC,WAAa;YACvBC,yBAA2BD,EAAAA,OAAAA,CAAQE,KAAK,CAGtC;AACAA,gBAAAA,KAAAA,EAAO,CAACC,GAAQ,GAAA,CAAC,4BAA4B,EAAEA,GAAAA,CAAI,cAAc,CAAC;gBAClEC,iBAAmB,EAAA,CAACC,QAAkDA,GAAAA,QAAAA,CAASC,IAAI;gBACnFC,YAAc,EAAA,CAACC,OAASC,EAAAA,MAAAA,EAAQN,GAAQ,GAAA;AAAC,wBAAA;4BAAEO,IAAM,EAAA,wBAAA;4BAA0BC,EAAIR,EAAAA;AAAI;AAAE;AACvF,aAAA,CAAA;YACAS,4BAA8BZ,EAAAA,OAAAA,CAAQa,QAAQ,CAAC;AAC7CX,gBAAAA,KAAAA,EAAO,CAAC,EAAEC,GAAG,EAAE,GAAGW,IAAAA,EAAM,IAAM;AAC5BC,wBAAAA,GAAAA,EAAK,CAAC,4BAA4B,EAAEZ,GAAAA,CAAI,cAAc,CAAC;wBACvDa,MAAQ,EAAA,KAAA;wBACRV,IAAMQ,EAAAA;qBACR,CAAA;gBACAV,iBAAmB,EAAA,CAACC,QAAoDA,GAAAA,QAAAA,CAASC,IAAI;AACrFW,gBAAAA,eAAAA,EAAiB,CAACT,OAASC,EAAAA,MAAAA,EAAQ,EAAEN,GAAG,EAAE,GAAK;AAC7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AAEA;;AAEkG,2GAE5Fe,mCAAsC,GAAA,IAAA;IAC1C,MAAMC,WAAAA,GAAcC,sBAClB,CAAA,CAACC,KAAUA,GAAAA,KAAAA,CAAMC,SAAS,CAACH,WAAW,CAACI,cAAc,EAAEC,wBAAAA,CAAAA;IAGzD,qBACE5B,cAAA,CAACC,iBAAK4B,OAAO,EAAA;QAACN,WAAaA,EAAAA,WAAAA;AACzB,QAAA,QAAA,gBAAAvB,cAACtE,CAAAA,0BAAAA,EAAAA,EAAAA;;AAGP;;;;;"}
|
@@ -3,8 +3,8 @@ import * as React from 'react';
|
|
3
3
|
import { useNotification, useAPIErrorHandler, Page } from '@strapi/admin/strapi-admin';
|
4
4
|
import { useIntl } from 'react-intl';
|
5
5
|
import { useParams } from 'react-router-dom';
|
6
|
-
import { C as ConfigurationForm, T as TEMP_FIELD_NAME } from './Form-
|
7
|
-
import { e as contentManagerApi, a as useGetInitialDataQuery, F as extractContentTypeComponents, G as DEFAULT_SETTINGS, J as convertEditLayoutToFieldLayouts } from './index-
|
6
|
+
import { C as ConfigurationForm, T as TEMP_FIELD_NAME } from './Form-CZmB6JIg.js';
|
7
|
+
import { e as contentManagerApi, a as useGetInitialDataQuery, F as extractContentTypeComponents, G as DEFAULT_SETTINGS, J as convertEditLayoutToFieldLayouts } from './index-BRlRBRLb.js';
|
8
8
|
import { u as useTypedSelector } from './hooks-DMvik5y_.js';
|
9
9
|
import { s as setIn } from './objects-wl73iEma.js';
|
10
10
|
import '@strapi/design-system';
|
@@ -273,4 +273,4 @@ const { useGetComponentConfigurationQuery, useUpdateComponentConfigurationMutati
|
|
273
273
|
};
|
274
274
|
|
275
275
|
export { ComponentConfigurationPage, ProtectedComponentConfigurationPage };
|
276
|
-
//# sourceMappingURL=ComponentConfigurationPage-
|
276
|
+
//# sourceMappingURL=ComponentConfigurationPage-DhYZp4nN.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ComponentConfigurationPage-BqW-t7Lr.js","sources":["../../../admin/src/services/components.ts","../../../admin/src/pages/ComponentConfigurationPage.tsx"],"sourcesContent":["import { contentManagerApi } from './api';\n\nimport type {\n FindComponentConfiguration,\n UpdateComponentConfiguration,\n} from '../../../shared/contracts/components';\n\nconst componentsApi = contentManagerApi.injectEndpoints({\n endpoints: (builder) => ({\n getComponentConfiguration: builder.query<\n FindComponentConfiguration.Response['data'],\n FindComponentConfiguration.Params['uid']\n >({\n query: (uid) => `/content-manager/components/${uid}/configuration`,\n transformResponse: (response: FindComponentConfiguration.Response) => response.data,\n providesTags: (_result, _error, uid) => [{ type: 'ComponentConfiguration', id: uid }],\n }),\n updateComponentConfiguration: builder.mutation({\n query: ({ uid, ...body }) => ({\n url: `/content-manager/components/${uid}/configuration`,\n method: 'PUT',\n data: body,\n }),\n transformResponse: (response: UpdateComponentConfiguration.Response) => response.data,\n invalidatesTags: (_result, _error, { uid }) => [\n { type: 'ComponentConfiguration', id: uid },\n // otherwise layouts already fetched will have stale component configuration data.\n { type: 'ContentTypeSettings', id: 'LIST' },\n ],\n }),\n }),\n});\n\nconst { useGetComponentConfigurationQuery, useUpdateComponentConfigurationMutation } =\n componentsApi;\n\nexport { useGetComponentConfigurationQuery, useUpdateComponentConfigurationMutation };\n","import * as React from 'react';\n\nimport { Page, useNotification, useAPIErrorHandler } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\nimport { useParams } from 'react-router-dom';\n\nimport { TEMP_FIELD_NAME } from '../components/ConfigurationForm/Fields';\nimport { ConfigurationForm, ConfigurationFormProps } from '../components/ConfigurationForm/Form';\nimport { ComponentsDictionary, extractContentTypeComponents } from '../hooks/useContentTypeSchema';\nimport {\n DEFAULT_SETTINGS,\n EditLayout,\n convertEditLayoutToFieldLayouts,\n} from '../hooks/useDocumentLayout';\nimport { useTypedSelector } from '../modules/hooks';\nimport {\n useGetComponentConfigurationQuery,\n useUpdateComponentConfigurationMutation,\n} from '../services/components';\nimport { useGetInitialDataQuery } from '../services/init';\nimport { setIn } from '../utils/objects';\n\nimport type { Component, FindComponentConfiguration } from '../../../shared/contracts/components';\nimport type { Metadatas } from '../../../shared/contracts/content-types';\n\n/* -------------------------------------------------------------------------------------------------\n * ComponentConfigurationPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ComponentConfigurationPage = () => {\n /**\n * useDocumentLayout only works for documents, not components,\n * it feels weird to make that hook work for both when this is SUCH\n * a unique use case and we only do it here, so in short, we essentially\n * just extracted the logic to make an edit view layout and reproduced it here.\n */\n const { slug: model } = useParams<{ slug: string }>();\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n\n const {\n components,\n fieldSizes,\n schema,\n error: errorSchema,\n isLoading: isLoadingSchema,\n isFetching: isFetchingSchema,\n } = useGetInitialDataQuery(undefined, {\n selectFromResult: (res) => {\n const schema = res.data?.components.find((ct) => ct.uid === model);\n\n const componentsByKey = res.data?.components.reduce<ComponentsDictionary>(\n (acc, component) => {\n acc[component.uid] = component;\n\n return acc;\n },\n {}\n );\n\n const components = extractContentTypeComponents(schema?.attributes, componentsByKey);\n\n const fieldSizes = Object.entries(res.data?.fieldSizes ?? {}).reduce<\n ConfigurationFormProps['fieldSizes']\n >((acc, [attributeName, { default: size }]) => {\n acc[attributeName] = size;\n\n return acc;\n }, {});\n\n return {\n isFetching: res.isFetching,\n isLoading: res.isLoading,\n error: res.error,\n components,\n schema,\n fieldSizes,\n };\n },\n });\n\n React.useEffect(() => {\n if (errorSchema) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(errorSchema),\n });\n }\n }, [errorSchema, formatAPIError, toggleNotification]);\n\n const {\n data,\n isLoading: isLoadingConfig,\n isFetching: isFetchingConfig,\n error,\n } = useGetComponentConfigurationQuery(model ?? '');\n\n React.useEffect(() => {\n if (error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(error),\n });\n }\n }, [error, formatAPIError, toggleNotification]);\n\n /**\n * you **must** check if we're loading or fetching in case the component gets new props\n * but nothing was unmounted, it then becomes a fetch, not a load.\n */\n const isLoading = isLoadingConfig || isLoadingSchema || isFetchingConfig || isFetchingSchema;\n\n const editLayout = React.useMemo(\n () =>\n data && !isLoading\n ? formatEditLayout(data, { schema, components })\n : ({\n layout: [],\n components: {},\n metadatas: {},\n options: {},\n settings: DEFAULT_SETTINGS,\n } as EditLayout),\n [data, isLoading, schema, components]\n );\n\n const [updateConfiguration] = useUpdateComponentConfigurationMutation();\n const handleSubmit: ConfigurationFormProps['onSubmit'] = async (formData) => {\n try {\n /**\n * We reconstruct the metadatas object by taking the existing list metadatas\n * and re-merging that by attribute name with the current list metadatas, whilst overwriting\n * the data from the form we've built.\n */\n const meta = Object.entries(data?.component.metadatas ?? {}).reduce<Metadatas>(\n (acc, [name, { edit, list }]) => {\n const {\n __temp_key__,\n size: _size,\n name: _name,\n ...editedMetadata\n } = formData.layout.flatMap((row) => row.children).find((field) => field.name === name) ??\n {};\n\n acc[name] = {\n edit: {\n ...edit,\n ...editedMetadata,\n },\n list,\n };\n\n return acc;\n },\n {}\n );\n\n const res = await updateConfiguration({\n layouts: {\n edit: formData.layout.map((row) =>\n row.children.reduce<Array<{ name: string; size: number }>>((acc, { name, size }) => {\n if (name !== TEMP_FIELD_NAME) {\n return [...acc, { name, size }];\n }\n\n return acc;\n }, [])\n ),\n list: data?.component.layouts.list,\n },\n settings: setIn(formData.settings, 'displayName', undefined),\n metadatas: meta,\n uid: model,\n });\n\n if ('data' in res) {\n toggleNotification({\n type: 'success',\n message: formatMessage({ id: 'notification.success.saved', defaultMessage: 'Saved' }),\n });\n } else {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(res.error),\n });\n }\n } catch {\n toggleNotification({\n type: 'danger',\n message: formatMessage({ id: 'notification.error', defaultMessage: 'An error occurred' }),\n });\n }\n };\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || errorSchema || !schema) {\n return <Page.Error />;\n }\n\n return (\n <>\n <Page.Title>{`Configure ${editLayout.settings.displayName} Edit View`}</Page.Title>\n <ConfigurationForm\n onSubmit={handleSubmit}\n attributes={schema.attributes}\n fieldSizes={fieldSizes}\n layout={editLayout}\n />\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\nconst formatEditLayout = (\n data: FindComponentConfiguration.Response['data'],\n { schema, components }: { schema?: Component; components: ComponentsDictionary }\n) => {\n const editAttributes = convertEditLayoutToFieldLayouts(\n data.component.layouts.edit,\n schema?.attributes,\n data.component.metadatas,\n { configurations: data.components, schemas: components }\n );\n\n const componentEditAttributes = Object.entries(data.components).reduce<EditLayout['components']>(\n (acc, [uid, configuration]) => {\n acc[uid] = {\n layout: convertEditLayoutToFieldLayouts(\n configuration.layouts.edit,\n components[uid].attributes,\n configuration.metadatas\n ),\n settings: {\n ...configuration.settings,\n icon: components[uid].info.icon,\n displayName: components[uid].info.displayName,\n },\n };\n return acc;\n },\n {}\n );\n\n const editMetadatas = Object.entries(data.component.metadatas).reduce<EditLayout['metadatas']>(\n (acc, [attribute, metadata]) => {\n return {\n ...acc,\n [attribute]: metadata.edit,\n };\n },\n {}\n );\n\n return {\n layout: [editAttributes],\n components: componentEditAttributes,\n metadatas: editMetadatas,\n options: {\n ...schema?.options,\n ...schema?.pluginOptions,\n },\n settings: {\n ...data.component.settings,\n displayName: schema?.info.displayName,\n },\n };\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedComponentConfigurationPage = () => {\n const permissions = useTypedSelector(\n (state) => state.admin_app.permissions.contentManager?.componentsConfigurations\n );\n\n return (\n <Page.Protect permissions={permissions}>\n <ComponentConfigurationPage />\n </Page.Protect>\n );\n};\n\nexport { ComponentConfigurationPage, ProtectedComponentConfigurationPage };\n"],"names":["componentsApi","contentManagerApi","injectEndpoints","endpoints","builder","getComponentConfiguration","query","uid","transformResponse","response","data","providesTags","_result","_error","type","id","updateComponentConfiguration","mutation","body","url","method","invalidatesTags","useGetComponentConfigurationQuery","useUpdateComponentConfigurationMutation","ComponentConfigurationPage","slug","model","useParams","toggleNotification","useNotification","formatMessage","useIntl","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","components","fieldSizes","schema","error","errorSchema","isLoading","isLoadingSchema","isFetching","isFetchingSchema","useGetInitialDataQuery","undefined","selectFromResult","res","find","ct","componentsByKey","reduce","acc","component","extractContentTypeComponents","attributes","Object","entries","attributeName","default","size","React","useEffect","message","isLoadingConfig","isFetchingConfig","editLayout","useMemo","formatEditLayout","layout","metadatas","options","settings","DEFAULT_SETTINGS","updateConfiguration","handleSubmit","formData","meta","name","edit","list","__temp_key__","_size","_name","editedMetadata","flatMap","row","children","field","layouts","map","TEMP_FIELD_NAME","setIn","defaultMessage","_jsx","Page","Loading","Error","_jsxs","_Fragment","Title","displayName","ConfigurationForm","onSubmit","editAttributes","convertEditLayoutToFieldLayouts","configurations","schemas","componentEditAttributes","configuration","icon","info","editMetadatas","attribute","metadata","pluginOptions","ProtectedComponentConfigurationPage","permissions","useTypedSelector","state","admin_app","contentManager","componentsConfigurations","Protect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAMA,aAAAA,GAAgBC,iBAAkBC,CAAAA,eAAe,CAAC;IACtDC,SAAW,EAAA,CAACC,WAAa;YACvBC,yBAA2BD,EAAAA,OAAAA,CAAQE,KAAK,CAGtC;AACAA,gBAAAA,KAAAA,EAAO,CAACC,GAAQ,GAAA,CAAC,4BAA4B,EAAEA,GAAAA,CAAI,cAAc,CAAC;gBAClEC,iBAAmB,EAAA,CAACC,QAAkDA,GAAAA,QAAAA,CAASC,IAAI;gBACnFC,YAAc,EAAA,CAACC,OAASC,EAAAA,MAAAA,EAAQN,GAAQ,GAAA;AAAC,wBAAA;4BAAEO,IAAM,EAAA,wBAAA;4BAA0BC,EAAIR,EAAAA;AAAI;AAAE;AACvF,aAAA,CAAA;YACAS,4BAA8BZ,EAAAA,OAAAA,CA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EACA,EAAC,CAAA;IAGH,OAAO;QACLV,MAAQ,EAAA;AAACmC,YAAAA;AAAe,SAAA;QACxBrE,UAAYyE,EAAAA,uBAAAA;QACZtC,SAAW0C,EAAAA,aAAAA;QACXzC,OAAS,EAAA;AACP,YAAA,GAAGlC,QAAQkC,OAAO;AAClB,YAAA,GAAGlC,QAAQ8E;AACb,SAAA;QACA3C,QAAU,EAAA;YACR,GAAG9D,IAAAA,CAAK2C,SAAS,CAACmB,QAAQ;AAC1B6B,YAAAA,WAAAA,EAAahE,QAAQ0E,IAAKV,CAAAA;AAC5B;AACF,KAAA;AACF,CAAA;AAEA;;AAEkG,2GAE5Fe,mCAAsC,GAAA,IAAA;IAC1C,MAAMC,WAAAA,GAAcC,gBAClB,CAAA,CAACC,KAAUA,GAAAA,KAAAA,CAAMC,SAAS,CAACH,WAAW,CAACI,cAAc,EAAEC,wBAAAA,CAAAA;IAGzD,qBACE5B,GAAA,CAACC,KAAK4B,OAAO,EAAA;QAACN,WAAaA,EAAAA,WAAAA;AACzB,QAAA,QAAA,gBAAAvB,GAACtE,CAAAA,0BAAAA,EAAAA,EAAAA;;AAGP;;;;"}
|
1
|
+
{"version":3,"file":"ComponentConfigurationPage-DhYZp4nN.js","sources":["../../../admin/src/services/components.ts","../../../admin/src/pages/ComponentConfigurationPage.tsx"],"sourcesContent":["import { contentManagerApi } from './api';\n\nimport type {\n FindComponentConfiguration,\n UpdateComponentConfiguration,\n} from '../../../shared/contracts/components';\n\nconst componentsApi = contentManagerApi.injectEndpoints({\n endpoints: (builder) => ({\n getComponentConfiguration: builder.query<\n FindComponentConfiguration.Response['data'],\n FindComponentConfiguration.Params['uid']\n >({\n query: (uid) => `/content-manager/components/${uid}/configuration`,\n transformResponse: (response: FindComponentConfiguration.Response) => response.data,\n providesTags: (_result, _error, uid) => [{ type: 'ComponentConfiguration', id: uid }],\n }),\n updateComponentConfiguration: builder.mutation({\n query: ({ uid, ...body }) => ({\n url: `/content-manager/components/${uid}/configuration`,\n method: 'PUT',\n data: body,\n }),\n transformResponse: (response: UpdateComponentConfiguration.Response) => response.data,\n invalidatesTags: (_result, _error, { uid }) => [\n { type: 'ComponentConfiguration', id: uid },\n // otherwise layouts already fetched will have stale component configuration data.\n { type: 'ContentTypeSettings', id: 'LIST' },\n ],\n }),\n }),\n});\n\nconst { useGetComponentConfigurationQuery, useUpdateComponentConfigurationMutation } =\n componentsApi;\n\nexport { useGetComponentConfigurationQuery, useUpdateComponentConfigurationMutation };\n","import * as React from 'react';\n\nimport { Page, useNotification, useAPIErrorHandler } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\nimport { useParams } from 'react-router-dom';\n\nimport { TEMP_FIELD_NAME } from '../components/ConfigurationForm/Fields';\nimport { ConfigurationForm, ConfigurationFormProps } from '../components/ConfigurationForm/Form';\nimport { ComponentsDictionary, extractContentTypeComponents } from '../hooks/useContentTypeSchema';\nimport {\n DEFAULT_SETTINGS,\n EditLayout,\n convertEditLayoutToFieldLayouts,\n} from '../hooks/useDocumentLayout';\nimport { useTypedSelector } from '../modules/hooks';\nimport {\n useGetComponentConfigurationQuery,\n useUpdateComponentConfigurationMutation,\n} from '../services/components';\nimport { useGetInitialDataQuery } from '../services/init';\nimport { setIn } from '../utils/objects';\n\nimport type { Component, FindComponentConfiguration } from '../../../shared/contracts/components';\nimport type { Metadatas } from '../../../shared/contracts/content-types';\n\n/* -------------------------------------------------------------------------------------------------\n * ComponentConfigurationPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ComponentConfigurationPage = () => {\n /**\n * useDocumentLayout only works for documents, not components,\n * it feels weird to make that hook work for both when this is SUCH\n * a unique use case and we only do it here, so in short, we essentially\n * just extracted the logic to make an edit view layout and reproduced it here.\n */\n const { slug: model } = useParams<{ slug: string }>();\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n\n const {\n components,\n fieldSizes,\n schema,\n error: errorSchema,\n isLoading: isLoadingSchema,\n isFetching: isFetchingSchema,\n } = useGetInitialDataQuery(undefined, {\n selectFromResult: (res) => {\n const schema = res.data?.components.find((ct) => ct.uid === model);\n\n const componentsByKey = res.data?.components.reduce<ComponentsDictionary>(\n (acc, component) => {\n acc[component.uid] = component;\n\n return acc;\n },\n {}\n );\n\n const components = extractContentTypeComponents(schema?.attributes, componentsByKey);\n\n const fieldSizes = Object.entries(res.data?.fieldSizes ?? {}).reduce<\n ConfigurationFormProps['fieldSizes']\n >((acc, [attributeName, { default: size }]) => {\n acc[attributeName] = size;\n\n return acc;\n }, {});\n\n return {\n isFetching: res.isFetching,\n isLoading: res.isLoading,\n error: res.error,\n components,\n schema,\n fieldSizes,\n };\n },\n });\n\n React.useEffect(() => {\n if (errorSchema) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(errorSchema),\n });\n }\n }, [errorSchema, formatAPIError, toggleNotification]);\n\n const {\n data,\n isLoading: isLoadingConfig,\n isFetching: isFetchingConfig,\n error,\n } = useGetComponentConfigurationQuery(model ?? '');\n\n React.useEffect(() => {\n if (error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(error),\n });\n }\n }, [error, formatAPIError, toggleNotification]);\n\n /**\n * you **must** check if we're loading or fetching in case the component gets new props\n * but nothing was unmounted, it then becomes a fetch, not a load.\n */\n const isLoading = isLoadingConfig || isLoadingSchema || isFetchingConfig || isFetchingSchema;\n\n const editLayout = React.useMemo(\n () =>\n data && !isLoading\n ? formatEditLayout(data, { schema, components })\n : ({\n layout: [],\n components: {},\n metadatas: {},\n options: {},\n settings: DEFAULT_SETTINGS,\n } as EditLayout),\n [data, isLoading, schema, components]\n );\n\n const [updateConfiguration] = useUpdateComponentConfigurationMutation();\n const handleSubmit: ConfigurationFormProps['onSubmit'] = async (formData) => {\n try {\n /**\n * We reconstruct the metadatas object by taking the existing list metadatas\n * and re-merging that by attribute name with the current list metadatas, whilst overwriting\n * the data from the form we've built.\n */\n const meta = Object.entries(data?.component.metadatas ?? {}).reduce<Metadatas>(\n (acc, [name, { edit, list }]) => {\n const {\n __temp_key__,\n size: _size,\n name: _name,\n ...editedMetadata\n } = formData.layout.flatMap((row) => row.children).find((field) => field.name === name) ??\n {};\n\n acc[name] = {\n edit: {\n ...edit,\n ...editedMetadata,\n },\n list,\n };\n\n return acc;\n },\n {}\n );\n\n const res = await updateConfiguration({\n layouts: {\n edit: formData.layout.map((row) =>\n row.children.reduce<Array<{ name: string; size: number }>>((acc, { name, size }) => {\n if (name !== TEMP_FIELD_NAME) {\n return [...acc, { name, size }];\n }\n\n return acc;\n }, [])\n ),\n list: data?.component.layouts.list,\n },\n settings: setIn(formData.settings, 'displayName', undefined),\n metadatas: meta,\n uid: model,\n });\n\n if ('data' in res) {\n toggleNotification({\n type: 'success',\n message: formatMessage({ id: 'notification.success.saved', defaultMessage: 'Saved' }),\n });\n } else {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(res.error),\n });\n }\n } catch {\n toggleNotification({\n type: 'danger',\n message: formatMessage({ id: 'notification.error', defaultMessage: 'An error occurred' }),\n });\n }\n };\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || errorSchema || !schema) {\n return <Page.Error />;\n }\n\n return (\n <>\n <Page.Title>{`Configure ${editLayout.settings.displayName} Edit View`}</Page.Title>\n <ConfigurationForm\n onSubmit={handleSubmit}\n attributes={schema.attributes}\n fieldSizes={fieldSizes}\n layout={editLayout}\n />\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\nconst formatEditLayout = (\n data: FindComponentConfiguration.Response['data'],\n { schema, components }: { schema?: Component; components: ComponentsDictionary }\n) => {\n const editAttributes = convertEditLayoutToFieldLayouts(\n data.component.layouts.edit,\n schema?.attributes,\n data.component.metadatas,\n { configurations: data.components, schemas: components }\n );\n\n const componentEditAttributes = Object.entries(data.components).reduce<EditLayout['components']>(\n (acc, [uid, configuration]) => {\n acc[uid] = {\n layout: convertEditLayoutToFieldLayouts(\n configuration.layouts.edit,\n components[uid].attributes,\n configuration.metadatas\n ),\n settings: {\n ...configuration.settings,\n icon: components[uid].info.icon,\n displayName: components[uid].info.displayName,\n },\n };\n return acc;\n },\n {}\n );\n\n const editMetadatas = Object.entries(data.component.metadatas).reduce<EditLayout['metadatas']>(\n (acc, [attribute, metadata]) => {\n return {\n ...acc,\n [attribute]: metadata.edit,\n };\n },\n {}\n );\n\n return {\n layout: [editAttributes],\n components: componentEditAttributes,\n metadatas: editMetadatas,\n options: {\n ...schema?.options,\n ...schema?.pluginOptions,\n },\n settings: {\n ...data.component.settings,\n displayName: schema?.info.displayName,\n },\n };\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedComponentConfigurationPage = () => {\n const permissions = useTypedSelector(\n (state) => state.admin_app.permissions.contentManager?.componentsConfigurations\n );\n\n return (\n <Page.Protect permissions={permissions}>\n <ComponentConfigurationPage />\n </Page.Protect>\n );\n};\n\nexport { ComponentConfigurationPage, ProtectedComponentConfigurationPage };\n"],"names":["componentsApi","contentManagerApi","injectEndpoints","endpoints","builder","getComponentConfiguration","query","uid","transformResponse","response","data","providesTags","_result","_error","type","id","updateComponentConfiguration","mutation","body","url","method","invalidatesTags","useGetComponentConfigurationQuery","useUpdateComponentConfigurationMutation","ComponentConfigurationPage","slug","model","useParams","toggleNotification","useNotification","formatMessage","useIntl","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","components","fieldSizes","schema","error","errorSchema","isLoading","isLoadingSchema","isFetching","isFetchingSchema","useGetInitialDataQuery","undefined","selectFromResult","res","find","ct","componentsByKey","reduce","acc","component","extractContentTypeComponents","attributes","Object","entries","attributeName","default","size","React","useEffect","message","isLoadingConfig","isFetchingConfig","editLayout","useMemo","formatEditLayout","layout","metadatas","options","settings","DEFAULT_SETTINGS","updateConfiguration","handleSubmit","formData","meta","name","edit","list","__temp_key__","_size","_name","editedMetadata","flatMap","row","children","field","layouts","map","TEMP_FIELD_NAME","setIn","defaultMessage","_jsx","Page","Loading","Error","_jsxs","_Fragment","Title","displayName","ConfigurationForm","onSubmit","editAttributes","convertEditLayoutToFieldLayouts","configurations","schemas","componentEditAttributes","configuration","icon","info","editMetadatas","attribute","metadata","pluginOptions","ProtectedComponentConfigurationPage","permissions","useTypedSelector","state","admin_app","contentManager","componentsConfigurations","Protect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAMA,aAAAA,GAAgBC,iBAAkBC,CAAAA,eAAe,CAAC;IACtDC,SAAW,EAAA,CAACC,WAAa;YACvBC,yBAA2BD,EAAAA,OAAAA,CAAQE,KAAK,CAGtC;AACAA,gBAAAA,KAAAA,EAAO,CAACC,GAAQ,GAAA,CAAC,4BAA4B,EAAEA,GAAAA,CAAI,cAAc,CAAC;gBAClEC,iBAAmB,EAAA,CAACC,QAAkDA,GAAAA,QAAAA,CAASC,IAAI;gBACnFC,YAAc,EAAA,CAACC,OAASC,EAAAA,MAAAA,EAAQN,GAAQ,GAAA;AAAC,wBAAA;4BAAEO,IAAM,EAAA,wBAAA;4BAA0BC,EAAIR,EAAAA;AAAI;AAAE;AACvF,aAAA,CAAA;YACAS,4BAA8BZ,EAAAA,OAAAA,CAAQa,QAAQ,CAAC;AAC7CX,gBAAAA,KAAAA,EAAO,CAAC,EAAEC,GAAG,EAAE,GAAGW,IAAAA,EAAM,IAAM;AAC5BC,wBAAAA,GAAAA,EAAK,CAAC,4BAA4B,EAAEZ,GAAAA,CAAI,cAAc,CAAC;wBACvDa,MAAQ,EAAA,KAAA;wBACRV,IAAMQ,EAAAA;qBACR,CAAA;gBACAV,iBAAmB,EAAA,CAACC,QAAoDA,GAAAA,QAAAA,CAASC,IAAI;AACrFW,gBAAAA,eAAAA,EAAiB,CAACT,OAASC,EAAAA,MAAAA,EAAQ,EAAEN,GAAG,EAAE,GAAK;AAC7C,wBAAA;4BAAEO,IAAM,EAAA,wBAAA;4BAA0BC,EAAIR,EAAAA;AA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AClB,CAAA,CAACC,KAAUA,GAAAA,KAAAA,CAAMC,SAAS,CAACH,WAAW,CAACI,cAAc,EAAEC,wBAAAA,CAAAA;IAGzD,qBACE5B,GAAA,CAACC,KAAK4B,OAAO,EAAA;QAACN,WAAaA,EAAAA,WAAAA;AACzB,QAAA,QAAA,gBAAAvB,GAACtE,CAAAA,0BAAAA,EAAAA,EAAAA;;AAGP;;;;"}
|
package/dist/admin/chunks/{EditConfigurationPage-CIKO27N8.js → EditConfigurationPage-D0Ng758X.js}
RENAMED
@@ -4,8 +4,8 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var React = require('react');
|
5
5
|
var strapiAdmin = require('@strapi/admin/strapi-admin');
|
6
6
|
var reactIntl = require('react-intl');
|
7
|
-
var Form = require('./Form
|
8
|
-
var index = require('./index-
|
7
|
+
var Form = require('./Form-BEqiuSvQ.js');
|
8
|
+
var index = require('./index-ZIwOPk6p.js');
|
9
9
|
var hooks = require('./hooks-D-sOYd1s.js');
|
10
10
|
var objects = require('./objects-C3EebVVe.js');
|
11
11
|
require('@strapi/design-system');
|
@@ -177,4 +177,4 @@ const ProtectedEditConfigurationPage = ()=>{
|
|
177
177
|
|
178
178
|
exports.EditConfigurationPage = EditConfigurationPage;
|
179
179
|
exports.ProtectedEditConfigurationPage = ProtectedEditConfigurationPage;
|
180
|
-
//# sourceMappingURL=EditConfigurationPage-
|
180
|
+
//# sourceMappingURL=EditConfigurationPage-D0Ng758X.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EditConfigurationPage-CIKO27N8.js","sources":["../../../admin/src/pages/EditConfigurationPage.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Page, useNotification, useTracking, useAPIErrorHandler } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\n\nimport { TEMP_FIELD_NAME } from '../components/ConfigurationForm/Fields';\nimport { ConfigurationForm, ConfigurationFormProps } from '../components/ConfigurationForm/Form';\nimport { useDoc } from '../hooks/useDocument';\nimport { useDocLayout } from '../hooks/useDocumentLayout';\nimport { useTypedSelector } from '../modules/hooks';\nimport { useUpdateContentTypeConfigurationMutation } from '../services/contentTypes';\nimport { useGetInitialDataQuery } from '../services/init';\nimport { setIn } from '../utils/objects';\n\nimport type { Metadatas } from '../../../shared/contracts/content-types';\n\nconst EditConfigurationPage = () => {\n const { trackUsage } = useTracking();\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n const { isLoading: isLoadingSchema, schema, model } = useDoc();\n const { isLoading: isLoadingLayout, error, list, edit } = useDocLayout();\n\n const {\n fieldSizes,\n error: errorFieldSizes,\n isLoading: isLoadingFieldSizes,\n isFetching: isFetchingFieldSizes,\n } = useGetInitialDataQuery(undefined, {\n selectFromResult: (res) => {\n const fieldSizes = Object.entries(res.data?.fieldSizes ?? {}).reduce<\n ConfigurationFormProps['fieldSizes']\n >((acc, [attributeName, { default: size }]) => {\n acc[attributeName] = size;\n\n return acc;\n }, {});\n\n return {\n isFetching: res.isFetching,\n isLoading: res.isLoading,\n error: res.error,\n fieldSizes,\n };\n },\n });\n\n React.useEffect(() => {\n if (errorFieldSizes) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(errorFieldSizes),\n });\n }\n }, [errorFieldSizes, formatAPIError, toggleNotification]);\n\n const isLoading =\n isLoadingSchema || isLoadingLayout || isLoadingFieldSizes || isFetchingFieldSizes;\n\n const [updateConfiguration] = useUpdateContentTypeConfigurationMutation();\n const handleSubmit: ConfigurationFormProps['onSubmit'] = async (data) => {\n try {\n trackUsage('willSaveContentTypeLayout');\n\n /**\n * We reconstruct the metadatas object by taking the existing list metadatas\n * and re-merging that by attribute name with the current list metadatas, whilst overwriting\n * the data from the form we've built.\n */\n const meta = Object.entries(list.metadatas).reduce<Metadatas>(\n (acc, [name, { mainField: _mainField, ...listMeta }]) => {\n const existingEditMeta = edit.metadatas[name];\n\n const {\n __temp_key__,\n size: _size,\n name: _name,\n ...editedMetadata\n } = data.layout.flatMap((row) => row.children).find((field) => field.name === name) ?? {};\n\n acc[name] = {\n edit: {\n ...existingEditMeta,\n ...editedMetadata,\n },\n list: listMeta,\n };\n\n return acc;\n },\n {}\n );\n\n const res = await updateConfiguration({\n layouts: {\n edit: data.layout.map((row) =>\n row.children.reduce<Array<{ name: string; size: number }>>((acc, { name, size }) => {\n if (name !== TEMP_FIELD_NAME) {\n return [...acc, { name, size }];\n }\n\n return acc;\n }, [])\n ),\n list: list.layout.map((field) => field.name),\n },\n settings: setIn(data.settings, 'displayName', undefined),\n metadatas: meta,\n uid: model,\n });\n\n if ('data' in res) {\n trackUsage('didEditEditSettings');\n toggleNotification({\n type: 'success',\n message: formatMessage({ id: 'notification.success.saved', defaultMessage: 'Saved' }),\n });\n } else {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(res.error),\n });\n }\n } catch {\n toggleNotification({\n type: 'danger',\n message: formatMessage({ id: 'notification.error', defaultMessage: 'An error occurred' }),\n });\n }\n };\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (errorFieldSizes || error || !schema) {\n return <Page.Error />;\n }\n\n return (\n <>\n <Page.Title>{`Configure ${edit.settings.displayName} Edit View`}</Page.Title>\n <ConfigurationForm\n onSubmit={handleSubmit}\n attributes={schema.attributes}\n fieldSizes={fieldSizes}\n layout={edit}\n />\n </>\n );\n};\n\nconst ProtectedEditConfigurationPage = () => {\n const permissions = useTypedSelector(\n (state) => state.admin_app.permissions.contentManager?.collectionTypesConfigurations\n );\n\n return (\n <Page.Protect permissions={permissions}>\n <EditConfigurationPage />\n </Page.Protect>\n );\n};\n\nexport { ProtectedEditConfigurationPage, EditConfigurationPage };\n"],"names":["EditConfigurationPage","trackUsage","useTracking","formatMessage","useIntl","toggleNotification","useNotification","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","isLoading","isLoadingSchema","schema","model","useDoc","isLoadingLayout","error","list","edit","useDocLayout","fieldSizes","errorFieldSizes","isLoadingFieldSizes","isFetching","isFetchingFieldSizes","useGetInitialDataQuery","undefined","selectFromResult","res","Object","entries","data","reduce","acc","attributeName","default","size","React","useEffect","type","message","updateConfiguration","useUpdateContentTypeConfigurationMutation","handleSubmit","meta","metadatas","name","mainField","_mainField","listMeta","existingEditMeta","__temp_key__","_size","_name","editedMetadata","layout","flatMap","row","children","find","field","layouts","map","TEMP_FIELD_NAME","settings","setIn","uid","id","defaultMessage","_jsx","Page","Loading","Error","_jsxs","_Fragment","Title","displayName","ConfigurationForm","onSubmit","attributes","ProtectedEditConfigurationPage","permissions","useTypedSelector","state","admin_app","contentManager","collectionTypesConfigurations","Protect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAMA,qBAAwB,GAAA,IAAA;IAC5B,MAAM,EAAEC,UAAU,EAAE,GAAGC,uBAAAA,EAAAA;IACvB,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;IAC1B,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,2BAAAA,EAAAA;AAC/B,IAAA,MAAM,EAAEC,uBAAAA,EAAyBC,cAAc,EAAE,GAAGC,8BAAAA,EAAAA;IACpD,MAAM,EAAEC,WAAWC,eAAe,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGC,YAAAA,EAAAA;IACtD,MAAM,EAAEJ,SAAWK,EAAAA,eAAe,EAAEC,KAAK,EAAEC,IAAI,EAAEC,IAAI,EAAE,GAAGC,kBAAAA,EAAAA;AAE1D,IAAA,MAAM,EACJC,UAAU,EACVJ,KAAAA,EAAOK,eAAe,EACtBX,SAAAA,EAAWY,mBAAmB,EAC9BC,UAAYC,EAAAA,oBAAoB,EACjC,GAAGC,6BAAuBC,SAAW,EAAA;AACpCC,QAAAA,gBAAAA,EAAkB,CAACC,GAAAA,GAAAA;YACjB,MAAMR,UAAAA,GAAaS,OAAOC,OAAO,CAACF,IAAIG,IAAI,EAAEX,cAAc,EAAC,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C,SAAS,CAACH,WAAW,CAACI,cAAc,EAAEC,6BAAAA,CAAAA;IAGzD,qBACEjB,cAAA,CAACC,iBAAKiB,OAAO,EAAA;QAACN,WAAaA,EAAAA,WAAAA;AACzB,QAAA,QAAA,gBAAAZ,cAACrE,CAAAA,qBAAAA,EAAAA,EAAAA;;AAGP;;;;;"}
|
1
|
+
{"version":3,"file":"EditConfigurationPage-D0Ng758X.js","sources":["../../../admin/src/pages/EditConfigurationPage.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Page, useNotification, useTracking, useAPIErrorHandler } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\n\nimport { TEMP_FIELD_NAME } from '../components/ConfigurationForm/Fields';\nimport { ConfigurationForm, ConfigurationFormProps } from '../components/ConfigurationForm/Form';\nimport { useDoc } from '../hooks/useDocument';\nimport { useDocLayout } from '../hooks/useDocumentLayout';\nimport { useTypedSelector } from '../modules/hooks';\nimport { useUpdateContentTypeConfigurationMutation } from '../services/contentTypes';\nimport { useGetInitialDataQuery } from '../services/init';\nimport { setIn } from '../utils/objects';\n\nimport type { Metadatas } from '../../../shared/contracts/content-types';\n\nconst EditConfigurationPage = () => {\n const { trackUsage } = useTracking();\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n const { isLoading: isLoadingSchema, schema, model } = useDoc();\n const { isLoading: isLoadingLayout, error, list, edit } = useDocLayout();\n\n const {\n fieldSizes,\n error: errorFieldSizes,\n isLoading: isLoadingFieldSizes,\n isFetching: isFetchingFieldSizes,\n } = useGetInitialDataQuery(undefined, {\n selectFromResult: (res) => {\n const fieldSizes = Object.entries(res.data?.fieldSizes ?? {}).reduce<\n ConfigurationFormProps['fieldSizes']\n >((acc, [attributeName, { default: size }]) => {\n acc[attributeName] = size;\n\n return acc;\n }, {});\n\n return {\n isFetching: res.isFetching,\n isLoading: res.isLoading,\n error: res.error,\n fieldSizes,\n };\n },\n });\n\n React.useEffect(() => {\n if (errorFieldSizes) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(errorFieldSizes),\n });\n }\n }, [errorFieldSizes, formatAPIError, toggleNotification]);\n\n const isLoading =\n isLoadingSchema || isLoadingLayout || isLoadingFieldSizes || isFetchingFieldSizes;\n\n const [updateConfiguration] = useUpdateContentTypeConfigurationMutation();\n const handleSubmit: ConfigurationFormProps['onSubmit'] = async (data) => {\n try {\n trackUsage('willSaveContentTypeLayout');\n\n /**\n * We reconstruct the metadatas object by taking the existing list metadatas\n * and re-merging that by attribute name with the current list metadatas, whilst overwriting\n * the data from the form we've built.\n */\n const meta = Object.entries(list.metadatas).reduce<Metadatas>(\n (acc, [name, { mainField: _mainField, ...listMeta }]) => {\n const existingEditMeta = edit.metadatas[name];\n\n const {\n __temp_key__,\n size: _size,\n name: _name,\n ...editedMetadata\n } = data.layout.flatMap((row) => row.children).find((field) => field.name === name) ?? {};\n\n acc[name] = {\n edit: {\n ...existingEditMeta,\n ...editedMetadata,\n },\n list: listMeta,\n };\n\n return acc;\n },\n {}\n );\n\n const res = await updateConfiguration({\n layouts: {\n edit: data.layout.map((row) =>\n row.children.reduce<Array<{ name: string; size: number }>>((acc, { name, size }) => {\n if (name !== TEMP_FIELD_NAME) {\n return [...acc, { name, size }];\n }\n\n return acc;\n }, [])\n ),\n list: list.layout.map((field) => field.name),\n },\n settings: setIn(data.settings, 'displayName', undefined),\n metadatas: meta,\n uid: model,\n });\n\n if ('data' in res) {\n trackUsage('didEditEditSettings');\n toggleNotification({\n type: 'success',\n message: formatMessage({ id: 'notification.success.saved', defaultMessage: 'Saved' }),\n });\n } else {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(res.error),\n });\n }\n } catch {\n toggleNotification({\n type: 'danger',\n message: formatMessage({ id: 'notification.error', defaultMessage: 'An error occurred' }),\n });\n }\n };\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (errorFieldSizes || error || !schema) {\n return <Page.Error />;\n }\n\n return (\n <>\n <Page.Title>{`Configure ${edit.settings.displayName} Edit View`}</Page.Title>\n <ConfigurationForm\n onSubmit={handleSubmit}\n attributes={schema.attributes}\n fieldSizes={fieldSizes}\n layout={edit}\n />\n </>\n );\n};\n\nconst ProtectedEditConfigurationPage = () => {\n const permissions = useTypedSelector(\n (state) => state.admin_app.permissions.contentManager?.collectionTypesConfigurations\n );\n\n return (\n <Page.Protect permissions={permissions}>\n <EditConfigurationPage />\n </Page.Protect>\n );\n};\n\nexport { ProtectedEditConfigurationPage, EditConfigurationPage };\n"],"names":["EditConfigurationPage","trackUsage","useTracking","formatMessage","useIntl","toggleNotification","useNotification","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","isLoading","isLoadingSchema","schema","model","useDoc","isLoadingLayout","error","list","edit","useDocLayout","fieldSizes","errorFieldSizes","isLoadingFieldSizes","isFetching","isFetchingFieldSizes","useGetInitialDataQuery","undefined","selectFromResult","res","Object","entries","data","reduce","acc","attributeName","default","size","React","useEffect","type","message","updateConfiguration","useUpdateContentTypeConfigurationMutation","handleSubmit","meta","metadatas","name","mainField","_mainField","listMeta","existingEditMeta","__temp_key__","_size","_name","editedMetadata","layout","flatMap","row","children","find","field","layouts","map","TEMP_FIELD_NAME","settings","setIn","uid","id","defaultMessage","_jsx","Page","Loading","Error","_jsxs","_Fragment","Title","displayName","ConfigurationForm","onSubmit","attributes","ProtectedEditConfigurationPage","permissions","useTypedSelector","state","admin_app","contentManager","collectionTypesConfigurations","Protect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAMA,qBAAwB,GAAA,IAAA;IAC5B,MAAM,EAAEC,UAAU,EAAE,GAAGC,uBAAAA,EAAAA;IACvB,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;IAC1B,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,2BAAAA,EAAAA;AAC/B,IAAA,MAAM,EAAEC,uBAAAA,EAAyBC,cA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qBAAOyD,cAAA,CAACC,iBAAKE,KAAK,EAAA,EAAA,CAAA;AACpB;IAEA,qBACEC,eAAA,CAAAC,mBAAA,EAAA;;AACE,0BAAAL,cAAA,CAACC,iBAAKK,KAAK,EAAA;0BAAE,CAAC,UAAU,EAAEzD,IAAK8C,CAAAA,QAAQ,CAACY,WAAW,CAAC,UAAU;;0BAC9DP,cAACQ,CAAAA,sBAAAA,EAAAA;gBACCC,QAAUnC,EAAAA,YAAAA;AACVoC,gBAAAA,UAAAA,EAAYnE,OAAOmE,UAAU;gBAC7B3D,UAAYA,EAAAA,UAAAA;gBACZmC,MAAQrC,EAAAA;;;;AAIhB;AAEA,MAAM8D,8BAAiC,GAAA,IAAA;IACrC,MAAMC,WAAAA,GAAcC,sBAClB,CAAA,CAACC,KAAUA,GAAAA,KAAAA,CAAMC,SAAS,CAACH,WAAW,CAACI,cAAc,EAAEC,6BAAAA,CAAAA;IAGzD,qBACEjB,cAAA,CAACC,iBAAKiB,OAAO,EAAA;QAACN,WAAaA,EAAAA,WAAAA;AACzB,QAAA,QAAA,gBAAAZ,cAACrE,CAAAA,qBAAAA,EAAAA,EAAAA;;AAGP;;;;;"}
|
package/dist/admin/chunks/{EditConfigurationPage-CYQ6mJWy.js → EditConfigurationPage-DDuPch5d.js}
RENAMED
@@ -2,8 +2,8 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
3
3
|
import { useTracking, useNotification, useAPIErrorHandler, Page } from '@strapi/admin/strapi-admin';
|
4
4
|
import { useIntl } from 'react-intl';
|
5
|
-
import { C as ConfigurationForm, T as TEMP_FIELD_NAME } from './Form-
|
6
|
-
import { c as useDoc, m as useDocLayout, a as useGetInitialDataQuery, A as useUpdateContentTypeConfigurationMutation } from './index-
|
5
|
+
import { C as ConfigurationForm, T as TEMP_FIELD_NAME } from './Form-CZmB6JIg.js';
|
6
|
+
import { c as useDoc, m as useDocLayout, a as useGetInitialDataQuery, A as useUpdateContentTypeConfigurationMutation } from './index-BRlRBRLb.js';
|
7
7
|
import { u as useTypedSelector } from './hooks-DMvik5y_.js';
|
8
8
|
import { s as setIn } from './objects-wl73iEma.js';
|
9
9
|
import '@strapi/design-system';
|
@@ -155,4 +155,4 @@ const ProtectedEditConfigurationPage = ()=>{
|
|
155
155
|
};
|
156
156
|
|
157
157
|
export { EditConfigurationPage, ProtectedEditConfigurationPage };
|
158
|
-
//# sourceMappingURL=EditConfigurationPage-
|
158
|
+
//# sourceMappingURL=EditConfigurationPage-DDuPch5d.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EditConfigurationPage-CYQ6mJWy.js","sources":["../../../admin/src/pages/EditConfigurationPage.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Page, useNotification, useTracking, useAPIErrorHandler } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\n\nimport { TEMP_FIELD_NAME } from '../components/ConfigurationForm/Fields';\nimport { ConfigurationForm, ConfigurationFormProps } from '../components/ConfigurationForm/Form';\nimport { useDoc } from '../hooks/useDocument';\nimport { useDocLayout } from '../hooks/useDocumentLayout';\nimport { useTypedSelector } from '../modules/hooks';\nimport { useUpdateContentTypeConfigurationMutation } from '../services/contentTypes';\nimport { useGetInitialDataQuery } from '../services/init';\nimport { setIn } from '../utils/objects';\n\nimport type { Metadatas } from '../../../shared/contracts/content-types';\n\nconst EditConfigurationPage = () => {\n const { trackUsage } = useTracking();\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n const { isLoading: isLoadingSchema, schema, model } = useDoc();\n const { isLoading: isLoadingLayout, error, list, edit } = useDocLayout();\n\n const {\n fieldSizes,\n error: errorFieldSizes,\n isLoading: isLoadingFieldSizes,\n isFetching: isFetchingFieldSizes,\n } = useGetInitialDataQuery(undefined, {\n selectFromResult: (res) => {\n const fieldSizes = Object.entries(res.data?.fieldSizes ?? {}).reduce<\n ConfigurationFormProps['fieldSizes']\n >((acc, [attributeName, { default: size }]) => {\n acc[attributeName] = size;\n\n return acc;\n }, {});\n\n return {\n isFetching: res.isFetching,\n isLoading: res.isLoading,\n error: res.error,\n fieldSizes,\n };\n },\n });\n\n React.useEffect(() => {\n if (errorFieldSizes) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(errorFieldSizes),\n });\n }\n }, [errorFieldSizes, formatAPIError, toggleNotification]);\n\n const isLoading =\n isLoadingSchema || isLoadingLayout || isLoadingFieldSizes || isFetchingFieldSizes;\n\n const [updateConfiguration] = useUpdateContentTypeConfigurationMutation();\n const handleSubmit: ConfigurationFormProps['onSubmit'] = async (data) => {\n try {\n trackUsage('willSaveContentTypeLayout');\n\n /**\n * We reconstruct the metadatas object by taking the existing list metadatas\n * and re-merging that by attribute name with the current list metadatas, whilst overwriting\n * the data from the form we've built.\n */\n const meta = Object.entries(list.metadatas).reduce<Metadatas>(\n (acc, [name, { mainField: _mainField, ...listMeta }]) => {\n const existingEditMeta = edit.metadatas[name];\n\n const {\n __temp_key__,\n size: _size,\n name: _name,\n ...editedMetadata\n } = data.layout.flatMap((row) => row.children).find((field) => field.name === name) ?? {};\n\n acc[name] = {\n edit: {\n ...existingEditMeta,\n ...editedMetadata,\n },\n list: listMeta,\n };\n\n return acc;\n },\n {}\n );\n\n const res = await updateConfiguration({\n layouts: {\n edit: data.layout.map((row) =>\n row.children.reduce<Array<{ name: string; size: number }>>((acc, { name, size }) => {\n if (name !== TEMP_FIELD_NAME) {\n return [...acc, { name, size }];\n }\n\n return acc;\n }, [])\n ),\n list: list.layout.map((field) => field.name),\n },\n settings: setIn(data.settings, 'displayName', undefined),\n metadatas: meta,\n uid: model,\n });\n\n if ('data' in res) {\n trackUsage('didEditEditSettings');\n toggleNotification({\n type: 'success',\n message: formatMessage({ id: 'notification.success.saved', defaultMessage: 'Saved' }),\n });\n } else {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(res.error),\n });\n }\n } catch {\n toggleNotification({\n type: 'danger',\n message: formatMessage({ id: 'notification.error', defaultMessage: 'An error occurred' }),\n });\n }\n };\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (errorFieldSizes || error || !schema) {\n return <Page.Error />;\n }\n\n return (\n <>\n <Page.Title>{`Configure ${edit.settings.displayName} Edit View`}</Page.Title>\n <ConfigurationForm\n onSubmit={handleSubmit}\n attributes={schema.attributes}\n fieldSizes={fieldSizes}\n layout={edit}\n />\n </>\n );\n};\n\nconst ProtectedEditConfigurationPage = () => {\n const permissions = useTypedSelector(\n (state) => state.admin_app.permissions.contentManager?.collectionTypesConfigurations\n );\n\n return (\n <Page.Protect permissions={permissions}>\n <EditConfigurationPage />\n </Page.Protect>\n );\n};\n\nexport { ProtectedEditConfigurationPage, EditConfigurationPage };\n"],"names":["EditConfigurationPage","trackUsage","useTracking","formatMessage","useIntl","toggleNotification","useNotification","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","isLoading","isLoadingSchema","schema","model","useDoc","isLoadingLayout","error","list","edit","useDocLayout","fieldSizes","errorFieldSizes","isLoadingFieldSizes","isFetching","isFetchingFieldSizes","useGetInitialDataQuery","undefined","selectFromResult","res","Object","entries","data","reduce","acc","attributeName","default","size","React","useEffect","type","message","updateConfiguration","useUpdateContentTypeConfigurationMutation","handleSubmit","meta","metadatas","name","mainField","_mainField","listMeta","existingEditMeta","__temp_key__","_size","_name","editedMetadata","layout","flatMap","row","children","find","field","layouts","map","TEMP_FIELD_NAME","settings","setIn","uid","id","defaultMessage","_jsx","Page","Loading","Error","_jsxs","_Fragment","Title","displayName","ConfigurationForm","onSubmit","attributes","ProtectedEditConfigurationPage","permissions","useTypedSelector","state","admin_app","contentManager","collectionTypesConfigurations","Protect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAMA,qBAAwB,GAAA,IAAA;IAC5B,MAAM,EAAEC,UAAU,EAAE,GAAGC,WAAAA,EAAAA;IACvB,MAAM,EAAEC,aAAa,EAAE,GAAGC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,CAACC,KAAKC,OAAO,EAAA,EAAA,CAAA;AACtB;IAEA,IAAIlD,eAAAA,IAAmBL,KAAS,IAAA,CAACJ,MAAQ,EAAA;QACvC,qBAAOyD,GAAA,CAACC,KAAKE,KAAK,EAAA,EAAA,CAAA;AACpB;IAEA,qBACEC,IAAA,CAAAC,QAAA,EAAA;;AACE,0BAAAL,GAAA,CAACC,KAAKK,KAAK,EAAA;0BAAE,CAAC,UAAU,EAAEzD,IAAK8C,CAAAA,QAAQ,CAACY,WAAW,CAAC,UAAU;;0BAC9DP,GAACQ,CAAAA,iBAAAA,EAAAA;gBACCC,QAAUnC,EAAAA,YAAAA;AACVoC,gBAAAA,UAAAA,EAAYnE,OAAOmE,UAAU;gBAC7B3D,UAAYA,EAAAA,UAAAA;gBACZmC,MAAQrC,EAAAA;;;;AAIhB;AAEA,MAAM8D,8BAAiC,GAAA,IAAA;IACrC,MAAMC,WAAAA,GAAcC,gBAClB,CAAA,CAACC,KAAUA,GAAAA,KAAAA,CAAMC,SAAS,CAACH,WAAW,CAACI,cAAc,EAAEC,6BAAAA,CAAAA;IAGzD,qBACEjB,GAAA,CAACC,KAAKiB,OAAO,EAAA;QAACN,WAAaA,EAAAA,WAAAA;AACzB,QAAA,QAAA,gBAAAZ,GAACrE,CAAAA,qBAAAA,EAAAA,EAAAA;;AAGP;;;;"}
|
1
|
+
{"version":3,"file":"EditConfigurationPage-DDuPch5d.js","sources":["../../../admin/src/pages/EditConfigurationPage.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Page, useNotification, useTracking, useAPIErrorHandler } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\n\nimport { TEMP_FIELD_NAME } from '../components/ConfigurationForm/Fields';\nimport { ConfigurationForm, ConfigurationFormProps } from '../components/ConfigurationForm/Form';\nimport { useDoc } from '../hooks/useDocument';\nimport { useDocLayout } from '../hooks/useDocumentLayout';\nimport { useTypedSelector } from '../modules/hooks';\nimport { useUpdateContentTypeConfigurationMutation } from '../services/contentTypes';\nimport { useGetInitialDataQuery } from '../services/init';\nimport { setIn } from '../utils/objects';\n\nimport type { Metadatas } from '../../../shared/contracts/content-types';\n\nconst EditConfigurationPage = () => {\n const { trackUsage } = useTracking();\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n const { isLoading: isLoadingSchema, schema, model } = useDoc();\n const { isLoading: isLoadingLayout, error, list, edit } = useDocLayout();\n\n const {\n fieldSizes,\n error: errorFieldSizes,\n isLoading: isLoadingFieldSizes,\n isFetching: isFetchingFieldSizes,\n } = useGetInitialDataQuery(undefined, {\n selectFromResult: (res) => {\n const fieldSizes = Object.entries(res.data?.fieldSizes ?? {}).reduce<\n ConfigurationFormProps['fieldSizes']\n >((acc, [attributeName, { default: size }]) => {\n acc[attributeName] = size;\n\n return acc;\n }, {});\n\n return {\n isFetching: res.isFetching,\n isLoading: res.isLoading,\n error: res.error,\n fieldSizes,\n };\n },\n });\n\n React.useEffect(() => {\n if (errorFieldSizes) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(errorFieldSizes),\n });\n }\n }, [errorFieldSizes, formatAPIError, toggleNotification]);\n\n const isLoading =\n isLoadingSchema || isLoadingLayout || isLoadingFieldSizes || isFetchingFieldSizes;\n\n const [updateConfiguration] = useUpdateContentTypeConfigurationMutation();\n const handleSubmit: ConfigurationFormProps['onSubmit'] = async (data) => {\n try {\n trackUsage('willSaveContentTypeLayout');\n\n /**\n * We reconstruct the metadatas object by taking the existing list metadatas\n * and re-merging that by attribute name with the current list metadatas, whilst overwriting\n * the data from the form we've built.\n */\n const meta = Object.entries(list.metadatas).reduce<Metadatas>(\n (acc, [name, { mainField: _mainField, ...listMeta }]) => {\n const existingEditMeta = edit.metadatas[name];\n\n const {\n __temp_key__,\n size: _size,\n name: _name,\n ...editedMetadata\n } = data.layout.flatMap((row) => row.children).find((field) => field.name === name) ?? {};\n\n acc[name] = {\n edit: {\n ...existingEditMeta,\n ...editedMetadata,\n },\n list: listMeta,\n };\n\n return acc;\n },\n {}\n );\n\n const res = await updateConfiguration({\n layouts: {\n edit: data.layout.map((row) =>\n row.children.reduce<Array<{ name: string; size: number }>>((acc, { name, size }) => {\n if (name !== TEMP_FIELD_NAME) {\n return [...acc, { name, size }];\n }\n\n return acc;\n }, [])\n ),\n list: list.layout.map((field) => field.name),\n },\n settings: setIn(data.settings, 'displayName', undefined),\n metadatas: meta,\n uid: model,\n });\n\n if ('data' in res) {\n trackUsage('didEditEditSettings');\n toggleNotification({\n type: 'success',\n message: formatMessage({ id: 'notification.success.saved', defaultMessage: 'Saved' }),\n });\n } else {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(res.error),\n });\n }\n } catch {\n toggleNotification({\n type: 'danger',\n message: formatMessage({ id: 'notification.error', defaultMessage: 'An error occurred' }),\n });\n }\n };\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (errorFieldSizes || error || !schema) {\n return <Page.Error />;\n }\n\n return (\n <>\n <Page.Title>{`Configure ${edit.settings.displayName} Edit View`}</Page.Title>\n <ConfigurationForm\n onSubmit={handleSubmit}\n attributes={schema.attributes}\n fieldSizes={fieldSizes}\n layout={edit}\n />\n </>\n );\n};\n\nconst ProtectedEditConfigurationPage = () => {\n const permissions = useTypedSelector(\n (state) => state.admin_app.permissions.contentManager?.collectionTypesConfigurations\n );\n\n return (\n <Page.Protect permissions={permissions}>\n <EditConfigurationPage />\n </Page.Protect>\n );\n};\n\nexport { ProtectedEditConfigurationPage, EditConfigurationPage };\n"],"names":["EditConfigurationPage","trackUsage","useTracking","formatMessage","useIntl","toggleNotification","useNotification","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","isLoading","isLoadingSchema","schema","model","useDoc","isLoadingLayout","error","list","edit","useDocLayout","fieldSizes","errorFieldSizes","isLoadingFieldSizes","isFetching","isFetchingFieldSizes","useGetInitialDataQuery","undefined","selectFromResult","res","Object","entries","data","reduce","acc","attributeName","default","size","React","useEffect","type","message","updateConfiguration","useUpdateContentTypeConfigurationMutation","handleSubmit","meta","metadatas","name","mainField","_mainField","listMeta","existingEditMeta","__temp_key__","_size","_name","editedMetadata","layout","flatMap","row","children","find","field","layouts","map","TEMP_FIELD_NAME","settings","setIn","uid","id","defaultMessage","_jsx","Page","Loading","Error","_jsxs","_Fragment","Title","displayName","ConfigurationForm","onSubmit","attributes","ProtectedEditConfigurationPage","permissions","useTypedSelector","state","admin_app","contentManager","collectionTypesConfigurations","Protect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAMA,qBAAwB,GAAA,IAAA;IAC5B,MAAM,EAAEC,UAAU,EAAE,GAAGC,WAAAA,EAAAA;IACvB,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;IAC1B,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,eAAAA,EAAAA;AAC/B,IAAA,MAAM,EAAEC,uBAAAA,EAAyBC,cAAc,EAAE,GAAGC,kBAAAA,EAAAA;IACpD,MAAM,EAAEC,WAAWC,eAAe,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGC,MAAAA,EAAAA;IACtD,MAAM,EAAEJ,SAAWK,EAAAA,eAAe,EAAEC,KAAK,EAAEC,IAAI,EAAEC,IAAI,EAAE,GAAGC,YAAAA,EAAAA;AAE1D,IAAA,MAAM,EACJC,UAAU,EACVJ,KAAAA,EAAOK,eAAe,EACtBX,SAAAA,EAAWY,mBAAmB,EAC9BC,UAAYC,EAAAA,oBAAoB,EACjC,GAAGC,uBAAuBC,SAAW,EAAA;AACpCC,QAAAA,gBAAAA,EAAkB,CAACC,GAAAA,GAAAA;YACjB,MAAMR,UAAAA,GAAaS,OAAOC,OAAO,CAACF,IAAIG,IAAI,EAAEX,cAAc,EAAC,CAAA,CAAGY,MAAM,CAElE,CAACC,KAAK,CAACC,aAAAA,EAAe,EAAEC,OAASC,EAAAA,IAAI,EAAE,CAAC,GAAA;gBACxCH,GAAG,CAACC,cAAc,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B,QAAA,QAAA,gBAAAZ,GAACrE,CAAAA,qBAAAA,EAAAA,EAAAA;;AAGP;;;;"}
|
@@ -5,8 +5,8 @@ import { Main, Tabs, Grid } from '@strapi/design-system';
|
|
5
5
|
import { useIntl } from 'react-intl';
|
6
6
|
import { useLocation, useParams } from 'react-router-dom';
|
7
7
|
import { styled } from 'styled-components';
|
8
|
-
import { c as useDoc, f as useDocumentRBAC, h as useDocumentLayout, i as createYupSchema, j as Header, g as getTranslation, P as Panels, k as PERMISSIONS, l as DocumentRBAC, S as SINGLE_TYPES } from './index-
|
9
|
-
import { u as useLazyComponents, F as FormLayout } from './Input-
|
8
|
+
import { c as useDoc, f as useDocumentRBAC, h as useDocumentLayout, i as createYupSchema, j as Header, g as getTranslation, P as Panels, k as PERMISSIONS, l as DocumentRBAC, S as SINGLE_TYPES } from './index-BRlRBRLb.js';
|
9
|
+
import { u as useLazyComponents, F as FormLayout } from './Input-CLX3C5DI.js';
|
10
10
|
import '@strapi/icons';
|
11
11
|
import 'lodash/fp/mapValues';
|
12
12
|
import 'yup';
|
@@ -20,56 +20,7 @@ import 'slate-history';
|
|
20
20
|
import 'slate-react';
|
21
21
|
import 'prismjs';
|
22
22
|
import 'prismjs/themes/prism-solarizedlight.css';
|
23
|
-
import '
|
24
|
-
import 'prismjs/components/prism-bash';
|
25
|
-
import 'prismjs/components/prism-basic';
|
26
|
-
import 'prismjs/components/prism-c';
|
27
|
-
import 'prismjs/components/prism-clojure';
|
28
|
-
import 'prismjs/components/prism-cobol';
|
29
|
-
import 'prismjs/components/prism-cpp';
|
30
|
-
import 'prismjs/components/prism-csharp';
|
31
|
-
import 'prismjs/components/prism-dart';
|
32
|
-
import 'prismjs/components/prism-docker';
|
33
|
-
import 'prismjs/components/prism-elixir';
|
34
|
-
import 'prismjs/components/prism-erlang';
|
35
|
-
import 'prismjs/components/prism-fortran';
|
36
|
-
import 'prismjs/components/prism-fsharp';
|
37
|
-
import 'prismjs/components/prism-go';
|
38
|
-
import 'prismjs/components/prism-graphql';
|
39
|
-
import 'prismjs/components/prism-groovy';
|
40
|
-
import 'prismjs/components/prism-haskell';
|
41
|
-
import 'prismjs/components/prism-haxe';
|
42
|
-
import 'prismjs/components/prism-ini';
|
43
|
-
import 'prismjs/components/prism-java';
|
44
|
-
import 'prismjs/components/prism-javascript';
|
45
|
-
import 'prismjs/components/prism-jsx';
|
46
|
-
import 'prismjs/components/prism-json';
|
47
|
-
import 'prismjs/components/prism-julia';
|
48
|
-
import 'prismjs/components/prism-kotlin';
|
49
|
-
import 'prismjs/components/prism-latex';
|
50
|
-
import 'prismjs/components/prism-lua';
|
51
|
-
import 'prismjs/components/prism-markdown';
|
52
|
-
import 'prismjs/components/prism-matlab';
|
53
|
-
import 'prismjs/components/prism-makefile';
|
54
|
-
import 'prismjs/components/prism-objectivec';
|
55
|
-
import 'prismjs/components/prism-perl';
|
56
|
-
import 'prismjs/components/prism-php';
|
57
|
-
import 'prismjs/components/prism-powershell';
|
58
|
-
import 'prismjs/components/prism-python';
|
59
|
-
import 'prismjs/components/prism-r';
|
60
|
-
import 'prismjs/components/prism-ruby';
|
61
|
-
import 'prismjs/components/prism-rust';
|
62
|
-
import 'prismjs/components/prism-sas';
|
63
|
-
import 'prismjs/components/prism-scala';
|
64
|
-
import 'prismjs/components/prism-scheme';
|
65
|
-
import 'prismjs/components/prism-sql';
|
66
|
-
import 'prismjs/components/prism-stata';
|
67
|
-
import 'prismjs/components/prism-swift';
|
68
|
-
import 'prismjs/components/prism-typescript';
|
69
|
-
import 'prismjs/components/prism-tsx';
|
70
|
-
import 'prismjs/components/prism-vbnet';
|
71
|
-
import 'prismjs/components/prism-yaml';
|
72
|
-
import './usePrev-tlgK0qPG.js';
|
23
|
+
import './usePrev-Bjw2dhmq.js';
|
73
24
|
import './useDragAndDrop-HYwNDExe.js';
|
74
25
|
import 'react-dnd';
|
75
26
|
import '@radix-ui/react-toolbar';
|
@@ -77,9 +28,9 @@ import 'react-dnd-html5-backend';
|
|
77
28
|
import './objects-wl73iEma.js';
|
78
29
|
import 'lodash/clone';
|
79
30
|
import 'lodash/toPath';
|
80
|
-
import './Relations-
|
31
|
+
import './Relations-C8jbZPVK.js';
|
81
32
|
import 'react-window';
|
82
|
-
import './relations-
|
33
|
+
import './relations-DYQAaXwZ.js';
|
83
34
|
import './ComponentIcon-BZcTc4rj.js';
|
84
35
|
import '@strapi/icons/symbols';
|
85
36
|
import 'codemirror5';
|
@@ -311,4 +262,4 @@ const StatusTab = styled(Tabs.Trigger)`
|
|
311
262
|
};
|
312
263
|
|
313
264
|
export { EditViewPage, ProtectedEditViewPage, getDocumentStatus };
|
314
|
-
//# sourceMappingURL=EditViewPage-
|
265
|
+
//# sourceMappingURL=EditViewPage-jCZnUuCR.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EditViewPage-DaY9aMeu.js","sources":["../../../admin/src/hooks/useOnce.ts","../../../admin/src/pages/EditView/EditViewPage.tsx"],"sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport * as React from 'react';\n\nexport const useOnce = (effect: React.EffectCallback) => React.useEffect(effect, emptyDeps);\n\nconst emptyDeps: React.DependencyList = [];\n","import * as React from 'react';\n\nimport {\n Page,\n Blocker,\n Form,\n useRBAC,\n useNotification,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport { Grid, Main, Tabs } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { useLocation, useParams } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { SINGLE_TYPES } from '../../constants/collections';\nimport { PERMISSIONS } from '../../constants/plugin';\nimport { DocumentRBAC, useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { type UseDocument, useDoc } from '../../hooks/useDocument';\nimport { useDocumentLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useOnce } from '../../hooks/useOnce';\nimport { getTranslation } from '../../utils/translations';\nimport { createYupSchema } from '../../utils/validation';\n\nimport { FormLayout } from './components/FormLayout';\nimport { Header } from './components/Header';\nimport { Panels } from './components/Panels';\nimport { transformDocument } from './utils/data';\nimport { createDefaultForm } from './utils/forms';\n\n/* -------------------------------------------------------------------------------------------------\n * EditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst EditViewPage = () => {\n const location = useLocation();\n const [\n {\n query: { status },\n },\n setQuery,\n ] = useQueryParams<{ status: 'draft' | 'published' }>({\n status: 'draft',\n });\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n\n const {\n document,\n meta,\n isLoading: isLoadingDocument,\n schema,\n components,\n collectionType,\n id,\n model,\n hasError,\n getTitle,\n getInitialFormValues,\n } = useDoc();\n\n const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;\n\n useOnce(() => {\n /**\n * We only ever want to fire the notification once otherwise\n * whenever the app re-renders it'll pop up regardless of\n * what we do because the state comes from react-router-dom\n */\n if (location?.state && 'error' in location.state) {\n toggleNotification({\n type: 'danger',\n message: location.state.error,\n timeout: 5000,\n });\n }\n });\n\n const isLoadingActionsRBAC = useDocumentRBAC('EditViewPage', (state) => state.isLoading);\n\n const isSingleType = collectionType === SINGLE_TYPES;\n\n /**\n * single-types don't current have an id, but because they're a singleton\n * we can simply use the update operation to continuously update the same\n * document with varying params.\n */\n const isCreatingDocument = !id && !isSingleType;\n\n const {\n isLoading: isLoadingLayout,\n edit: {\n layout,\n settings: { mainField },\n },\n } = useDocumentLayout(model);\n\n const { isLazyLoading } = useLazyComponents([]);\n\n const isLoading = isLoadingActionsRBAC || isLoadingDocument || isLoadingLayout || isLazyLoading;\n\n const initialValues = getInitialFormValues(isCreatingDocument);\n\n if (hasError) {\n return <Page.Error />;\n }\n\n if (isLoading && !document?.documentId) {\n return <Page.Loading />;\n }\n\n if (!initialValues) {\n return <Page.Error />;\n }\n\n const handleTabChange = (status: string) => {\n if (status === 'published' || status === 'draft') {\n setQuery({ status }, 'push', true);\n }\n };\n\n const validateSync = (values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validateSync(values, { abortEarly: false });\n };\n\n return (\n <Main paddingLeft={10} paddingRight={10}>\n <Page.Title>{getTitle(mainField)}</Page.Title>\n <Form\n disabled={hasDraftAndPublished && status === 'published'}\n initialValues={initialValues}\n method={isCreatingDocument ? 'POST' : 'PUT'}\n validate={(values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validate(values, { abortEarly: false });\n }}\n initialErrors={location?.state?.forceValidation ? validateSync(initialValues, {}) : {}}\n >\n {({ resetForm }) => (\n <>\n <Header\n isCreating={isCreatingDocument}\n status={hasDraftAndPublished ? getDocumentStatus(document, meta) : undefined}\n title={getTitle(mainField)}\n />\n <Tabs.Root variant=\"simple\" value={status} onValueChange={handleTabChange}>\n <Tabs.List\n aria-label={formatMessage({\n id: getTranslation('containers.edit.tabs.label'),\n defaultMessage: 'Document status',\n })}\n >\n {hasDraftAndPublished ? (\n <>\n <StatusTab value=\"draft\">\n {formatMessage({\n id: getTranslation('containers.edit.tabs.draft'),\n defaultMessage: 'draft',\n })}\n </StatusTab>\n <StatusTab\n disabled={!meta || meta.availableStatus.length === 0}\n value=\"published\"\n >\n {formatMessage({\n id: getTranslation('containers.edit.tabs.published'),\n defaultMessage: 'published',\n })}\n </StatusTab>\n </>\n ) : null}\n </Tabs.List>\n <Grid.Root paddingTop={8} gap={4}>\n <Grid.Item col={9} s={12} direction=\"column\" alignItems=\"stretch\">\n <Tabs.Content value=\"draft\">\n <FormLayout layout={layout} />\n </Tabs.Content>\n <Tabs.Content value=\"published\">\n <FormLayout layout={layout} />\n </Tabs.Content>\n </Grid.Item>\n <Grid.Item col={3} s={12} direction=\"column\" alignItems=\"stretch\">\n <Panels />\n </Grid.Item>\n </Grid.Root>\n </Tabs.Root>\n <Blocker\n // We reset the form to the published version to avoid errors like – https://strapi-inc.atlassian.net/browse/CONTENT-2284\n onProceed={resetForm}\n />\n </>\n )}\n </Form>\n </Main>\n );\n};\n\nconst StatusTab = styled(Tabs.Trigger)`\n text-transform: uppercase;\n`;\n\n/**\n * @internal\n * @description Returns the status of the document where its latest state takes priority,\n * this typically will be \"published\" unless a user has edited their draft in which we should\n * display \"modified\".\n */\nconst getDocumentStatus = (\n document: ReturnType<UseDocument>['document'],\n meta: ReturnType<UseDocument>['meta']\n): 'draft' | 'published' | 'modified' => {\n const docStatus = document?.status;\n const statuses = meta?.availableStatus ?? [];\n\n /**\n * Creating an entry\n */\n if (!docStatus) {\n return 'draft';\n }\n\n /**\n * We're viewing a draft, but the document could have a published version\n */\n if (docStatus === 'draft' && statuses.find((doc) => doc.publishedAt !== null)) {\n return 'published';\n }\n\n return docStatus;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ProtectedEditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedEditViewPage = () => {\n const { slug = '' } = useParams<{\n slug: string;\n }>();\n const {\n permissions = [],\n isLoading,\n error,\n } = useRBAC(\n PERMISSIONS.map((action) => ({\n action,\n subject: slug,\n }))\n );\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || !slug) {\n return <Page.Error />;\n }\n\n return (\n <Page.Protect permissions={permissions}>\n {({ permissions }) => (\n <DocumentRBAC permissions={permissions}>\n <EditViewPage />\n </DocumentRBAC>\n )}\n </Page.Protect>\n );\n};\n\nexport { EditViewPage, ProtectedEditViewPage, getDocumentStatus };\n"],"names":["useOnce","effect","React","useEffect","emptyDeps","EditViewPage","location","useLocation","query","status","setQuery","useQueryParams","formatMessage","useIntl","toggleNotification","useNotification","document","meta","isLoading","isLoadingDocument","schema","components","collectionType","id","model","hasError","getTitle","getInitialFormValues","useDoc","hasDraftAndPublished","options","draftAndPublish","state","type","message","error","timeout","isLoadingActionsRBAC","useDocumentRBAC","isSingleType","SINGLE_TYPES","isCreatingDocument","isLoadingLayout","edit","layout","settings","mainField","useDocumentLayout","isLazyLoading","useLazyComponents","initialValues","_jsx","Page","Error","documentId","Loading","handleTabChange","validateSync","values","yupSchema","createYupSchema","attributes","abortEarly","_jsxs","Main","paddingLeft","paddingRight","Title","Form","disabled","method","validate","initialErrors","forceValidation","resetForm","_Fragment","Header","isCreating","getDocumentStatus","undefined","title","Tabs","Root","variant","value","onValueChange","List","aria-label","getTranslation","defaultMessage","StatusTab","availableStatus","length","Grid","paddingTop","gap","Item","col","s","direction","alignItems","Content","FormLayout","Panels","Blocker","onProceed","styled","Trigger","docStatus","statuses","find","doc","publishedAt","ProtectedEditViewPage","slug","useParams","permissions","useRBAC","PERMISSIONS","map","action","subject","Protect","DocumentRBAC"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,UAAU,CAACC,MAAAA,GAAiCC,MAAMC,SAAS,CAACF,QAAQG,SAAW,CAAA;AAE5F,MAAMA,YAAkC,EAAE;;AC0B1C;;AAEkG,2GAE5FC,YAAe,GAAA,IAAA;AACnB,IAAA,MAAMC,QAAWC,GAAAA,WAAAA,EAAAA;IACjB,MAAM,CACJ,EACEC,KAAAA,EAAO,EAAEC,MAAM,EAAE,EAClB,EACDC,QACD,CAAA,GAAGC,cAAkD,CAAA;QACpDF,MAAQ,EAAA;AACV,KAAA,CAAA;IACA,MAAM,EAAEG,aAAa,EAAE,GAAGC,OAAAA,EAAAA;IAC1B,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,eAAAA,EAAAA;IAE/B,MAAM,EACJC,QAAQ,EACRC,IAAI,EACJC,WAAWC,iBAAiB,EAC5BC,MAAM,EACNC,UAAU,EACVC,cAAc,EACdC,EAAE,EACFC,KAAK,EACLC,QAAQ,EACRC,QAAQ,EACRC,oBAAoB,EACrB,GAAGC,MAAAA,EAAAA;IAEJ,MAAMC,oBAAAA,GAAuBT,MAAQU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AGA,IAAI,CAACiB,SAAW,EAAA;QACd,OAAO,OAAA;AACT;AAEA;;MAGA,IAAIA,SAAc,KAAA,OAAA,IAAWC,QAASC,CAAAA,IAAI,CAAC,CAACC,GAAQA,GAAAA,GAAAA,CAAIC,WAAW,KAAK,IAAO,CAAA,EAAA;QAC7E,OAAO,WAAA;AACT;IAEA,OAAOJ,SAAAA;AACT;AAEA;;AAEkG,2GAE5FK,qBAAwB,GAAA,IAAA;AAC5B,IAAA,MAAM,EAAEC,IAAAA,GAAO,EAAE,EAAE,GAAGC,SAAAA,EAAAA;AAGtB,IAAA,MAAM,EACJC,WAAAA,GAAc,EAAE,EAChBlG,SAAS,EACTiB,KAAK,EACN,GAAGkF,QACFC,WAAYC,CAAAA,GAAG,CAAC,CAACC,UAAY;AAC3BA,YAAAA,MAAAA;YACAC,OAASP,EAAAA;SACX,CAAA,CAAA,CAAA;AAGF,IAAA,IAAIhG,SAAW,EAAA;QACb,qBAAOiC,GAAA,CAACC,KAAKG,OAAO,EAAA,EAAA,CAAA;AACtB;IAEA,IAAIpB,KAAAA,IAAS,CAAC+E,IAAM,EAAA;QAClB,qBAAO/D,GAAA,CAACC,KAAKC,KAAK,EAAA,EAAA,CAAA;AACpB;IAEA,qBACEF,GAAA,CAACC,KAAKsE,OAAO,EAAA;QAACN,WAAaA,EAAAA,WAAAA;AACxB,QAAA,QAAA,EAAA,CAAC,EAAEA,WAAW,EAAE,iBACfjE,GAACwE,CAAAA,YAAAA,EAAAA;gBAAaP,WAAaA,EAAAA,WAAAA;AACzB,gBAAA,QAAA,gBAAAjE,GAAC9C,CAAAA,YAAAA,EAAAA,EAAAA;;;AAKX;;;;"}
|
1
|
+
{"version":3,"file":"EditViewPage-jCZnUuCR.js","sources":["../../../admin/src/hooks/useOnce.ts","../../../admin/src/pages/EditView/EditViewPage.tsx"],"sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport * as React from 'react';\n\nexport const useOnce = (effect: React.EffectCallback) => React.useEffect(effect, emptyDeps);\n\nconst emptyDeps: React.DependencyList = [];\n","import * as React from 'react';\n\nimport {\n Page,\n Blocker,\n Form,\n useRBAC,\n useNotification,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport { Grid, Main, Tabs } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { useLocation, useParams } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { SINGLE_TYPES } from '../../constants/collections';\nimport { PERMISSIONS } from '../../constants/plugin';\nimport { DocumentRBAC, useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { type UseDocument, useDoc } from '../../hooks/useDocument';\nimport { useDocumentLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useOnce } from '../../hooks/useOnce';\nimport { getTranslation } from '../../utils/translations';\nimport { createYupSchema } from '../../utils/validation';\n\nimport { FormLayout } from './components/FormLayout';\nimport { Header } from './components/Header';\nimport { Panels } from './components/Panels';\nimport { transformDocument } from './utils/data';\nimport { createDefaultForm } from './utils/forms';\n\n/* -------------------------------------------------------------------------------------------------\n * EditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst EditViewPage = () => {\n const location = useLocation();\n const [\n {\n query: { status },\n },\n setQuery,\n ] = useQueryParams<{ status: 'draft' | 'published' }>({\n status: 'draft',\n });\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n\n const {\n document,\n meta,\n isLoading: isLoadingDocument,\n schema,\n components,\n collectionType,\n id,\n model,\n hasError,\n getTitle,\n getInitialFormValues,\n } = useDoc();\n\n const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;\n\n useOnce(() => {\n /**\n * We only ever want to fire the notification once otherwise\n * whenever the app re-renders it'll pop up regardless of\n * what we do because the state comes from react-router-dom\n */\n if (location?.state && 'error' in location.state) {\n toggleNotification({\n type: 'danger',\n message: location.state.error,\n timeout: 5000,\n });\n }\n });\n\n const isLoadingActionsRBAC = useDocumentRBAC('EditViewPage', (state) => state.isLoading);\n\n const isSingleType = collectionType === SINGLE_TYPES;\n\n /**\n * single-types don't current have an id, but because they're a singleton\n * we can simply use the update operation to continuously update the same\n * document with varying params.\n */\n const isCreatingDocument = !id && !isSingleType;\n\n const {\n isLoading: isLoadingLayout,\n edit: {\n layout,\n settings: { mainField },\n },\n } = useDocumentLayout(model);\n\n const { isLazyLoading } = useLazyComponents([]);\n\n const isLoading = isLoadingActionsRBAC || isLoadingDocument || isLoadingLayout || isLazyLoading;\n\n const initialValues = getInitialFormValues(isCreatingDocument);\n\n if (hasError) {\n return <Page.Error />;\n }\n\n if (isLoading && !document?.documentId) {\n return <Page.Loading />;\n }\n\n if (!initialValues) {\n return <Page.Error />;\n }\n\n const handleTabChange = (status: string) => {\n if (status === 'published' || status === 'draft') {\n setQuery({ status }, 'push', true);\n }\n };\n\n const validateSync = (values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validateSync(values, { abortEarly: false });\n };\n\n return (\n <Main paddingLeft={10} paddingRight={10}>\n <Page.Title>{getTitle(mainField)}</Page.Title>\n <Form\n disabled={hasDraftAndPublished && status === 'published'}\n initialValues={initialValues}\n method={isCreatingDocument ? 'POST' : 'PUT'}\n validate={(values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validate(values, { abortEarly: false });\n }}\n initialErrors={location?.state?.forceValidation ? validateSync(initialValues, {}) : {}}\n >\n {({ resetForm }) => (\n <>\n <Header\n isCreating={isCreatingDocument}\n status={hasDraftAndPublished ? getDocumentStatus(document, meta) : undefined}\n title={getTitle(mainField)}\n />\n <Tabs.Root variant=\"simple\" value={status} onValueChange={handleTabChange}>\n <Tabs.List\n aria-label={formatMessage({\n id: getTranslation('containers.edit.tabs.label'),\n defaultMessage: 'Document status',\n })}\n >\n {hasDraftAndPublished ? (\n <>\n <StatusTab value=\"draft\">\n {formatMessage({\n id: getTranslation('containers.edit.tabs.draft'),\n defaultMessage: 'draft',\n })}\n </StatusTab>\n <StatusTab\n disabled={!meta || meta.availableStatus.length === 0}\n value=\"published\"\n >\n {formatMessage({\n id: getTranslation('containers.edit.tabs.published'),\n defaultMessage: 'published',\n })}\n </StatusTab>\n </>\n ) : null}\n </Tabs.List>\n <Grid.Root paddingTop={8} gap={4}>\n <Grid.Item col={9} s={12} direction=\"column\" alignItems=\"stretch\">\n <Tabs.Content value=\"draft\">\n <FormLayout layout={layout} />\n </Tabs.Content>\n <Tabs.Content value=\"published\">\n <FormLayout layout={layout} />\n </Tabs.Content>\n </Grid.Item>\n <Grid.Item col={3} s={12} direction=\"column\" alignItems=\"stretch\">\n <Panels />\n </Grid.Item>\n </Grid.Root>\n </Tabs.Root>\n <Blocker\n // We reset the form to the published version to avoid errors like – https://strapi-inc.atlassian.net/browse/CONTENT-2284\n onProceed={resetForm}\n />\n </>\n )}\n </Form>\n </Main>\n );\n};\n\nconst StatusTab = styled(Tabs.Trigger)`\n text-transform: uppercase;\n`;\n\n/**\n * @internal\n * @description Returns the status of the document where its latest state takes priority,\n * this typically will be \"published\" unless a user has edited their draft in which we should\n * display \"modified\".\n */\nconst getDocumentStatus = (\n document: ReturnType<UseDocument>['document'],\n meta: ReturnType<UseDocument>['meta']\n): 'draft' | 'published' | 'modified' => {\n const docStatus = document?.status;\n const statuses = meta?.availableStatus ?? [];\n\n /**\n * Creating an entry\n */\n if (!docStatus) {\n return 'draft';\n }\n\n /**\n * We're viewing a draft, but the document could have a published version\n */\n if (docStatus === 'draft' && statuses.find((doc) => doc.publishedAt !== null)) {\n return 'published';\n }\n\n return docStatus;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ProtectedEditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedEditViewPage = () => {\n const { slug = '' } = useParams<{\n slug: string;\n }>();\n const {\n permissions = [],\n isLoading,\n error,\n } = useRBAC(\n PERMISSIONS.map((action) => ({\n action,\n subject: slug,\n }))\n );\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || !slug) {\n return <Page.Error />;\n }\n\n return (\n <Page.Protect permissions={permissions}>\n {({ permissions }) => (\n <DocumentRBAC permissions={permissions}>\n <EditViewPage />\n </DocumentRBAC>\n )}\n </Page.Protect>\n );\n};\n\nexport { EditViewPage, ProtectedEditViewPage, getDocumentStatus };\n"],"names":["useOnce","effect","React","useEffect","emptyDeps","EditViewPage","location","useLocation","query","status","setQuery","useQueryParams","formatMessage","useIntl","toggleNotification","useNotification","document","meta","isLoading","isLoadingDocument","schema","components","collectionType","id","model","hasError","getTitle","getInitialFormValues","useDoc","hasDraftAndPublished","options","draftAndPublish","state","type","message","error","timeout","isLoadingActionsRBAC","useDocumentRBAC","isSingleType","SINGLE_TYPES","isCreatingDocument","isLoadingLayout","edit","layout","settings","mainField","useDocumentLayout","isLazyLoading","useLazyComponents","initialValues","_jsx","Page","Error","documentId","Loading","handleTabChange","validateSync","values","yupSchema","createYupSchema","attributes","abortEarly","_jsxs","Main","paddingLeft","paddingRight","Title","Form","disabled","method","validate","initialErrors","forceValidation","resetForm","_Fragment","Header","isCreating","getDocumentStatus","undefined","title","Tabs","Root","variant","value","onValueChange","List","aria-label","getTranslation","defaultMessage","StatusTab","availableStatus","length","Grid","paddingTop","gap","Item","col","s","direction","alignItems","Content","FormLayout","Panels","Blocker","onProceed","styled","Trigger","docStatus","statuses","find","doc","publishedAt","ProtectedEditViewPage","slug","useParams","permissions","useRBAC","PERMISSIONS","map","action","subject","Protect","DocumentRBAC"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,UAAU,CAACC,MAAAA,GAAiCC,MAAMC,SAAS,CAACF,QAAQG,SAAW,CAAA;AAE5F,MAAMA,YAAkC,EAAE;;AC0B1C;;AAEkG,2GAE5FC,YAAe,GAAA,IAAA;AACnB,IAAA,MAAMC,QAAWC,GAAAA,WA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