mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-12 03:24:09 +00:00
Merge pull request #5615 from overleaf/revert-5611-revert-4746-ae-project-history
Add endpoint for migrating a project from track-changes to full project history (second attempt) GitOrigin-RevId: 86ff0a149bd56f028fc7af854f1684bf126e503f
This commit is contained in:
parent
e5676a9643
commit
d706109823
8 changed files with 237 additions and 721 deletions
3
services/web/.gitignore
vendored
3
services/web/.gitignore
vendored
|
@ -80,3 +80,6 @@ modules/**/Makefile
|
|||
# Intellij
|
||||
.idea
|
||||
.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/uploads && \
|
||||
mkdir -p /app/data/zippedProjects && \
|
||||
mkdir -p /app/data/projectHistories && \
|
||||
chmod -R 0755 /app/data/ && \
|
||||
chown -R node:node /app/data/
|
||||
|
||||
|
|
|
@ -7,15 +7,19 @@ const UserGetter = require('../User/UserGetter')
|
|||
module.exports = {
|
||||
initializeProject: callbackify(initializeProject),
|
||||
flushProject: callbackify(flushProject),
|
||||
flushMigration: callbackify(flushMigration),
|
||||
resyncProject: callbackify(resyncProject),
|
||||
deleteProject: callbackify(deleteProject),
|
||||
deleteProjectHistory: callbackify(deleteProjectHistory),
|
||||
injectUserDetails: callbackify(injectUserDetails),
|
||||
promises: {
|
||||
initializeProject,
|
||||
flushProject,
|
||||
flushMigration,
|
||||
resyncProject,
|
||||
deleteProject,
|
||||
injectUserDetails,
|
||||
deleteProjectHistory,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -55,10 +59,39 @@ async function flushProject(projectId) {
|
|||
}
|
||||
}
|
||||
|
||||
async function resyncProject(projectId) {
|
||||
async function flushMigration(projectId) {
|
||||
try {
|
||||
await request.post({
|
||||
url: `${settings.apis.project_history_importer.url}/project/${projectId}/flush`,
|
||||
})
|
||||
} catch (err) {
|
||||
throw OError.tag(
|
||||
err,
|
||||
'failed to flush project migration to project history importer',
|
||||
{
|
||||
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 {
|
||||
await request.post({
|
||||
url: `${settings.apis.project_history.url}/project/${projectId}/resync`,
|
||||
qs: { force }, // TODO: only send if true?
|
||||
})
|
||||
} catch (err) {
|
||||
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
|
||||
if (callback == null) {
|
||||
callback = function () {}
|
||||
|
@ -80,6 +88,7 @@ const ProjectHistoryHandler = {
|
|||
{
|
||||
'overleaf.history.display': true,
|
||||
'overleaf.history.upgradedAt': new Date(),
|
||||
'overleaf.history.allowDowngrade': allowDowngrade,
|
||||
},
|
||||
function (err, result) {
|
||||
if (err != null) {
|
||||
|
|
|
@ -99,6 +99,7 @@ const ProjectSchema = new Schema({
|
|||
id: { type: Number },
|
||||
display: { type: Boolean },
|
||||
upgradedAt: { type: Date },
|
||||
allowDowngrade: { type: Boolean },
|
||||
},
|
||||
},
|
||||
collabratecUsers: [
|
||||
|
|
0
services/web/data/projectHistories/.gitignore
vendored
Normal file
0
services/web/data/projectHistories/.gitignore
vendored
Normal file
905
services/web/package-lock.json
generated
905
services/web/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -169,6 +169,7 @@
|
|||
"sanitize-html": "^1.27.1",
|
||||
"scroll-into-view-if-needed": "^2.2.25",
|
||||
"underscore": "^1.13.1",
|
||||
"unzipper": "^0.10.11",
|
||||
"url-parse": "^1.4.7",
|
||||
"utf-8-validate": "^5.0.2",
|
||||
"uuid": "^3.0.1",
|
||||
|
@ -241,6 +242,7 @@
|
|||
"mkdirp": "0.5.1",
|
||||
"mocha": "^8.3.2",
|
||||
"mock-fs": "^4.11.0",
|
||||
"nock": "^13.1.1",
|
||||
"node-fetch": "^2.6.1",
|
||||
"nodemon": "^2.0.6",
|
||||
"optimize-css-assets-webpack-plugin": "^5.0.3",
|
||||
|
|
Loading…
Add table
Reference in a new issue