UNPKG

payloadcms-import-export-plugin

Version:

A comprehensive Payload CMS plugin that enables seamless import and export of collection data with support for CSV and JSON formats, featuring advanced field mapping, duplicate handling, and batch processing capabilities.

45 lines (44 loc) 1.79 kB
'use client'; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { getTranslation } from '@payloadcms/translations'; import { PopupList, Translation, useConfig, useDocumentDrawer, useTranslation } from '@payloadcms/ui'; import React, { useEffect } from 'react'; import { useImportExport } from '../ImportExportProvider/index.js'; import './index.scss'; const baseClass = 'import-list-menu-item'; export const ImportListMenuItem = ({ collectionSlug, importCollectionSlug })=>{ const { getEntityConfig } = useConfig(); const { i18n, t } = useTranslation(); const currentCollectionConfig = getEntityConfig({ collectionSlug }); const [DocumentDrawer, DocumentDrawerToggler] = useDocumentDrawer({ collectionSlug: importCollectionSlug }); const { setCollection } = useImportExport(); // Set collection and selected items on mount or when selection changes useEffect(()=>{ setCollection(currentCollectionConfig.slug ?? ''); }, [ currentCollectionConfig, setCollection ]); return /*#__PURE__*/ _jsxs(PopupList.Button, { className: baseClass, children: [ /*#__PURE__*/ _jsx(DocumentDrawerToggler, { children: /*#__PURE__*/ _jsx(Translation, { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error i18nKey: "plugin-import-export:importDocumentLabel", t: t, variables: { label: getTranslation(currentCollectionConfig.labels.plural, i18n) } }) }), /*#__PURE__*/ _jsx(DocumentDrawer, {}) ] }); }; //# sourceMappingURL=index.js.map