fix: Initial export in admin

pull/28/head
Boaz Poolman 2021-11-20 20:24:57 +01:00
parent 4efa1f30ff
commit c88f6f02e3
2 changed files with 10 additions and 11 deletions

View File

@ -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))}
/>
<NoContent
content={{

View File

@ -1,6 +1,7 @@
'use strict';
const fs = require('fs');
const { isEmpty } = require('lodash');
/**
* Main controllers for config import/export.
@ -14,17 +15,14 @@ module.exports = {
* @returns {void}
*/
exportAll: async (ctx) => {
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')}.`,