fix: Initial export in admin
parent
4efa1f30ff
commit
c88f6f02e3
|
@ -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={{
|
||||
|
|
|
@ -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')}.`,
|
||||
|
|
Loading…
Reference in New Issue