Skip to content

Commit

Permalink
handles excluded types in import export module to avoid storing data …
Browse files Browse the repository at this point in the history
…out of apos
  • Loading branch information
ValJed committed Aug 26, 2024
1 parent beb3abc commit a3923c0
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 31 deletions.
54 changes: 54 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,60 @@ module.exports = {

self.enableBrowserData();
},
handlers(self) {
return {
'apostrophe:modulesRegistered': {
setContextOperations() {
const excludedExportTypes = [];
const excludedImportTypes = [];
for (const mod of Object.values(self.apos.modules)) {
if (!self.apos.instanceOf(mod, '@apostrophecms/doc-type')) {
continue;
}

if (mod.options.importExport?.export === false) {
excludedExportTypes.push({
type: {
$ne: mod.__meta.name
}
});
}

if (!mod.options.singleton || mod.options.importExport?.import === false) {
excludedImportTypes.push({
type: {
$ne: mod.__meta.name
}
});
}
}

const exportOperation = {
action: 'import-export-export',
context: 'update',
label: 'aposImportExport:export',
modal: 'AposExportModal',
props: {
action: 'import-export-export'
},
if: { $and: excludedExportTypes }
};
const importOperation = {
action: 'import-export-import',
context: 'update',
label: 'aposImportExport:import',
modal: 'AposImportModal',
if: { $and: excludedImportTypes },
canCreate: true,
canEdit: true
};

self.apos.doc.addContextOperation(exportOperation);
self.apos.doc.addContextOperation(importOperation);
}
}
};
},
methods,
apiRoutes
};
Expand Down
31 changes: 0 additions & 31 deletions modules/@apostrophecms/import-export-doc-type/index.js

This file was deleted.

0 comments on commit a3923c0

Please sign in to comment.