diff --git a/admin/src/components/FirstExport/index.js b/admin/src/components/FirstExport/index.js index 244de24..67ad328 100644 --- a/admin/src/components/FirstExport/index.js +++ b/admin/src/components/FirstExport/index.js @@ -1,12 +1,13 @@ import React, { useState } from 'react'; import { useDispatch } from 'react-redux'; -import { NoContent } from '@strapi/helper-plugin'; +import { NoContent, useNotification } from '@strapi/helper-plugin'; import { Button } from '@strapi/design-system/Button'; import { exportAllConfig } from '../../state/actions/Config'; import ConfirmModal from '../ConfirmModal'; const FirstExport = () => { + const toggleNotification = useNotification(); const dispatch = useDispatch(); const [modalIsOpen, setModalIsOpen] = useState(false); @@ -16,7 +17,7 @@ const FirstExport = () => { isOpen={modalIsOpen} onClose={() => setModalIsOpen(false)} type="export" - onSubmit={() => dispatch(exportAllConfig())} + onSubmit={() => dispatch(exportAllConfig([], toggleNotification))} /> { - if (!ctx.request.body) { - ctx.send({ - message: 'No config was specified for the export endpoint.', - }); - - return; + if (isEmpty(ctx.request.body)) { + await strapi.plugin('config-sync').service('main').exportAllConfig(); + } else { + await Promise.all(ctx.request.body.map(async (configName) => { + await strapi.plugin('config-sync').service('main').exportSingleConfig(configName); + })); } - await Promise.all(ctx.request.body.map(async (configName) => { - await strapi.plugin('config-sync').service('main').exportSingleConfig(configName); - })); ctx.send({ message: `Config was successfully exported to ${strapi.config.get('plugin.config-sync.destination')}.`,