fix: Initial export in admin
parent
4efa1f30ff
commit
c88f6f02e3
|
@ -1,12 +1,13 @@
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useDispatch } from 'react-redux';
|
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 { Button } from '@strapi/design-system/Button';
|
||||||
|
|
||||||
import { exportAllConfig } from '../../state/actions/Config';
|
import { exportAllConfig } from '../../state/actions/Config';
|
||||||
import ConfirmModal from '../ConfirmModal';
|
import ConfirmModal from '../ConfirmModal';
|
||||||
|
|
||||||
const FirstExport = () => {
|
const FirstExport = () => {
|
||||||
|
const toggleNotification = useNotification();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [modalIsOpen, setModalIsOpen] = useState(false);
|
const [modalIsOpen, setModalIsOpen] = useState(false);
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ const FirstExport = () => {
|
||||||
isOpen={modalIsOpen}
|
isOpen={modalIsOpen}
|
||||||
onClose={() => setModalIsOpen(false)}
|
onClose={() => setModalIsOpen(false)}
|
||||||
type="export"
|
type="export"
|
||||||
onSubmit={() => dispatch(exportAllConfig())}
|
onSubmit={() => dispatch(exportAllConfig([], toggleNotification))}
|
||||||
/>
|
/>
|
||||||
<NoContent
|
<NoContent
|
||||||
content={{
|
content={{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const { isEmpty } = require('lodash');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main controllers for config import/export.
|
* Main controllers for config import/export.
|
||||||
|
@ -14,17 +15,14 @@ module.exports = {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
exportAll: async (ctx) => {
|
exportAll: async (ctx) => {
|
||||||
if (!ctx.request.body) {
|
if (isEmpty(ctx.request.body)) {
|
||||||
ctx.send({
|
await strapi.plugin('config-sync').service('main').exportAllConfig();
|
||||||
message: 'No config was specified for the export endpoint.',
|
} else {
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(ctx.request.body.map(async (configName) => {
|
await Promise.all(ctx.request.body.map(async (configName) => {
|
||||||
await strapi.plugin('config-sync').service('main').exportSingleConfig(configName);
|
await strapi.plugin('config-sync').service('main').exportSingleConfig(configName);
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ctx.send({
|
ctx.send({
|
||||||
message: `Config was successfully exported to ${strapi.config.get('plugin.config-sync.destination')}.`,
|
message: `Config was successfully exported to ${strapi.config.get('plugin.config-sync.destination')}.`,
|
||||||
|
|
Loading…
Reference in New Issue