Skip to content

Commit

Permalink
remove replaceDocIds
Browse files Browse the repository at this point in the history
  • Loading branch information
haroun committed Sep 4, 2024
1 parent 5c7e539 commit 09844b2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
13 changes: 6 additions & 7 deletions lib/methods/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,6 @@ module.exports = self => {
const overrideLocale = self.apos.launder.boolean(req.body.overrideLocale);
const exportPath = await self.getExportPathById(self.apos.launder.string(req.body.exportPathId));
const docIds = self.apos.launder.strings(req.body.docIds);
// Import aposDocId/Existing aposDocId pairs
const replaceAposDocIds = req.body.replaceDocIds?.map(arr => self.apos.launder.strings(arr)) ?? [];
const duplicatedDocs = req.body.duplicatedDocs?.map(duplicatedDoc => {
return {
aposDocId: self.apos.launder.string(duplicatedDoc.aposDocId),
Expand Down Expand Up @@ -822,20 +820,21 @@ module.exports = self => {
}
}

const [ , replaceAposDocId ] = replaceAposDocIds
.find(([ importId ]) => importId === doc.aposDocId) ?? [];
const existingAposDocId = duplicatedDocs
.filter(({ aposDocId }) => aposDocId === doc.aposDocId)
.map(({ replaceId }) => replaceId);
await self.insertOrUpdateDoc(req, {
doc,
method: 'update',
failedIds,
existingAposDocId: replaceAposDocId,
existingAposDocId,
duplicatedDocs
});

if (replaceAposDocId) {
if (existingAposDocId) {
replaceDocIdPairs.push([
doc._id,
`${replaceAposDocId}:${doc.aposLocale}`
`${existingAposDocId}:${doc.aposLocale}`
]);
}

Expand Down
4 changes: 0 additions & 4 deletions test/import-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,14 +773,10 @@ describe('@apostrophecms/import-export:import-page', function () {
notificationId,
formatLabel
} = await apos.modules['@apostrophecms/import-export'].import(importReq);
const replaceDocIds = duplicatedDocs
.filter(({ replaceId }) => replaceId)
.map(({ aposDocId, replaceId }) => ([ aposDocId, replaceId ]));
const importDuplicateReq = apos.task.getReq({
body: {
docIds: duplicatedDocs.map(({ aposDocId }) => aposDocId),
duplicatedDocs,
replaceDocIds,
importedAttachments,
exportPathId,
jobId,
Expand Down
8 changes: 0 additions & 8 deletions ui/apos/components/AposDuplicateImportModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,6 @@ export default {
return this.checked.length
? 'var(--a-white)'
: 'transparent';
},
replaceDocIds() {
return this.checked.map(
aposDocId => this.duplicatedDocs.find(doc => doc.replaceId && doc.aposDocId === aposDocId)
)
.filter(Boolean)
.map(({ aposDocId, replaceId }) => [ aposDocId, replaceId ]);
}
},
Expand Down Expand Up @@ -227,7 +220,6 @@ export default {
body: {
docIds: this.checked,
duplicatedDocs: this.duplicatedDocs,
replaceDocIds: this.replaceDocIds,
importedAttachments: this.importedAttachments,
exportPathId: this.exportPathId,
jobId: this.jobId,
Expand Down

0 comments on commit 09844b2

Please sign in to comment.