@payloadcms/plugin-search 4.0.0-canary.27 → 4.0.0-canary.29
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/Search/ui/ReindexButton/index.client.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAyC,MAAM,OAAO,CAAA;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAMpD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/Search/ui/ReindexButton/index.client.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAyC,MAAM,OAAO,CAAA;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAMpD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAsI5D,CAAA"}
|
|
@@ -10,6 +10,7 @@ export const ReindexButtonClient = ({ collectionLabels, searchCollections, searc
|
|
|
10
10
|
const { config } = useConfig();
|
|
11
11
|
const { i18n: { t } } = useTranslation();
|
|
12
12
|
const locale = useLocale();
|
|
13
|
+
const localeCode = locale?.code;
|
|
13
14
|
const router = useRouter();
|
|
14
15
|
const [reindexCollections, setReindexCollections] = useState([]);
|
|
15
16
|
const openConfirmModal = useCallback(()=>openModal(confirmReindexModalSlug), [
|
|
@@ -22,7 +23,7 @@ export const ReindexButtonClient = ({ collectionLabels, searchCollections, searc
|
|
|
22
23
|
try {
|
|
23
24
|
const res = await fetch(formatAdminURL({
|
|
24
25
|
apiRoute: config.routes.api,
|
|
25
|
-
path: `/${searchSlug}/reindex?locale=${
|
|
26
|
+
path: `/${searchSlug}/reindex${localeCode ? `?locale=${localeCode}` : ''}`
|
|
26
27
|
}), {
|
|
27
28
|
body: JSON.stringify({
|
|
28
29
|
collections: reindexCollections
|
|
@@ -45,7 +46,7 @@ export const ReindexButtonClient = ({ collectionLabels, searchCollections, searc
|
|
|
45
46
|
reindexCollections,
|
|
46
47
|
router,
|
|
47
48
|
searchSlug,
|
|
48
|
-
|
|
49
|
+
localeCode,
|
|
49
50
|
config
|
|
50
51
|
]);
|
|
51
52
|
const handleShowConfirmModal = useCallback((collections = searchCollections)=>{
|
|
@@ -68,11 +69,11 @@ export const ReindexButtonClient = ({ collectionLabels, searchCollections, searc
|
|
|
68
69
|
if (typeof label === 'string') {
|
|
69
70
|
return label;
|
|
70
71
|
} else {
|
|
71
|
-
return label && Object.hasOwn(label,
|
|
72
|
+
return label && localeCode && Object.hasOwn(label, localeCode) ? label[localeCode] : slug;
|
|
72
73
|
}
|
|
73
74
|
}, [
|
|
74
75
|
collectionLabels,
|
|
75
|
-
|
|
76
|
+
localeCode
|
|
76
77
|
]);
|
|
77
78
|
const pluralizedLabels = useMemo(()=>{
|
|
78
79
|
return searchCollections.reduce((acc, slug)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/Search/ui/ReindexButton/index.client.tsx"],"sourcesContent":["'use client'\n\nimport {\n ConfirmationModal,\n Popup,\n PopupList,\n toast,\n useConfig,\n useLocale,\n useModal,\n useRouter,\n useTranslation,\n} from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { useCallback, useMemo, useState } from 'react'\n\nimport type { ReindexButtonProps } from './types.js'\n\nimport { ReindexButtonLabel } from './ReindexButtonLabel/index.js'\n\nconst confirmReindexModalSlug = 'confirm-reindex-modal'\n\nexport const ReindexButtonClient: React.FC<ReindexButtonProps> = ({\n collectionLabels,\n searchCollections,\n searchSlug,\n}) => {\n const { openModal } = useModal()\n\n const { config } = useConfig()\n\n const {\n i18n: { t },\n } = useTranslation()\n\n const locale = useLocale()\n const router = useRouter()\n\n const [reindexCollections, setReindexCollections] = useState<string[]>([])\n\n const openConfirmModal = useCallback(() => openModal(confirmReindexModalSlug), [openModal])\n\n const handleReindexSubmit = useCallback(async () => {\n if (!reindexCollections.length) {\n return\n }\n\n try {\n const res = await fetch(\n formatAdminURL({\n apiRoute: config.routes.api,\n path: `/${searchSlug}/reindex?locale=${
|
|
1
|
+
{"version":3,"sources":["../../../../src/Search/ui/ReindexButton/index.client.tsx"],"sourcesContent":["'use client'\n\nimport {\n ConfirmationModal,\n Popup,\n PopupList,\n toast,\n useConfig,\n useLocale,\n useModal,\n useRouter,\n useTranslation,\n} from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { useCallback, useMemo, useState } from 'react'\n\nimport type { ReindexButtonProps } from './types.js'\n\nimport { ReindexButtonLabel } from './ReindexButtonLabel/index.js'\n\nconst confirmReindexModalSlug = 'confirm-reindex-modal'\n\nexport const ReindexButtonClient: React.FC<ReindexButtonProps> = ({\n collectionLabels,\n searchCollections,\n searchSlug,\n}) => {\n const { openModal } = useModal()\n\n const { config } = useConfig()\n\n const {\n i18n: { t },\n } = useTranslation()\n\n const locale = useLocale()\n const localeCode = locale?.code\n const router = useRouter()\n\n const [reindexCollections, setReindexCollections] = useState<string[]>([])\n\n const openConfirmModal = useCallback(() => openModal(confirmReindexModalSlug), [openModal])\n\n const handleReindexSubmit = useCallback(async () => {\n if (!reindexCollections.length) {\n return\n }\n\n try {\n const res = await fetch(\n formatAdminURL({\n apiRoute: config.routes.api,\n path: `/${searchSlug}/reindex${localeCode ? `?locale=${localeCode}` : ''}`,\n }),\n {\n body: JSON.stringify({\n collections: reindexCollections,\n }),\n method: 'POST',\n },\n )\n\n const { message } = (await res.json()) as { message: string }\n\n if (!res.ok) {\n toast.error(message)\n } else {\n toast.success(message)\n return router.refresh()\n }\n } catch (_err: unknown) {\n // swallow error, toast shown above\n } finally {\n setReindexCollections([])\n }\n }, [reindexCollections, router, searchSlug, localeCode, config])\n\n const handleShowConfirmModal = useCallback(\n (collections: string | string[] = searchCollections) => {\n setReindexCollections(typeof collections === 'string' ? [collections] : collections)\n openConfirmModal()\n },\n [openConfirmModal, searchCollections],\n )\n\n const handlePopupButtonClick = useCallback(\n (closePopup: () => void, slug?: string) => {\n closePopup()\n handleShowConfirmModal(slug)\n },\n [handleShowConfirmModal],\n )\n\n const getPluralizedLabel = useCallback(\n (slug: string) => {\n const label = collectionLabels[slug]\n if (typeof label === 'string') {\n return label\n } else {\n return label && localeCode && Object.hasOwn(label, localeCode) ? label[localeCode] : slug\n }\n },\n [collectionLabels, localeCode],\n )\n\n const pluralizedLabels = useMemo(() => {\n return searchCollections.reduce<Record<string, string>>((acc, slug) => {\n const label = getPluralizedLabel(slug)\n if (label) {\n acc[slug] = label\n }\n return acc\n }, {})\n }, [searchCollections, getPluralizedLabel])\n\n const selectedAll = reindexCollections.length === searchCollections.length\n const selectedLabels = reindexCollections.map((slug) => pluralizedLabels[slug]).join(', ')\n\n const modalTitle = selectedAll\n ? t('general:confirmReindexAll')\n : t('general:confirmReindex', { collections: selectedLabels })\n const modalDescription = selectedAll\n ? t('general:confirmReindexDescriptionAll')\n : t('general:confirmReindexDescription', { collections: selectedLabels })\n\n return (\n <div>\n <Popup\n render={({ close }) => (\n <PopupList.ButtonGroup>\n {searchCollections.map((collectionSlug) => (\n <PopupList.Button\n key={collectionSlug}\n onClick={() => handlePopupButtonClick(close, collectionSlug)}\n >\n {pluralizedLabels[collectionSlug]}\n </PopupList.Button>\n ))}\n <PopupList.Button onClick={() => handlePopupButtonClick(close)}>\n {t('general:allCollections')}\n </PopupList.Button>\n </PopupList.ButtonGroup>\n )}\n renderButton={(buttonProps) => <ReindexButtonLabel {...buttonProps} />}\n showScrollbar\n size=\"large\"\n verticalAlign=\"bottom\"\n />\n <ConfirmationModal\n body={modalDescription}\n heading={modalTitle}\n modalSlug={confirmReindexModalSlug}\n onConfirm={handleReindexSubmit}\n />\n </div>\n )\n}\n"],"names":["ConfirmationModal","Popup","PopupList","toast","useConfig","useLocale","useModal","useRouter","useTranslation","formatAdminURL","React","useCallback","useMemo","useState","ReindexButtonLabel","confirmReindexModalSlug","ReindexButtonClient","collectionLabels","searchCollections","searchSlug","openModal","config","i18n","t","locale","localeCode","code","router","reindexCollections","setReindexCollections","openConfirmModal","handleReindexSubmit","length","res","fetch","apiRoute","routes","api","path","body","JSON","stringify","collections","method","message","json","ok","error","success","refresh","_err","handleShowConfirmModal","handlePopupButtonClick","closePopup","slug","getPluralizedLabel","label","Object","hasOwn","pluralizedLabels","reduce","acc","selectedAll","selectedLabels","map","join","modalTitle","modalDescription","div","render","close","ButtonGroup","collectionSlug","Button","onClick","renderButton","buttonProps","showScrollbar","size","verticalAlign","heading","modalSlug","onConfirm"],"mappings":"AAAA;;AAEA,SACEA,iBAAiB,EACjBC,KAAK,EACLC,SAAS,EACTC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,QAAQ,EACRC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAI7D,SAASC,kBAAkB,QAAQ,gCAA+B;AAElE,MAAMC,0BAA0B;AAEhC,OAAO,MAAMC,sBAAoD,CAAC,EAChEC,gBAAgB,EAChBC,iBAAiB,EACjBC,UAAU,EACX;IACC,MAAM,EAAEC,SAAS,EAAE,GAAGd;IAEtB,MAAM,EAAEe,MAAM,EAAE,GAAGjB;IAEnB,MAAM,EACJkB,MAAM,EAAEC,CAAC,EAAE,EACZ,GAAGf;IAEJ,MAAMgB,SAASnB;IACf,MAAMoB,aAAaD,QAAQE;IAC3B,MAAMC,SAASpB;IAEf,MAAM,CAACqB,oBAAoBC,sBAAsB,GAAGhB,SAAmB,EAAE;IAEzE,MAAMiB,mBAAmBnB,YAAY,IAAMS,UAAUL,0BAA0B;QAACK;KAAU;IAE1F,MAAMW,sBAAsBpB,YAAY;QACtC,IAAI,CAACiB,mBAAmBI,MAAM,EAAE;YA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P;YAC5D,MAAME,QAAQD,mBAAmBD;YACjC,IAAIE,OAAO;gBACTK,GAAG,CAACP,KAAK,GAAGE;YACd;YACA,OAAOK;QACT,GAAG,CAAC;IACN,GAAG;QAAC3C;QAAmBqC;KAAmB;IAE1C,MAAMO,cAAclC,mBAAmBI,MAAM,KAAKd,kBAAkBc,MAAM;IAC1E,MAAM+B,iBAAiBnC,mBAAmBoC,GAAG,CAAC,CAACV,OAASK,gBAAgB,CAACL,KAAK,EAAEW,IAAI,CAAC;IAErF,MAAMC,aAAaJ,cACfvC,EAAE,+BACFA,EAAE,0BAA0B;QAAEmB,aAAaqB;IAAe;IAC9D,MAAMI,mBAAmBL,cACrBvC,EAAE,0CACFA,EAAE,qCAAqC;QAAEmB,aAAaqB;IAAe;IAEzE,qBACE,MAACK;;0BACC,KAACnE;gBACCoE,QAAQ,CAAC,EAAEC,KAAK,EAAE,iBAChB,MAACpE,UAAUqE,WAAW;;4BACnBrD,kBAAkB8C,GAAG,CAAC,CAACQ,+BACtB,KAACtE,UAAUuE,MAAM;oCAEfC,SAAS,IAAMtB,uBAAuBkB,OAAOE;8CAE5Cb,gBAAgB,CAACa,eAAe;mCAH5BA;0CAMT,KAACtE,UAAUuE,MAAM;gCAACC,SAAS,IAAMtB,uBAAuBkB;0CACrD/C,EAAE;;;;gBAIToD,cAAc,CAACC,4BAAgB,KAAC9D;wBAAoB,GAAG8D,WAAW;;gBAClEC,aAAa;gBACbC,MAAK;gBACLC,eAAc;;0BAEhB,KAAC/E;gBACCuC,MAAM4B;gBACNa,SAASd;gBACTe,WAAWlE;gBACXmE,WAAWnD;;;;AAInB,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-search",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.29",
|
|
4
4
|
"description": "Search plugin for Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -50,19 +50,19 @@
|
|
|
50
50
|
"dist"
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@payloadcms/next": "4.0.0-canary.
|
|
54
|
-
"@payloadcms/ui": "4.0.0-canary.
|
|
53
|
+
"@payloadcms/next": "4.0.0-canary.29",
|
|
54
|
+
"@payloadcms/ui": "4.0.0-canary.29"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/react": "19.2.14",
|
|
58
58
|
"@types/react-dom": "19.2.3",
|
|
59
|
-
"payload": "4.0.0-canary.
|
|
59
|
+
"payload": "4.0.0-canary.29",
|
|
60
60
|
"@payloadcms/eslint-config": "3.28.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
64
64
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
65
|
-
"payload": "4.0.0-canary.
|
|
65
|
+
"payload": "4.0.0-canary.29"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"registry": "https://registry.npmjs.org/"
|