-
Notifications
You must be signed in to change notification settings - Fork 2
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
Changes from 15 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
f7fd8df
Add export batch operation for pages
myovchev 6b1aac7
when overriding page keep position info of the existing one
ValJed 99f5247
add tests for import pages from a tree
haroun 42bdef8
do not commit test public files
haroun 4a2087c
cleanup before import
haroun 722d5db
add missing dependency
haroun 3692c95
add todos
haroun c626e94
polish assertions
haroun 98ad75f
use import-page
haroun b7df1dd
remove form-data
haroun 81e4e75
use apostrophe batch pages branch
haroun 563e1ea
clean lint errors
haroun 434c2fe
retrieve target
haroun dbfe6c9
test import twice and handling of parked pages
haroun c3c3216
Resolve conflicts
myovchev 53bd65d
Add computed documents types
myovchev 60c26e7
Ensure unique types
myovchev 7586943
Add batch label for notificaitons
myovchev 69798d4
Changelog
myovchev 05d4afb
support parked pages
haroun a46bf26
Fix missing module action
myovchev 3315330
Fix import labels for singleton pieces
myovchev 173ffe1
override duplicates needs duplicated docs
haroun 507bafd
Merge branch 'pro-6436-batch-operation-page' into pro-6419-import-pages
haroun bd044f2
fix lint issues
haroun d31e191
bring back doc ids
haroun 998e3cf
keep slug from import file
haroun e40406d
fix rank values
haroun 60969a0
remove branch
haroun 7055681
Add replaces configuration for singleton import menu
myovchev a354598
fix typo with options, remove logs from tests
haroun 5c7e539
do not throw error if we can not dismiss job notification
haroun 09844b2
remove replaceDocIds
haroun 274c153
run two separate suite for remove
haroun b2ee0bf
restore correct existing apos doc id
haroun b7a0239
revert mocks
haroun a4ff488
revert changes to test/index.js
haroun 832e774
Merge branch 'pro-6436-batch-operation-page' into pro-6419-import-pages
haroun 45dd288
do not try to replace existing attachments, just merge crops and use …
boutell 1f5772b
keep attachment name
haroun 828efa9
Merge branch 'main' into pro-6419-import-pages
haroun 1ee1378
Merge branch 'pro-6337' into pro-6419-import-pages
haroun 5b151a0
Merge branch 'main' into pro-6419-import-pages
haroun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,14 +18,15 @@ | |
"author": "Apostrophe Technologies", | ||
"license": "UNLICENSED", | ||
"devDependencies": { | ||
"apostrophe": "github:apostrophecms/apostrophe", | ||
"apostrophe": "github:apostrophecms/apostrophe#pro-6425-batch-operation-page", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needs to be changed |
||
"eslint": "^8.44.0", | ||
"eslint-config-apostrophe": "^4.2.0", | ||
"eslint-config-standard": "^17.1.0", | ||
"eslint-plugin-import": "^2.29.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^6.1.1", | ||
"eslint-plugin-vue": "^9.19.2", | ||
"form-data": "^4.0.0", | ||
"mocha": "^10.2.0", | ||
"stylelint": "^16.0.0", | ||
"stylelint-config-apostrophe": "^4.1.0", | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a problem. aposMode in my knowledge always exists (no matter localized or not). We check for draft here because we want to trigger this (expensive) code only once per unique page (aposDocId).