@mattisvensson/strapi-plugin-webatlas 0.6.2 → 0.7.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.
Files changed (51) hide show
  1. package/dist/_chunks/{de-CL1TIZPg.js → de-BZc1BkzH.js} +4 -1
  2. package/dist/_chunks/{de-CL1TIZPg.js.map → de-BZc1BkzH.js.map} +1 -1
  3. package/dist/_chunks/{de-CzVD4dbZ.mjs → de-oxxH8hft.mjs} +4 -1
  4. package/dist/_chunks/{de-CzVD4dbZ.mjs.map → de-oxxH8hft.mjs.map} +1 -1
  5. package/dist/_chunks/{en-Du-Ap60j.js → en-Deg4n_IM.js} +4 -1
  6. package/dist/_chunks/{en-Du-Ap60j.js.map → en-Deg4n_IM.js.map} +1 -1
  7. package/dist/_chunks/{en-Nk6QcTdr.mjs → en-DqC5aDzA.mjs} +4 -1
  8. package/dist/_chunks/{en-Nk6QcTdr.mjs.map → en-DqC5aDzA.mjs.map} +1 -1
  9. package/dist/_chunks/{index-C4-VBSgi.mjs → index-B6MYtu3A.mjs} +11 -6
  10. package/dist/_chunks/index-B6MYtu3A.mjs.map +1 -0
  11. package/dist/_chunks/index-BEgpEtto.mjs +247 -0
  12. package/dist/_chunks/index-BEgpEtto.mjs.map +1 -0
  13. package/dist/_chunks/{index-Z3yKckP0.js → index-BOEv4jIJ.js} +6 -6
  14. package/dist/_chunks/{index-Z3yKckP0.js.map → index-BOEv4jIJ.js.map} +1 -1
  15. package/dist/_chunks/{index-CC1UR_w8.mjs → index-BPhRQoGD.mjs} +2 -2
  16. package/dist/_chunks/{index-CC1UR_w8.mjs.map → index-BPhRQoGD.mjs.map} +1 -1
  17. package/dist/_chunks/index-BdlPAWj6.mjs +246 -0
  18. package/dist/_chunks/index-Bg96TqDm.js +247 -0
  19. package/dist/_chunks/index-Bg96TqDm.js.map +1 -0
  20. package/dist/_chunks/{index-B9OfSpne.mjs → index-BgzZLDPv.mjs} +10 -5
  21. package/dist/_chunks/index-BoVX1KF8.js +246 -0
  22. package/dist/_chunks/{index-Ch8tSWp4.js → index-ByU38WNH.js} +5 -5
  23. package/dist/_chunks/{index-iF1y6Mhe.mjs → index-CZ5qsGXH.mjs} +6 -6
  24. package/dist/_chunks/{index-iF1y6Mhe.mjs.map → index-CZ5qsGXH.mjs.map} +1 -1
  25. package/dist/_chunks/{index-BPIdov2N.mjs → index-D3xDvB4d.mjs} +5 -5
  26. package/dist/_chunks/{index-13yB9fna.mjs → index-DKdAgBbF.mjs} +1 -1
  27. package/dist/_chunks/{index-BDoljrOj.js → index-D_QCV5Z5.js} +2 -2
  28. package/dist/_chunks/{index-BDoljrOj.js.map → index-D_QCV5Z5.js.map} +1 -1
  29. package/dist/_chunks/{index-CjA6bLGU.js → index-UJ0LQ3Y3.js} +1 -1
  30. package/dist/_chunks/{index-Bw2Yq-Hx.js → index-dSU20yZ4.js} +10 -5
  31. package/dist/_chunks/{index-D1zlwukG.js → index-mObQ5NXj.js} +11 -6
  32. package/dist/_chunks/index-mObQ5NXj.js.map +1 -0
  33. package/dist/admin/index.js +1 -1
  34. package/dist/admin/index.mjs +1 -1
  35. package/dist/admin/src/pages/Routes/TableHeader.d.ts +5 -1
  36. package/dist/admin/src/pages/Routes/compareBy.d.ts +2 -0
  37. package/dist/server/index.js +1 -1
  38. package/dist/server/index.mjs +1 -1
  39. package/package.json +1 -1
  40. package/dist/_chunks/EmptyBox-BM4IscSk.mjs +0 -13
  41. package/dist/_chunks/EmptyBox-BM4IscSk.mjs.map +0 -1
  42. package/dist/_chunks/EmptyBox-T8t29l25.js +0 -12
  43. package/dist/_chunks/EmptyBox-T8t29l25.js.map +0 -1
  44. package/dist/_chunks/index-AIXu4HZz.mjs +0 -127
  45. package/dist/_chunks/index-AIXu4HZz.mjs.map +0 -1
  46. package/dist/_chunks/index-BOF-1QDH.js +0 -127
  47. package/dist/_chunks/index-BOF-1QDH.js.map +0 -1
  48. package/dist/_chunks/index-BluRjThy.mjs +0 -126
  49. package/dist/_chunks/index-C4-VBSgi.mjs.map +0 -1
  50. package/dist/_chunks/index-D1zlwukG.js.map +0 -1
  51. package/dist/_chunks/index-DeNZkmpv.js +0 -126
@@ -2,7 +2,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useReducer, useState, useEffect } from "react";
3
3
  import { Button, Box, Accordion, Field, SingleSelect, SingleSelectOption, MultiSelect, MultiSelectOption } from "@strapi/design-system";
4
4
  import { Page, Layouts, useNotification } from "@strapi/strapi/admin";
5
- import { P as PLUGIN_NAME, g as getTranslation, T as Tooltip, b as usePluginConfig, c as useAllContentTypes, t as transformToUrl } from "./index-iF1y6Mhe.mjs";
5
+ import { P as PLUGIN_NAME, g as getTranslation, T as Tooltip, b as usePluginConfig, c as useAllContentTypes, t as transformToUrl } from "./index-CZ5qsGXH.mjs";
6
6
  import { useIntl } from "react-intl";
7
7
  import "@strapi/icons/symbols";
8
8
  import { F as FullLoader } from "./FullLoader-CrPED_dY.mjs";
@@ -279,4 +279,4 @@ const Settings = () => {
279
279
  export {
280
280
  Settings as default
281
281
  };
282
- //# sourceMappingURL=index-CC1UR_w8.mjs.map
282
+ //# sourceMappingURL=index-BPhRQoGD.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-CC1UR_w8.mjs","sources":["../../admin/src/pages/Settings/PageWrapper.tsx","../../admin/src/pages/Settings/ContentTypeAccordion.tsx","../../admin/src/pages/Settings/index.tsx"],"sourcesContent":["import { Button, Box } from '@strapi/design-system';\nimport { Page, Layouts} from '@strapi/strapi/admin'\nimport { PLUGIN_NAME } from '../../../../pluginId';\nimport { getTranslation } from '../../utils';\nimport { useIntl } from 'react-intl';\nimport type { ConfigContentType } from '../../../../types';\n\nexport default function PageWrapper({ \n settingsState, \n initialState, \n save, \n isSaving,\n children\n}: { \n settingsState?: any, \n initialState?: any, \n save?: () => void, \n isSaving?: boolean,\n children: React.ReactNode \n}) {\n\n const { formatMessage } = useIntl();\n \n return (\n <Page.Main>\n <Layouts.Header\n title={PLUGIN_NAME}\n subtitle={formatMessage({\n id: getTranslation('settings.page.subtitle'),\n defaultMessage: 'Settings',\n })}\n primaryAction={ settingsState && initialState && save &&\n <Button\n type=\"submit\"\n onClick={() => save()}\n loading={isSaving}\n disabled={\n JSON.stringify(settingsState) === JSON.stringify(initialState)\n || settingsState.selectedContentTypes.find((cta: ConfigContentType) => !cta.default) !== undefined\n || isSaving\n }\n >\n {formatMessage({\n id: getTranslation('save'),\n defaultMessage: 'Save',\n })}\n </Button>\n }\n />\n <Layouts.Content>\n <Box\n background='neutral0'\n borderColor=\"neutral150\"\n hasRadius\n paddingBottom={4}\n paddingLeft={4}\n paddingRight={4}\n paddingTop={6}\n shadow=\"tableShadow\"\n >\n {children}\n </Box>\n </Layouts.Content>\n </Page.Main>\n )\n}","import { SingleSelect, SingleSelectOption } from '@strapi/design-system';\nimport Tooltip from '../../components/Tooltip'\nimport { Box, Accordion, Field } from '@strapi/design-system';\nimport { getTranslation } from '../../utils';\nimport { useIntl } from 'react-intl';\nimport type { ContentType, ConfigContentType } from '../../../../types';\n\nexport default function ContentTypeAccordion({ \n contentType,\n contentTypeSettings,\n dispatch\n}: { \n contentType: ContentType | undefined, \n contentTypeSettings: ConfigContentType, \n dispatch: React.Dispatch<any>\n}) {\n \n const { formatMessage } = useIntl();\n\n if (!contentType) return null\n\n return (\n <Box\n borderColor={!contentTypeSettings.default && 'danger500'}\n key={contentType.uid}\n >\n <Accordion.Item key={contentType.uid} value={contentType.uid} size=\"S\">\n <Accordion.Header>\n <Accordion.Trigger>\n {contentType?.info.displayName}\n </Accordion.Trigger>\n </Accordion.Header>\n <Accordion.Content>\n <Box padding={3}>\n <Field.Root\n name=\"selectedContentTypes\"\n hint={formatMessage({\n id: getTranslation('settings.page.defaultField.hint'),\n defaultMessage: 'The selected field from the content type will be used to generate the URL alias. Use a field that is unique and descriptive, such as a \"title\" or \"name\".',\n })}\n error={!contentTypeSettings.default && formatMessage({\n id: getTranslation('settings.page.defaultField.error'),\n defaultMessage: 'Please select a default field',\n })}\n required\n >\n <Field.Label>\n {formatMessage({\n id: getTranslation('settings.page.defaultField'),\n defaultMessage: 'Default URL Alias field',\n })}\n </Field.Label>\n <SingleSelect\n name={`defaultField-${contentType.uid}`}\n onClear={() => dispatch({ type: 'SET_DEFAULT_FIELD', payload: { ctUid: contentType.uid, field: '' } })}\n value={contentTypeSettings?.default || ''}\n onChange={(value: string) => dispatch({ type: 'SET_DEFAULT_FIELD', payload: { ctUid: contentType.uid, field: value } })}\n >\n {Object.entries(contentType.attributes).map(([key], index) => {\n if (\n key === 'id' || \n key === 'documentId' ||\n key === 'createdAt' || \n key === 'updatedAt' || \n key === 'createdBy' || \n key === 'updatedBy' ||\n key === 'webatlas_path' ||\n key === 'webatlas_override'\n ) return null\n return <SingleSelectOption key={index} value={key}>{key}</SingleSelectOption>\n })}\n </SingleSelect>\n <Field.Hint/>\n </Field.Root>\n <Box paddingTop={4}>\n <Field.Root\n name=\"urlAliasPattern\"\n hint={formatMessage({\n id: getTranslation('settings.page.urlAliasPattern.hint'),\n defaultMessage: 'The pattern to prepend to the generated URL alias. For example, if you enter \"blog\" and the value of default field is \"My First Post\", the generated URL alias will be \"blog/my-first-post\". Leave empty for no prefix.',\n })}\n >\n <Field.Label>\n {formatMessage({\n id: getTranslation('settings.page.urlAliasPattern'),\n defaultMessage: 'URL Alias Pattern',\n })}\n <Tooltip description={formatMessage({\n id: getTranslation('settings.page.urlAliasPattern.tooltip'),\n defaultMessage: 'Leading and trailing slashes will be removed. Spaces will be replaced with hyphens. Special characters will be encoded.',\n })} />\n </Field.Label>\n <Field.Input\n value={contentTypeSettings.pattern}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => dispatch({ type: 'SET_PATTERN', payload: { ctUid: contentType.uid, pattern: e.target.value } })}\n disabled={!contentTypeSettings.default}\n type=\"text\"\n placeholder={formatMessage({\n id: getTranslation('settings.page.urlAliasPattern.placeholder'),\n defaultMessage: 'e.g. blog',\n })}\n />\n <Field.Hint />\n </Field.Root>\n </Box>\n </Box>\n </Accordion.Content>\n </Accordion.Item>\n </Box>\n \n )\n}","/*\n *\n * Settings\n * This file contains the settings page for the Webatlas plugin in Strapi.\n * It allows users to configure which content types are enabled for URL aliases and navigations,\n * as well as setting default fields and the URL alias patterns for each content type. \n *\n*/\n\nimport { useEffect, useState, useReducer } from 'react';\nimport { Box, Accordion, Field } from '@strapi/design-system';\nimport { useNotification } from '@strapi/strapi/admin'\nimport { MultiSelect, MultiSelectOption } from '@strapi/design-system';\nimport usePluginConfig from '../../hooks/usePluginConfig';\nimport type { ContentType, ConfigContentType, PluginConfig } from '../../../../types';\nimport transformToUrl from '../../../../utils/transformToUrl';\nimport useAllContentTypes from '../../hooks/useAllContentTypes';\nimport { getTranslation } from '../../utils';\nimport { useIntl } from 'react-intl';\nimport { FullLoader } from '../../components/UI';\nimport PageWrapper from './PageWrapper';\nimport ContentTypeAccordion from './ContentTypeAccordion';\n\ntype Action =\n | { type: 'SET_SELECTED_CONTENT_TYPES'; payload: ConfigContentType[] }\n | { type: 'SET_DEFAULT_FIELD'; payload: { ctUid: string; field: string } }\n | { type: 'SET_PATTERN'; payload: { ctUid: string; pattern: string } }\n\nfunction reducer(settingsState: PluginConfig, action: Action): PluginConfig {\n let updatedContentTypes\n switch (action.type) {\n case 'SET_SELECTED_CONTENT_TYPES':\n updatedContentTypes = action.payload.map(ct => {\n return settingsState.selectedContentTypes.find((cta: ConfigContentType) => cta.uid === ct.uid) || ct\n })\n return { ...settingsState, selectedContentTypes: updatedContentTypes };\n case 'SET_DEFAULT_FIELD':\n updatedContentTypes = settingsState.selectedContentTypes.map(ct =>\n ct.uid === action.payload.ctUid ? { ...ct, default: action.payload.field } : ct\n );\n return { ...settingsState, selectedContentTypes: updatedContentTypes };\n case 'SET_PATTERN':\n updatedContentTypes = settingsState.selectedContentTypes.map(ct =>\n ct.uid === action.payload.ctUid ? { ...ct, pattern: transformToUrl(action.payload.pattern) } : ct\n );\n return { ...settingsState, selectedContentTypes: updatedContentTypes };\n default:\n throw new Error();\n }\n}\n\nconst Settings = () => {\n const { config, setConfig, loading, fetchError } = usePluginConfig();\n const [settingsState, dispatch] = useReducer(reducer, config || { selectedContentTypes: [] });\n const { contentTypes: allContentTypesData } = useAllContentTypes();\n const allContentTypes = allContentTypesData?.filter((ct: ContentType) => ct.pluginOptions?.webatlas?.active === true);\n const [initialState, setInitialState] = useState(config || { selectedContentTypes: [] })\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const [isSaving, setIsSaving] = useState(false);\n\n useEffect(() => {\n setInitialState(config || { selectedContentTypes: [] })\n }, [config]);\n\n useEffect(() => {\n if (!config) return;\n dispatch({ type: 'SET_SELECTED_CONTENT_TYPES', payload: config.selectedContentTypes });\n }, [config]);\n \n useEffect(() => {\n if (fetchError) {\n toggleNotification({\n type: 'danger',\n message: formatMessage({\n id: getTranslation('notification.error'),\n defaultMessage: 'An error occurred',\n }) + ': ' + fetchError,\n });\n }\n }, [fetchError, toggleNotification, formatMessage]);\n\n async function save() {\n if (\n !settingsState \n || settingsState.selectedContentTypes.find((cta: ConfigContentType) => !cta.default) !== undefined\n ) return\n\n setIsSaving(true);\n try {\n await setConfig(settingsState)\n setInitialState(settingsState)\n\n toggleNotification({\n type: 'success',\n message: formatMessage({\n id: getTranslation('notification.settings.saved'),\n defaultMessage: 'Settings saved successfully',\n }),\n });\n setIsSaving(false);\n } catch (err) {\n setIsSaving(false);\n toggleNotification({\n type: 'danger',\n message: formatMessage({\n id: getTranslation('notification.error'),\n defaultMessage: 'An error occurred',\n }) + ': ' + err,\n });\n console.error(err);\n }\n }\n\n if (loading) {\n return <PageWrapper>\n <FullLoader height={200} />\n </PageWrapper>\n }\n\n return (\n <PageWrapper settingsState={settingsState} initialState={initialState} save={save} isSaving={isSaving}>\n <Field.Root\n name=\"selectedContentTypes\"\n hint={formatMessage({\n id: getTranslation('settings.page.enabledContentTypes.hint'),\n defaultMessage: 'Select the content types for which you want to enable URL aliases',\n })}\n >\n <Field.Label>\n {formatMessage({\n id: getTranslation('settings.page.enabledContentTypes'),\n defaultMessage: 'Enabled Content Types',\n })}\n </Field.Label>\n <MultiSelect\n placeholder={formatMessage({\n id: getTranslation('settings.page.enabledContentTypes.placeholder'),\n defaultMessage: 'Select content types...',\n })}\n onClear={() => dispatch({ type: 'SET_SELECTED_CONTENT_TYPES', payload: [] })}\n value={[...settingsState.selectedContentTypes.map((ct: ConfigContentType) => ct.uid)]}\n onChange={(value: string[]) =>\n dispatch({\n type: 'SET_SELECTED_CONTENT_TYPES',\n payload: value.map(v => ({\n uid: v,\n default: '',\n pattern: '',\n })),\n })\n }\n withTags\n >\n {allContentTypes && allContentTypes.map(item => \n <MultiSelectOption key={item.uid} value={item.uid}>{item.info.displayName}</MultiSelectOption>\n )}\n </MultiSelect>\n <Field.Hint/>\n </Field.Root>\n {settingsState.selectedContentTypes && settingsState.selectedContentTypes.length > 0 && \n <Box paddingTop={4}>\n <Field.Root name=\"selectedContentTypesAccordion\">\n <Field.Label>\n {formatMessage({\n id: getTranslation('settings.page.contentTypeSettings'),\n defaultMessage: 'Content Type settings',\n })}\n </Field.Label>\n <Accordion.Root>\n {settingsState.selectedContentTypes?.map((contentTypeSettings: ConfigContentType) => {\n const ct: ContentType | undefined = allContentTypes?.find((item) => item.uid === contentTypeSettings.uid)\n return <ContentTypeAccordion key={contentTypeSettings.uid} contentType={ct} contentTypeSettings={contentTypeSettings} dispatch={dispatch} />\n })}\n </Accordion.Root>\n </Field.Root>\n </Box>\n }\n </PageWrapper>\n );\n};\n\nexport default Settings;\n"],"names":[],"mappings":";;;;;;;;AAOA,SAAwB,YAAY;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMG;AAEK,QAAA,EAAE,cAAc,IAAI,QAAQ;AAGhC,SAAA,qBAAC,KAAK,MAAL,EACC,UAAA;AAAA,IAAA;AAAA,MAAC,QAAQ;AAAA,MAAR;AAAA,QACC,OAA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aAAa,IAAI,qBAA0C,SAAA,GAApF,oBAAoB,GAAoF;AAAA,MAAA,CAC3I,EACH,CAAA;AAAA,IAAA,EAAA,CACF,EACF,CAAA;AAAA,EAAA,GAEJ;AAEJ;"}
1
+ {"version":3,"file":"index-BPhRQoGD.mjs","sources":["../../admin/src/pages/Settings/PageWrapper.tsx","../../admin/src/pages/Settings/ContentTypeAccordion.tsx","../../admin/src/pages/Settings/index.tsx"],"sourcesContent":["import { Button, Box } from '@strapi/design-system';\nimport { Page, Layouts} from '@strapi/strapi/admin'\nimport { PLUGIN_NAME } from '../../../../pluginId';\nimport { getTranslation } from '../../utils';\nimport { useIntl } from 'react-intl';\nimport type { ConfigContentType } from '../../../../types';\n\nexport default function PageWrapper({ \n settingsState, \n initialState, \n save, \n isSaving,\n children\n}: { \n settingsState?: any, \n initialState?: any, \n save?: () => void, \n isSaving?: boolean,\n children: React.ReactNode \n}) {\n\n const { formatMessage } = useIntl();\n \n return (\n <Page.Main>\n <Layouts.Header\n title={PLUGIN_NAME}\n subtitle={formatMessage({\n id: getTranslation('settings.page.subtitle'),\n defaultMessage: 'Settings',\n })}\n primaryAction={ settingsState && initialState && save &&\n <Button\n type=\"submit\"\n onClick={() => save()}\n loading={isSaving}\n disabled={\n JSON.stringify(settingsState) === JSON.stringify(initialState)\n || settingsState.selectedContentTypes.find((cta: ConfigContentType) => !cta.default) !== undefined\n || isSaving\n }\n >\n {formatMessage({\n id: getTranslation('save'),\n defaultMessage: 'Save',\n })}\n </Button>\n }\n />\n <Layouts.Content>\n <Box\n background='neutral0'\n borderColor=\"neutral150\"\n hasRadius\n paddingBottom={4}\n paddingLeft={4}\n paddingRight={4}\n paddingTop={6}\n shadow=\"tableShadow\"\n >\n {children}\n </Box>\n </Layouts.Content>\n </Page.Main>\n )\n}","import { SingleSelect, SingleSelectOption } from '@strapi/design-system';\nimport Tooltip from '../../components/Tooltip'\nimport { Box, Accordion, Field } from '@strapi/design-system';\nimport { getTranslation } from '../../utils';\nimport { useIntl } from 'react-intl';\nimport type { ContentType, ConfigContentType } from '../../../../types';\n\nexport default function ContentTypeAccordion({ \n contentType,\n contentTypeSettings,\n dispatch\n}: { \n contentType: ContentType | undefined, \n contentTypeSettings: ConfigContentType, \n dispatch: React.Dispatch<any>\n}) {\n \n const { formatMessage } = useIntl();\n\n if (!contentType) return null\n\n return (\n <Box\n borderColor={!contentTypeSettings.default && 'danger500'}\n key={contentType.uid}\n >\n <Accordion.Item key={contentType.uid} value={contentType.uid} size=\"S\">\n <Accordion.Header>\n <Accordion.Trigger>\n {contentType?.info.displayName}\n </Accordion.Trigger>\n </Accordion.Header>\n <Accordion.Content>\n <Box padding={3}>\n <Field.Root\n name=\"selectedContentTypes\"\n hint={formatMessage({\n id: getTranslation('settings.page.defaultField.hint'),\n defaultMessage: 'The selected field from the content type will be used to generate the URL alias. Use a field that is unique and descriptive, such as a \"title\" or \"name\".',\n })}\n error={!contentTypeSettings.default && formatMessage({\n id: getTranslation('settings.page.defaultField.error'),\n defaultMessage: 'Please select a default field',\n })}\n required\n >\n <Field.Label>\n {formatMessage({\n id: getTranslation('settings.page.defaultField'),\n defaultMessage: 'Default URL Alias field',\n })}\n </Field.Label>\n <SingleSelect\n name={`defaultField-${contentType.uid}`}\n onClear={() => dispatch({ type: 'SET_DEFAULT_FIELD', payload: { ctUid: contentType.uid, field: '' } })}\n value={contentTypeSettings?.default || ''}\n onChange={(value: string) => dispatch({ type: 'SET_DEFAULT_FIELD', payload: { ctUid: contentType.uid, field: value } })}\n >\n {Object.entries(contentType.attributes).map(([key], index) => {\n if (\n key === 'id' || \n key === 'documentId' ||\n key === 'createdAt' || \n key === 'updatedAt' || \n key === 'createdBy' || \n key === 'updatedBy' ||\n key === 'webatlas_path' ||\n key === 'webatlas_override'\n ) return null\n return <SingleSelectOption key={index} value={key}>{key}</SingleSelectOption>\n })}\n </SingleSelect>\n <Field.Hint/>\n </Field.Root>\n <Box paddingTop={4}>\n <Field.Root\n name=\"urlAliasPattern\"\n hint={formatMessage({\n id: getTranslation('settings.page.urlAliasPattern.hint'),\n defaultMessage: 'The pattern to prepend to the generated URL alias. For example, if you enter \"blog\" and the value of default field is \"My First Post\", the generated URL alias will be \"blog/my-first-post\". Leave empty for no prefix.',\n })}\n >\n <Field.Label>\n {formatMessage({\n id: getTranslation('settings.page.urlAliasPattern'),\n defaultMessage: 'URL Alias Pattern',\n })}\n <Tooltip description={formatMessage({\n id: getTranslation('settings.page.urlAliasPattern.tooltip'),\n defaultMessage: 'Leading and trailing slashes will be removed. Spaces will be replaced with hyphens. Special characters will be encoded.',\n })} />\n </Field.Label>\n <Field.Input\n value={contentTypeSettings.pattern}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => dispatch({ type: 'SET_PATTERN', payload: { ctUid: contentType.uid, pattern: e.target.value } })}\n disabled={!contentTypeSettings.default}\n type=\"text\"\n placeholder={formatMessage({\n id: getTranslation('settings.page.urlAliasPattern.placeholder'),\n defaultMessage: 'e.g. blog',\n })}\n />\n <Field.Hint />\n </Field.Root>\n </Box>\n </Box>\n </Accordion.Content>\n </Accordion.Item>\n </Box>\n \n )\n}","/*\n *\n * Settings\n * This file contains the settings page for the Webatlas plugin in Strapi.\n * It allows users to configure which content types are enabled for URL aliases and navigations,\n * as well as setting default fields and the URL alias patterns for each content type. \n *\n*/\n\nimport { useEffect, useState, useReducer } from 'react';\nimport { Box, Accordion, Field } from '@strapi/design-system';\nimport { useNotification } from '@strapi/strapi/admin'\nimport { MultiSelect, MultiSelectOption } from '@strapi/design-system';\nimport usePluginConfig from '../../hooks/usePluginConfig';\nimport type { ContentType, ConfigContentType, PluginConfig } from '../../../../types';\nimport transformToUrl from '../../../../utils/transformToUrl';\nimport useAllContentTypes from '../../hooks/useAllContentTypes';\nimport { getTranslation } from '../../utils';\nimport { useIntl } from 'react-intl';\nimport { FullLoader } from '../../components/UI';\nimport PageWrapper from './PageWrapper';\nimport ContentTypeAccordion from './ContentTypeAccordion';\n\ntype Action =\n | { type: 'SET_SELECTED_CONTENT_TYPES'; payload: ConfigContentType[] }\n | { type: 'SET_DEFAULT_FIELD'; payload: { ctUid: string; field: string } }\n | { type: 'SET_PATTERN'; payload: { ctUid: string; pattern: string } }\n\nfunction reducer(settingsState: PluginConfig, action: Action): PluginConfig {\n let updatedContentTypes\n switch (action.type) {\n case 'SET_SELECTED_CONTENT_TYPES':\n updatedContentTypes = action.payload.map(ct => {\n return settingsState.selectedContentTypes.find((cta: ConfigContentType) => cta.uid === ct.uid) || ct\n })\n return { ...settingsState, selectedContentTypes: updatedContentTypes };\n case 'SET_DEFAULT_FIELD':\n updatedContentTypes = settingsState.selectedContentTypes.map(ct =>\n ct.uid === action.payload.ctUid ? { ...ct, default: action.payload.field } : ct\n );\n return { ...settingsState, selectedContentTypes: updatedContentTypes };\n case 'SET_PATTERN':\n updatedContentTypes = settingsState.selectedContentTypes.map(ct =>\n ct.uid === action.payload.ctUid ? { ...ct, pattern: transformToUrl(action.payload.pattern) } : ct\n );\n return { ...settingsState, selectedContentTypes: updatedContentTypes };\n default:\n throw new Error();\n }\n}\n\nconst Settings = () => {\n const { config, setConfig, loading, fetchError } = usePluginConfig();\n const [settingsState, dispatch] = useReducer(reducer, config || { selectedContentTypes: [] });\n const { contentTypes: allContentTypesData } = useAllContentTypes();\n const allContentTypes = allContentTypesData?.filter((ct: ContentType) => ct.pluginOptions?.webatlas?.active === true);\n const [initialState, setInitialState] = useState(config || { selectedContentTypes: [] })\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const [isSaving, setIsSaving] = useState(false);\n\n useEffect(() => {\n setInitialState(config || { selectedContentTypes: [] })\n }, [config]);\n\n useEffect(() => {\n if (!config) return;\n dispatch({ type: 'SET_SELECTED_CONTENT_TYPES', payload: config.selectedContentTypes });\n }, [config]);\n \n useEffect(() => {\n if (fetchError) {\n toggleNotification({\n type: 'danger',\n message: formatMessage({\n id: getTranslation('notification.error'),\n defaultMessage: 'An error occurred',\n }) + ': ' + fetchError,\n });\n }\n }, [fetchError, toggleNotification, formatMessage]);\n\n async function save() {\n if (\n !settingsState \n || settingsState.selectedContentTypes.find((cta: ConfigContentType) => !cta.default) !== undefined\n ) return\n\n setIsSaving(true);\n try {\n await setConfig(settingsState)\n setInitialState(settingsState)\n\n toggleNotification({\n type: 'success',\n message: formatMessage({\n id: getTranslation('notification.settings.saved'),\n defaultMessage: 'Settings saved successfully',\n }),\n });\n setIsSaving(false);\n } catch (err) {\n setIsSaving(false);\n toggleNotification({\n type: 'danger',\n message: formatMessage({\n id: getTranslation('notification.error'),\n defaultMessage: 'An error occurred',\n }) + ': ' + err,\n });\n console.error(err);\n }\n }\n\n if (loading) {\n return <PageWrapper>\n <FullLoader height={200} />\n </PageWrapper>\n }\n\n return (\n <PageWrapper settingsState={settingsState} initialState={initialState} save={save} isSaving={isSaving}>\n <Field.Root\n name=\"selectedContentTypes\"\n hint={formatMessage({\n id: getTranslation('settings.page.enabledContentTypes.hint'),\n defaultMessage: 'Select the content types for which you want to enable URL aliases',\n })}\n >\n <Field.Label>\n {formatMessage({\n id: getTranslation('settings.page.enabledContentTypes'),\n defaultMessage: 'Enabled Content Types',\n })}\n </Field.Label>\n <MultiSelect\n placeholder={formatMessage({\n id: getTranslation('settings.page.enabledContentTypes.placeholder'),\n defaultMessage: 'Select content types...',\n })}\n onClear={() => dispatch({ type: 'SET_SELECTED_CONTENT_TYPES', payload: [] })}\n value={[...settingsState.selectedContentTypes.map((ct: ConfigContentType) => ct.uid)]}\n onChange={(value: string[]) =>\n dispatch({\n type: 'SET_SELECTED_CONTENT_TYPES',\n payload: value.map(v => ({\n uid: v,\n default: '',\n pattern: '',\n })),\n })\n }\n withTags\n >\n {allContentTypes && allContentTypes.map(item => \n <MultiSelectOption key={item.uid} value={item.uid}>{item.info.displayName}</MultiSelectOption>\n )}\n </MultiSelect>\n <Field.Hint/>\n </Field.Root>\n {settingsState.selectedContentTypes && settingsState.selectedContentTypes.length > 0 && \n <Box paddingTop={4}>\n <Field.Root name=\"selectedContentTypesAccordion\">\n <Field.Label>\n {formatMessage({\n id: getTranslation('settings.page.contentTypeSettings'),\n defaultMessage: 'Content Type settings',\n })}\n </Field.Label>\n <Accordion.Root>\n {settingsState.selectedContentTypes?.map((contentTypeSettings: ConfigContentType) => {\n const ct: ContentType | undefined = allContentTypes?.find((item) => item.uid === contentTypeSettings.uid)\n return <ContentTypeAccordion key={contentTypeSettings.uid} contentType={ct} contentTypeSettings={contentTypeSettings} dispatch={dispatch} />\n })}\n </Accordion.Root>\n </Field.Root>\n </Box>\n }\n </PageWrapper>\n );\n};\n\nexport default Settings;\n"],"names":[],"mappings":";;;;;;;;AAOA,SAAwB,YAAY;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMG;AAEK,QAAA,EAAE,cAAc,IAAI,QAAQ;AAGhC,SAAA,qBAAC,KAAK,MAAL,EACC,UAAA;AAAA,IAAA;AAAA,MAAC,QAAQ;AAAA,MAAR;AAAA,QACC,OAAO;AAAA,QACP,UAAU,cAAc;AAAA,UACtB,IAAI,eAAe,wBAAwB;AAAA,UAC3C,gBAAgB;AAAA,QAAA,CACjB;AAAA,QACD,eAAgB,iBAAiB,gBAAgB,QAC/C;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAS,MAAM,KAAK;AAAA,YACpB,SAAS;AAAA,YACT,UACE,KAAK,UAAU,aAAa,MAAM,KAAK,UAAU,YAAY,KAC1D,cAAc,qBAAqB,KAAK,CAAC,QAA2B,CAAC,IAAI,OAAO,MAAM,UACtF;AAAA,YAGJ,UAAc,cAAA;AAAA,cACb,IAAI,eAAe,MAAM;AAAA,cACzB,gBAAgB;AAAA,YACjB,CAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAEJ;AAAA,IACA,oBAAC,QAAQ,SAAR,EACC,UAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,YAAW;AAAA,QACX,aAAY;AAAA,QACZ,WAAS;AAA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A,EAAiC,OAAO,KAAK,KAAM,UAAK,KAAA,KAAK,YAAtC,GAAA,KAAK,GAA6C;AAAA,cAAA;AAAA,YAC5E;AAAA,UACF;AAAA,UACA,oBAAC,MAAM,MAAN,CAAU,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACb;AAAA,IACC,cAAc,wBAAwB,cAAc,qBAAqB,SAAS,KACjF,oBAAC,KAAI,EAAA,YAAY,GACf,UAAC,qBAAA,MAAM,MAAN,EAAW,MAAK,iCACf,UAAA;AAAA,MAAC,oBAAA,MAAM,OAAN,EACE,UAAc,cAAA;AAAA,QACb,IAAI,eAAe,mCAAmC;AAAA,QACtD,gBAAgB;AAAA,MACjB,CAAA,GACH;AAAA,MACA,oBAAC,UAAU,MAAV,EACE,wBAAc,sBAAsB,IAAI,CAAC,wBAA2C;AAC7E,cAAA,KAA8B,iBAAiB,KAAK,CAAC,SAAS,KAAK,QAAQ,oBAAoB,GAAG;AACxG,mCAAQ,sBAAmD,EAAA,aAAa,IAAI,qBAA0C,SAAA,GAApF,oBAAoB,GAAoF;AAAA,MAAA,CAC3I,EACH,CAAA;AAAA,IAAA,EAAA,CACF,EACF,CAAA;AAAA,EAAA,GAEJ;AAEJ;"}
@@ -0,0 +1,246 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { useState, useEffect, useMemo } from "react";
3
+ import { Thead, Tr, Th, Typography, VisuallyHidden, Td, Flex, LinkButton, Grid, Box, Field, Table, Tbody, EmptyStateLayout } from "@strapi/design-system";
4
+ import { ChevronDown, Pencil, Cross } from "@strapi/icons";
5
+ import { g as getTranslation, u as useApi, d as debounce } from "./index-D3xDvB4d.mjs";
6
+ import { Page, Layouts, useNotification } from "@strapi/strapi/admin";
7
+ import "@strapi/icons/symbols";
8
+ import { F as FullLoader } from "./FullLoader-CrPED_dY.mjs";
9
+ import { useIntl } from "react-intl";
10
+ import { useSearchParams } from "react-router-dom";
11
+ function getRouteType(route) {
12
+ if (route.wrapper) {
13
+ return "wrapper";
14
+ } else if (!route.internal) {
15
+ return "external";
16
+ } else {
17
+ return "internal";
18
+ }
19
+ }
20
+ function TableHeader({
21
+ sortKey,
22
+ handleSort
23
+ }) {
24
+ const { formatMessage } = useIntl();
25
+ return /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
26
+ /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("title"), cursor: "pointer", children: [
27
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
28
+ id: getTranslation("title"),
29
+ defaultMessage: "Title"
30
+ }) }),
31
+ sortKey === "title" && /* @__PURE__ */ jsx(ChevronDown, {})
32
+ ] }),
33
+ /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("fullPath"), cursor: "pointer", children: [
34
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
35
+ id: getTranslation("route"),
36
+ defaultMessage: "Route"
37
+ }) }),
38
+ sortKey === "fullPath" && /* @__PURE__ */ jsx(ChevronDown, {})
39
+ ] }),
40
+ /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("type"), cursor: "pointer", children: [
41
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
42
+ id: getTranslation("routes.page.column.type"),
43
+ defaultMessage: "Type"
44
+ }) }),
45
+ sortKey === "type" && /* @__PURE__ */ jsx(ChevronDown, {})
46
+ ] }),
47
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(VisuallyHidden, { children: formatMessage({
48
+ id: getTranslation("actions"),
49
+ defaultMessage: "Actions"
50
+ }) }) })
51
+ ] }) });
52
+ }
53
+ function TableRow({ route }) {
54
+ const { formatMessage } = useIntl();
55
+ return /* @__PURE__ */ jsxs(Tr, { children: [
56
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.title }) }),
57
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.fullPath }) }),
58
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: formatMessage({
59
+ id: getTranslation(`route.type.${getRouteType(route)}`),
60
+ defaultMessage: "-"
61
+ }) }) }),
62
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Flex, { gap: 2, justifyContent: "end", children: route.internal && /* @__PURE__ */ jsx(
63
+ LinkButton,
64
+ {
65
+ variant: "secondary",
66
+ startIcon: /* @__PURE__ */ jsx(Pencil, {}),
67
+ href: `/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`,
68
+ children: formatMessage({
69
+ id: getTranslation("edit"),
70
+ defaultMessage: "Edit"
71
+ })
72
+ }
73
+ ) }) })
74
+ ] });
75
+ }
76
+ function PageWrapper({ children }) {
77
+ const { formatMessage } = useIntl();
78
+ return /* @__PURE__ */ jsxs(Page.Main, { children: [
79
+ /* @__PURE__ */ jsx(
80
+ Layouts.Header,
81
+ {
82
+ title: formatMessage({
83
+ id: getTranslation("routes.page.title"),
84
+ defaultMessage: "Routes"
85
+ }),
86
+ subtitle: formatMessage({
87
+ id: getTranslation("routes.page.subtitle"),
88
+ defaultMessage: "Overview of all existing routes"
89
+ })
90
+ }
91
+ ),
92
+ /* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsx(Fragment, { children }) })
93
+ ] });
94
+ }
95
+ function compareBy(field, direction) {
96
+ if (!field) {
97
+ return () => 0;
98
+ }
99
+ if (field === "type") {
100
+ return (a, b) => {
101
+ const typeA = a.internal ? "internal" : "external";
102
+ const typeB = b.internal ? "internal" : "external";
103
+ return direction === "asc" ? typeA.localeCompare(typeB) : typeB.localeCompare(typeA);
104
+ };
105
+ }
106
+ return (a, b) => {
107
+ const aValue = a[field];
108
+ const bValue = b[field];
109
+ if (typeof aValue === "string" && typeof bValue === "string") {
110
+ return direction === "asc" ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
111
+ }
112
+ return 0;
113
+ };
114
+ }
115
+ function SearchInput({
116
+ searchQuery,
117
+ handleSearchChange
118
+ }) {
119
+ const { formatMessage } = useIntl();
120
+ return /* @__PURE__ */ jsx(Grid.Root, { style: { marginBottom: "16px" }, children: /* @__PURE__ */ jsx(Grid.Item, { col: 4, s: 12, children: /* @__PURE__ */ jsx(Box, { width: "100%", children: /* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsx(
121
+ Field.Input,
122
+ {
123
+ name: "search",
124
+ placeholder: formatMessage({
125
+ id: getTranslation("routes.page.searchPlaceholder"),
126
+ defaultMessage: "Search routes"
127
+ }),
128
+ value: searchQuery,
129
+ onChange: handleSearchChange,
130
+ endAction: searchQuery ? /* @__PURE__ */ jsx(
131
+ "button",
132
+ {
133
+ type: "button",
134
+ onClick: () => handleSearchChange({ target: { value: "" } }),
135
+ style: { color: "inherit", background: "none", border: "none", cursor: "pointer" },
136
+ "aria-label": "Clear search",
137
+ children: /* @__PURE__ */ jsx(Cross, {})
138
+ }
139
+ ) : null
140
+ }
141
+ ) }) }) }) });
142
+ }
143
+ function RouteTable({
144
+ routes,
145
+ sortKey,
146
+ handleSort
147
+ }) {
148
+ const { formatMessage } = useIntl();
149
+ return /* @__PURE__ */ jsxs(Table, { colCount: 4, rowCount: routes.length, children: [
150
+ /* @__PURE__ */ jsx(TableHeader, { sortKey, handleSort }),
151
+ /* @__PURE__ */ jsx(Tbody, { children: routes.length > 0 ? routes.map((route) => /* @__PURE__ */ jsx(TableRow, { route }, route.id)) : /* @__PURE__ */ jsx(Tr, { children: /* @__PURE__ */ jsx(Td, { colSpan: 4, children: /* @__PURE__ */ jsx(
152
+ EmptyStateLayout,
153
+ {
154
+ content: formatMessage({
155
+ id: getTranslation("routes.page.emptyRoutes"),
156
+ defaultMessage: "No routes found"
157
+ }),
158
+ shadow: false
159
+ }
160
+ ) }) }) })
161
+ ] });
162
+ }
163
+ const Routes = () => {
164
+ const { getRoutes } = useApi();
165
+ const { formatMessage } = useIntl();
166
+ const { toggleNotification } = useNotification();
167
+ const [allRoutes, setAllRoutes] = useState([]);
168
+ const [routes, setRoutes] = useState([]);
169
+ const [loading, setLoading] = useState(true);
170
+ const [searchParams, setSearchParams] = useSearchParams();
171
+ const initialQuery = searchParams.get("search") || "";
172
+ const [searchQuery, setSearchQuery] = useState(initialQuery);
173
+ const [sortKey, setSortKey] = useState(void 0);
174
+ const [sortDirection, setSortDirection] = useState("asc");
175
+ useEffect(() => {
176
+ const query = searchQuery.toLowerCase();
177
+ setRoutes(
178
+ allRoutes.filter(
179
+ (route) => JSON.stringify(route.id).toLowerCase().includes(query) || route.title.toLowerCase().includes(query) || route.fullPath.toLowerCase().includes(query) || route.relatedDocumentId.toLowerCase().includes(query) || route.relatedContentType.toLowerCase().includes(query)
180
+ )
181
+ );
182
+ }, [searchQuery, allRoutes]);
183
+ const debouncedSetSearchParams = useMemo(
184
+ () => debounce((value) => {
185
+ value ? setSearchParams({ search: value }) : setSearchParams({});
186
+ }, 300),
187
+ [setSearchParams]
188
+ );
189
+ const handleSearchChange = (e) => {
190
+ const value = e.target.value;
191
+ setSearchQuery(value);
192
+ debouncedSetSearchParams(value);
193
+ };
194
+ useEffect(() => {
195
+ async function fetchRoutes() {
196
+ try {
197
+ const data = await getRoutes();
198
+ setAllRoutes(data);
199
+ setRoutes(data);
200
+ } catch (err) {
201
+ console.error("Failed to fetch routes:", err);
202
+ toggleNotification({
203
+ type: "danger",
204
+ message: formatMessage({
205
+ id: getTranslation("notification.routes.fetchFailed"),
206
+ defaultMessage: "Failed to fetch routes"
207
+ })
208
+ });
209
+ } finally {
210
+ setLoading(false);
211
+ }
212
+ }
213
+ fetchRoutes();
214
+ }, []);
215
+ const handleSort = (key) => {
216
+ setSortDirection((prev) => prev === "asc" ? "desc" : "asc");
217
+ setSortKey(key);
218
+ };
219
+ useEffect(() => {
220
+ const sortedRoutes = sortKey ? [...routes].sort(compareBy(sortKey, sortDirection)) : routes;
221
+ setRoutes(sortedRoutes);
222
+ }, [sortKey, sortDirection]);
223
+ if (loading) {
224
+ return /* @__PURE__ */ jsx(PageWrapper, { children: /* @__PURE__ */ jsx(FullLoader, {}) });
225
+ }
226
+ return /* @__PURE__ */ jsxs(PageWrapper, { children: [
227
+ /* @__PURE__ */ jsx(
228
+ SearchInput,
229
+ {
230
+ handleSearchChange,
231
+ searchQuery
232
+ }
233
+ ),
234
+ /* @__PURE__ */ jsx(
235
+ RouteTable,
236
+ {
237
+ routes,
238
+ sortKey,
239
+ handleSort
240
+ }
241
+ )
242
+ ] });
243
+ };
244
+ export {
245
+ Routes as default
246
+ };
@@ -0,0 +1,247 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const designSystem = require("@strapi/design-system");
6
+ const icons = require("@strapi/icons");
7
+ const index = require("./index-BOEv4jIJ.js");
8
+ const admin = require("@strapi/strapi/admin");
9
+ require("@strapi/icons/symbols");
10
+ const FullLoader = require("./FullLoader-Cmsf8xS6.js");
11
+ const reactIntl = require("react-intl");
12
+ const reactRouterDom = require("react-router-dom");
13
+ function getRouteType(route) {
14
+ if (route.wrapper) {
15
+ return "wrapper";
16
+ } else if (!route.internal) {
17
+ return "external";
18
+ } else {
19
+ return "internal";
20
+ }
21
+ }
22
+ function TableHeader({
23
+ sortKey,
24
+ handleSort
25
+ }) {
26
+ const { formatMessage } = reactIntl.useIntl();
27
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
28
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Th, { onClick: () => handleSort("title"), cursor: "pointer", children: [
29
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: formatMessage({
30
+ id: index.getTranslation("title"),
31
+ defaultMessage: "Title"
32
+ }) }),
33
+ sortKey === "title" && /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronDown, {})
34
+ ] }),
35
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Th, { onClick: () => handleSort("fullPath"), cursor: "pointer", children: [
36
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: formatMessage({
37
+ id: index.getTranslation("route"),
38
+ defaultMessage: "Route"
39
+ }) }),
40
+ sortKey === "fullPath" && /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronDown, {})
41
+ ] }),
42
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Th, { onClick: () => handleSort("type"), cursor: "pointer", children: [
43
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: formatMessage({
44
+ id: index.getTranslation("routes.page.column.type"),
45
+ defaultMessage: "Type"
46
+ }) }),
47
+ sortKey === "type" && /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronDown, {})
48
+ ] }),
49
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: formatMessage({
50
+ id: index.getTranslation("actions"),
51
+ defaultMessage: "Actions"
52
+ }) }) })
53
+ ] }) });
54
+ }
55
+ function TableRow({ route }) {
56
+ const { formatMessage } = reactIntl.useIntl();
57
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
58
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: route.title }) }),
59
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: route.fullPath }) }),
60
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: formatMessage({
61
+ id: index.getTranslation(`route.type.${getRouteType(route)}`),
62
+ defaultMessage: "-"
63
+ }) }) }),
64
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, justifyContent: "end", children: route.internal && /* @__PURE__ */ jsxRuntime.jsx(
65
+ designSystem.LinkButton,
66
+ {
67
+ variant: "secondary",
68
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {}),
69
+ href: `/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`,
70
+ children: formatMessage({
71
+ id: index.getTranslation("edit"),
72
+ defaultMessage: "Edit"
73
+ })
74
+ }
75
+ ) }) })
76
+ ] });
77
+ }
78
+ function PageWrapper({ children }) {
79
+ const { formatMessage } = reactIntl.useIntl();
80
+ return /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { children: [
81
+ /* @__PURE__ */ jsxRuntime.jsx(
82
+ admin.Layouts.Header,
83
+ {
84
+ title: formatMessage({
85
+ id: index.getTranslation("routes.page.title"),
86
+ defaultMessage: "Routes"
87
+ }),
88
+ subtitle: formatMessage({
89
+ id: index.getTranslation("routes.page.subtitle"),
90
+ defaultMessage: "Overview of all existing routes"
91
+ })
92
+ }
93
+ ),
94
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children }) })
95
+ ] });
96
+ }
97
+ function compareBy(field, direction) {
98
+ if (!field) {
99
+ return () => 0;
100
+ }
101
+ if (field === "type") {
102
+ return (a, b) => {
103
+ const typeA = a.internal ? "internal" : "external";
104
+ const typeB = b.internal ? "internal" : "external";
105
+ return direction === "asc" ? typeA.localeCompare(typeB) : typeB.localeCompare(typeA);
106
+ };
107
+ }
108
+ return (a, b) => {
109
+ const aValue = a[field];
110
+ const bValue = b[field];
111
+ if (typeof aValue === "string" && typeof bValue === "string") {
112
+ return direction === "asc" ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
113
+ }
114
+ return 0;
115
+ };
116
+ }
117
+ function SearchInput({
118
+ searchQuery,
119
+ handleSearchChange
120
+ }) {
121
+ const { formatMessage } = reactIntl.useIntl();
122
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { style: { marginBottom: "16px" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 4, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(
123
+ designSystem.Field.Input,
124
+ {
125
+ name: "search",
126
+ placeholder: formatMessage({
127
+ id: index.getTranslation("routes.page.searchPlaceholder"),
128
+ defaultMessage: "Search routes"
129
+ }),
130
+ value: searchQuery,
131
+ onChange: handleSearchChange,
132
+ endAction: searchQuery ? /* @__PURE__ */ jsxRuntime.jsx(
133
+ "button",
134
+ {
135
+ type: "button",
136
+ onClick: () => handleSearchChange({ target: { value: "" } }),
137
+ style: { color: "inherit", background: "none", border: "none", cursor: "pointer" },
138
+ "aria-label": "Clear search",
139
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {})
140
+ }
141
+ ) : null
142
+ }
143
+ ) }) }) }) });
144
+ }
145
+ function RouteTable({
146
+ routes,
147
+ sortKey,
148
+ handleSort
149
+ }) {
150
+ const { formatMessage } = reactIntl.useIntl();
151
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 4, rowCount: routes.length, children: [
152
+ /* @__PURE__ */ jsxRuntime.jsx(TableHeader, { sortKey, handleSort }),
153
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: routes.length > 0 ? routes.map((route) => /* @__PURE__ */ jsxRuntime.jsx(TableRow, { route }, route.id)) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tr, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { colSpan: 4, children: /* @__PURE__ */ jsxRuntime.jsx(
154
+ designSystem.EmptyStateLayout,
155
+ {
156
+ content: formatMessage({
157
+ id: index.getTranslation("routes.page.emptyRoutes"),
158
+ defaultMessage: "No routes found"
159
+ }),
160
+ shadow: false
161
+ }
162
+ ) }) }) })
163
+ ] });
164
+ }
165
+ const Routes = () => {
166
+ const { getRoutes } = index.useApi();
167
+ const { formatMessage } = reactIntl.useIntl();
168
+ const { toggleNotification } = admin.useNotification();
169
+ const [allRoutes, setAllRoutes] = React.useState([]);
170
+ const [routes, setRoutes] = React.useState([]);
171
+ const [loading, setLoading] = React.useState(true);
172
+ const [searchParams, setSearchParams] = reactRouterDom.useSearchParams();
173
+ const initialQuery = searchParams.get("search") || "";
174
+ const [searchQuery, setSearchQuery] = React.useState(initialQuery);
175
+ const [sortKey, setSortKey] = React.useState(void 0);
176
+ const [sortDirection, setSortDirection] = React.useState("asc");
177
+ React.useEffect(() => {
178
+ const query = searchQuery.toLowerCase();
179
+ setRoutes(
180
+ allRoutes.filter(
181
+ (route) => JSON.stringify(route.id).toLowerCase().includes(query) || route.title.toLowerCase().includes(query) || route.fullPath.toLowerCase().includes(query) || route.relatedDocumentId.toLowerCase().includes(query) || route.relatedContentType.toLowerCase().includes(query)
182
+ )
183
+ );
184
+ }, [searchQuery, allRoutes]);
185
+ const debouncedSetSearchParams = React.useMemo(
186
+ () => index.debounce((value) => {
187
+ value ? setSearchParams({ search: value }) : setSearchParams({});
188
+ }, 300),
189
+ [setSearchParams]
190
+ );
191
+ const handleSearchChange = (e) => {
192
+ const value = e.target.value;
193
+ setSearchQuery(value);
194
+ debouncedSetSearchParams(value);
195
+ };
196
+ React.useEffect(() => {
197
+ async function fetchRoutes() {
198
+ try {
199
+ const data = await getRoutes();
200
+ setAllRoutes(data);
201
+ setRoutes(data);
202
+ } catch (err) {
203
+ console.error("Failed to fetch routes:", err);
204
+ toggleNotification({
205
+ type: "danger",
206
+ message: formatMessage({
207
+ id: index.getTranslation("notification.routes.fetchFailed"),
208
+ defaultMessage: "Failed to fetch routes"
209
+ })
210
+ });
211
+ } finally {
212
+ setLoading(false);
213
+ }
214
+ }
215
+ fetchRoutes();
216
+ }, []);
217
+ const handleSort = (key) => {
218
+ setSortDirection((prev) => prev === "asc" ? "desc" : "asc");
219
+ setSortKey(key);
220
+ };
221
+ React.useEffect(() => {
222
+ const sortedRoutes = sortKey ? [...routes].sort(compareBy(sortKey, sortDirection)) : routes;
223
+ setRoutes(sortedRoutes);
224
+ }, [sortKey, sortDirection]);
225
+ if (loading) {
226
+ return /* @__PURE__ */ jsxRuntime.jsx(PageWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(FullLoader.FullLoader, {}) });
227
+ }
228
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageWrapper, { children: [
229
+ /* @__PURE__ */ jsxRuntime.jsx(
230
+ SearchInput,
231
+ {
232
+ handleSearchChange,
233
+ searchQuery
234
+ }
235
+ ),
236
+ /* @__PURE__ */ jsxRuntime.jsx(
237
+ RouteTable,
238
+ {
239
+ routes,
240
+ sortKey,
241
+ handleSort
242
+ }
243
+ )
244
+ ] });
245
+ };
246
+ exports.default = Routes;
247
+ //# sourceMappingURL=index-Bg96TqDm.js.map