mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Merge pull request #4746 from overleaf/ae-project-history
Add endpoint for migrating a project from track-changes to full project history GitOrigin-RevId: 74e1fb1379a78a9569dda2007e677a4d277e38fb
This commit is contained in:
@@ -80,3 +80,6 @@ modules/**/Makefile
|
|||||||
# Intellij
|
# Intellij
|
||||||
.idea
|
.idea
|
||||||
.run
|
.run
|
||||||
|
|
||||||
|
# Test fixture zip
|
||||||
|
!modules/admin-panel/test/unit/src/data/track-changes-project.zip
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ RUN mkdir -p /app/data/dumpFolder && \
|
|||||||
mkdir -p /app/data/pdf && \
|
mkdir -p /app/data/pdf && \
|
||||||
mkdir -p /app/data/uploads && \
|
mkdir -p /app/data/uploads && \
|
||||||
mkdir -p /app/data/zippedProjects && \
|
mkdir -p /app/data/zippedProjects && \
|
||||||
|
mkdir -p /app/data/projectHistories && \
|
||||||
chmod -R 0755 /app/data/ && \
|
chmod -R 0755 /app/data/ && \
|
||||||
chown -R node:node /app/data/
|
chown -R node:node /app/data/
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ module.exports = {
|
|||||||
flushProject: callbackify(flushProject),
|
flushProject: callbackify(flushProject),
|
||||||
resyncProject: callbackify(resyncProject),
|
resyncProject: callbackify(resyncProject),
|
||||||
deleteProject: callbackify(deleteProject),
|
deleteProject: callbackify(deleteProject),
|
||||||
|
deleteProjectHistory: callbackify(deleteProjectHistory),
|
||||||
injectUserDetails: callbackify(injectUserDetails),
|
injectUserDetails: callbackify(injectUserDetails),
|
||||||
promises: {
|
promises: {
|
||||||
initializeProject,
|
initializeProject,
|
||||||
@@ -16,6 +17,7 @@ module.exports = {
|
|||||||
resyncProject,
|
resyncProject,
|
||||||
deleteProject,
|
deleteProject,
|
||||||
injectUserDetails,
|
injectUserDetails,
|
||||||
|
deleteProjectHistory,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,10 +57,23 @@ async function flushProject(projectId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resyncProject(projectId) {
|
async function deleteProjectHistory(projectId) {
|
||||||
|
try {
|
||||||
|
await request.delete({
|
||||||
|
url: `${settings.apis.project_history.url}/project/${projectId}`,
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
throw OError.tag(err, 'failed to delete project history', {
|
||||||
|
projectId,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resyncProject(projectId, force = false) {
|
||||||
try {
|
try {
|
||||||
await request.post({
|
await request.post({
|
||||||
url: `${settings.apis.project_history.url}/project/${projectId}/resync`,
|
url: `${settings.apis.project_history.url}/project/${projectId}/resync`,
|
||||||
|
qs: { force }, // TODO: only send if true?
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw OError.tag(err, 'failed to resync project history', { projectId })
|
throw OError.tag(err, 'failed to resync project history', { projectId })
|
||||||
|
|||||||
@@ -70,7 +70,15 @@ const ProjectHistoryHandler = {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
upgradeHistory(project_id, callback) {
|
unsetHistory(project_id, callback) {
|
||||||
|
return Project.updateOne(
|
||||||
|
{ _id: project_id },
|
||||||
|
{ $unset: { 'overleaf.history': true } },
|
||||||
|
callback
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
|
upgradeHistory(project_id, allowDowngrade, callback) {
|
||||||
// project must have an overleaf.history.id before allowing display of new history
|
// project must have an overleaf.history.id before allowing display of new history
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
@@ -80,6 +88,7 @@ const ProjectHistoryHandler = {
|
|||||||
{
|
{
|
||||||
'overleaf.history.display': true,
|
'overleaf.history.display': true,
|
||||||
'overleaf.history.upgradedAt': new Date(),
|
'overleaf.history.upgradedAt': new Date(),
|
||||||
|
'overleaf.history.allowDowngrade': allowDowngrade,
|
||||||
},
|
},
|
||||||
function (err, result) {
|
function (err, result) {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ const ProjectSchema = new Schema({
|
|||||||
id: { type: Number },
|
id: { type: Number },
|
||||||
display: { type: Boolean },
|
display: { type: Boolean },
|
||||||
upgradedAt: { type: Date },
|
upgradedAt: { type: Date },
|
||||||
|
allowDowngrade: { type: Boolean },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
collabratecUsers: [
|
collabratecUsers: [
|
||||||
|
|||||||
Generated
+186
-719
File diff suppressed because it is too large
Load Diff
@@ -169,6 +169,7 @@
|
|||||||
"sanitize-html": "^1.27.1",
|
"sanitize-html": "^1.27.1",
|
||||||
"scroll-into-view-if-needed": "^2.2.25",
|
"scroll-into-view-if-needed": "^2.2.25",
|
||||||
"underscore": "^1.13.1",
|
"underscore": "^1.13.1",
|
||||||
|
"unzipper": "^0.10.11",
|
||||||
"url-parse": "^1.4.7",
|
"url-parse": "^1.4.7",
|
||||||
"utf-8-validate": "^5.0.2",
|
"utf-8-validate": "^5.0.2",
|
||||||
"uuid": "^3.0.1",
|
"uuid": "^3.0.1",
|
||||||
@@ -241,6 +242,7 @@
|
|||||||
"mkdirp": "0.5.1",
|
"mkdirp": "0.5.1",
|
||||||
"mocha": "^8.3.2",
|
"mocha": "^8.3.2",
|
||||||
"mock-fs": "^4.11.0",
|
"mock-fs": "^4.11.0",
|
||||||
|
"nock": "^13.1.1",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"nodemon": "^2.0.6",
|
"nodemon": "^2.0.6",
|
||||||
"optimize-css-assets-webpack-plugin": "^5.0.3",
|
"optimize-css-assets-webpack-plugin": "^5.0.3",
|
||||||
|
|||||||
Reference in New Issue
Block a user