-
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-6418: parked pages & singletons #74
Conversation
package.json
Outdated
@@ -17,7 +18,7 @@ | |||
"author": "Apostrophe Technologies", | |||
"license": "UNLICENSED", | |||
"devDependencies": { | |||
"apostrophe": "github:apostrophecms/apostrophe", | |||
"apostrophe": "github:apostrophecms/apostrophe#pro-6418-parked-singletons", |
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.
FIXME: Revert before merge/after core is merged.
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.
Few questions feedback
aposDocId => this.duplicatedDocs.find(doc => doc.replaceId && doc.aposDocId === aposDocId) | ||
) | ||
.filter(Boolean) | ||
.map(({ aposDocId, replaceId }) => [ aposDocId, replaceId ]); |
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.
Maybe an object instead of an array would be clearer, and would avoid things like replaceItem[1]
which is not really clear I think?
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.
this follows the backend argument requirements - see await self.apos.doc.changeDocIds(replaceDocIdPairs, { skipReplace: true });
and the relevant code in overrideDuplicates
.
For consistency, every "pair" is in that format.
width: calc(100% + 60px); | ||
height: 100%; | ||
content: ""; | ||
background-color: var(--a-base-9); |
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.
Does these changes are about linting?
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.
Auto formatted by stylelint
.
.stylelintrc.json
Outdated
"files": ["*.s{c,a}ss", "**/*.s{c,a}ss"], | ||
"customSyntax": "postcss-scss" | ||
} | ||
] |
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.
This should not be needed, it already exists in stylelint-config-apostrophe
. No extra config should be needed to use the same config in each project/
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.
Example error this fix:
λ npm run stylelint
> @apostrophecms/[email protected] stylelint
> stylelint ui/**/*.{scss,vue}
ui/apos/components/AposDuplicateImportModal.vue
366:21 ✖ Unexpected unit "s" for property declaration-property-unit-allowed-list
"transition"
366:21 ✖ Expected a minimum of 200 time-min-milliseconds
milliseconds
2 problems (2 errors, 0 warnings)
Same when removing it:
λ npm run stylelint
> @apostrophecms/[email protected] stylelint
> stylelint ui/**/*.{scss,vue}
/apostrophe/import-export/ui/apos/components/AposDuplicateImportModal.vue: you should use the "customSyntax" option when linting something other than CSS
/apostrophe/import-export/ui/apos/components/AposExportModal.vue: you should use the "customSyntax" option when linting something other than CSS
/apostrophe/import-export/ui/apos/components/AposImportModal.vue: you should use the "customSyntax" option when linting something other than CSS
ui/apos/components/AposDuplicateImportModal.vue
15:16 ✖ Unknown word CssSyntaxError
ui/apos/components/AposExportModal.vue
15:16 ✖ Unknown word CssSyntaxError
ui/apos/components/AposImportModal.vue
15:16 ✖ Unknown word CssSyntaxError
3 problems (3 errors, 0 warnings)
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.
Ok this is because you don't use the latest version of our stylelint config.
Please upgrade to 4.1
and remove the added config.
}); | ||
continue; | ||
} | ||
} |
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.
[Optional]: Maybe we could have used a Map
here to store singletons list id -> replaceId
in order to use the same array map above that build the duplicatedDocs
and having another loop on replaceId
.
Just an idea here not sure it would really improve code readability / maintainability here
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've tried many variants, including trying to extract the whole logic in a function. The real problem is the complex continue
logic (extremely sensitive to bugs). I prefer to keep it as it is now until we have really good idea how to do it.
I think the current is clean because its 2 phase logic - 1. either replace or duplicate (no change) set, 1.5. duplicate set only logic (no change), 2. append replace set directly to the result, it's prebuilt.
A better design is to move the whole logic (for a single document) in a separate method. This would "relax" the code depth and open possibilities for improvements. I don't think we are still there/forced to do this effort yett.
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.
Yes it's good for me.
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.
Just upgrade the stylelint to avoid extra config. Otherwise LGTM.
FYI after stylelint upgrade (still works):
|
Summary
All singleton documents (parked pages and pieces having option
singleton: true
) are now marked as "duplicates" in order to get a user confirmation for override. This happen ONLY if the singleton document exists in the target site database. If it doesn't exist, the document is handled as a new generic document (fallback to the previous behavior).The UI now accepts
replaceIds
pairs beside the usualdociIds
. Those are sent back on confirmation (only for thechecked
documents). The backend is using them to perform document ID replacement while importing and for updating all document relationships at the end of the import process.What are the specific steps to test this change?
Export parked pages (such as
@apostrophecms/home-page
,@apostrophecms/search-page
) and a singleton piece(s) (such as@apostrophecms/global
). Ensure that those documents have some relationships and attachments (e.g. images)Import the previous exported in another (blank) site (e.g. change the database after the export). Ensure that all of the imported singletons are keeping the ID's from the target site. Ensure that all reverse relationships (in the related documents) have the proper ID's (the target site documents).
What kind of change does this PR introduce?
(Check at least one)
Make sure the PR fulfills these requirements:
If adding a new feature without an already open issue, it's best to open a feature request issue first and wait for approval before working on it.
Other information: