|
@@ -204,6 +204,9 @@ module.exports = (crowi) => {
|
|
|
.custom(v => v === 'true' || v === true || v == null)
|
|
.custom(v => v === 'true' || v === true || v == null)
|
|
|
.withMessage('The body property "isRecursively" must be "true" or true. (Omit param for false)'),
|
|
.withMessage('The body property "isRecursively" must be "true" or true. (Omit param for false)'),
|
|
|
],
|
|
],
|
|
|
|
|
+ convertPagesByPath: [
|
|
|
|
|
+ body('convertPath').optional().isString().withMessage('convertPath must be a string'),
|
|
|
|
|
+ ],
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
async function createPageAction({
|
|
async function createPageAction({
|
|
@@ -823,29 +826,33 @@ module.exports = (crowi) => {
|
|
|
return res.apiv3({ paths: pagesCanBeDeleted.map(p => p.path), isRecursively, isCompletely });
|
|
return res.apiv3({ paths: pagesCanBeDeleted.map(p => p.path), isRecursively, isCompletely });
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// eslint-disable-next-line max-len
|
|
// eslint-disable-next-line max-len
|
|
|
- router.post('/legacy-pages-migration', accessTokenParser, loginRequired, csrf, validator.legacyPagesMigration, apiV3FormValidator, async(req, res) => {
|
|
|
|
|
- const { convertPath, pageIds: _pageIds, isRecursively } = req.body;
|
|
|
|
|
|
|
+ router.post('/convert-pages-by-path', accessTokenParser, loginRequiredStrictly, adminRequired, csrf, validator.convertPagesByPath, apiV3FormValidator, async(req, res) => {
|
|
|
|
|
+ const { convertPath } = req.body;
|
|
|
|
|
|
|
|
// Convert by path
|
|
// Convert by path
|
|
|
- if (convertPath != null) {
|
|
|
|
|
- const normalizedPath = pathUtils.normalizePath(convertPath);
|
|
|
|
|
- try {
|
|
|
|
|
- await crowi.pageService.normalizeParentByPath(normalizedPath, req.user);
|
|
|
|
|
- }
|
|
|
|
|
- catch (err) {
|
|
|
|
|
- logger.error(err);
|
|
|
|
|
-
|
|
|
|
|
- if (isV5ConversionError(err)) {
|
|
|
|
|
- return res.apiv3Err(new ErrorV3(err.message, err.code), 400);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const normalizedPath = pathUtils.normalizePath(convertPath);
|
|
|
|
|
+ try {
|
|
|
|
|
+ await crowi.pageService.normalizeParentByPath(normalizedPath, req.user);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (err) {
|
|
|
|
|
+ logger.error(err);
|
|
|
|
|
|
|
|
- return res.apiv3Err(new ErrorV3('Failed to convert pages.'), 400);
|
|
|
|
|
|
|
+ if (isV5ConversionError(err)) {
|
|
|
|
|
+ return res.apiv3Err(new ErrorV3(err.message, err.code), 400);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return res.apiv3({});
|
|
|
|
|
|
|
+ return res.apiv3Err(new ErrorV3('Failed to convert pages.'), 400);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ return res.apiv3({});
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // eslint-disable-next-line max-len
|
|
|
|
|
+ router.post('/legacy-pages-migration', accessTokenParser, loginRequired, csrf, validator.legacyPagesMigration, apiV3FormValidator, async(req, res) => {
|
|
|
|
|
+ const { pageIds: _pageIds, isRecursively } = req.body;
|
|
|
|
|
+
|
|
|
// Convert by pageIds
|
|
// Convert by pageIds
|
|
|
const pageIds = _pageIds == null ? [] : _pageIds;
|
|
const pageIds = _pageIds == null ? [] : _pageIds;
|
|
|
|
|
|