Skip to content

Commit

Permalink
oui
Browse files Browse the repository at this point in the history
  • Loading branch information
ETLaurent committed Oct 18, 2024
1 parent 5c571ca commit 93c0e7e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
26 changes: 25 additions & 1 deletion lib/methods/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = self => {
}

const { file } = req.files || {};
const importDraftsOnly = self.apos.launder.boolean(req.body.importDraftsOnly);

Check failure on line 12 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (20, 5.0)

'importDraftsOnly' is assigned a value but never used. Allowed unused vars must match /apos/u
const overrideLocale = self.apos.launder.boolean(req.body.overrideLocale);
const formatLabel = self.apos.launder.string(req.body.formatLabel);
let exportPath = await self.getExportPathById(self.apos.launder.string(req.body.exportPathId));
Expand Down Expand Up @@ -59,6 +60,11 @@ module.exports = self => {
throw self.apos.error(error.message);
}

// if (importDraftsOnly) {
// docs = docs.filter(doc => !doc.aposMode || doc.aposMode === 'draft');
// }
// console.log('🚀 ~ import ~ docs:', docs);

const differentDocsLocale = self.getFirstDifferentLocale(req, docs);
const siteHasMultipleLocales = Object.keys(self.apos.i18n.locales).length > 1;

Expand Down Expand Up @@ -491,6 +497,10 @@ module.exports = self => {
fetchRelationships: false
});

if (importDraftsOnly && docToInsert.aposMode !== 'draft') {

Check failure on line 500 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (20, 5.0)

'importDraftsOnly' is not defined
return docToInsert;
}

if (self.isPage(manager)) {
// TODO: check if this is still true
// `convert` sets the type to `@apostrophecms/home-page`,
Expand Down Expand Up @@ -537,6 +547,11 @@ module.exports = self => {
presentFieldsOnly: true,
fetchRelationships: false
});

if (importDraftsOnly && docToUpdate.aposMode !== 'draft') {

Check failure on line 551 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (20, 5.0)

'importDraftsOnly' is not defined
return docToUpdate;
}

self.isPage(manager)
? await importPage.update({
manager: self.apos.page,
Expand All @@ -547,7 +562,9 @@ module.exports = self => {
: await manager.update(_req, docToUpdate);
}

await self.setDocAsNotModified(matchingDraft);
if (!importDraftOnly) {

Check failure on line 565 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (20, 5.0)

'importDraftOnly' is not defined
await self.setDocAsNotModified(matchingDraft);
}
}
},

Expand Down Expand Up @@ -647,6 +664,10 @@ module.exports = self => {
fetchRelationships: false
});

if (importDraftsOnly && docToInsert.aposMode !== 'draft') {

Check failure on line 667 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (20, 5.0)

'importDraftsOnly' is not defined
return docToInsert;
}

if (self.isPage(manager)) {
// TODO: check if this is still true
// `convert` sets the type to `@apostrophecms/home-page`,
Expand All @@ -672,6 +693,9 @@ module.exports = self => {
presentFieldsOnly: true,
fetchRelationships: false
});
if (importDraftsOnly && docToUpdate.aposMode !== 'draft') {

Check failure on line 696 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (20, 5.0)

'importDraftsOnly' is not defined
return docToUpdate;
}
if (self.isPage(manager)) {
await importPage.update({
manager: self.apos.page,
Expand Down
1 change: 1 addition & 0 deletions ui/apos/components/AposImportModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export default {
}
const formData = new FormData();
formData.append('file', this.selectedFile);
formData.append('importDraftsOnly', this.checked.includes('importDraftsOnly'));
apos.bus.$emit('import-export-import-started');
apos.http.post(`${this.universalModuleAction}/${this.action}`, {
Expand Down

0 comments on commit 93c0e7e

Please sign in to comment.