From c88f6f02e329cf2c9edf516b8cecacbe92e04ebd Mon Sep 17 00:00:00 2001 From: Boaz Poolman Date: Sat, 20 Nov 2021 20:24:57 +0100 Subject: [PATCH] fix: Initial export in admin --- admin/src/components/FirstExport/index.js | 5 +++-- server/controllers/config.js | 16 +++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) 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')}.`,