Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pro 6419 import pages #79

Merged
merged 43 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f7fd8df
Add export batch operation for pages
myovchev Aug 21, 2024
6b1aac7
when overriding page keep position info of the existing one
ValJed Aug 28, 2024
99f5247
add tests for import pages from a tree
haroun Aug 29, 2024
42bdef8
do not commit test public files
haroun Aug 29, 2024
4a2087c
cleanup before import
haroun Aug 29, 2024
722d5db
add missing dependency
haroun Aug 30, 2024
3692c95
add todos
haroun Aug 30, 2024
c626e94
polish assertions
haroun Aug 30, 2024
98ad75f
use import-page
haroun Aug 30, 2024
b7df1dd
remove form-data
haroun Aug 30, 2024
81e4e75
use apostrophe batch pages branch
haroun Aug 30, 2024
563e1ea
clean lint errors
haroun Aug 30, 2024
434c2fe
retrieve target
haroun Sep 2, 2024
dbfe6c9
test import twice and handling of parked pages
haroun Sep 2, 2024
c3c3216
Resolve conflicts
myovchev Sep 2, 2024
53bd65d
Add computed documents types
myovchev Sep 2, 2024
60c26e7
Ensure unique types
myovchev Sep 3, 2024
7586943
Add batch label for notificaitons
myovchev Sep 3, 2024
69798d4
Changelog
myovchev Sep 3, 2024
05d4afb
support parked pages
haroun Sep 3, 2024
a46bf26
Fix missing module action
myovchev Sep 3, 2024
3315330
Fix import labels for singleton pieces
myovchev Sep 3, 2024
173ffe1
override duplicates needs duplicated docs
haroun Sep 3, 2024
507bafd
Merge branch 'pro-6436-batch-operation-page' into pro-6419-import-pages
haroun Sep 3, 2024
bd044f2
fix lint issues
haroun Sep 3, 2024
d31e191
bring back doc ids
haroun Sep 3, 2024
998e3cf
keep slug from import file
haroun Sep 3, 2024
e40406d
fix rank values
haroun Sep 4, 2024
60969a0
remove branch
haroun Sep 4, 2024
7055681
Add replaces configuration for singleton import menu
myovchev Sep 4, 2024
a354598
fix typo with options, remove logs from tests
haroun Sep 4, 2024
5c7e539
do not throw error if we can not dismiss job notification
haroun Sep 4, 2024
09844b2
remove replaceDocIds
haroun Sep 4, 2024
274c153
run two separate suite for remove
haroun Sep 4, 2024
b2ee0bf
restore correct existing apos doc id
haroun Sep 4, 2024
b7a0239
revert mocks
haroun Sep 4, 2024
a4ff488
revert changes to test/index.js
haroun Sep 4, 2024
832e774
Merge branch 'pro-6436-batch-operation-page' into pro-6419-import-pages
haroun Sep 4, 2024
45dd288
do not try to replace existing attachments, just merge crops and use …
boutell Sep 4, 2024
1f5772b
keep attachment name
haroun Sep 5, 2024
828efa9
Merge branch 'main' into pro-6419-import-pages
haroun Sep 5, 2024
1ee1378
Merge branch 'pro-6337' into pro-6419-import-pages
haroun Sep 5, 2024
5b151a0
Merge branch 'main' into pro-6419-import-pages
haroun Sep 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,12 @@ node_modules

# vim swp files
.*.sw*
/test/public/uploads

# Dont commit test generated css
test/public/css/*.css
test/public/css/master-*.less

# Dont commit test uploads
/test/data
/test/public/exports
/test/public/uploads
2 changes: 1 addition & 1 deletion lib/methods/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = self => {
const ids = self.apos.launder.ids(req.body._ids);
const relatedTypes = self.apos.launder.strings(req.body.relatedTypes);
const expiration = self.options.importExport?.export?.expiration &&
self.apos.launder.integer(self.options.export.expiration);
self.apos.launder.integer(self.options.importExport.export.expiration);

const [ defaultFormatName ] = Object.keys(self.formats);
const formatName = self.apos.launder.string(req.body.formatName, defaultFormatName);
Expand Down
94 changes: 94 additions & 0 deletions lib/methods/import-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
const getTargetId = async ({
manager,
doc,
req,
duplicatedDocs = []
}) => {
if (doc.archived) {
return '_archive';
}

const duplicatedDocsMapping = Object.fromEntries(
duplicatedDocs.map(duplicate => [ duplicate.aposDocId, duplicate.replaceId ])
);

const { path = '' } = doc;
const ancestorIds = path.split('/').reverse().slice(1);
for (const ancestorId of ancestorIds) {
try {
const { aposDocId } = await manager.getTarget(req, duplicatedDocsMapping[ancestorId] || ancestorId);

return aposDocId;
} catch (error) {
// continue search
}
}

return '_home';
};

const insert = async ({
manager,
doc,
req,
duplicatedDocs
}) => {
const targetId = await getTargetId({
manager,
doc,
req,
duplicatedDocs
});
const position = 'lastChild';

return manager.insert(
req,
targetId,
position,
doc,
{ setModified: false }
);
};

const update = async ({
manager,
doc,
req,
duplicatedDocs
}) => {
const {
_id,
aposDocId,
path,
rank,
level,
...patch
} = doc;

const move = doc.parkedId
? {}
: {
_targetId: await getTargetId({
manager,
doc,
req,
duplicatedDocs
}),
_position: 'lastChild'
};

return manager.patch(
req.clone({
body: {
...patch,
...move
}
}),
_id
);
};

module.exports = {
insert,
update
};
Loading
Loading