Skip to content

Commit f5e1e07

Browse files
committed
Fix content export
1 parent ab2f59f commit f5e1e07

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix content export. @davisagli

frontend/packages/kitconcept-core/src/actions/exportImport/exportImport.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
import { POST_IMPORT, POST_EXPORT } from '../../constants/ActionTypes';
2-
3-
export const exportContent = () => {
4-
return {
5-
type: POST_EXPORT,
6-
request: {
7-
op: 'post',
8-
path: '/@export',
9-
},
10-
};
11-
};
1+
import { POST_IMPORT } from '../../constants/ActionTypes';
122

133
export const importContent = (file) => {
144
const formData = new FormData();

frontend/packages/kitconcept-core/src/components/Controlpanels/ExportImport.jsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ import { Button, Container } from '@plone/components';
1414
import { toast } from 'react-toastify';
1515
import { createPortal } from 'react-dom';
1616

17-
import { useDispatch } from 'react-redux';
18-
import {
19-
exportContent,
20-
importContent,
21-
} from '../../actions/exportImport/exportImport';
17+
import { useDispatch, useSelector } from 'react-redux';
18+
import { importContent } from '../../actions/exportImport/exportImport';
2219

2320
import uploadSVG from '@plone/volto/icons/upload.svg';
2421
import downloadSVG from '@plone/volto/icons/download.svg';
@@ -82,6 +79,7 @@ const ContentTransfer = ({ pathname }) => {
8279
const intl = useIntl();
8380
const isClient = useClient();
8481
const dispatch = useDispatch();
82+
const token = useSelector((state) => state.userSession.token);
8583

8684
const [exporting, setExporting] = useState(false);
8785
const [importing, setImporting] = useState(false);
@@ -90,7 +88,12 @@ const ContentTransfer = ({ pathname }) => {
9088
try {
9189
setExporting(true);
9290

93-
const res = await dispatch(exportContent());
91+
const res = await fetch('/++api++/@export', {
92+
method: 'POST',
93+
headers: {
94+
Authorization: `Bearer ${token}`,
95+
},
96+
});
9497

9598
if (!res.ok) throw new Error('Export failed');
9699

frontend/packages/kitconcept-core/src/constants/ActionTypes.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
* @module constants/ActionTypes
44
*/
55

6-
export const POST_EXPORT = 'POST_EXPORT';
76
export const POST_IMPORT = 'POST_IMPORT';

0 commit comments

Comments
 (0)