@strapi/content-manager 5.2.0 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{ComponentConfigurationPage-Br8hp2Xt.js → ComponentConfigurationPage-Cjr64OS0.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-Br8hp2Xt.js.map → ComponentConfigurationPage-Cjr64OS0.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-DhwMhiRn.mjs → ComponentConfigurationPage-DKuCF_uX.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-DhwMhiRn.mjs.map → ComponentConfigurationPage-DKuCF_uX.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-BG7rpPjL.js → EditConfigurationPage-BeikGxvq.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-BG7rpPjL.js.map → EditConfigurationPage-BeikGxvq.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CWao3CZ3.mjs → EditConfigurationPage-CyqSP6ru.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CWao3CZ3.mjs.map → EditConfigurationPage-CyqSP6ru.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-hiwZg61J.mjs → EditViewPage-PrPHZN_9.mjs} +29 -5
- package/dist/_chunks/EditViewPage-PrPHZN_9.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-BUtpHsMz.js → EditViewPage-pyqEgLgP.js} +29 -5
- package/dist/_chunks/EditViewPage-pyqEgLgP.js.map +1 -0
- package/dist/_chunks/{Field-BQQLwyUs.mjs → Field-DuAYQka5.mjs} +26 -6
- package/dist/_chunks/Field-DuAYQka5.mjs.map +1 -0
- package/dist/_chunks/{Field-DEdug-Ll.js → Field-fKtb7rWK.js} +26 -6
- package/dist/_chunks/Field-fKtb7rWK.js.map +1 -0
- package/dist/_chunks/{Form-v5pkY-X_.js → Form-BPXw-S-J.js} +2 -2
- package/dist/_chunks/{Form-v5pkY-X_.js.map → Form-BPXw-S-J.js.map} +1 -1
- package/dist/_chunks/{Form-DwJovCha.mjs → Form-Dxh71ckp.mjs} +2 -2
- package/dist/_chunks/{Form-DwJovCha.mjs.map → Form-Dxh71ckp.mjs.map} +1 -1
- package/dist/_chunks/{History-40apIShV.js → History-BGGn9JGY.js} +5 -54
- package/dist/_chunks/History-BGGn9JGY.js.map +1 -0
- package/dist/_chunks/{History-B9uJsxZl.mjs → History-CGblSVMc.mjs} +5 -54
- package/dist/_chunks/History-CGblSVMc.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DAGbWDIL.js → ListConfigurationPage-D3Avyi4t.js} +2 -2
- package/dist/_chunks/{ListConfigurationPage-DAGbWDIL.js.map → ListConfigurationPage-D3Avyi4t.js.map} +1 -1
- package/dist/_chunks/{ListConfigurationPage-CA4oi4Hj.mjs → ListConfigurationPage-TIM0JveM.mjs} +2 -2
- package/dist/_chunks/{ListConfigurationPage-CA4oi4Hj.mjs.map → ListConfigurationPage-TIM0JveM.mjs.map} +1 -1
- package/dist/_chunks/{ListViewPage-Ca8F1NL-.mjs → ListViewPage-C975eW-t.mjs} +16 -5
- package/dist/_chunks/{ListViewPage-Ca8F1NL-.mjs.map → ListViewPage-C975eW-t.mjs.map} +1 -1
- package/dist/_chunks/{ListViewPage-CjaHQ2_V.js → ListViewPage-DtAHWFMV.js} +16 -5
- package/dist/_chunks/{ListViewPage-CjaHQ2_V.js.map → ListViewPage-DtAHWFMV.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-CGxqLI8j.js → NoContentTypePage-BFjWZX0i.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-CGxqLI8j.js.map → NoContentTypePage-BFjWZX0i.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-CwfnU-aN.mjs → NoContentTypePage-SgNTVGjF.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-CwfnU-aN.mjs.map → NoContentTypePage-SgNTVGjF.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-iPk2lFR6.mjs → NoPermissionsPage-D4XYRoPf.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-iPk2lFR6.mjs.map → NoPermissionsPage-D4XYRoPf.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-CY3_QduF.js → NoPermissionsPage-j7oulOpl.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-CY3_QduF.js.map → NoPermissionsPage-j7oulOpl.js.map} +1 -1
- package/dist/_chunks/{Preview-V8XOfrQf.js → Preview-Bx1WfmKJ.js} +29 -59
- package/dist/_chunks/Preview-Bx1WfmKJ.js.map +1 -0
- package/dist/_chunks/{Preview-DRJhcaIO.mjs → Preview-Cy6fuAnd.mjs} +31 -61
- package/dist/_chunks/Preview-Cy6fuAnd.mjs.map +1 -0
- package/dist/_chunks/{Relations-CGerEwji.js → Relations-CXQqwRXC.js} +3 -3
- package/dist/_chunks/{Relations-CGerEwji.js.map → Relations-CXQqwRXC.js.map} +1 -1
- package/dist/_chunks/{Relations-DGWa9W2j.mjs → Relations-DUrYWw0N.mjs} +3 -3
- package/dist/_chunks/{Relations-DGWa9W2j.mjs.map → Relations-DUrYWw0N.mjs.map} +1 -1
- package/dist/_chunks/{en-D_BMf0hT.mjs → en-69jRDM9j.mjs} +3 -2
- package/dist/_chunks/{en-D_BMf0hT.mjs.map → en-69jRDM9j.mjs.map} +1 -1
- package/dist/_chunks/{en-CHOp_xJv.js → en-DAgtrRoa.js} +3 -2
- package/dist/_chunks/{en-CHOp_xJv.js.map → en-DAgtrRoa.js.map} +1 -1
- package/dist/_chunks/{index-V8MWkDSd.mjs → index-Ta--2bRa.mjs} +40 -66
- package/dist/_chunks/index-Ta--2bRa.mjs.map +1 -0
- package/dist/_chunks/{index-tN1hpOMN.js → index-_j7lH3CO.js} +39 -65
- package/dist/_chunks/index-_j7lH3CO.js.map +1 -0
- package/dist/_chunks/{layout-BzX903CL.js → layout-BDwU2I_y.js} +3 -3
- package/dist/_chunks/{layout-BzX903CL.js.map → layout-BDwU2I_y.js.map} +1 -1
- package/dist/_chunks/{layout-Bue_C6ui.mjs → layout-C8H4oKDo.mjs} +3 -3
- package/dist/_chunks/{layout-Bue_C6ui.mjs.map → layout-C8H4oKDo.mjs.map} +1 -1
- package/dist/_chunks/{relations-C4HcWYYJ.js → relations-CPfMNzM6.js} +2 -2
- package/dist/_chunks/{relations-C4HcWYYJ.js.map → relations-CPfMNzM6.js.map} +1 -1
- package/dist/_chunks/{relations-C8eyDiIO.mjs → relations-Ch70q86O.mjs} +2 -2
- package/dist/_chunks/{relations-C8eyDiIO.mjs.map → relations-Ch70q86O.mjs.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
- package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
- package/dist/admin/src/router.d.ts +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/_chunks/EditViewPage-BUtpHsMz.js.map +0 -1
- package/dist/_chunks/EditViewPage-hiwZg61J.mjs.map +0 -1
- package/dist/_chunks/Field-BQQLwyUs.mjs.map +0 -1
- package/dist/_chunks/Field-DEdug-Ll.js.map +0 -1
- package/dist/_chunks/History-40apIShV.js.map +0 -1
- package/dist/_chunks/History-B9uJsxZl.mjs.map +0 -1
- package/dist/_chunks/Preview-DRJhcaIO.mjs.map +0 -1
- package/dist/_chunks/Preview-V8XOfrQf.js.map +0 -1
- package/dist/_chunks/index-V8MWkDSd.mjs.map +0 -1
- package/dist/_chunks/index-tN1hpOMN.js.map +0 -1
@@ -10,8 +10,8 @@ const reactDnd = require("react-dnd");
|
|
10
10
|
const CardDragPreview = require("./CardDragPreview-C0QyJgRA.js");
|
11
11
|
const Icons = require("@strapi/icons");
|
12
12
|
const styledComponents = require("styled-components");
|
13
|
-
const index = require("./index-
|
14
|
-
const Relations = require("./Relations-
|
13
|
+
const index = require("./index-_j7lH3CO.js");
|
14
|
+
const Relations = require("./Relations-CXQqwRXC.js");
|
15
15
|
const qs = require("qs");
|
16
16
|
const hooks = require("./hooks-BAaaKPS_.js");
|
17
17
|
const useDragAndDrop = require("./useDragAndDrop-J0TUUbR6.js");
|
@@ -486,4 +486,4 @@ function renderDraglayerItem({ type, item }) {
|
|
486
486
|
}
|
487
487
|
}
|
488
488
|
exports.Layout = Layout;
|
489
|
-
//# sourceMappingURL=layout-
|
489
|
+
//# sourceMappingURL=layout-BDwU2I_y.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"layout-BzX903CL.js","sources":["../../admin/src/components/DragLayer.tsx","../../admin/src/components/DragPreviews/ComponentDragPreview.tsx","../../admin/src/components/DragPreviews/RelationDragPreview.tsx","../../admin/src/components/LeftMenu.tsx","../../admin/src/hooks/useContentManagerInitData.ts","../../admin/src/layout.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box } from '@strapi/design-system';\nimport { DragLayerMonitor, XYCoord, useDragLayer } from 'react-dnd';\n\nfunction getStyle(\n initialOffset: XYCoord | null,\n currentOffset: XYCoord | null,\n mouseOffset: XYCoord | null\n) {\n if (!initialOffset || !currentOffset || !mouseOffset) {\n return { display: 'none' };\n }\n\n const { x, y } = mouseOffset;\n\n return {\n transform: `translate(${x}px, ${y}px)`,\n };\n}\n\nexport interface DragLayerProps {\n renderItem: (item: {\n /**\n * TODO: it'd be great if we could make this a union where the type infers the item.\n */\n item: any;\n type: ReturnType<DragLayerMonitor['getItemType']>;\n }) => React.ReactNode;\n}\n\nconst DragLayer = ({ renderItem }: DragLayerProps) => {\n const { itemType, isDragging, item, initialOffset, currentOffset, mouseOffset } = useDragLayer(\n (monitor) => ({\n item: monitor.getItem(),\n itemType: monitor.getItemType(),\n initialOffset: monitor.getInitialSourceClientOffset(),\n currentOffset: monitor.getSourceClientOffset(),\n isDragging: monitor.isDragging(),\n mouseOffset: monitor.getClientOffset(),\n })\n );\n\n if (!isDragging) {\n return null;\n }\n\n return (\n <Box\n height=\"100%\"\n left={0}\n position=\"fixed\"\n pointerEvents=\"none\"\n top={0}\n zIndex={100}\n width=\"100%\"\n >\n <Box style={getStyle(initialOffset, currentOffset, mouseOffset)}>\n {renderItem({ type: itemType, item })}\n </Box>\n </Box>\n );\n};\n\nexport { DragLayer };\n","import { Flex, FlexComponent, IconButton, Typography } from '@strapi/design-system';\nimport { CaretDown, Drag, Trash } from '@strapi/icons';\nimport { styled } from 'styled-components';\n\ninterface ComponentDragPreviewProps {\n displayedValue: string;\n}\n\nconst ComponentDragPreview = ({ displayedValue }: ComponentDragPreviewProps) => {\n return (\n <Flex\n background=\"neutral0\"\n borderColor=\"neutral200\"\n justifyContent=\"space-between\"\n gap={3}\n padding={3}\n width=\"30rem\"\n >\n <ToggleButton type=\"button\">\n <Flex gap={6}>\n <DropdownIconWrapper\n alignItems=\"center\"\n justifyContent=\"center\"\n background=\"neutral200\"\n height=\"3.2rem\"\n width=\"3.2rem\"\n >\n <CaretDown />\n </DropdownIconWrapper>\n\n <Flex maxWidth=\"15rem\">\n <Typography textColor=\"neutral700\" ellipsis>\n {displayedValue}\n </Typography>\n </Flex>\n </Flex>\n </ToggleButton>\n\n <Flex gap={2}>\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Trash />\n </IconButton>\n\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Drag />\n </IconButton>\n </Flex>\n </Flex>\n );\n};\n\nconst DropdownIconWrapper = styled<FlexComponent>(Flex)`\n border-radius: 50%;\n\n svg {\n height: 0.6rem;\n width: 1.1rem;\n > path {\n fill: ${({ theme }) => theme.colors.neutral600};\n }\n }\n`;\n\n// TODO: we shouldn't have to reset a whole button\nconst ToggleButton = styled.button`\n border: none;\n background: transparent;\n display: block;\n width: 100%;\n text-align: unset;\n padding: 0;\n`;\n\nexport { ComponentDragPreview };\nexport type { ComponentDragPreviewProps };\n","import { Box, Flex, IconButton, Typography } from '@strapi/design-system';\nimport { Cross, Drag } from '@strapi/icons';\n\nimport { DocumentStatus } from '../../pages/EditView/components/DocumentStatus';\nimport {\n DisconnectButton,\n LinkEllipsis,\n FlexWrapper,\n} from '../../pages/EditView/components/FormInputs/Relations';\n\nimport type { Data } from '@strapi/types';\n\ninterface RelationDragPreviewProps {\n status?: string;\n displayedValue: string;\n id: Data.ID;\n index: number;\n width: number;\n}\n\nconst RelationDragPreview = ({ status, displayedValue, width }: RelationDragPreviewProps) => {\n return (\n <Box style={{ width }}>\n <Flex\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={2}\n paddingRight={4}\n hasRadius\n borderWidth={1}\n background=\"neutral0\"\n borderColor=\"neutral200\"\n justifyContent=\"space-between\"\n gap={4}\n >\n <FlexWrapper gap={1}>\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Drag />\n </IconButton>\n <Flex width=\"100%\" minWidth={0} justifyContent=\"space-between\">\n <Box minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>\n <LinkEllipsis href=\"\">\n <Typography textColor=\"primary600\" ellipsis>\n {displayedValue}\n </Typography>\n </LinkEllipsis>\n </Box>\n {status ? <DocumentStatus status={status} /> : null}\n </Flex>\n </FlexWrapper>\n <DisconnectButton type=\"button\">\n <Cross width=\"12px\" />\n </DisconnectButton>\n </Flex>\n </Box>\n );\n};\n\nexport { RelationDragPreview };\nexport type { RelationDragPreviewProps };\n","import * as React from 'react';\n\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\nimport {\n useCollator,\n useFilter,\n SubNav,\n SubNavHeader,\n SubNavLink,\n SubNavSection,\n SubNavSections,\n} from '@strapi/design-system';\nimport { parse, stringify } from 'qs';\nimport { useIntl } from 'react-intl';\nimport { NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { useContentTypeSchema } from '../hooks/useContentTypeSchema';\nimport { useTypedSelector } from '../modules/hooks';\nimport { getTranslation } from '../utils/translations';\n\nimport type { ContentManagerLink } from '../hooks/useContentManagerInitData';\n\nconst SubNavLinkCustom = styled(SubNavLink)`\n div {\n width: inherit;\n span:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n width: inherit;\n }\n }\n`;\n\nconst LeftMenu = () => {\n const [search, setSearch] = React.useState('');\n const [{ query }] = useQueryParams<{ plugins?: object }>();\n const { formatMessage, locale } = useIntl();\n\n const collectionTypeLinks = useTypedSelector(\n (state) => state['content-manager'].app.collectionTypeLinks\n );\n\n const singleTypeLinks = useTypedSelector((state) => state['content-manager'].app.singleTypeLinks);\n const { schemas } = useContentTypeSchema();\n\n const { startsWith } = useFilter(locale, {\n sensitivity: 'base',\n });\n\n const formatter = useCollator(locale, {\n sensitivity: 'base',\n });\n\n const menu = React.useMemo(\n () =>\n [\n {\n id: 'collectionTypes',\n title: formatMessage({\n id: getTranslation('components.LeftMenu.collection-types'),\n defaultMessage: 'Collection Types',\n }),\n searchable: true,\n links: collectionTypeLinks,\n },\n {\n id: 'singleTypes',\n title: formatMessage({\n id: getTranslation('components.LeftMenu.single-types'),\n defaultMessage: 'Single Types',\n }),\n searchable: true,\n links: singleTypeLinks,\n },\n ].map((section) => ({\n ...section,\n links: section.links\n /**\n * Filter by the search value\n */\n .filter((link) => startsWith(link.title, search))\n /**\n * Sort correctly using the language\n */\n .sort((a, b) => formatter.compare(a.title, b.title))\n /**\n * Apply the formated strings to the links from react-intl\n */\n .map((link) => {\n return {\n ...link,\n title: formatMessage({ id: link.title, defaultMessage: link.title }),\n };\n }),\n })),\n [collectionTypeLinks, search, singleTypeLinks, startsWith, formatMessage, formatter]\n );\n\n const handleClear = () => {\n setSearch('');\n };\n\n const handleChangeSearch = ({ target: { value } }: { target: { value: string } }) => {\n setSearch(value);\n };\n\n const label = formatMessage({\n id: getTranslation('header.name'),\n defaultMessage: 'Content Manager',\n });\n\n const getPluginsParamsForLink = (link: ContentManagerLink) => {\n const schema = schemas.find((schema) => schema.uid === link.uid);\n const isI18nEnabled = Boolean((schema?.pluginOptions?.i18n as any)?.localized);\n\n // The search params have the i18n plugin\n if (query.plugins && 'i18n' in query.plugins) {\n // Prepare removal of i18n from the plugins search params\n const { i18n, ...restPlugins } = query.plugins;\n\n // i18n is not enabled, remove it from the plugins search params\n if (!isI18nEnabled) {\n return restPlugins;\n }\n\n // i18n is enabled, put the plugins search params back together\n return { i18n, ...restPlugins };\n }\n\n return query.plugins;\n };\n\n return (\n <SubNav aria-label={label}>\n <SubNavHeader\n label={label}\n searchable\n value={search}\n onChange={handleChangeSearch}\n onClear={handleClear}\n searchLabel={formatMessage({\n id: 'content-manager.components.LeftMenu.Search.label',\n defaultMessage: 'Search for a content type',\n })}\n />\n <SubNavSections>\n {menu.map((section) => {\n return (\n <SubNavSection\n key={section.id}\n label={section.title}\n badgeLabel={section.links.length.toString()}\n >\n {section.links.map((link) => {\n return (\n <SubNavLinkCustom\n tag={NavLink}\n key={link.uid}\n to={{\n pathname: link.to,\n search: stringify({\n ...parse(link.search ?? ''),\n plugins: getPluginsParamsForLink(link),\n }),\n }}\n width=\"100%\"\n >\n {link.title}\n </SubNavLinkCustom>\n );\n })}\n </SubNavSection>\n );\n })}\n </SubNavSections>\n </SubNav>\n );\n};\n\nexport { LeftMenu };\n","import { useEffect } from 'react';\n\nimport {\n useAuth,\n type Permission,\n useNotification,\n useStrapiApp,\n useAPIErrorHandler,\n} from '@strapi/admin/strapi-admin';\nimport { useNotifyAT } from '@strapi/design-system';\nimport { stringify } from 'qs';\nimport { useIntl } from 'react-intl';\n\nimport { COLLECTION_TYPES, SINGLE_TYPES } from '../constants/collections';\nimport { HOOKS } from '../constants/hooks';\nimport { AppState, setInitialData } from '../modules/app';\nimport { useTypedDispatch, useTypedSelector } from '../modules/hooks';\nimport { useGetAllContentTypeSettingsQuery } from '../services/contentTypes';\nimport { useGetInitialDataQuery } from '../services/init';\nimport { getTranslation } from '../utils/translations';\n\nimport type { Component } from '../../../shared/contracts/components';\nimport type {\n ContentType,\n FindContentTypesSettings,\n} from '../../../shared/contracts/content-types';\nimport type { GetInitData } from '../../../shared/contracts/init';\n\nconst { MUTATE_COLLECTION_TYPES_LINKS, MUTATE_SINGLE_TYPES_LINKS } = HOOKS;\n\ninterface ContentManagerLink {\n permissions: Permission[];\n search: string | null;\n kind: string;\n title: string;\n to: string;\n uid: string;\n name: string;\n isDisplayed: boolean;\n}\n\nconst useContentManagerInitData = (): AppState => {\n const { toggleNotification } = useNotification();\n const dispatch = useTypedDispatch();\n const runHookWaterfall = useStrapiApp(\n 'useContentManagerInitData',\n (state) => state.runHookWaterfall\n );\n const { notifyStatus } = useNotifyAT();\n const { formatMessage } = useIntl();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler(getTranslation);\n const checkUserHasPermissions = useAuth(\n 'useContentManagerInitData',\n (state) => state.checkUserHasPermissions\n );\n\n const state = useTypedSelector((state) => state['content-manager'].app);\n\n const initialDataQuery = useGetInitialDataQuery(undefined, {\n /**\n * TODO: remove this when the CTB has been refactored to use redux-toolkit-query\n * and it can invalidate the cache on mutation\n */\n refetchOnMountOrArgChange: true,\n });\n\n useEffect(() => {\n if (initialDataQuery.data) {\n notifyStatus(\n formatMessage({\n id: getTranslation('App.schemas.data-loaded'),\n defaultMessage: 'The schemas have been successfully loaded.',\n })\n );\n }\n }, [formatMessage, initialDataQuery.data, notifyStatus]);\n\n useEffect(() => {\n if (initialDataQuery.error) {\n toggleNotification({ type: 'danger', message: formatAPIError(initialDataQuery.error) });\n }\n }, [formatAPIError, initialDataQuery.error, toggleNotification]);\n\n const contentTypeSettingsQuery = useGetAllContentTypeSettingsQuery();\n\n useEffect(() => {\n if (contentTypeSettingsQuery.error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(contentTypeSettingsQuery.error),\n });\n }\n }, [formatAPIError, contentTypeSettingsQuery.error, toggleNotification]);\n\n const formatData = async (\n components: Component[],\n contentTypes: ContentType[],\n fieldSizes: GetInitData.Response['data']['fieldSizes'],\n contentTypeConfigurations: FindContentTypesSettings.Response['data']\n ) => {\n /**\n * We group these by the two types we support. We do with an object because we can use default\n * values of arrays to make sure we always have an array to manipulate further on if, for example,\n * a user has not made any single types.\n *\n * This means we have to manually add new content types to this hook if we add a new type – but\n * the safety is worth it.\n */\n const { collectionType: collectionTypeLinks, singleType: singleTypeLinks } =\n contentTypes.reduce<{\n collectionType: ContentType[];\n singleType: ContentType[];\n }>(\n (acc, model) => {\n acc[model.kind].push(model);\n return acc;\n },\n {\n collectionType: [],\n singleType: [],\n }\n );\n const collectionTypeSectionLinks = generateLinks(\n collectionTypeLinks,\n 'collectionTypes',\n contentTypeConfigurations\n );\n const singleTypeSectionLinks = generateLinks(singleTypeLinks, 'singleTypes');\n\n // Collection Types verifications\n const collectionTypeLinksPermissions = await Promise.all(\n collectionTypeSectionLinks.map(({ permissions }) => checkUserHasPermissions(permissions))\n );\n\n const authorizedCollectionTypeLinks = collectionTypeSectionLinks.filter(\n (_, index) => collectionTypeLinksPermissions[index].length > 0\n );\n\n // Single Types verifications\n const singleTypeLinksPermissions = await Promise.all(\n singleTypeSectionLinks.map(({ permissions }) => checkUserHasPermissions(permissions))\n );\n const authorizedSingleTypeLinks = singleTypeSectionLinks.filter(\n (_, index) => singleTypeLinksPermissions[index].length > 0\n );\n const { ctLinks } = runHookWaterfall(MUTATE_COLLECTION_TYPES_LINKS, {\n ctLinks: authorizedCollectionTypeLinks,\n models: contentTypes,\n });\n const { stLinks } = runHookWaterfall(MUTATE_SINGLE_TYPES_LINKS, {\n stLinks: authorizedSingleTypeLinks,\n models: contentTypes,\n });\n\n dispatch(\n setInitialData({\n authorizedCollectionTypeLinks: ctLinks,\n authorizedSingleTypeLinks: stLinks,\n components,\n contentTypeSchemas: contentTypes,\n fieldSizes,\n })\n );\n };\n\n useEffect(() => {\n if (initialDataQuery.data && contentTypeSettingsQuery.data) {\n formatData(\n initialDataQuery.data.components,\n initialDataQuery.data.contentTypes,\n initialDataQuery.data.fieldSizes,\n contentTypeSettingsQuery.data\n );\n }\n }, [initialDataQuery.data, contentTypeSettingsQuery.data]);\n\n return { ...state };\n};\n\nconst generateLinks = (\n links: ContentType[],\n type: 'collectionTypes' | 'singleTypes',\n configurations: FindContentTypesSettings.Response['data'] = []\n) => {\n return links\n .filter((link) => link.isDisplayed)\n .map((link) => {\n const collectionTypesPermissions = [\n { action: 'plugin::content-manager.explorer.create', subject: link.uid },\n { action: 'plugin::content-manager.explorer.read', subject: link.uid },\n ];\n const singleTypesPermissions = [\n { action: 'plugin::content-manager.explorer.read', subject: link.uid },\n ];\n const permissions =\n type === 'collectionTypes' ? collectionTypesPermissions : singleTypesPermissions;\n\n const currentContentTypeConfig = configurations.find(({ uid }) => uid === link.uid);\n\n let search = null;\n\n if (currentContentTypeConfig) {\n const searchParams = {\n page: 1,\n pageSize: currentContentTypeConfig.settings.pageSize,\n sort: `${currentContentTypeConfig.settings.defaultSortBy}:${currentContentTypeConfig.settings.defaultSortOrder}`,\n };\n\n search = stringify(searchParams, { encode: false });\n }\n\n return {\n permissions,\n search,\n kind: link.kind,\n title: link.info.displayName,\n to: `/content-manager/${link.kind === 'collectionType' ? COLLECTION_TYPES : SINGLE_TYPES}/${\n link.uid\n }`,\n uid: link.uid,\n // Used for the list item key in the helper plugin\n name: link.uid,\n isDisplayed: link.isDisplayed,\n } satisfies ContentManagerLink;\n });\n};\n\nexport { useContentManagerInitData };\nexport type { ContentManagerLink };\n","/* eslint-disable check-file/filename-naming-convention */\nimport * as React from 'react';\n\nimport { Page, useGuidedTour, Layouts } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\nimport { Navigate, Outlet, useLocation, useMatch } from 'react-router-dom';\n\nimport { DragLayer, DragLayerProps } from './components/DragLayer';\nimport { CardDragPreview } from './components/DragPreviews/CardDragPreview';\nimport { ComponentDragPreview } from './components/DragPreviews/ComponentDragPreview';\nimport { RelationDragPreview } from './components/DragPreviews/RelationDragPreview';\nimport { LeftMenu } from './components/LeftMenu';\nimport { ItemTypes } from './constants/dragAndDrop';\nimport { useContentManagerInitData } from './hooks/useContentManagerInitData';\nimport { getTranslation } from './utils/translations';\n\n/* -------------------------------------------------------------------------------------------------\n * Layout\n * -----------------------------------------------------------------------------------------------*/\n\nconst Layout = () => {\n const contentTypeMatch = useMatch('/content-manager/:kind/:uid/*');\n\n const { isLoading, collectionTypeLinks, models, singleTypeLinks } = useContentManagerInitData();\n const authorisedModels = [...collectionTypeLinks, ...singleTypeLinks].sort((a, b) =>\n a.title.localeCompare(b.title)\n );\n\n const { pathname } = useLocation();\n const { formatMessage } = useIntl();\n const startSection = useGuidedTour('Layout', (state) => state.startSection);\n const startSectionRef = React.useRef(startSection);\n\n React.useEffect(() => {\n if (startSectionRef.current) {\n startSectionRef.current('contentManager');\n }\n }, []);\n\n if (isLoading) {\n return (\n <>\n <Page.Title>\n {formatMessage({\n id: getTranslation('plugin.name'),\n defaultMessage: 'Content Manager',\n })}\n </Page.Title>\n <Page.Loading />\n </>\n );\n }\n\n // Array of models that are displayed in the content manager\n const supportedModelsToDisplay = models.filter(({ isDisplayed }) => isDisplayed);\n\n // Redirect the user to the 403 page\n if (\n authorisedModels.length === 0 &&\n supportedModelsToDisplay.length > 0 &&\n pathname !== '/content-manager/403'\n ) {\n return <Navigate to=\"/403\" />;\n }\n\n // Redirect the user to the create content type page\n if (supportedModelsToDisplay.length === 0 && pathname !== '/no-content-types') {\n return <Navigate to=\"/no-content-types\" />;\n }\n\n if (!contentTypeMatch && authorisedModels.length > 0) {\n return (\n <Navigate\n to={{\n pathname: authorisedModels[0].to,\n search: authorisedModels[0].search ?? '',\n }}\n replace\n />\n );\n }\n\n return (\n <>\n <Page.Title>\n {formatMessage({\n id: getTranslation('plugin.name'),\n defaultMessage: 'Content Manager',\n })}\n </Page.Title>\n <Layouts.Root sideNav={<LeftMenu />}>\n <DragLayer renderItem={renderDraglayerItem} />\n <Outlet />\n </Layouts.Root>\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * renderDraglayerItem\n * -----------------------------------------------------------------------------------------------*/\n\nfunction renderDraglayerItem({ type, item }: Parameters<DragLayerProps['renderItem']>[0]) {\n if (!type || (type && typeof type !== 'string')) {\n return null;\n }\n\n /**\n * Because a user may have multiple relations / dynamic zones / repeable fields in the same content type,\n * we append the fieldName for the item type to make them unique, however, we then want to extract that\n * first type to apply the correct preview.\n */\n const [actualType] = type.split('_');\n\n switch (actualType) {\n case ItemTypes.EDIT_FIELD:\n case ItemTypes.FIELD:\n return <CardDragPreview label={item.label} />;\n case ItemTypes.COMPONENT:\n case ItemTypes.DYNAMIC_ZONE:\n return <ComponentDragPreview displayedValue={item.displayedValue} />;\n\n case ItemTypes.RELATION:\n return <RelationDragPreview {...item} />;\n\n default:\n return null;\n }\n}\n\nexport { Layout };\n"],"names":["useDragLayer","jsx","Box","jsxs","Flex","CaretDown","Typography","IconButton","Trash","Drag","styled","FlexWrapper","LinkEllipsis","DocumentStatus","DisconnectButton","Cross","SubNavLink","React","useQueryParams","useIntl","useTypedSelector","useContentTypeSchema","useFilter","useCollator","getTranslation","schema","SubNav","SubNavHeader","SubNavSections","SubNavSection","NavLink","stringify","parse","HOOKS","useNotification","useTypedDispatch","useStrapiApp","state","useNotifyAT","useAPIErrorHandler","useAuth","useGetInitialDataQuery","useEffect","useGetAllContentTypeSettingsQuery","index","setInitialData","COLLECTION_TYPES","SINGLE_TYPES","useMatch","useLocation","useGuidedTour","Fragment","Page","Navigate","Layouts","Outlet","ItemTypes","CardDragPreview"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAAS,SACP,eACA,eACA,aACA;AACA,MAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,aAAa;AAC7C,WAAA,EAAE,SAAS;EACpB;AAEM,QAAA,EAAE,GAAG,EAAM,IAAA;AAEV,SAAA;AAAA,IACL,WAAW,aAAa,CAAC,OAAO,CAAC;AAAA,EAAA;AAErC;AAYA,MAAM,YAAY,CAAC,EAA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AA;AACN,aAAAvD,2BAAA,IAAC,qBAAqB,EAAA,GAAG,KAAM,CAAA;AAAA,IAExC;AACS,aAAA;AAAA,EACX;AACF;;"}
|
1
|
+
{"version":3,"file":"layout-BDwU2I_y.js","sources":["../../admin/src/components/DragLayer.tsx","../../admin/src/components/DragPreviews/ComponentDragPreview.tsx","../../admin/src/components/DragPreviews/RelationDragPreview.tsx","../../admin/src/components/LeftMenu.tsx","../../admin/src/hooks/useContentManagerInitData.ts","../../admin/src/layout.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box } from '@strapi/design-system';\nimport { DragLayerMonitor, XYCoord, useDragLayer } from 'react-dnd';\n\nfunction getStyle(\n initialOffset: XYCoord | null,\n currentOffset: XYCoord | null,\n mouseOffset: XYCoord | null\n) {\n if (!initialOffset || !currentOffset || !mouseOffset) {\n return { display: 'none' };\n }\n\n const { x, y } = mouseOffset;\n\n return {\n transform: `translate(${x}px, ${y}px)`,\n };\n}\n\nexport interface DragLayerProps {\n renderItem: (item: {\n /**\n * TODO: it'd be great if we could make this a union where the type infers the item.\n */\n item: any;\n type: ReturnType<DragLayerMonitor['getItemType']>;\n }) => React.ReactNode;\n}\n\nconst DragLayer = ({ renderItem }: DragLayerProps) => {\n const { itemType, isDragging, item, initialOffset, currentOffset, mouseOffset } = useDragLayer(\n (monitor) => ({\n item: monitor.getItem(),\n itemType: monitor.getItemType(),\n initialOffset: monitor.getInitialSourceClientOffset(),\n currentOffset: monitor.getSourceClientOffset(),\n isDragging: monitor.isDragging(),\n mouseOffset: monitor.getClientOffset(),\n })\n );\n\n if (!isDragging) {\n return null;\n }\n\n return (\n <Box\n height=\"100%\"\n left={0}\n position=\"fixed\"\n pointerEvents=\"none\"\n top={0}\n zIndex={100}\n width=\"100%\"\n >\n <Box style={getStyle(initialOffset, currentOffset, mouseOffset)}>\n {renderItem({ type: itemType, item })}\n </Box>\n </Box>\n );\n};\n\nexport { DragLayer };\n","import { Flex, FlexComponent, IconButton, Typography } from '@strapi/design-system';\nimport { CaretDown, Drag, Trash } from '@strapi/icons';\nimport { styled } from 'styled-components';\n\ninterface ComponentDragPreviewProps {\n displayedValue: string;\n}\n\nconst ComponentDragPreview = ({ displayedValue }: ComponentDragPreviewProps) => {\n return (\n <Flex\n background=\"neutral0\"\n borderColor=\"neutral200\"\n justifyContent=\"space-between\"\n gap={3}\n padding={3}\n width=\"30rem\"\n >\n <ToggleButton type=\"button\">\n <Flex gap={6}>\n <DropdownIconWrapper\n alignItems=\"center\"\n justifyContent=\"center\"\n background=\"neutral200\"\n height=\"3.2rem\"\n width=\"3.2rem\"\n >\n <CaretDown />\n </DropdownIconWrapper>\n\n <Flex maxWidth=\"15rem\">\n <Typography textColor=\"neutral700\" ellipsis>\n {displayedValue}\n </Typography>\n </Flex>\n </Flex>\n </ToggleButton>\n\n <Flex gap={2}>\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Trash />\n </IconButton>\n\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Drag />\n </IconButton>\n </Flex>\n </Flex>\n );\n};\n\nconst DropdownIconWrapper = styled<FlexComponent>(Flex)`\n border-radius: 50%;\n\n svg {\n height: 0.6rem;\n width: 1.1rem;\n > path {\n fill: ${({ theme }) => theme.colors.neutral600};\n }\n }\n`;\n\n// TODO: we shouldn't have to reset a whole button\nconst ToggleButton = styled.button`\n border: none;\n background: transparent;\n display: block;\n width: 100%;\n text-align: unset;\n padding: 0;\n`;\n\nexport { ComponentDragPreview };\nexport type { ComponentDragPreviewProps };\n","import { Box, Flex, IconButton, Typography } from '@strapi/design-system';\nimport { Cross, Drag } from '@strapi/icons';\n\nimport { DocumentStatus } from '../../pages/EditView/components/DocumentStatus';\nimport {\n DisconnectButton,\n LinkEllipsis,\n FlexWrapper,\n} from '../../pages/EditView/components/FormInputs/Relations';\n\nimport type { Data } from '@strapi/types';\n\ninterface RelationDragPreviewProps {\n status?: string;\n displayedValue: string;\n id: Data.ID;\n index: number;\n width: number;\n}\n\nconst RelationDragPreview = ({ status, displayedValue, width }: RelationDragPreviewProps) => {\n return (\n <Box style={{ width }}>\n <Flex\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={2}\n paddingRight={4}\n hasRadius\n borderWidth={1}\n background=\"neutral0\"\n borderColor=\"neutral200\"\n justifyContent=\"space-between\"\n gap={4}\n >\n <FlexWrapper gap={1}>\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Drag />\n </IconButton>\n <Flex width=\"100%\" minWidth={0} justifyContent=\"space-between\">\n <Box minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>\n <LinkEllipsis href=\"\">\n <Typography textColor=\"primary600\" ellipsis>\n {displayedValue}\n </Typography>\n </LinkEllipsis>\n </Box>\n {status ? <DocumentStatus status={status} /> : null}\n </Flex>\n </FlexWrapper>\n <DisconnectButton type=\"button\">\n <Cross width=\"12px\" />\n </DisconnectButton>\n </Flex>\n </Box>\n );\n};\n\nexport { RelationDragPreview };\nexport type { RelationDragPreviewProps };\n","import * as React from 'react';\n\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\nimport {\n useCollator,\n useFilter,\n SubNav,\n SubNavHeader,\n SubNavLink,\n SubNavSection,\n SubNavSections,\n} from '@strapi/design-system';\nimport { parse, stringify } from 'qs';\nimport { useIntl } from 'react-intl';\nimport { NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { useContentTypeSchema } from '../hooks/useContentTypeSchema';\nimport { useTypedSelector } from '../modules/hooks';\nimport { getTranslation } from '../utils/translations';\n\nimport type { ContentManagerLink } from '../hooks/useContentManagerInitData';\n\nconst SubNavLinkCustom = styled(SubNavLink)`\n div {\n width: inherit;\n span:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n width: inherit;\n }\n }\n`;\n\nconst LeftMenu = () => {\n const [search, setSearch] = React.useState('');\n const [{ query }] = useQueryParams<{ plugins?: object }>();\n const { formatMessage, locale } = useIntl();\n\n const collectionTypeLinks = useTypedSelector(\n (state) => state['content-manager'].app.collectionTypeLinks\n );\n\n const singleTypeLinks = useTypedSelector((state) => state['content-manager'].app.singleTypeLinks);\n const { schemas } = useContentTypeSchema();\n\n const { startsWith } = useFilter(locale, {\n sensitivity: 'base',\n });\n\n const formatter = useCollator(locale, {\n sensitivity: 'base',\n });\n\n const menu = React.useMemo(\n () =>\n [\n {\n id: 'collectionTypes',\n title: formatMessage({\n id: getTranslation('components.LeftMenu.collection-types'),\n defaultMessage: 'Collection Types',\n }),\n searchable: true,\n links: collectionTypeLinks,\n },\n {\n id: 'singleTypes',\n title: formatMessage({\n id: getTranslation('components.LeftMenu.single-types'),\n defaultMessage: 'Single Types',\n }),\n searchable: true,\n links: singleTypeLinks,\n },\n ].map((section) => ({\n ...section,\n links: section.links\n /**\n * Filter by the search value\n */\n .filter((link) => startsWith(link.title, search))\n /**\n * Sort correctly using the language\n */\n .sort((a, b) => formatter.compare(a.title, b.title))\n /**\n * Apply the formated strings to the links from react-intl\n */\n .map((link) => {\n return {\n ...link,\n title: formatMessage({ id: link.title, defaultMessage: link.title }),\n };\n }),\n })),\n [collectionTypeLinks, search, singleTypeLinks, startsWith, formatMessage, formatter]\n );\n\n const handleClear = () => {\n setSearch('');\n };\n\n const handleChangeSearch = ({ target: { value } }: { target: { value: string } }) => {\n setSearch(value);\n };\n\n const label = formatMessage({\n id: getTranslation('header.name'),\n defaultMessage: 'Content Manager',\n });\n\n const getPluginsParamsForLink = (link: ContentManagerLink) => {\n const schema = schemas.find((schema) => schema.uid === link.uid);\n const isI18nEnabled = Boolean((schema?.pluginOptions?.i18n as any)?.localized);\n\n // The search params have the i18n plugin\n if (query.plugins && 'i18n' in query.plugins) {\n // Prepare removal of i18n from the plugins search params\n const { i18n, ...restPlugins } = query.plugins;\n\n // i18n is not enabled, remove it from the plugins search params\n if (!isI18nEnabled) {\n return restPlugins;\n }\n\n // i18n is enabled, put the plugins search params back together\n return { i18n, ...restPlugins };\n }\n\n return query.plugins;\n };\n\n return (\n <SubNav aria-label={label}>\n <SubNavHeader\n label={label}\n searchable\n value={search}\n onChange={handleChangeSearch}\n onClear={handleClear}\n searchLabel={formatMessage({\n id: 'content-manager.components.LeftMenu.Search.label',\n defaultMessage: 'Search for a content type',\n })}\n />\n <SubNavSections>\n {menu.map((section) => {\n return (\n <SubNavSection\n key={section.id}\n label={section.title}\n badgeLabel={section.links.length.toString()}\n >\n {section.links.map((link) => {\n return (\n <SubNavLinkCustom\n tag={NavLink}\n key={link.uid}\n to={{\n pathname: link.to,\n search: stringify({\n ...parse(link.search ?? ''),\n plugins: getPluginsParamsForLink(link),\n }),\n }}\n width=\"100%\"\n >\n {link.title}\n </SubNavLinkCustom>\n );\n })}\n </SubNavSection>\n );\n })}\n </SubNavSections>\n </SubNav>\n );\n};\n\nexport { LeftMenu };\n","import { useEffect } from 'react';\n\nimport {\n useAuth,\n type Permission,\n useNotification,\n useStrapiApp,\n useAPIErrorHandler,\n} from '@strapi/admin/strapi-admin';\nimport { useNotifyAT } from '@strapi/design-system';\nimport { stringify } from 'qs';\nimport { useIntl } from 'react-intl';\n\nimport { COLLECTION_TYPES, SINGLE_TYPES } from '../constants/collections';\nimport { HOOKS } from '../constants/hooks';\nimport { AppState, setInitialData } from '../modules/app';\nimport { useTypedDispatch, useTypedSelector } from '../modules/hooks';\nimport { useGetAllContentTypeSettingsQuery } from '../services/contentTypes';\nimport { useGetInitialDataQuery } from '../services/init';\nimport { getTranslation } from '../utils/translations';\n\nimport type { Component } from '../../../shared/contracts/components';\nimport type {\n ContentType,\n FindContentTypesSettings,\n} from '../../../shared/contracts/content-types';\nimport type { GetInitData } from '../../../shared/contracts/init';\n\nconst { MUTATE_COLLECTION_TYPES_LINKS, MUTATE_SINGLE_TYPES_LINKS } = HOOKS;\n\ninterface ContentManagerLink {\n permissions: Permission[];\n search: string | null;\n kind: string;\n title: string;\n to: string;\n uid: string;\n name: string;\n isDisplayed: boolean;\n}\n\nconst useContentManagerInitData = (): AppState => {\n const { toggleNotification } = useNotification();\n const dispatch = useTypedDispatch();\n const runHookWaterfall = useStrapiApp(\n 'useContentManagerInitData',\n (state) => state.runHookWaterfall\n );\n const { notifyStatus } = useNotifyAT();\n const { formatMessage } = useIntl();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler(getTranslation);\n const checkUserHasPermissions = useAuth(\n 'useContentManagerInitData',\n (state) => state.checkUserHasPermissions\n );\n\n const state = useTypedSelector((state) => state['content-manager'].app);\n\n const initialDataQuery = useGetInitialDataQuery(undefined, {\n /**\n * TODO: remove this when the CTB has been refactored to use redux-toolkit-query\n * and it can invalidate the cache on mutation\n */\n refetchOnMountOrArgChange: true,\n });\n\n useEffect(() => {\n if (initialDataQuery.data) {\n notifyStatus(\n formatMessage({\n id: getTranslation('App.schemas.data-loaded'),\n defaultMessage: 'The schemas have been successfully loaded.',\n })\n );\n }\n }, [formatMessage, initialDataQuery.data, notifyStatus]);\n\n useEffect(() => {\n if (initialDataQuery.error) {\n toggleNotification({ type: 'danger', message: formatAPIError(initialDataQuery.error) });\n }\n }, [formatAPIError, initialDataQuery.error, toggleNotification]);\n\n const contentTypeSettingsQuery = useGetAllContentTypeSettingsQuery();\n\n useEffect(() => {\n if (contentTypeSettingsQuery.error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(contentTypeSettingsQuery.error),\n });\n }\n }, [formatAPIError, contentTypeSettingsQuery.error, toggleNotification]);\n\n const formatData = async (\n components: Component[],\n contentTypes: ContentType[],\n fieldSizes: GetInitData.Response['data']['fieldSizes'],\n contentTypeConfigurations: FindContentTypesSettings.Response['data']\n ) => {\n /**\n * We group these by the two types we support. We do with an object because we can use default\n * values of arrays to make sure we always have an array to manipulate further on if, for example,\n * a user has not made any single types.\n *\n * This means we have to manually add new content types to this hook if we add a new type – but\n * the safety is worth it.\n */\n const { collectionType: collectionTypeLinks, singleType: singleTypeLinks } =\n contentTypes.reduce<{\n collectionType: ContentType[];\n singleType: ContentType[];\n }>(\n (acc, model) => {\n acc[model.kind].push(model);\n return acc;\n },\n {\n collectionType: [],\n singleType: [],\n }\n );\n const collectionTypeSectionLinks = generateLinks(\n collectionTypeLinks,\n 'collectionTypes',\n contentTypeConfigurations\n );\n const singleTypeSectionLinks = generateLinks(singleTypeLinks, 'singleTypes');\n\n // Collection Types verifications\n const collectionTypeLinksPermissions = await Promise.all(\n collectionTypeSectionLinks.map(({ permissions }) => checkUserHasPermissions(permissions))\n );\n\n const authorizedCollectionTypeLinks = collectionTypeSectionLinks.filter(\n (_, index) => collectionTypeLinksPermissions[index].length > 0\n );\n\n // Single Types verifications\n const singleTypeLinksPermissions = await Promise.all(\n singleTypeSectionLinks.map(({ permissions }) => checkUserHasPermissions(permissions))\n );\n const authorizedSingleTypeLinks = singleTypeSectionLinks.filter(\n (_, index) => singleTypeLinksPermissions[index].length > 0\n );\n const { ctLinks } = runHookWaterfall(MUTATE_COLLECTION_TYPES_LINKS, {\n ctLinks: authorizedCollectionTypeLinks,\n models: contentTypes,\n });\n const { stLinks } = runHookWaterfall(MUTATE_SINGLE_TYPES_LINKS, {\n stLinks: authorizedSingleTypeLinks,\n models: contentTypes,\n });\n\n dispatch(\n setInitialData({\n authorizedCollectionTypeLinks: ctLinks,\n authorizedSingleTypeLinks: stLinks,\n components,\n contentTypeSchemas: contentTypes,\n fieldSizes,\n })\n );\n };\n\n useEffect(() => {\n if (initialDataQuery.data && contentTypeSettingsQuery.data) {\n formatData(\n initialDataQuery.data.components,\n initialDataQuery.data.contentTypes,\n initialDataQuery.data.fieldSizes,\n contentTypeSettingsQuery.data\n );\n }\n }, [initialDataQuery.data, contentTypeSettingsQuery.data]);\n\n return { ...state };\n};\n\nconst generateLinks = (\n links: ContentType[],\n type: 'collectionTypes' | 'singleTypes',\n configurations: FindContentTypesSettings.Response['data'] = []\n) => {\n return links\n .filter((link) => link.isDisplayed)\n .map((link) => {\n const collectionTypesPermissions = [\n { action: 'plugin::content-manager.explorer.create', subject: link.uid },\n { action: 'plugin::content-manager.explorer.read', subject: link.uid },\n ];\n const singleTypesPermissions = [\n { action: 'plugin::content-manager.explorer.read', subject: link.uid },\n ];\n const permissions =\n type === 'collectionTypes' ? collectionTypesPermissions : singleTypesPermissions;\n\n const currentContentTypeConfig = configurations.find(({ uid }) => uid === link.uid);\n\n let search = null;\n\n if (currentContentTypeConfig) {\n const searchParams = {\n page: 1,\n pageSize: currentContentTypeConfig.settings.pageSize,\n sort: `${currentContentTypeConfig.settings.defaultSortBy}:${currentContentTypeConfig.settings.defaultSortOrder}`,\n };\n\n search = stringify(searchParams, { encode: false });\n }\n\n return {\n permissions,\n search,\n kind: link.kind,\n title: link.info.displayName,\n to: `/content-manager/${link.kind === 'collectionType' ? COLLECTION_TYPES : SINGLE_TYPES}/${\n link.uid\n }`,\n uid: link.uid,\n // Used for the list item key in the helper plugin\n name: link.uid,\n isDisplayed: link.isDisplayed,\n } satisfies ContentManagerLink;\n });\n};\n\nexport { useContentManagerInitData };\nexport type { ContentManagerLink };\n","/* eslint-disable check-file/filename-naming-convention */\nimport * as React from 'react';\n\nimport { Page, useGuidedTour, Layouts } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\nimport { Navigate, Outlet, useLocation, useMatch } from 'react-router-dom';\n\nimport { DragLayer, DragLayerProps } from './components/DragLayer';\nimport { CardDragPreview } from './components/DragPreviews/CardDragPreview';\nimport { ComponentDragPreview } from './components/DragPreviews/ComponentDragPreview';\nimport { RelationDragPreview } from './components/DragPreviews/RelationDragPreview';\nimport { LeftMenu } from './components/LeftMenu';\nimport { ItemTypes } from './constants/dragAndDrop';\nimport { useContentManagerInitData } from './hooks/useContentManagerInitData';\nimport { getTranslation } from './utils/translations';\n\n/* -------------------------------------------------------------------------------------------------\n * Layout\n * -----------------------------------------------------------------------------------------------*/\n\nconst Layout = () => {\n const contentTypeMatch = useMatch('/content-manager/:kind/:uid/*');\n\n const { isLoading, collectionTypeLinks, models, singleTypeLinks } = useContentManagerInitData();\n const authorisedModels = [...collectionTypeLinks, ...singleTypeLinks].sort((a, b) =>\n a.title.localeCompare(b.title)\n );\n\n const { pathname } = useLocation();\n const { formatMessage } = useIntl();\n const startSection = useGuidedTour('Layout', (state) => state.startSection);\n const startSectionRef = React.useRef(startSection);\n\n React.useEffect(() => {\n if (startSectionRef.current) {\n startSectionRef.current('contentManager');\n }\n }, []);\n\n if (isLoading) {\n return (\n <>\n <Page.Title>\n {formatMessage({\n id: getTranslation('plugin.name'),\n defaultMessage: 'Content Manager',\n })}\n </Page.Title>\n <Page.Loading />\n </>\n );\n }\n\n // Array of models that are displayed in the content manager\n const supportedModelsToDisplay = models.filter(({ isDisplayed }) => isDisplayed);\n\n // Redirect the user to the 403 page\n if (\n authorisedModels.length === 0 &&\n supportedModelsToDisplay.length > 0 &&\n pathname !== '/content-manager/403'\n ) {\n return <Navigate to=\"/403\" />;\n }\n\n // Redirect the user to the create content type page\n if (supportedModelsToDisplay.length === 0 && pathname !== '/no-content-types') {\n return <Navigate to=\"/no-content-types\" />;\n }\n\n if (!contentTypeMatch && authorisedModels.length > 0) {\n return (\n <Navigate\n to={{\n pathname: authorisedModels[0].to,\n search: authorisedModels[0].search ?? '',\n }}\n replace\n />\n );\n }\n\n return (\n <>\n <Page.Title>\n {formatMessage({\n id: getTranslation('plugin.name'),\n defaultMessage: 'Content Manager',\n })}\n </Page.Title>\n <Layouts.Root sideNav={<LeftMenu />}>\n <DragLayer renderItem={renderDraglayerItem} />\n <Outlet />\n </Layouts.Root>\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * renderDraglayerItem\n * -----------------------------------------------------------------------------------------------*/\n\nfunction renderDraglayerItem({ type, item }: Parameters<DragLayerProps['renderItem']>[0]) {\n if (!type || (type && typeof type !== 'string')) {\n return null;\n }\n\n /**\n * Because a user may have multiple relations / dynamic zones / repeable fields in the same content type,\n * we append the fieldName for the item type to make them unique, however, we then want to extract that\n * first type to apply the correct preview.\n */\n const [actualType] = type.split('_');\n\n switch (actualType) {\n case ItemTypes.EDIT_FIELD:\n case ItemTypes.FIELD:\n return <CardDragPreview label={item.label} />;\n case ItemTypes.COMPONENT:\n case ItemTypes.DYNAMIC_ZONE:\n return <ComponentDragPreview displayedValue={item.displayedValue} />;\n\n case ItemTypes.RELATION:\n return <RelationDragPreview {...item} />;\n\n default:\n return null;\n }\n}\n\nexport { Layout };\n"],"names":["useDragLayer","jsx","Box","jsxs","Flex","CaretDown","Typography","IconButton","Trash","Drag","styled","FlexWrapper","LinkEllipsis","DocumentStatus","DisconnectButton","Cross","SubNavLink","React","useQueryParams","useIntl","useTypedSelector","useContentTypeSchema","useFilter","useCollator","getTranslation","schema","SubNav","SubNavHeader","SubNavSections","SubNavSection","NavLink","stringify","parse","HOOKS","useNotification","useTypedDispatch","useStrapiApp","state","useNotifyAT","useAPIErrorHandler","useAuth","useGetInitialDataQuery","useEffect","useGetAllContentTypeSettingsQuery","index","setInitialData","COLLECTION_TYPES","SINGLE_TYPES","useMatch","useLocation","useGuidedTour","Fragment","Page","Navigate","Layouts","Outlet","ItemTypes","CardDragPreview"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAAS,SACP,eACA,eACA,aACA;AACA,MAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,aAAa;AAC7C,WAAA,EAAE,SAAS;EACpB;AAEM,QAAA,EAAE,GAAG,EAAM,IAAA;AAEV,SAAA;AAAA,IACL,WAAW,aAAa,CAAC,OAAO,CAAC;AAAA,EAAA;AAErC;AAYA,MAAM,YAAY,CAAC,EAAE,iBAAiC;AACpD,QAAM,EAAE,UAAU,YAAY,MAAM,eAAe,eAAe,gBAAgBA,SAAA;AAAA,IAChF,CAAC,aAAa;AAAA,MACZ,MAAM,QAAQ,QAAQ;AAAA,MACtB,UAAU,QAAQ,YAAY;AAAA,MAC9B,eAAe,QAAQ,6BAA6B;AAAA,MACpD,eAAe,QAAQ,sBAAsB;AAAA,MAC7C,YAAY,QAAQ,WAAW;AAAA,MAC/B,aAAa,QAAQ,gBA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AAO;AAAA,MAAA;AAAA,IAAA;AAAA,EAGb;AAEA,SAEIlD,2BAAA,KAAAgD,qBAAA,EAAA,UAAA;AAAA,IAAClD,2BAAAA,IAAAmD,YAAAA,KAAK,OAAL,EACE,UAAc,cAAA;AAAA,MACb,IAAI5B,qBAAe,aAAa;AAAA,MAChC,gBAAgB;AAAA,IACjB,CAAA,GACH;AAAA,oCACC8B,YAAAA,QAAQ,MAAR,EAAa,SAASrD,2BAAAA,IAAC,YAAS,GAC/B,UAAA;AAAA,MAACA,2BAAAA,IAAA,WAAA,EAAU,YAAY,oBAAqB,CAAA;AAAA,qCAC3CsD,eAAO,QAAA,EAAA;AAAA,IAAA,GACV;AAAA,EACF,EAAA,CAAA;AAEJ;AAMA,SAAS,oBAAoB,EAAE,MAAM,QAAqD;AACxF,MAAI,CAAC,QAAS,QAAQ,OAAO,SAAS,UAAW;AACxC,WAAA;AAAA,EACT;AAOA,QAAM,CAAC,UAAU,IAAI,KAAK,MAAM,GAAG;AAEnC,UAAQ,YAAY;AAAA,IAClB,KAAKC,eAAAA,UAAU;AAAA,IACf,KAAKA,eAAU,UAAA;AACb,aAAQvD,2BAAAA,IAAAwD,gBAAAA,iBAAA,EAAgB,OAAO,KAAK,MAAO,CAAA;AAAA,IAC7C,KAAKD,eAAAA,UAAU;AAAA,IACf,KAAKA,eAAU,UAAA;AACb,aAAQvD,2BAAAA,IAAA,sBAAA,EAAqB,gBAAgB,KAAK,eAAgB,CAAA;AAAA,IAEpE,KAAKuD,eAAU,UAAA;AACN,aAAAvD,2BAAA,IAAC,qBAAqB,EAAA,GAAG,KAAM,CAAA;AAAA,IAExC;AACS,aAAA;AAAA,EACX;AACF;;"}
|
@@ -9,8 +9,8 @@ import { useDragLayer } from "react-dnd";
|
|
9
9
|
import { C as CardDragPreview } from "./CardDragPreview-DOxamsuj.mjs";
|
10
10
|
import { CaretDown, Trash, Drag, Cross } from "@strapi/icons";
|
11
11
|
import { styled } from "styled-components";
|
12
|
-
import { D as DocumentStatus, u as useContentTypeSchema, g as getTranslation, a as useGetInitialDataQuery, b as useGetAllContentTypeSettingsQuery, s as setInitialData, C as COLLECTION_TYPES, S as SINGLE_TYPES, H as HOOKS } from "./index-
|
13
|
-
import { F as FlexWrapper, L as LinkEllipsis, D as DisconnectButton } from "./Relations-
|
12
|
+
import { D as DocumentStatus, u as useContentTypeSchema, g as getTranslation, a as useGetInitialDataQuery, b as useGetAllContentTypeSettingsQuery, s as setInitialData, C as COLLECTION_TYPES, S as SINGLE_TYPES, H as HOOKS } from "./index-Ta--2bRa.mjs";
|
13
|
+
import { F as FlexWrapper, L as LinkEllipsis, D as DisconnectButton } from "./Relations-DUrYWw0N.mjs";
|
14
14
|
import { stringify, parse } from "qs";
|
15
15
|
import { u as useTypedSelector, a as useTypedDispatch } from "./hooks-E5u1mcgM.mjs";
|
16
16
|
import { I as ItemTypes } from "./useDragAndDrop-DdHgKsqq.mjs";
|
@@ -468,4 +468,4 @@ function renderDraglayerItem({ type, item }) {
|
|
468
468
|
export {
|
469
469
|
Layout
|
470
470
|
};
|
471
|
-
//# sourceMappingURL=layout-
|
471
|
+
//# sourceMappingURL=layout-C8H4oKDo.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"layout-Bue_C6ui.mjs","sources":["../../admin/src/components/DragLayer.tsx","../../admin/src/components/DragPreviews/ComponentDragPreview.tsx","../../admin/src/components/DragPreviews/RelationDragPreview.tsx","../../admin/src/components/LeftMenu.tsx","../../admin/src/hooks/useContentManagerInitData.ts","../../admin/src/layout.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box } from '@strapi/design-system';\nimport { DragLayerMonitor, XYCoord, useDragLayer } from 'react-dnd';\n\nfunction getStyle(\n initialOffset: XYCoord | null,\n currentOffset: XYCoord | null,\n mouseOffset: XYCoord | null\n) {\n if (!initialOffset || !currentOffset || !mouseOffset) {\n return { display: 'none' };\n }\n\n const { x, y } = mouseOffset;\n\n return {\n transform: `translate(${x}px, ${y}px)`,\n };\n}\n\nexport interface DragLayerProps {\n renderItem: (item: {\n /**\n * TODO: it'd be great if we could make this a union where the type infers the item.\n */\n item: any;\n type: ReturnType<DragLayerMonitor['getItemType']>;\n }) => React.ReactNode;\n}\n\nconst DragLayer = ({ renderItem }: DragLayerProps) => {\n const { itemType, isDragging, item, initialOffset, currentOffset, mouseOffset } = useDragLayer(\n (monitor) => ({\n item: monitor.getItem(),\n itemType: monitor.getItemType(),\n initialOffset: monitor.getInitialSourceClientOffset(),\n currentOffset: monitor.getSourceClientOffset(),\n isDragging: monitor.isDragging(),\n mouseOffset: monitor.getClientOffset(),\n })\n );\n\n if (!isDragging) {\n return null;\n }\n\n return (\n <Box\n height=\"100%\"\n left={0}\n position=\"fixed\"\n pointerEvents=\"none\"\n top={0}\n zIndex={100}\n width=\"100%\"\n >\n <Box style={getStyle(initialOffset, currentOffset, mouseOffset)}>\n {renderItem({ type: itemType, item })}\n </Box>\n </Box>\n );\n};\n\nexport { DragLayer };\n","import { Flex, FlexComponent, IconButton, Typography } from '@strapi/design-system';\nimport { CaretDown, Drag, Trash } from '@strapi/icons';\nimport { styled } from 'styled-components';\n\ninterface ComponentDragPreviewProps {\n displayedValue: string;\n}\n\nconst ComponentDragPreview = ({ displayedValue }: ComponentDragPreviewProps) => {\n return (\n <Flex\n background=\"neutral0\"\n borderColor=\"neutral200\"\n justifyContent=\"space-between\"\n gap={3}\n padding={3}\n width=\"30rem\"\n >\n <ToggleButton type=\"button\">\n <Flex gap={6}>\n <DropdownIconWrapper\n alignItems=\"center\"\n justifyContent=\"center\"\n background=\"neutral200\"\n height=\"3.2rem\"\n width=\"3.2rem\"\n >\n <CaretDown />\n </DropdownIconWrapper>\n\n <Flex maxWidth=\"15rem\">\n <Typography textColor=\"neutral700\" ellipsis>\n {displayedValue}\n </Typography>\n </Flex>\n </Flex>\n </ToggleButton>\n\n <Flex gap={2}>\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Trash />\n </IconButton>\n\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Drag />\n </IconButton>\n </Flex>\n </Flex>\n );\n};\n\nconst DropdownIconWrapper = styled<FlexComponent>(Flex)`\n border-radius: 50%;\n\n svg {\n height: 0.6rem;\n width: 1.1rem;\n > path {\n fill: ${({ theme }) => theme.colors.neutral600};\n }\n }\n`;\n\n// TODO: we shouldn't have to reset a whole button\nconst ToggleButton = styled.button`\n border: none;\n background: transparent;\n display: block;\n width: 100%;\n text-align: unset;\n padding: 0;\n`;\n\nexport { ComponentDragPreview };\nexport type { ComponentDragPreviewProps };\n","import { Box, Flex, IconButton, Typography } from '@strapi/design-system';\nimport { Cross, Drag } from '@strapi/icons';\n\nimport { DocumentStatus } from '../../pages/EditView/components/DocumentStatus';\nimport {\n DisconnectButton,\n LinkEllipsis,\n FlexWrapper,\n} from '../../pages/EditView/components/FormInputs/Relations';\n\nimport type { Data } from '@strapi/types';\n\ninterface RelationDragPreviewProps {\n status?: string;\n displayedValue: string;\n id: Data.ID;\n index: number;\n width: number;\n}\n\nconst RelationDragPreview = ({ status, displayedValue, width }: RelationDragPreviewProps) => {\n return (\n <Box style={{ width }}>\n <Flex\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={2}\n paddingRight={4}\n hasRadius\n borderWidth={1}\n background=\"neutral0\"\n borderColor=\"neutral200\"\n justifyContent=\"space-between\"\n gap={4}\n >\n <FlexWrapper gap={1}>\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Drag />\n </IconButton>\n <Flex width=\"100%\" minWidth={0} justifyContent=\"space-between\">\n <Box minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>\n <LinkEllipsis href=\"\">\n <Typography textColor=\"primary600\" ellipsis>\n {displayedValue}\n </Typography>\n </LinkEllipsis>\n </Box>\n {status ? <DocumentStatus status={status} /> : null}\n </Flex>\n </FlexWrapper>\n <DisconnectButton type=\"button\">\n <Cross width=\"12px\" />\n </DisconnectButton>\n </Flex>\n </Box>\n );\n};\n\nexport { RelationDragPreview };\nexport type { RelationDragPreviewProps };\n","import * as React from 'react';\n\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\nimport {\n useCollator,\n useFilter,\n SubNav,\n SubNavHeader,\n SubNavLink,\n SubNavSection,\n SubNavSections,\n} from '@strapi/design-system';\nimport { parse, stringify } from 'qs';\nimport { useIntl } from 'react-intl';\nimport { NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { useContentTypeSchema } from '../hooks/useContentTypeSchema';\nimport { useTypedSelector } from '../modules/hooks';\nimport { getTranslation } from '../utils/translations';\n\nimport type { ContentManagerLink } from '../hooks/useContentManagerInitData';\n\nconst SubNavLinkCustom = styled(SubNavLink)`\n div {\n width: inherit;\n span:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n width: inherit;\n }\n }\n`;\n\nconst LeftMenu = () => {\n const [search, setSearch] = React.useState('');\n const [{ query }] = useQueryParams<{ plugins?: object }>();\n const { formatMessage, locale } = useIntl();\n\n const collectionTypeLinks = useTypedSelector(\n (state) => state['content-manager'].app.collectionTypeLinks\n );\n\n const singleTypeLinks = useTypedSelector((state) => state['content-manager'].app.singleTypeLinks);\n const { schemas } = useContentTypeSchema();\n\n const { startsWith } = useFilter(locale, {\n sensitivity: 'base',\n });\n\n const formatter = useCollator(locale, {\n sensitivity: 'base',\n });\n\n const menu = React.useMemo(\n () =>\n [\n {\n id: 'collectionTypes',\n title: formatMessage({\n id: getTranslation('components.LeftMenu.collection-types'),\n defaultMessage: 'Collection Types',\n }),\n searchable: true,\n links: collectionTypeLinks,\n },\n {\n id: 'singleTypes',\n title: formatMessage({\n id: getTranslation('components.LeftMenu.single-types'),\n defaultMessage: 'Single Types',\n }),\n searchable: true,\n links: singleTypeLinks,\n },\n ].map((section) => ({\n ...section,\n links: section.links\n /**\n * Filter by the search value\n */\n .filter((link) => startsWith(link.title, search))\n /**\n * Sort correctly using the language\n */\n .sort((a, b) => formatter.compare(a.title, b.title))\n /**\n * Apply the formated strings to the links from react-intl\n */\n .map((link) => {\n return {\n ...link,\n title: formatMessage({ id: link.title, defaultMessage: link.title }),\n };\n }),\n })),\n [collectionTypeLinks, search, singleTypeLinks, startsWith, formatMessage, formatter]\n );\n\n const handleClear = () => {\n setSearch('');\n };\n\n const handleChangeSearch = ({ target: { value } }: { target: { value: string } }) => {\n setSearch(value);\n };\n\n const label = formatMessage({\n id: getTranslation('header.name'),\n defaultMessage: 'Content Manager',\n });\n\n const getPluginsParamsForLink = (link: ContentManagerLink) => {\n const schema = schemas.find((schema) => schema.uid === link.uid);\n const isI18nEnabled = Boolean((schema?.pluginOptions?.i18n as any)?.localized);\n\n // The search params have the i18n plugin\n if (query.plugins && 'i18n' in query.plugins) {\n // Prepare removal of i18n from the plugins search params\n const { i18n, ...restPlugins } = query.plugins;\n\n // i18n is not enabled, remove it from the plugins search params\n if (!isI18nEnabled) {\n return restPlugins;\n }\n\n // i18n is enabled, put the plugins search params back together\n return { i18n, ...restPlugins };\n }\n\n return query.plugins;\n };\n\n return (\n <SubNav aria-label={label}>\n <SubNavHeader\n label={label}\n searchable\n value={search}\n onChange={handleChangeSearch}\n onClear={handleClear}\n searchLabel={formatMessage({\n id: 'content-manager.components.LeftMenu.Search.label',\n defaultMessage: 'Search for a content type',\n })}\n />\n <SubNavSections>\n {menu.map((section) => {\n return (\n <SubNavSection\n key={section.id}\n label={section.title}\n badgeLabel={section.links.length.toString()}\n >\n {section.links.map((link) => {\n return (\n <SubNavLinkCustom\n tag={NavLink}\n key={link.uid}\n to={{\n pathname: link.to,\n search: stringify({\n ...parse(link.search ?? ''),\n plugins: getPluginsParamsForLink(link),\n }),\n }}\n width=\"100%\"\n >\n {link.title}\n </SubNavLinkCustom>\n );\n })}\n </SubNavSection>\n );\n })}\n </SubNavSections>\n </SubNav>\n );\n};\n\nexport { LeftMenu };\n","import { useEffect } from 'react';\n\nimport {\n useAuth,\n type Permission,\n useNotification,\n useStrapiApp,\n useAPIErrorHandler,\n} from '@strapi/admin/strapi-admin';\nimport { useNotifyAT } from '@strapi/design-system';\nimport { stringify } from 'qs';\nimport { useIntl } from 'react-intl';\n\nimport { COLLECTION_TYPES, SINGLE_TYPES } from '../constants/collections';\nimport { HOOKS } from '../constants/hooks';\nimport { AppState, setInitialData } from '../modules/app';\nimport { useTypedDispatch, useTypedSelector } from '../modules/hooks';\nimport { useGetAllContentTypeSettingsQuery } from '../services/contentTypes';\nimport { useGetInitialDataQuery } from '../services/init';\nimport { getTranslation } from '../utils/translations';\n\nimport type { Component } from '../../../shared/contracts/components';\nimport type {\n ContentType,\n FindContentTypesSettings,\n} from '../../../shared/contracts/content-types';\nimport type { GetInitData } from '../../../shared/contracts/init';\n\nconst { MUTATE_COLLECTION_TYPES_LINKS, MUTATE_SINGLE_TYPES_LINKS } = HOOKS;\n\ninterface ContentManagerLink {\n permissions: Permission[];\n search: string | null;\n kind: string;\n title: string;\n to: string;\n uid: string;\n name: string;\n isDisplayed: boolean;\n}\n\nconst useContentManagerInitData = (): AppState => {\n const { toggleNotification } = useNotification();\n const dispatch = useTypedDispatch();\n const runHookWaterfall = useStrapiApp(\n 'useContentManagerInitData',\n (state) => state.runHookWaterfall\n );\n const { notifyStatus } = useNotifyAT();\n const { formatMessage } = useIntl();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler(getTranslation);\n const checkUserHasPermissions = useAuth(\n 'useContentManagerInitData',\n (state) => state.checkUserHasPermissions\n );\n\n const state = useTypedSelector((state) => state['content-manager'].app);\n\n const initialDataQuery = useGetInitialDataQuery(undefined, {\n /**\n * TODO: remove this when the CTB has been refactored to use redux-toolkit-query\n * and it can invalidate the cache on mutation\n */\n refetchOnMountOrArgChange: true,\n });\n\n useEffect(() => {\n if (initialDataQuery.data) {\n notifyStatus(\n formatMessage({\n id: getTranslation('App.schemas.data-loaded'),\n defaultMessage: 'The schemas have been successfully loaded.',\n })\n );\n }\n }, [formatMessage, initialDataQuery.data, notifyStatus]);\n\n useEffect(() => {\n if (initialDataQuery.error) {\n toggleNotification({ type: 'danger', message: formatAPIError(initialDataQuery.error) });\n }\n }, [formatAPIError, initialDataQuery.error, toggleNotification]);\n\n const contentTypeSettingsQuery = useGetAllContentTypeSettingsQuery();\n\n useEffect(() => {\n if (contentTypeSettingsQuery.error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(contentTypeSettingsQuery.error),\n });\n }\n }, [formatAPIError, contentTypeSettingsQuery.error, toggleNotification]);\n\n const formatData = async (\n components: Component[],\n contentTypes: ContentType[],\n fieldSizes: GetInitData.Response['data']['fieldSizes'],\n contentTypeConfigurations: FindContentTypesSettings.Response['data']\n ) => {\n /**\n * We group these by the two types we support. We do with an object because we can use default\n * values of arrays to make sure we always have an array to manipulate further on if, for example,\n * a user has not made any single types.\n *\n * This means we have to manually add new content types to this hook if we add a new type – but\n * the safety is worth it.\n */\n const { collectionType: collectionTypeLinks, singleType: singleTypeLinks } =\n contentTypes.reduce<{\n collectionType: ContentType[];\n singleType: ContentType[];\n }>(\n (acc, model) => {\n acc[model.kind].push(model);\n return acc;\n },\n {\n collectionType: [],\n singleType: [],\n }\n );\n const collectionTypeSectionLinks = generateLinks(\n collectionTypeLinks,\n 'collectionTypes',\n contentTypeConfigurations\n );\n const singleTypeSectionLinks = generateLinks(singleTypeLinks, 'singleTypes');\n\n // Collection Types verifications\n const collectionTypeLinksPermissions = await Promise.all(\n collectionTypeSectionLinks.map(({ permissions }) => checkUserHasPermissions(permissions))\n );\n\n const authorizedCollectionTypeLinks = collectionTypeSectionLinks.filter(\n (_, index) => collectionTypeLinksPermissions[index].length > 0\n );\n\n // Single Types verifications\n const singleTypeLinksPermissions = await Promise.all(\n singleTypeSectionLinks.map(({ permissions }) => checkUserHasPermissions(permissions))\n );\n const authorizedSingleTypeLinks = singleTypeSectionLinks.filter(\n (_, index) => singleTypeLinksPermissions[index].length > 0\n );\n const { ctLinks } = runHookWaterfall(MUTATE_COLLECTION_TYPES_LINKS, {\n ctLinks: authorizedCollectionTypeLinks,\n models: contentTypes,\n });\n const { stLinks } = runHookWaterfall(MUTATE_SINGLE_TYPES_LINKS, {\n stLinks: authorizedSingleTypeLinks,\n models: contentTypes,\n });\n\n dispatch(\n setInitialData({\n authorizedCollectionTypeLinks: ctLinks,\n authorizedSingleTypeLinks: stLinks,\n components,\n contentTypeSchemas: contentTypes,\n fieldSizes,\n })\n );\n };\n\n useEffect(() => {\n if (initialDataQuery.data && contentTypeSettingsQuery.data) {\n formatData(\n initialDataQuery.data.components,\n initialDataQuery.data.contentTypes,\n initialDataQuery.data.fieldSizes,\n contentTypeSettingsQuery.data\n );\n }\n }, [initialDataQuery.data, contentTypeSettingsQuery.data]);\n\n return { ...state };\n};\n\nconst generateLinks = (\n links: ContentType[],\n type: 'collectionTypes' | 'singleTypes',\n configurations: FindContentTypesSettings.Response['data'] = []\n) => {\n return links\n .filter((link) => link.isDisplayed)\n .map((link) => {\n const collectionTypesPermissions = [\n { action: 'plugin::content-manager.explorer.create', subject: link.uid },\n { action: 'plugin::content-manager.explorer.read', subject: link.uid },\n ];\n const singleTypesPermissions = [\n { action: 'plugin::content-manager.explorer.read', subject: link.uid },\n ];\n const permissions =\n type === 'collectionTypes' ? collectionTypesPermissions : singleTypesPermissions;\n\n const currentContentTypeConfig = configurations.find(({ uid }) => uid === link.uid);\n\n let search = null;\n\n if (currentContentTypeConfig) {\n const searchParams = {\n page: 1,\n pageSize: currentContentTypeConfig.settings.pageSize,\n sort: `${currentContentTypeConfig.settings.defaultSortBy}:${currentContentTypeConfig.settings.defaultSortOrder}`,\n };\n\n search = stringify(searchParams, { encode: false });\n }\n\n return {\n permissions,\n search,\n kind: link.kind,\n title: link.info.displayName,\n to: `/content-manager/${link.kind === 'collectionType' ? COLLECTION_TYPES : SINGLE_TYPES}/${\n link.uid\n }`,\n uid: link.uid,\n // Used for the list item key in the helper plugin\n name: link.uid,\n isDisplayed: link.isDisplayed,\n } satisfies ContentManagerLink;\n });\n};\n\nexport { useContentManagerInitData };\nexport type { ContentManagerLink };\n","/* eslint-disable check-file/filename-naming-convention */\nimport * as React from 'react';\n\nimport { Page, useGuidedTour, Layouts } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\nimport { Navigate, Outlet, useLocation, useMatch } from 'react-router-dom';\n\nimport { DragLayer, DragLayerProps } from './components/DragLayer';\nimport { CardDragPreview } from './components/DragPreviews/CardDragPreview';\nimport { ComponentDragPreview } from './components/DragPreviews/ComponentDragPreview';\nimport { RelationDragPreview } from './components/DragPreviews/RelationDragPreview';\nimport { LeftMenu } from './components/LeftMenu';\nimport { ItemTypes } from './constants/dragAndDrop';\nimport { useContentManagerInitData } from './hooks/useContentManagerInitData';\nimport { getTranslation } from './utils/translations';\n\n/* -------------------------------------------------------------------------------------------------\n * Layout\n * -----------------------------------------------------------------------------------------------*/\n\nconst Layout = () => {\n const contentTypeMatch = useMatch('/content-manager/:kind/:uid/*');\n\n const { isLoading, collectionTypeLinks, models, singleTypeLinks } = useContentManagerInitData();\n const authorisedModels = [...collectionTypeLinks, ...singleTypeLinks].sort((a, b) =>\n a.title.localeCompare(b.title)\n );\n\n const { pathname } = useLocation();\n const { formatMessage } = useIntl();\n const startSection = useGuidedTour('Layout', (state) => state.startSection);\n const startSectionRef = React.useRef(startSection);\n\n React.useEffect(() => {\n if (startSectionRef.current) {\n startSectionRef.current('contentManager');\n }\n }, []);\n\n if (isLoading) {\n return (\n <>\n <Page.Title>\n {formatMessage({\n id: getTranslation('plugin.name'),\n defaultMessage: 'Content Manager',\n })}\n </Page.Title>\n <Page.Loading />\n </>\n );\n }\n\n // Array of models that are displayed in the content manager\n const supportedModelsToDisplay = models.filter(({ isDisplayed }) => isDisplayed);\n\n // Redirect the user to the 403 page\n if (\n authorisedModels.length === 0 &&\n supportedModelsToDisplay.length > 0 &&\n pathname !== '/content-manager/403'\n ) {\n return <Navigate to=\"/403\" />;\n }\n\n // Redirect the user to the create content type page\n if (supportedModelsToDisplay.length === 0 && pathname !== '/no-content-types') {\n return <Navigate to=\"/no-content-types\" />;\n }\n\n if (!contentTypeMatch && authorisedModels.length > 0) {\n return (\n <Navigate\n to={{\n pathname: authorisedModels[0].to,\n search: authorisedModels[0].search ?? '',\n }}\n replace\n />\n );\n }\n\n return (\n <>\n <Page.Title>\n {formatMessage({\n id: getTranslation('plugin.name'),\n defaultMessage: 'Content Manager',\n })}\n </Page.Title>\n <Layouts.Root sideNav={<LeftMenu />}>\n <DragLayer renderItem={renderDraglayerItem} />\n <Outlet />\n </Layouts.Root>\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * renderDraglayerItem\n * -----------------------------------------------------------------------------------------------*/\n\nfunction renderDraglayerItem({ type, item }: Parameters<DragLayerProps['renderItem']>[0]) {\n if (!type || (type && typeof type !== 'string')) {\n return null;\n }\n\n /**\n * Because a user may have multiple relations / dynamic zones / repeable fields in the same content type,\n * we append the fieldName for the item type to make them unique, however, we then want to extract that\n * first type to apply the correct preview.\n */\n const [actualType] = type.split('_');\n\n switch (actualType) {\n case ItemTypes.EDIT_FIELD:\n case ItemTypes.FIELD:\n return <CardDragPreview label={item.label} />;\n case ItemTypes.COMPONENT:\n case ItemTypes.DYNAMIC_ZONE:\n return <ComponentDragPreview displayedValue={item.displayedValue} />;\n\n case ItemTypes.RELATION:\n return <RelationDragPreview {...item} />;\n\n default:\n return null;\n }\n}\n\nexport { Layout };\n"],"names":["schema","state"],"mappings":";;;;;;;;;;;;;;;;AAKA,SAAS,SACP,eACA,eACA,aACA;AACA,MAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,aAAa;AAC7C,WAAA,EAAE,SAAS;EACpB;AAEM,QAAA,EAAE,GAAG,EAAM,IAAA;AAEV,SAAA;AAAA,IACL,WAAW,aAAa,CAAC,OAAO,CAAC;AAAA,EAAA;AAErC;AAYA,MAAM,YAAY,CAAC,EAAE,iBAAiC;AACpD,QAAM,EAAE,UAAU,YAAY,MAAM,eAAe,eAAe,gBAAgB;AAAA,IAChF,CAAC,aAAa;AAAA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ACf,KAAK,UAAU;AACb,aAAQ,oBAAA,iBAAA,EAAgB,OAAO,KAAK,MAAO,CAAA;AAAA,IAC7C,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AACb,aAAQ,oBAAA,sBAAA,EAAqB,gBAAgB,KAAK,eAAgB,CAAA;AAAA,IAEpE,KAAK,UAAU;AACN,aAAA,oBAAC,qBAAqB,EAAA,GAAG,KAAM,CAAA;AAAA,IAExC;AACS,aAAA;AAAA,EACX;AACF;"}
|
1
|
+
{"version":3,"file":"layout-C8H4oKDo.mjs","sources":["../../admin/src/components/DragLayer.tsx","../../admin/src/components/DragPreviews/ComponentDragPreview.tsx","../../admin/src/components/DragPreviews/RelationDragPreview.tsx","../../admin/src/components/LeftMenu.tsx","../../admin/src/hooks/useContentManagerInitData.ts","../../admin/src/layout.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box } from '@strapi/design-system';\nimport { DragLayerMonitor, XYCoord, useDragLayer } from 'react-dnd';\n\nfunction getStyle(\n initialOffset: XYCoord | null,\n currentOffset: XYCoord | null,\n mouseOffset: XYCoord | null\n) {\n if (!initialOffset || !currentOffset || !mouseOffset) {\n return { display: 'none' };\n }\n\n const { x, y } = mouseOffset;\n\n return {\n transform: `translate(${x}px, ${y}px)`,\n };\n}\n\nexport interface DragLayerProps {\n renderItem: (item: {\n /**\n * TODO: it'd be great if we could make this a union where the type infers the item.\n */\n item: any;\n type: ReturnType<DragLayerMonitor['getItemType']>;\n }) => React.ReactNode;\n}\n\nconst DragLayer = ({ renderItem }: DragLayerProps) => {\n const { itemType, isDragging, item, initialOffset, currentOffset, mouseOffset } = useDragLayer(\n (monitor) => ({\n item: monitor.getItem(),\n itemType: monitor.getItemType(),\n initialOffset: monitor.getInitialSourceClientOffset(),\n currentOffset: monitor.getSourceClientOffset(),\n isDragging: monitor.isDragging(),\n mouseOffset: monitor.getClientOffset(),\n })\n );\n\n if (!isDragging) {\n return null;\n }\n\n return (\n <Box\n height=\"100%\"\n left={0}\n position=\"fixed\"\n pointerEvents=\"none\"\n top={0}\n zIndex={100}\n width=\"100%\"\n >\n <Box style={getStyle(initialOffset, currentOffset, mouseOffset)}>\n {renderItem({ type: itemType, item })}\n </Box>\n </Box>\n );\n};\n\nexport { DragLayer };\n","import { Flex, FlexComponent, IconButton, Typography } from '@strapi/design-system';\nimport { CaretDown, Drag, Trash } from '@strapi/icons';\nimport { styled } from 'styled-components';\n\ninterface ComponentDragPreviewProps {\n displayedValue: string;\n}\n\nconst ComponentDragPreview = ({ displayedValue }: ComponentDragPreviewProps) => {\n return (\n <Flex\n background=\"neutral0\"\n borderColor=\"neutral200\"\n justifyContent=\"space-between\"\n gap={3}\n padding={3}\n width=\"30rem\"\n >\n <ToggleButton type=\"button\">\n <Flex gap={6}>\n <DropdownIconWrapper\n alignItems=\"center\"\n justifyContent=\"center\"\n background=\"neutral200\"\n height=\"3.2rem\"\n width=\"3.2rem\"\n >\n <CaretDown />\n </DropdownIconWrapper>\n\n <Flex maxWidth=\"15rem\">\n <Typography textColor=\"neutral700\" ellipsis>\n {displayedValue}\n </Typography>\n </Flex>\n </Flex>\n </ToggleButton>\n\n <Flex gap={2}>\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Trash />\n </IconButton>\n\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Drag />\n </IconButton>\n </Flex>\n </Flex>\n );\n};\n\nconst DropdownIconWrapper = styled<FlexComponent>(Flex)`\n border-radius: 50%;\n\n svg {\n height: 0.6rem;\n width: 1.1rem;\n > path {\n fill: ${({ theme }) => theme.colors.neutral600};\n }\n }\n`;\n\n// TODO: we shouldn't have to reset a whole button\nconst ToggleButton = styled.button`\n border: none;\n background: transparent;\n display: block;\n width: 100%;\n text-align: unset;\n padding: 0;\n`;\n\nexport { ComponentDragPreview };\nexport type { ComponentDragPreviewProps };\n","import { Box, Flex, IconButton, Typography } from '@strapi/design-system';\nimport { Cross, Drag } from '@strapi/icons';\n\nimport { DocumentStatus } from '../../pages/EditView/components/DocumentStatus';\nimport {\n DisconnectButton,\n LinkEllipsis,\n FlexWrapper,\n} from '../../pages/EditView/components/FormInputs/Relations';\n\nimport type { Data } from '@strapi/types';\n\ninterface RelationDragPreviewProps {\n status?: string;\n displayedValue: string;\n id: Data.ID;\n index: number;\n width: number;\n}\n\nconst RelationDragPreview = ({ status, displayedValue, width }: RelationDragPreviewProps) => {\n return (\n <Box style={{ width }}>\n <Flex\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={2}\n paddingRight={4}\n hasRadius\n borderWidth={1}\n background=\"neutral0\"\n borderColor=\"neutral200\"\n justifyContent=\"space-between\"\n gap={4}\n >\n <FlexWrapper gap={1}>\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Drag />\n </IconButton>\n <Flex width=\"100%\" minWidth={0} justifyContent=\"space-between\">\n <Box minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>\n <LinkEllipsis href=\"\">\n <Typography textColor=\"primary600\" ellipsis>\n {displayedValue}\n </Typography>\n </LinkEllipsis>\n </Box>\n {status ? <DocumentStatus status={status} /> : null}\n </Flex>\n </FlexWrapper>\n <DisconnectButton type=\"button\">\n <Cross width=\"12px\" />\n </DisconnectButton>\n </Flex>\n </Box>\n );\n};\n\nexport { RelationDragPreview };\nexport type { RelationDragPreviewProps };\n","import * as React from 'react';\n\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\nimport {\n useCollator,\n useFilter,\n SubNav,\n SubNavHeader,\n SubNavLink,\n SubNavSection,\n SubNavSections,\n} from '@strapi/design-system';\nimport { parse, stringify } from 'qs';\nimport { useIntl } from 'react-intl';\nimport { NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { useContentTypeSchema } from '../hooks/useContentTypeSchema';\nimport { useTypedSelector } from '../modules/hooks';\nimport { getTranslation } from '../utils/translations';\n\nimport type { ContentManagerLink } from '../hooks/useContentManagerInitData';\n\nconst SubNavLinkCustom = styled(SubNavLink)`\n div {\n width: inherit;\n span:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n width: inherit;\n }\n }\n`;\n\nconst LeftMenu = () => {\n const [search, setSearch] = React.useState('');\n const [{ query }] = useQueryParams<{ plugins?: object }>();\n const { formatMessage, locale } = useIntl();\n\n const collectionTypeLinks = useTypedSelector(\n (state) => state['content-manager'].app.collectionTypeLinks\n );\n\n const singleTypeLinks = useTypedSelector((state) => state['content-manager'].app.singleTypeLinks);\n const { schemas } = useContentTypeSchema();\n\n const { startsWith } = useFilter(locale, {\n sensitivity: 'base',\n });\n\n const formatter = useCollator(locale, {\n sensitivity: 'base',\n });\n\n const menu = React.useMemo(\n () =>\n [\n {\n id: 'collectionTypes',\n title: formatMessage({\n id: getTranslation('components.LeftMenu.collection-types'),\n defaultMessage: 'Collection Types',\n }),\n searchable: true,\n links: collectionTypeLinks,\n },\n {\n id: 'singleTypes',\n title: formatMessage({\n id: getTranslation('components.LeftMenu.single-types'),\n defaultMessage: 'Single Types',\n }),\n searchable: true,\n links: singleTypeLinks,\n },\n ].map((section) => ({\n ...section,\n links: section.links\n /**\n * Filter by the search value\n */\n .filter((link) => startsWith(link.title, search))\n /**\n * Sort correctly using the language\n */\n .sort((a, b) => formatter.compare(a.title, b.title))\n /**\n * Apply the formated strings to the links from react-intl\n */\n .map((link) => {\n return {\n ...link,\n title: formatMessage({ id: link.title, defaultMessage: link.title }),\n };\n }),\n })),\n [collectionTypeLinks, search, singleTypeLinks, startsWith, formatMessage, formatter]\n );\n\n const handleClear = () => {\n setSearch('');\n };\n\n const handleChangeSearch = ({ target: { value } }: { target: { value: string } }) => {\n setSearch(value);\n };\n\n const label = formatMessage({\n id: getTranslation('header.name'),\n defaultMessage: 'Content Manager',\n });\n\n const getPluginsParamsForLink = (link: ContentManagerLink) => {\n const schema = schemas.find((schema) => schema.uid === link.uid);\n const isI18nEnabled = Boolean((schema?.pluginOptions?.i18n as any)?.localized);\n\n // The search params have the i18n plugin\n if (query.plugins && 'i18n' in query.plugins) {\n // Prepare removal of i18n from the plugins search params\n const { i18n, ...restPlugins } = query.plugins;\n\n // i18n is not enabled, remove it from the plugins search params\n if (!isI18nEnabled) {\n return restPlugins;\n }\n\n // i18n is enabled, put the plugins search params back together\n return { i18n, ...restPlugins };\n }\n\n return query.plugins;\n };\n\n return (\n <SubNav aria-label={label}>\n <SubNavHeader\n label={label}\n searchable\n value={search}\n onChange={handleChangeSearch}\n onClear={handleClear}\n searchLabel={formatMessage({\n id: 'content-manager.components.LeftMenu.Search.label',\n defaultMessage: 'Search for a content type',\n })}\n />\n <SubNavSections>\n {menu.map((section) => {\n return (\n <SubNavSection\n key={section.id}\n label={section.title}\n badgeLabel={section.links.length.toString()}\n >\n {section.links.map((link) => {\n return (\n <SubNavLinkCustom\n tag={NavLink}\n key={link.uid}\n to={{\n pathname: link.to,\n search: stringify({\n ...parse(link.search ?? ''),\n plugins: getPluginsParamsForLink(link),\n }),\n }}\n width=\"100%\"\n >\n {link.title}\n </SubNavLinkCustom>\n );\n })}\n </SubNavSection>\n );\n })}\n </SubNavSections>\n </SubNav>\n );\n};\n\nexport { LeftMenu };\n","import { useEffect } from 'react';\n\nimport {\n useAuth,\n type Permission,\n useNotification,\n useStrapiApp,\n useAPIErrorHandler,\n} from '@strapi/admin/strapi-admin';\nimport { useNotifyAT } from '@strapi/design-system';\nimport { stringify } from 'qs';\nimport { useIntl } from 'react-intl';\n\nimport { COLLECTION_TYPES, SINGLE_TYPES } from '../constants/collections';\nimport { HOOKS } from '../constants/hooks';\nimport { AppState, setInitialData } from '../modules/app';\nimport { useTypedDispatch, useTypedSelector } from '../modules/hooks';\nimport { useGetAllContentTypeSettingsQuery } from '../services/contentTypes';\nimport { useGetInitialDataQuery } from '../services/init';\nimport { getTranslation } from '../utils/translations';\n\nimport type { Component } from '../../../shared/contracts/components';\nimport type {\n ContentType,\n FindContentTypesSettings,\n} from '../../../shared/contracts/content-types';\nimport type { GetInitData } from '../../../shared/contracts/init';\n\nconst { MUTATE_COLLECTION_TYPES_LINKS, MUTATE_SINGLE_TYPES_LINKS } = HOOKS;\n\ninterface ContentManagerLink {\n permissions: Permission[];\n search: string | null;\n kind: string;\n title: string;\n to: string;\n uid: string;\n name: string;\n isDisplayed: boolean;\n}\n\nconst useContentManagerInitData = (): AppState => {\n const { toggleNotification } = useNotification();\n const dispatch = useTypedDispatch();\n const runHookWaterfall = useStrapiApp(\n 'useContentManagerInitData',\n (state) => state.runHookWaterfall\n );\n const { notifyStatus } = useNotifyAT();\n const { formatMessage } = useIntl();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler(getTranslation);\n const checkUserHasPermissions = useAuth(\n 'useContentManagerInitData',\n (state) => state.checkUserHasPermissions\n );\n\n const state = useTypedSelector((state) => state['content-manager'].app);\n\n const initialDataQuery = useGetInitialDataQuery(undefined, {\n /**\n * TODO: remove this when the CTB has been refactored to use redux-toolkit-query\n * and it can invalidate the cache on mutation\n */\n refetchOnMountOrArgChange: true,\n });\n\n useEffect(() => {\n if (initialDataQuery.data) {\n notifyStatus(\n formatMessage({\n id: getTranslation('App.schemas.data-loaded'),\n defaultMessage: 'The schemas have been successfully loaded.',\n })\n );\n }\n }, [formatMessage, initialDataQuery.data, notifyStatus]);\n\n useEffect(() => {\n if (initialDataQuery.error) {\n toggleNotification({ type: 'danger', message: formatAPIError(initialDataQuery.error) });\n }\n }, [formatAPIError, initialDataQuery.error, toggleNotification]);\n\n const contentTypeSettingsQuery = useGetAllContentTypeSettingsQuery();\n\n useEffect(() => {\n if (contentTypeSettingsQuery.error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(contentTypeSettingsQuery.error),\n });\n }\n }, [formatAPIError, contentTypeSettingsQuery.error, toggleNotification]);\n\n const formatData = async (\n components: Component[],\n contentTypes: ContentType[],\n fieldSizes: GetInitData.Response['data']['fieldSizes'],\n contentTypeConfigurations: FindContentTypesSettings.Response['data']\n ) => {\n /**\n * We group these by the two types we support. We do with an object because we can use default\n * values of arrays to make sure we always have an array to manipulate further on if, for example,\n * a user has not made any single types.\n *\n * This means we have to manually add new content types to this hook if we add a new type – but\n * the safety is worth it.\n */\n const { collectionType: collectionTypeLinks, singleType: singleTypeLinks } =\n contentTypes.reduce<{\n collectionType: ContentType[];\n singleType: ContentType[];\n }>(\n (acc, model) => {\n acc[model.kind].push(model);\n return acc;\n },\n {\n collectionType: [],\n singleType: [],\n }\n );\n const collectionTypeSectionLinks = generateLinks(\n collectionTypeLinks,\n 'collectionTypes',\n contentTypeConfigurations\n );\n const singleTypeSectionLinks = generateLinks(singleTypeLinks, 'singleTypes');\n\n // Collection Types verifications\n const collectionTypeLinksPermissions = await Promise.all(\n collectionTypeSectionLinks.map(({ permissions }) => checkUserHasPermissions(permissions))\n );\n\n const authorizedCollectionTypeLinks = collectionTypeSectionLinks.filter(\n (_, index) => collectionTypeLinksPermissions[index].length > 0\n );\n\n // Single Types verifications\n const singleTypeLinksPermissions = await Promise.all(\n singleTypeSectionLinks.map(({ permissions }) => checkUserHasPermissions(permissions))\n );\n const authorizedSingleTypeLinks = singleTypeSectionLinks.filter(\n (_, index) => singleTypeLinksPermissions[index].length > 0\n );\n const { ctLinks } = runHookWaterfall(MUTATE_COLLECTION_TYPES_LINKS, {\n ctLinks: authorizedCollectionTypeLinks,\n models: contentTypes,\n });\n const { stLinks } = runHookWaterfall(MUTATE_SINGLE_TYPES_LINKS, {\n stLinks: authorizedSingleTypeLinks,\n models: contentTypes,\n });\n\n dispatch(\n setInitialData({\n authorizedCollectionTypeLinks: ctLinks,\n authorizedSingleTypeLinks: stLinks,\n components,\n contentTypeSchemas: contentTypes,\n fieldSizes,\n })\n );\n };\n\n useEffect(() => {\n if (initialDataQuery.data && contentTypeSettingsQuery.data) {\n formatData(\n initialDataQuery.data.components,\n initialDataQuery.data.contentTypes,\n initialDataQuery.data.fieldSizes,\n contentTypeSettingsQuery.data\n );\n }\n }, [initialDataQuery.data, contentTypeSettingsQuery.data]);\n\n return { ...state };\n};\n\nconst generateLinks = (\n links: ContentType[],\n type: 'collectionTypes' | 'singleTypes',\n configurations: FindContentTypesSettings.Response['data'] = []\n) => {\n return links\n .filter((link) => link.isDisplayed)\n .map((link) => {\n const collectionTypesPermissions = [\n { action: 'plugin::content-manager.explorer.create', subject: link.uid },\n { action: 'plugin::content-manager.explorer.read', subject: link.uid },\n ];\n const singleTypesPermissions = [\n { action: 'plugin::content-manager.explorer.read', subject: link.uid },\n ];\n const permissions =\n type === 'collectionTypes' ? collectionTypesPermissions : singleTypesPermissions;\n\n const currentContentTypeConfig = configurations.find(({ uid }) => uid === link.uid);\n\n let search = null;\n\n if (currentContentTypeConfig) {\n const searchParams = {\n page: 1,\n pageSize: currentContentTypeConfig.settings.pageSize,\n sort: `${currentContentTypeConfig.settings.defaultSortBy}:${currentContentTypeConfig.settings.defaultSortOrder}`,\n };\n\n search = stringify(searchParams, { encode: false });\n }\n\n return {\n permissions,\n search,\n kind: link.kind,\n title: link.info.displayName,\n to: `/content-manager/${link.kind === 'collectionType' ? COLLECTION_TYPES : SINGLE_TYPES}/${\n link.uid\n }`,\n uid: link.uid,\n // Used for the list item key in the helper plugin\n name: link.uid,\n isDisplayed: link.isDisplayed,\n } satisfies ContentManagerLink;\n });\n};\n\nexport { useContentManagerInitData };\nexport type { ContentManagerLink };\n","/* eslint-disable check-file/filename-naming-convention */\nimport * as React from 'react';\n\nimport { Page, useGuidedTour, Layouts } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\nimport { Navigate, Outlet, useLocation, useMatch } from 'react-router-dom';\n\nimport { DragLayer, DragLayerProps } from './components/DragLayer';\nimport { CardDragPreview } from './components/DragPreviews/CardDragPreview';\nimport { ComponentDragPreview } from './components/DragPreviews/ComponentDragPreview';\nimport { RelationDragPreview } from './components/DragPreviews/RelationDragPreview';\nimport { LeftMenu } from './components/LeftMenu';\nimport { ItemTypes } from './constants/dragAndDrop';\nimport { useContentManagerInitData } from './hooks/useContentManagerInitData';\nimport { getTranslation } from './utils/translations';\n\n/* -------------------------------------------------------------------------------------------------\n * Layout\n * -----------------------------------------------------------------------------------------------*/\n\nconst Layout = () => {\n const contentTypeMatch = useMatch('/content-manager/:kind/:uid/*');\n\n const { isLoading, collectionTypeLinks, models, singleTypeLinks } = useContentManagerInitData();\n const authorisedModels = [...collectionTypeLinks, ...singleTypeLinks].sort((a, b) =>\n a.title.localeCompare(b.title)\n );\n\n const { pathname } = useLocation();\n const { formatMessage } = useIntl();\n const startSection = useGuidedTour('Layout', (state) => state.startSection);\n const startSectionRef = React.useRef(startSection);\n\n React.useEffect(() => {\n if (startSectionRef.current) {\n startSectionRef.current('contentManager');\n }\n }, []);\n\n if (isLoading) {\n return (\n <>\n <Page.Title>\n {formatMessage({\n id: getTranslation('plugin.name'),\n defaultMessage: 'Content Manager',\n })}\n </Page.Title>\n <Page.Loading />\n </>\n );\n }\n\n // Array of models that are displayed in the content manager\n const supportedModelsToDisplay = models.filter(({ isDisplayed }) => isDisplayed);\n\n // Redirect the user to the 403 page\n if (\n authorisedModels.length === 0 &&\n supportedModelsToDisplay.length > 0 &&\n pathname !== '/content-manager/403'\n ) {\n return <Navigate to=\"/403\" />;\n }\n\n // Redirect the user to the create content type page\n if (supportedModelsToDisplay.length === 0 && pathname !== '/no-content-types') {\n return <Navigate to=\"/no-content-types\" />;\n }\n\n if (!contentTypeMatch && authorisedModels.length > 0) {\n return (\n <Navigate\n to={{\n pathname: authorisedModels[0].to,\n search: authorisedModels[0].search ?? '',\n }}\n replace\n />\n );\n }\n\n return (\n <>\n <Page.Title>\n {formatMessage({\n id: getTranslation('plugin.name'),\n defaultMessage: 'Content Manager',\n })}\n </Page.Title>\n <Layouts.Root sideNav={<LeftMenu />}>\n <DragLayer renderItem={renderDraglayerItem} />\n <Outlet />\n </Layouts.Root>\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * renderDraglayerItem\n * -----------------------------------------------------------------------------------------------*/\n\nfunction renderDraglayerItem({ type, item }: Parameters<DragLayerProps['renderItem']>[0]) {\n if (!type || (type && typeof type !== 'string')) {\n return null;\n }\n\n /**\n * Because a user may have multiple relations / dynamic zones / repeable fields in the same content type,\n * we append the fieldName for the item type to make them unique, however, we then want to extract that\n * first type to apply the correct preview.\n */\n const [actualType] = type.split('_');\n\n switch (actualType) {\n case ItemTypes.EDIT_FIELD:\n case ItemTypes.FIELD:\n return <CardDragPreview label={item.label} />;\n case ItemTypes.COMPONENT:\n case ItemTypes.DYNAMIC_ZONE:\n return <ComponentDragPreview displayedValue={item.displayedValue} />;\n\n case ItemTypes.RELATION:\n return <RelationDragPreview {...item} />;\n\n default:\n return null;\n }\n}\n\nexport { Layout };\n"],"names":["schema","state"],"mappings":";;;;;;;;;;;;;;;;AAKA,SAAS,SACP,eACA,eACA,aACA;AACA,MAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,aAAa;AAC7C,WAAA,EAAE,SAAS;EACpB;AAEM,QAAA,EAAE,GAAG,EAAM,IAAA;AAEV,SAAA;AAAA,IACL,WAAW,aAAa,CAAC,OAAO,CAAC;AAAA,EAAA;AAErC;AAYA,MAAM,YAAY,CAAC,EAAE,iBAAiC;AACpD,QAAM,EAAE,UAAU,YAAY,MAAM,eAAe,eAAe,gBAAgB;AAAA,IAChF,CAAC,aAAa;AAAA,MACZ,MAAM,QAAQ,QAAQ;AAAA,MACtB,UAAU,QAAQ,YAAY;AAAA,MAC9B,eAAe,QAAQ,6BAA6B;AAAA,MACpD,eAAe,QAAQ,sBAAsB;AAAA,MAC7C,YAAY,QAAQ,WAAW;AAAA,MAC/B,aAAa,QAAQ,gBAAgB;AAAA,IAAA;AAAA,EACvC;AAGF,MAAI,CAAC,YAAY;AACR,WAAA;AAAA,EACT;AAGE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,QAAO;AAAA,MACP,MAAM;AAAA,MACN,UAAS;AAAA,MACT,eAAc;AAAA,MACd,KAAK;AAAA,MACL,QAAQ;AAAA,MACR,OAAM;AAAA,MAEN,UAAC,oBAAA,KAAA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,iBAAiB,SAAS,GAAG;AAElD,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAI;AAAA,UACF,UAAU,iBAAiB,CAAC,EAAE;AAAA,UAC9B,QAAQ,iBAAiB,CAAC,EAAE,UAAU;AAAA,QACxC;AAAA,QACA,SAAO;AAAA,MAAA;AAAA,IAAA;AAAA,EAGb;AAEA,SAEI,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAC,oBAAA,KAAK,OAAL,EACE,UAAc,cAAA;AAAA,MACb,IAAI,eAAe,aAAa;AAAA,MAChC,gBAAgB;AAAA,IACjB,CAAA,GACH;AAAA,yBACC,QAAQ,MAAR,EAAa,SAAS,oBAAC,YAAS,GAC/B,UAAA;AAAA,MAAC,oBAAA,WAAA,EAAU,YAAY,oBAAqB,CAAA;AAAA,0BAC3C,QAAO,EAAA;AAAA,IAAA,GACV;AAAA,EACF,EAAA,CAAA;AAEJ;AAMA,SAAS,oBAAoB,EAAE,MAAM,QAAqD;AACxF,MAAI,CAAC,QAAS,QAAQ,OAAO,SAAS,UAAW;AACxC,WAAA;AAAA,EACT;AAOA,QAAM,CAAC,UAAU,IAAI,KAAK,MAAM,GAAG;AAEnC,UAAQ,YAAY;AAAA,IAClB,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AACb,aAAQ,oBAAA,iBAAA,EAAgB,OAAO,KAAK,MAAO,CAAA;AAAA,IAC7C,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AACb,aAAQ,oBAAA,sBAAA,EAAqB,gBAAgB,KAAK,eAAgB,CAAA;AAAA,IAEpE,KAAK,UAAU;AACN,aAAA,oBAAC,qBAAqB,EAAA,GAAG,KAAM,CAAA;AAAA,IAExC;AACS,aAAA;AAAA,EACX;AACF;"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
const fractionalIndexing = require("fractional-indexing");
|
3
|
-
const index = require("./index-
|
3
|
+
const index = require("./index-_j7lH3CO.js");
|
4
4
|
const relationsApi = index.contentManagerApi.injectEndpoints({
|
5
5
|
endpoints: (build) => ({
|
6
6
|
getRelations: build.query({
|
@@ -130,4 +130,4 @@ const getRelationLabel = (relation, mainField) => {
|
|
130
130
|
exports.getRelationLabel = getRelationLabel;
|
131
131
|
exports.useGetRelationsQuery = useGetRelationsQuery;
|
132
132
|
exports.useLazySearchRelationsQuery = useLazySearchRelationsQuery;
|
133
|
-
//# sourceMappingURL=relations-
|
133
|
+
//# sourceMappingURL=relations-CPfMNzM6.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"relations-C4HcWYYJ.js","sources":["../../admin/src/services/relations.ts","../../admin/src/utils/relations.ts"],"sourcesContent":["import { generateNKeysBetween } from 'fractional-indexing';\n\nimport {\n RelationResult as RelResult,\n FindAvailable,\n FindExisting,\n} from '../../../shared/contracts/relations';\n\nimport { contentManagerApi } from './api';\n\nimport type { Modules } from '@strapi/types';\nimport type { errors } from '@strapi/utils';\n\ninterface RelationResult extends RelResult {\n __temp_key__: string;\n}\n\ntype GetRelationsResponse =\n | {\n results: Array<RelationResult>;\n pagination: {\n page: NonNullable<Modules.EntityService.Params.Pagination.PageNotation['page']>;\n pageSize: NonNullable<Modules.EntityService.Params.Pagination.PageNotation['pageSize']>;\n pageCount: number;\n total: number;\n } | null;\n error?: never;\n }\n | {\n results?: never;\n pagination?: never;\n error: errors.ApplicationError | errors.YupValidationError;\n };\n\nconst relationsApi = contentManagerApi.injectEndpoints({\n endpoints: (build) => ({\n getRelations: build.query<\n GetRelationsResponse,\n FindExisting.Params & {\n params?: FindExisting.Request['query'];\n }\n >({\n query: ({ model, id, targetField, params }) => {\n return {\n url: `/content-manager/relations/${model}/${id}/${targetField}`,\n method: 'GET',\n config: {\n params,\n },\n };\n },\n serializeQueryArgs: (args) => {\n const { endpointName, queryArgs } = args;\n return {\n endpointName,\n model: queryArgs.model,\n id: queryArgs.id,\n targetField: queryArgs.targetField,\n locale: queryArgs.params?.locale,\n status: queryArgs.params?.status,\n };\n },\n merge: (currentCache, newItems) => {\n if (currentCache.pagination && newItems.pagination) {\n if (currentCache.pagination.page < newItems.pagination.page) {\n /**\n * Relations will always have unique IDs, so we can therefore assume\n * that we only need to push the new items to the cache.\n *\n * Push new items at the beginning as latest items are shown first\n */\n currentCache.results = [\n ...prepareTempKeys(newItems.results, currentCache.results),\n ...currentCache.results,\n ];\n currentCache.pagination = newItems.pagination;\n } else if (newItems.pagination.page === 1) {\n /**\n * We're resetting the relations\n */\n currentCache.results = prepareTempKeys(newItems.results);\n currentCache.pagination = newItems.pagination;\n }\n }\n },\n forceRefetch({ currentArg, previousArg }) {\n if (!currentArg?.params && !previousArg?.params) {\n return false;\n }\n\n return (\n currentArg?.params?.page !== previousArg?.params?.page ||\n currentArg?.params?.pageSize !== previousArg?.params?.pageSize\n );\n },\n transformResponse: (response: FindExisting.Response) => {\n if ('results' in response && response.results) {\n return {\n ...response,\n results: prepareTempKeys(response.results.toReversed()),\n };\n } else {\n return response;\n }\n },\n providesTags: ['Relations'],\n }),\n searchRelations: build.query<\n FindAvailable.Response,\n FindAvailable.Params & {\n params?: FindAvailable.Request['query'];\n }\n >({\n query: ({ model, targetField, params }) => {\n return {\n url: `/content-manager/relations/${model}/${targetField}`,\n method: 'GET',\n config: {\n params,\n },\n };\n },\n serializeQueryArgs: (args) => {\n const { endpointName, queryArgs } = args;\n return {\n endpointName,\n model: queryArgs.model,\n targetField: queryArgs.targetField,\n _q: queryArgs.params?._q,\n idsToOmit: queryArgs.params?.idsToOmit,\n idsToInclude: queryArgs.params?.idsToInclude,\n };\n },\n merge: (currentCache, newItems) => {\n if (currentCache.pagination && newItems.pagination) {\n if (currentCache.pagination.page < newItems.pagination.page) {\n /**\n * Relations will always have unique IDs, so we can therefore assume\n * that we only need to push the new items to the cache.\n */\n const existingIds = currentCache.results.map((item) => item.documentId);\n const uniqueNewItems = newItems.results.filter(\n (item) => !existingIds.includes(item.documentId)\n );\n currentCache.results.push(...uniqueNewItems);\n currentCache.pagination = newItems.pagination;\n } else if (newItems.pagination.page === 1) {\n /**\n * We're resetting the relations\n */\n currentCache.results = newItems.results;\n currentCache.pagination = newItems.pagination;\n }\n }\n },\n forceRefetch({ currentArg, previousArg }) {\n if (!currentArg?.params && !previousArg?.params) {\n return false;\n }\n\n return (\n currentArg?.params?.page !== previousArg?.params?.page ||\n currentArg?.params?.pageSize !== previousArg?.params?.pageSize\n );\n },\n transformResponse: (response: FindAvailable.Response) => {\n if (response.results) {\n return {\n ...response,\n results: response.results,\n };\n } else {\n return response;\n }\n },\n }),\n }),\n});\n\n/**\n * @internal\n * @description Adds a `__temp_key__` to each relation item. This gives us\n * a stable identifier regardless of it's ids etc. that we can then use for drag and drop.\n */\nconst prepareTempKeys = (relations: RelResult[], existingRelations: RelationResult[] = []) => {\n const [firstItem] = existingRelations.slice(0);\n const keys = generateNKeysBetween(null, firstItem?.__temp_key__ ?? null, relations.length);\n\n return relations.map((datum, index) => ({\n ...datum,\n __temp_key__: keys[index],\n }));\n};\n\nconst { useGetRelationsQuery, useLazySearchRelationsQuery } = relationsApi;\n\nexport { useGetRelationsQuery, useLazySearchRelationsQuery };\nexport type { RelationResult };\n","import type { MainField } from './attributes';\nimport type { RelationResult } from '../../../shared/contracts/relations';\n\n/**\n * @internal\n * @description Get the label of a relation, the contract has [key: string]: unknown,\n * so we need to check if the mainFieldKey is defined and if the relation has a value\n * under that property. If it does, we then verify it's type of string and return it.\n *\n * We fallback to the documentId.\n */\nconst getRelationLabel = (relation: RelationResult, mainField?: MainField): string => {\n const label = mainField && relation[mainField.name] ? relation[mainField.name] : null;\n\n if (typeof label === 'string') {\n return label;\n }\n\n return relation.documentId;\n};\n\nexport { getRelationLabel };\n"],"names":["contentManagerApi","generateNKeysBetween","index"],"mappings":";;;AAkCA,MAAM,eAAeA,wBAAkB,gBAAgB;AAAA,EACrD,WAAW,CAAC,WAAW;AAAA,IACrB,cAAc,MAAM,MAKlB;AAAA,MACA,OAAO,CAAC,EAAE,OAAO,IAAI,aAAa,a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,YAAI,SAAS,SAAS;AACb,iBAAA;AAAA,YACL,GAAG;AAAA,YACH,SAAS,SAAS;AAAA,UAAA;AAAA,QACpB,OACK;AACE,iBAAA;AAAA,QACT;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EAAA;AAEL,CAAC;AAOD,MAAM,kBAAkB,CAAC,WAAwB,oBAAsC,OAAO;AAC5F,QAAM,CAAC,SAAS,IAAI,kBAAkB,MAAM,CAAC;AAC7C,QAAM,OAAOC,mBAAqB,qBAAA,MAAM,WAAW,gBAAgB,MAAM,UAAU,MAAM;AAEzF,SAAO,UAAU,IAAI,CAAC,OAAOC,YAAW;AAAA,IACtC,GAAG;AAAA,IACH,cAAc,KAAKA,MAAK;AAAA,EACxB,EAAA;AACJ;AAEM,MAAA,EAAE,sBAAsB,gCAAgC;ACvLxD,MAAA,mBAAmB,CAAC,UAA0B,cAAkC;AAC9E,QAAA,QAAQ,aAAa,SAAS,UAAU,IAAI,IAAI,SAAS,UAAU,IAAI,IAAI;AAE7E,MAAA,OAAO,UAAU,UAAU;AACtB,WAAA;AAAA,EACT;AAEA,SAAO,SAAS;AAClB;;;;"}
|
1
|
+
{"version":3,"file":"relations-CPfMNzM6.js","sources":["../../admin/src/services/relations.ts","../../admin/src/utils/relations.ts"],"sourcesContent":["import { generateNKeysBetween } from 'fractional-indexing';\n\nimport {\n RelationResult as RelResult,\n FindAvailable,\n FindExisting,\n} from '../../../shared/contracts/relations';\n\nimport { contentManagerApi } from './api';\n\nimport type { Modules } from '@strapi/types';\nimport type { errors } from '@strapi/utils';\n\ninterface RelationResult extends RelResult {\n __temp_key__: string;\n}\n\ntype GetRelationsResponse =\n | {\n results: Array<RelationResult>;\n pagination: {\n page: NonNullable<Modules.EntityService.Params.Pagination.PageNotation['page']>;\n pageSize: NonNullable<Modules.EntityService.Params.Pagination.PageNotation['pageSize']>;\n pageCount: number;\n total: number;\n } | null;\n error?: never;\n }\n | {\n results?: never;\n pagination?: never;\n error: errors.ApplicationError | errors.YupValidationError;\n };\n\nconst relationsApi = contentManagerApi.injectEndpoints({\n endpoints: (build) => ({\n getRelations: build.query<\n GetRelationsResponse,\n FindExisting.Params & {\n params?: FindExisting.Request['query'];\n }\n >({\n query: ({ model, id, targetField, params }) => {\n return {\n url: `/content-manager/relations/${model}/${id}/${targetField}`,\n method: 'GET',\n config: {\n params,\n },\n };\n },\n serializeQueryArgs: (args) => {\n const { endpointName, queryArgs } = args;\n return {\n endpointName,\n model: queryArgs.model,\n id: queryArgs.id,\n targetField: queryArgs.targetField,\n locale: queryArgs.params?.locale,\n status: queryArgs.params?.status,\n };\n },\n merge: (currentCache, newItems) => {\n if (currentCache.pagination && newItems.pagination) {\n if (currentCache.pagination.page < newItems.pagination.page) {\n /**\n * Relations will always have unique IDs, so we can therefore assume\n * that we only need to push the new items to the cache.\n *\n * Push new items at the beginning as latest items are shown first\n */\n currentCache.results = [\n ...prepareTempKeys(newItems.results, currentCache.results),\n ...currentCache.results,\n ];\n currentCache.pagination = newItems.pagination;\n } else if (newItems.pagination.page === 1) {\n /**\n * We're resetting the relations\n */\n currentCache.results = prepareTempKeys(newItems.results);\n currentCache.pagination = newItems.pagination;\n }\n }\n },\n forceRefetch({ currentArg, previousArg }) {\n if (!currentArg?.params && !previousArg?.params) {\n return false;\n }\n\n return (\n currentArg?.params?.page !== previousArg?.params?.page ||\n currentArg?.params?.pageSize !== previousArg?.params?.pageSize\n );\n },\n transformResponse: (response: FindExisting.Response) => {\n if ('results' in response && response.results) {\n return {\n ...response,\n results: prepareTempKeys(response.results.toReversed()),\n };\n } else {\n return response;\n }\n },\n providesTags: ['Relations'],\n }),\n searchRelations: build.query<\n FindAvailable.Response,\n FindAvailable.Params & {\n params?: FindAvailable.Request['query'];\n }\n >({\n query: ({ model, targetField, params }) => {\n return {\n url: `/content-manager/relations/${model}/${targetField}`,\n method: 'GET',\n config: {\n params,\n },\n };\n },\n serializeQueryArgs: (args) => {\n const { endpointName, queryArgs } = args;\n return {\n endpointName,\n model: queryArgs.model,\n targetField: queryArgs.targetField,\n _q: queryArgs.params?._q,\n idsToOmit: queryArgs.params?.idsToOmit,\n idsToInclude: queryArgs.params?.idsToInclude,\n };\n },\n merge: (currentCache, newItems) => {\n if (currentCache.pagination && newItems.pagination) {\n if (currentCache.pagination.page < newItems.pagination.page) {\n /**\n * Relations will always have unique IDs, so we can therefore assume\n * that we only need to push the new items to the cache.\n */\n const existingIds = currentCache.results.map((item) => item.documentId);\n const uniqueNewItems = newItems.results.filter(\n (item) => !existingIds.includes(item.documentId)\n );\n currentCache.results.push(...uniqueNewItems);\n currentCache.pagination = newItems.pagination;\n } else if (newItems.pagination.page === 1) {\n /**\n * We're resetting the relations\n */\n currentCache.results = newItems.results;\n currentCache.pagination = newItems.pagination;\n }\n }\n },\n forceRefetch({ currentArg, previousArg }) {\n if (!currentArg?.params && !previousArg?.params) {\n return false;\n }\n\n return (\n currentArg?.params?.page !== previousArg?.params?.page ||\n currentArg?.params?.pageSize !== previousArg?.params?.pageSize\n );\n },\n transformResponse: (response: FindAvailable.Response) => {\n if (response.results) {\n return {\n ...response,\n results: response.results,\n };\n } else {\n return response;\n }\n },\n }),\n }),\n});\n\n/**\n * @internal\n * @description Adds a `__temp_key__` to each relation item. This gives us\n * a stable identifier regardless of it's ids etc. that we can then use for drag and drop.\n */\nconst prepareTempKeys = (relations: RelResult[], existingRelations: RelationResult[] = []) => {\n const [firstItem] = existingRelations.slice(0);\n const keys = generateNKeysBetween(null, firstItem?.__temp_key__ ?? null, relations.length);\n\n return relations.map((datum, index) => ({\n ...datum,\n __temp_key__: keys[index],\n }));\n};\n\nconst { useGetRelationsQuery, useLazySearchRelationsQuery } = relationsApi;\n\nexport { useGetRelationsQuery, useLazySearchRelationsQuery };\nexport type { RelationResult };\n","import type { MainField } from './attributes';\nimport type { RelationResult } from '../../../shared/contracts/relations';\n\n/**\n * @internal\n * @description Get the label of a relation, the contract has [key: string]: unknown,\n * so we need to check if the mainFieldKey is defined and if the relation has a value\n * under that property. If it does, we then verify it's type of string and return it.\n *\n * We fallback to the documentId.\n */\nconst getRelationLabel = (relation: RelationResult, mainField?: MainField): string => {\n const label = mainField && relation[mainField.name] ? relation[mainField.name] : null;\n\n if (typeof label === 'string') {\n return label;\n }\n\n return relation.documentId;\n};\n\nexport { getRelationLabel };\n"],"names":["contentManagerApi","generateNKeysBetween","index"],"mappings":";;;AAkCA,MAAM,eAAeA,wBAAkB,gBAAgB;AAAA,EACrD,WAAW,CAAC,WAAW;AAAA,IACrB,cAAc,MAAM,MAKlB;AAAA,MACA,OAAO,CAAC,EAAE,OAAO,IAAI,aAAa,aAAa;AACtC,eAAA;AAAA,UACL,KAAK,8BAA8B,KAAK,IAAI,EAAE,IAAI,WAAW;AAAA,UAC7D,QAAQ;AAAA,UACR,QAAQ;AAAA,YACN;AAAA,UACF;AAAA,QAAA;AAAA,MAEJ;AAAA,MACA,oBAAoB,CAAC,SAAS;AACtB,cAAA,EAAE,cAAc,UAAc,IAAA;AAC7B,eAAA;AAAA,UACL;AAAA,UACA,OAAO,UAAU;AAAA,UACjB,IAAI,UAAU;AAAA,UACd,aAAa,UAAU;AAAA,UACvB,QAAQ,UAAU,QAAQ;AAAA,UAC1B,QAAQ,UAAU,QAAQ;AAAA,QAAA;AAAA,MAE9B;AAAA,MACA,OAAO,CAAC,cAAc,aAAa;AAC7B,YAAA,aAAa,cAAc,SAAS,YAAY;AAClD,cAAI,aAAa,WAAW,OAAO,SAAS,WAAW,MAAM;AAO3D,yBAAa,UAAU;AAAA,cACrB,GAAG,gBAAgB,SAAS,SAAS,aAAa,OAAO;AAAA,cACzD,GAAG,aAAa;AAAA,YAAA;AAElB,yBAAa,aAAa,SAAS;AAAA,UAC1B,WAAA,SAAS,WAAW,SAAS,GAAG;AAI5B,yBAAA,UAAU,gBAAgB,SAAS,OAAO;AACvD,yBAAa,aAAa,SAAS;AAAA,UACrC;AAAA,QACF;AAAA,MACF;AAAA,MACA,aAAa,EAAE,YAAY,eAAe;AACxC,YAAI,CAA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AAS;AAAA,UAC1B,WAAA,SAAS,WAAW,SAAS,GAAG;AAIzC,yBAAa,UAAU,SAAS;AAChC,yBAAa,aAAa,SAAS;AAAA,UACrC;AAAA,QACF;AAAA,MACF;AAAA,MACA,aAAa,EAAE,YAAY,eAAe;AACxC,YAAI,CAAC,YAAY,UAAU,CAAC,aAAa,QAAQ;AACxC,iBAAA;AAAA,QACT;AAGE,eAAA,YAAY,QAAQ,SAAS,aAAa,QAAQ,QAClD,YAAY,QAAQ,aAAa,aAAa,QAAQ;AAAA,MAE1D;AAAA,MACA,mBAAmB,CAAC,aAAqC;AACvD,YAAI,SAAS,SAAS;AACb,iBAAA;AAAA,YACL,GAAG;AAAA,YACH,SAAS,SAAS;AAAA,UAAA;AAAA,QACpB,OACK;AACE,iBAAA;AAAA,QACT;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EAAA;AAEL,CAAC;AAOD,MAAM,kBAAkB,CAAC,WAAwB,oBAAsC,OAAO;AAC5F,QAAM,CAAC,SAAS,IAAI,kBAAkB,MAAM,CAAC;AAC7C,QAAM,OAAOC,mBAAqB,qBAAA,MAAM,WAAW,gBAAgB,MAAM,UAAU,MAAM;AAEzF,SAAO,UAAU,IAAI,CAAC,OAAOC,YAAW;AAAA,IACtC,GAAG;AAAA,IACH,cAAc,KAAKA,MAAK;AAAA,EACxB,EAAA;AACJ;AAEM,MAAA,EAAE,sBAAsB,gCAAgC;ACvLxD,MAAA,mBAAmB,CAAC,UAA0B,cAAkC;AAC9E,QAAA,QAAQ,aAAa,SAAS,UAAU,IAAI,IAAI,SAAS,UAAU,IAAI,IAAI;AAE7E,MAAA,OAAO,UAAU,UAAU;AACtB,WAAA;AAAA,EACT;AAEA,SAAO,SAAS;AAClB;;;;"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { generateNKeysBetween } from "fractional-indexing";
|
2
|
-
import { e as contentManagerApi } from "./index-
|
2
|
+
import { e as contentManagerApi } from "./index-Ta--2bRa.mjs";
|
3
3
|
const relationsApi = contentManagerApi.injectEndpoints({
|
4
4
|
endpoints: (build) => ({
|
5
5
|
getRelations: build.query({
|
@@ -131,4 +131,4 @@ export {
|
|
131
131
|
getRelationLabel as g,
|
132
132
|
useGetRelationsQuery as u
|
133
133
|
};
|
134
|
-
//# sourceMappingURL=relations-
|
134
|
+
//# sourceMappingURL=relations-Ch70q86O.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"relations-C8eyDiIO.mjs","sources":["../../admin/src/services/relations.ts","../../admin/src/utils/relations.ts"],"sourcesContent":["import { generateNKeysBetween } from 'fractional-indexing';\n\nimport {\n RelationResult as RelResult,\n FindAvailable,\n FindExisting,\n} from '../../../shared/contracts/relations';\n\nimport { contentManagerApi } from './api';\n\nimport type { Modules } from '@strapi/types';\nimport type { errors } from '@strapi/utils';\n\ninterface RelationResult extends RelResult {\n __temp_key__: string;\n}\n\ntype GetRelationsResponse =\n | {\n results: Array<RelationResult>;\n pagination: {\n page: NonNullable<Modules.EntityService.Params.Pagination.PageNotation['page']>;\n pageSize: NonNullable<Modules.EntityService.Params.Pagination.PageNotation['pageSize']>;\n pageCount: number;\n total: number;\n } | null;\n error?: never;\n }\n | {\n results?: never;\n pagination?: never;\n error: errors.ApplicationError | errors.YupValidationError;\n };\n\nconst relationsApi = contentManagerApi.injectEndpoints({\n endpoints: (build) => ({\n getRelations: build.query<\n GetRelationsResponse,\n FindExisting.Params & {\n params?: FindExisting.Request['query'];\n }\n >({\n query: ({ model, id, targetField, params }) => {\n return {\n url: `/content-manager/relations/${model}/${id}/${targetField}`,\n method: 'GET',\n config: {\n params,\n },\n };\n },\n serializeQueryArgs: (args) => {\n const { endpointName, queryArgs } = args;\n return {\n endpointName,\n model: queryArgs.model,\n id: queryArgs.id,\n targetField: queryArgs.targetField,\n locale: queryArgs.params?.locale,\n status: queryArgs.params?.status,\n };\n },\n merge: (currentCache, newItems) => {\n if (currentCache.pagination && newItems.pagination) {\n if (currentCache.pagination.page < newItems.pagination.page) {\n /**\n * Relations will always have unique IDs, so we can therefore assume\n * that we only need to push the new items to the cache.\n *\n * Push new items at the beginning as latest items are shown first\n */\n currentCache.results = [\n ...prepareTempKeys(newItems.results, currentCache.results),\n ...currentCache.results,\n ];\n currentCache.pagination = newItems.pagination;\n } else if (newItems.pagination.page === 1) {\n /**\n * We're resetting the relations\n */\n currentCache.results = prepareTempKeys(newItems.results);\n currentCache.pagination = newItems.pagination;\n }\n }\n },\n forceRefetch({ currentArg, previousArg }) {\n if (!currentArg?.params && !previousArg?.params) {\n return false;\n }\n\n return (\n currentArg?.params?.page !== previousArg?.params?.page ||\n currentArg?.params?.pageSize !== previousArg?.params?.pageSize\n );\n },\n transformResponse: (response: FindExisting.Response) => {\n if ('results' in response && response.results) {\n return {\n ...response,\n results: prepareTempKeys(response.results.toReversed()),\n };\n } else {\n return response;\n }\n },\n providesTags: ['Relations'],\n }),\n searchRelations: build.query<\n FindAvailable.Response,\n FindAvailable.Params & {\n params?: FindAvailable.Request['query'];\n }\n >({\n query: ({ model, targetField, params }) => {\n return {\n url: `/content-manager/relations/${model}/${targetField}`,\n method: 'GET',\n config: {\n params,\n },\n };\n },\n serializeQueryArgs: (args) => {\n const { endpointName, queryArgs } = args;\n return {\n endpointName,\n model: queryArgs.model,\n targetField: queryArgs.targetField,\n _q: queryArgs.params?._q,\n idsToOmit: queryArgs.params?.idsToOmit,\n idsToInclude: queryArgs.params?.idsToInclude,\n };\n },\n merge: (currentCache, newItems) => {\n if (currentCache.pagination && newItems.pagination) {\n if (currentCache.pagination.page < newItems.pagination.page) {\n /**\n * Relations will always have unique IDs, so we can therefore assume\n * that we only need to push the new items to the cache.\n */\n const existingIds = currentCache.results.map((item) => item.documentId);\n const uniqueNewItems = newItems.results.filter(\n (item) => !existingIds.includes(item.documentId)\n );\n currentCache.results.push(...uniqueNewItems);\n currentCache.pagination = newItems.pagination;\n } else if (newItems.pagination.page === 1) {\n /**\n * We're resetting the relations\n */\n currentCache.results = newItems.results;\n currentCache.pagination = newItems.pagination;\n }\n }\n },\n forceRefetch({ currentArg, previousArg }) {\n if (!currentArg?.params && !previousArg?.params) {\n return false;\n }\n\n return (\n currentArg?.params?.page !== previousArg?.params?.page ||\n currentArg?.params?.pageSize !== previousArg?.params?.pageSize\n );\n },\n transformResponse: (response: FindAvailable.Response) => {\n if (response.results) {\n return {\n ...response,\n results: response.results,\n };\n } else {\n return response;\n }\n },\n }),\n }),\n});\n\n/**\n * @internal\n * @description Adds a `__temp_key__` to each relation item. This gives us\n * a stable identifier regardless of it's ids etc. that we can then use for drag and drop.\n */\nconst prepareTempKeys = (relations: RelResult[], existingRelations: RelationResult[] = []) => {\n const [firstItem] = existingRelations.slice(0);\n const keys = generateNKeysBetween(null, firstItem?.__temp_key__ ?? null, relations.length);\n\n return relations.map((datum, index) => ({\n ...datum,\n __temp_key__: keys[index],\n }));\n};\n\nconst { useGetRelationsQuery, useLazySearchRelationsQuery } = relationsApi;\n\nexport { useGetRelationsQuery, useLazySearchRelationsQuery };\nexport type { RelationResult };\n","import type { MainField } from './attributes';\nimport type { RelationResult } from '../../../shared/contracts/relations';\n\n/**\n * @internal\n * @description Get the label of a relation, the contract has [key: string]: unknown,\n * so we need to check if the mainFieldKey is defined and if the relation has a value\n * under that property. If it does, we then verify it's type of string and return it.\n *\n * We fallback to the documentId.\n */\nconst getRelationLabel = (relation: RelationResult, mainField?: MainField): string => {\n const label = mainField && relation[mainField.name] ? relation[mainField.name] : null;\n\n if (typeof label === 'string') {\n return label;\n }\n\n return relation.documentId;\n};\n\nexport { getRelationLabel };\n"],"names":[],"mappings":";;AAkCA,MAAM,eAAe,kBAAkB,gBAAgB;AAAA,EACrD,WAAW,CAAC,WAAW;AAAA,IACrB,cAAc,MAAM,MAKlB;AAAA,MACA,OAAO,CAAC,EAAE,OAAO,IAAI,aAAa,aAAa;AACtC,eAAA;AAAA,UACL,KAAK,8BAA8B,KAAK,IAAI,EAAE,IAAI,WAAW;AAAA,UAC7D,QAAQ;AAAA,UACR,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,iBAAA;AAAA,QACT;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EAAA;AAEL,CAAC;AAOD,MAAM,kBAAkB,CAAC,WAAwB,oBAAsC,OAAO;AAC5F,QAAM,CAAC,SAAS,IAAI,kBAAkB,MAAM,CAAC;AAC7C,QAAM,OAAO,qBAAqB,MAAM,WAAW,gBAAgB,MAAM,UAAU,MAAM;AAEzF,SAAO,UAAU,IAAI,CAAC,OAAO,WAAW;AAAA,IACtC,GAAG;AAAA,IACH,cAAc,KAAK,KAAK;AAAA,EACxB,EAAA;AACJ;AAEM,MAAA,EAAE,sBAAsB,gCAAgC;ACvLxD,MAAA,mBAAmB,CAAC,UAA0B,cAAkC;AAC9E,QAAA,QAAQ,aAAa,SAAS,UAAU,IAAI,IAAI,SAAS,UAAU,IAAI,IAAI;AAE7E,MAAA,OAAO,UAAU,UAAU;AACtB,WAAA;AAAA,EACT;AAEA,SAAO,SAAS;AAClB;"}
|
1
|
+
{"version":3,"file":"relations-Ch70q86O.mjs","sources":["../../admin/src/services/relations.ts","../../admin/src/utils/relations.ts"],"sourcesContent":["import { generateNKeysBetween } from 'fractional-indexing';\n\nimport {\n RelationResult as RelResult,\n FindAvailable,\n FindExisting,\n} from '../../../shared/contracts/relations';\n\nimport { contentManagerApi } from './api';\n\nimport type { Modules } from '@strapi/types';\nimport type { errors } from '@strapi/utils';\n\ninterface RelationResult extends RelResult {\n __temp_key__: string;\n}\n\ntype GetRelationsResponse =\n | {\n results: Array<RelationResult>;\n pagination: {\n page: NonNullable<Modules.EntityService.Params.Pagination.PageNotation['page']>;\n pageSize: NonNullable<Modules.EntityService.Params.Pagination.PageNotation['pageSize']>;\n pageCount: number;\n total: number;\n } | null;\n error?: never;\n }\n | {\n results?: never;\n pagination?: never;\n error: errors.ApplicationError | errors.YupValidationError;\n };\n\nconst relationsApi = contentManagerApi.injectEndpoints({\n endpoints: (build) => ({\n getRelations: build.query<\n GetRelationsResponse,\n FindExisting.Params & {\n params?: FindExisting.Request['query'];\n }\n >({\n query: ({ model, id, targetField, params }) => {\n return {\n url: `/content-manager/relations/${model}/${id}/${targetField}`,\n method: 'GET',\n config: {\n params,\n },\n };\n },\n serializeQueryArgs: (args) => {\n const { endpointName, queryArgs } = args;\n return {\n endpointName,\n model: queryArgs.model,\n id: queryArgs.id,\n targetField: queryArgs.targetField,\n locale: queryArgs.params?.locale,\n status: queryArgs.params?.status,\n };\n },\n merge: (currentCache, newItems) => {\n if (currentCache.pagination && newItems.pagination) {\n if (currentCache.pagination.page < newItems.pagination.page) {\n /**\n * Relations will always have unique IDs, so we can therefore assume\n * that we only need to push the new items to the cache.\n *\n * Push new items at the beginning as latest items are shown first\n */\n currentCache.results = [\n ...prepareTempKeys(newItems.results, currentCache.results),\n ...currentCache.results,\n ];\n currentCache.pagination = newItems.pagination;\n } else if (newItems.pagination.page === 1) {\n /**\n * We're resetting the relations\n */\n currentCache.results = prepareTempKeys(newItems.results);\n currentCache.pagination = newItems.pagination;\n }\n }\n },\n forceRefetch({ currentArg, previousArg }) {\n if (!currentArg?.params && !previousArg?.params) {\n return false;\n }\n\n return (\n currentArg?.params?.page !== previousArg?.params?.page ||\n currentArg?.params?.pageSize !== previousArg?.params?.pageSize\n );\n },\n transformResponse: (response: FindExisting.Response) => {\n if ('results' in response && response.results) {\n return {\n ...response,\n results: prepareTempKeys(response.results.toReversed()),\n };\n } else {\n return response;\n }\n },\n providesTags: ['Relations'],\n }),\n searchRelations: build.query<\n FindAvailable.Response,\n FindAvailable.Params & {\n params?: FindAvailable.Request['query'];\n }\n >({\n query: ({ model, targetField, params }) => {\n return {\n url: `/content-manager/relations/${model}/${targetField}`,\n method: 'GET',\n config: {\n params,\n },\n };\n },\n serializeQueryArgs: (args) => {\n const { endpointName, queryArgs } = args;\n return {\n endpointName,\n model: queryArgs.model,\n targetField: queryArgs.targetField,\n _q: queryArgs.params?._q,\n idsToOmit: queryArgs.params?.idsToOmit,\n idsToInclude: queryArgs.params?.idsToInclude,\n };\n },\n merge: (currentCache, newItems) => {\n if (currentCache.pagination && newItems.pagination) {\n if (currentCache.pagination.page < newItems.pagination.page) {\n /**\n * Relations will always have unique IDs, so we can therefore assume\n * that we only need to push the new items to the cache.\n */\n const existingIds = currentCache.results.map((item) => item.documentId);\n const uniqueNewItems = newItems.results.filter(\n (item) => !existingIds.includes(item.documentId)\n );\n currentCache.results.push(...uniqueNewItems);\n currentCache.pagination = newItems.pagination;\n } else if (newItems.pagination.page === 1) {\n /**\n * We're resetting the relations\n */\n currentCache.results = newItems.results;\n currentCache.pagination = newItems.pagination;\n }\n }\n },\n forceRefetch({ currentArg, previousArg }) {\n if (!currentArg?.params && !previousArg?.params) {\n return false;\n }\n\n return (\n currentArg?.params?.page !== previousArg?.params?.page ||\n currentArg?.params?.pageSize !== previousArg?.params?.pageSize\n );\n },\n transformResponse: (response: FindAvailable.Response) => {\n if (response.results) {\n return {\n ...response,\n results: response.results,\n };\n } else {\n return response;\n }\n },\n }),\n }),\n});\n\n/**\n * @internal\n * @description Adds a `__temp_key__` to each relation item. This gives us\n * a stable identifier regardless of it's ids etc. that we can then use for drag and drop.\n */\nconst prepareTempKeys = (relations: RelResult[], existingRelations: RelationResult[] = []) => {\n const [firstItem] = existingRelations.slice(0);\n const keys = generateNKeysBetween(null, firstItem?.__temp_key__ ?? null, relations.length);\n\n return relations.map((datum, index) => ({\n ...datum,\n __temp_key__: keys[index],\n }));\n};\n\nconst { useGetRelationsQuery, useLazySearchRelationsQuery } = relationsApi;\n\nexport { useGetRelationsQuery, useLazySearchRelationsQuery };\nexport type { RelationResult };\n","import type { MainField } from './attributes';\nimport type { RelationResult } from '../../../shared/contracts/relations';\n\n/**\n * @internal\n * @description Get the label of a relation, the contract has [key: string]: unknown,\n * so we need to check if the mainFieldKey is defined and if the relation has a value\n * under that property. If it does, we then verify it's type of string and return it.\n *\n * We fallback to the documentId.\n */\nconst getRelationLabel = (relation: RelationResult, mainField?: MainField): string => {\n const label = mainField && relation[mainField.name] ? relation[mainField.name] : null;\n\n if (typeof label === 'string') {\n return label;\n }\n\n return relation.documentId;\n};\n\nexport { getRelationLabel };\n"],"names":[],"mappings":";;AAkCA,MAAM,eAAe,kBAAkB,gBAAgB;AAAA,EACrD,WAAW,CAAC,WAAW;AAAA,IACrB,cAAc,MAAM,MAKlB;AAAA,MACA,OAAO,CAAC,EAAE,OAAO,IAAI,aAAa,aAAa;AACtC,eAAA;AAAA,UACL,KAAK,8BAA8B,KAAK,IAAI,EAAE,IAAI,WAAW;AAAA,UAC7D,QAAQ;AAAA,UACR,QAAQ;AAAA,YACN;AAAA,UACF;AAAA,QAAA;AAAA,MAEJ;AAAA,MACA,oBAAoB,CAAC,SAAS;AACtB,cAAA,EAAE,cAAc,UAAc,IAAA;AAC7B,eAAA;AAAA,UACL;AAAA,UACA,OAAO,UAAU;AAAA,UACjB,IAAI,UAAU;AAAA,UACd,aAAa,UAAU;AAAA,UACvB,QAAQ,UAAU,QAAQ;AAAA,UAC1B,QAAQ,UAAU,QAAQ;AAAA,QAAA;AAAA,MAE9B;AAAA,MACA,OAAO,CAAC,cAAc,aAAa;AAC7B,YAAA,aAAa,cAAc,SAAS,YAAY;AAClD,cAAI,aAAa,WAAW,OAAO,SAAS,WAAW,MAAM;AAO3D,yBAAa,UAAU;AAAA,cACrB,GAAG,gBAAgB,SAAS,SAAS,aAAa,OAAO;AAAA,cACzD,GAAG,aAAa;AAAA,YAAA;AAElB,yBAAa,aAAa,SAAS;AAAA,UAC1B,WAAA,SAAS,WAAW,SAAS,GAAG;AAI5B,yBAAA,UAAU,gBAAgB,SAAS,OAAO;AACvD,yBAAa,aAAa,SAAS;AAAA,UACrC;AAAA,QACF;AAAA,MACF;AAAA,MACA,aAAa,EAAE,YAAY,eAAe;AACxC,YAAI,CAAC,YAAY,UAAU,CAAC,aAAa,QAAQ;AACxC,iBAAA;AAAA,QACT;AAGE,eAAA,YAAY,QAAQ,SAAS,aAAa,QAAQ,QAClD,YAAY,QAAQ,aAAa,aAAa,QAAQ;AA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,aAAa,EAAE,YAAY,eAAe;AACxC,YAAI,CAAC,YAAY,UAAU,CAAC,aAAa,QAAQ;AACxC,iBAAA;AAAA,QACT;AAGE,eAAA,YAAY,QAAQ,SAAS,aAAa,QAAQ,QAClD,YAAY,QAAQ,aAAa,aAAa,QAAQ;AAAA,MAE1D;AAAA,MACA,mBAAmB,CAAC,aAAqC;AACvD,YAAI,SAAS,SAAS;AACb,iBAAA;AAAA,YACL,GAAG;AAAA,YACH,SAAS,SAAS;AAAA,UAAA;AAAA,QACpB,OACK;AACE,iBAAA;AAAA,QACT;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EAAA;AAEL,CAAC;AAOD,MAAM,kBAAkB,CAAC,WAAwB,oBAAsC,OAAO;AAC5F,QAAM,CAAC,SAAS,IAAI,kBAAkB,MAAM,CAAC;AAC7C,QAAM,OAAO,qBAAqB,MAAM,WAAW,gBAAgB,MAAM,UAAU,MAAM;AAEzF,SAAO,UAAU,IAAI,CAAC,OAAO,WAAW;AAAA,IACtC,GAAG;AAAA,IACH,cAAc,KAAK,KAAK;AAAA,EACxB,EAAA;AACJ;AAEM,MAAA,EAAE,sBAAsB,gCAAgC;ACvLxD,MAAA,mBAAmB,CAAC,UAA0B,cAAkC;AAC9E,QAAA,QAAQ,aAAa,SAAS,UAAU,IAAI,IAAI,SAAS,UAAU,IAAI,IAAI;AAE7E,MAAA,OAAO,UAAU,UAAU;AACtB,WAAA;AAAA,EACT;AAEA,SAAO,SAAS;AAClB;"}
|
package/dist/admin/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
3
|
-
const index = require("../_chunks/index-
|
3
|
+
const index = require("../_chunks/index-_j7lH3CO.js");
|
4
4
|
require("@strapi/icons");
|
5
5
|
exports.DocumentRBAC = index.DocumentRBAC;
|
6
6
|
exports.buildValidParams = index.buildValidParams;
|
package/dist/admin/index.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { StatusProps } from '@strapi/design-system';
|
2
|
-
interface DocumentStatusProps extends Omit<StatusProps, 'children' | '
|
2
|
+
interface DocumentStatusProps extends Omit<StatusProps, 'children' | 'variant'> {
|
3
3
|
/**
|
4
4
|
* The status of the document (draft, published, etc.)
|
5
5
|
* @default 'draft'
|
@@ -11,6 +11,6 @@ interface DocumentStatusProps extends Omit<StatusProps, 'children' | 'showBullet
|
|
11
11
|
* @description Displays the status of a document (draft, published, etc.)
|
12
12
|
* and automatically calculates the appropriate variant for the status.
|
13
13
|
*/
|
14
|
-
declare const DocumentStatus: ({ status, ...restProps }: DocumentStatusProps) => import("react/jsx-runtime").JSX.Element;
|
14
|
+
declare const DocumentStatus: ({ status, size, ...restProps }: DocumentStatusProps) => import("react/jsx-runtime").JSX.Element;
|
15
15
|
export { DocumentStatus };
|
16
16
|
export type { DocumentStatusProps };
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { PathRouteProps } from 'react-router-dom';
|
2
2
|
declare const CLONE_PATH = "/content-manager/:collectionType/:slug/clone/:origin";
|
3
|
-
declare const LIST_PATH = "/content-manager/:
|
3
|
+
declare const LIST_PATH = "/content-manager/collection-types/:slug";
|
4
4
|
declare const routes: PathRouteProps[];
|
5
5
|
export { routes, CLONE_PATH, LIST_PATH };
|