mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #5575 from overleaf/bg-improve-undelete-doc-admin-page
add deletedAt timestamp to undelete doc admin page GitOrigin-RevId: 46893aae35290e42886320731a5f68811fb3ed46
This commit is contained in:
parent
e681c6322f
commit
4688cb7b54
2 changed files with 49 additions and 11 deletions
|
@ -117,14 +117,18 @@ module.exports = HttpController = {
|
|||
logger.log({ project_id }, 'getting all deleted docs')
|
||||
DocManager.getAllDeletedDocs(
|
||||
project_id,
|
||||
{ name: true },
|
||||
{ name: true, deletedAt: true },
|
||||
function (error, docs) {
|
||||
if (error) {
|
||||
return next(error)
|
||||
}
|
||||
res.json(
|
||||
docs.map(doc => {
|
||||
return { _id: doc._id.toString(), name: doc.name }
|
||||
return {
|
||||
_id: doc._id.toString(),
|
||||
name: doc.name,
|
||||
deletedAt: doc.deletedAt,
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
|
|
@ -302,7 +302,13 @@ describe('Delete via PATCH', function () {
|
|||
|
||||
describe('when the doc gets a name on delete', function () {
|
||||
beforeEach(function (done) {
|
||||
DocstoreClient.deleteDoc(this.project_id, this.doc_id, done)
|
||||
this.deletedAt = new Date()
|
||||
DocstoreClient.deleteDocWithDate(
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
this.deletedAt,
|
||||
done
|
||||
)
|
||||
})
|
||||
|
||||
it('should show the doc in deleted docs response', function (done) {
|
||||
|
@ -311,7 +317,11 @@ describe('Delete via PATCH', function () {
|
|||
(error, deletedDocs) => {
|
||||
if (error) return done(error)
|
||||
expect(deletedDocs).to.deep.equal([
|
||||
{ _id: this.doc_id.toString(), name: 'main.tex' },
|
||||
{
|
||||
_id: this.doc_id.toString(),
|
||||
name: 'main.tex',
|
||||
deletedAt: this.deletedAt.toISOString(),
|
||||
},
|
||||
])
|
||||
done()
|
||||
}
|
||||
|
@ -331,9 +341,11 @@ describe('Delete via PATCH', function () {
|
|||
)
|
||||
})
|
||||
beforeEach('delete doc2', function (done) {
|
||||
DocstoreClient.deleteDocWithName(
|
||||
this.deletedAt2 = new Date()
|
||||
DocstoreClient.deleteDocWithDateAndName(
|
||||
this.project_id,
|
||||
this.doc_id2,
|
||||
this.deletedAt2,
|
||||
'two.tex',
|
||||
done
|
||||
)
|
||||
|
@ -350,9 +362,11 @@ describe('Delete via PATCH', function () {
|
|||
)
|
||||
})
|
||||
beforeEach('delete doc3', function (done) {
|
||||
DocstoreClient.deleteDocWithName(
|
||||
this.deletedAt3 = new Date()
|
||||
DocstoreClient.deleteDocWithDateAndName(
|
||||
this.project_id,
|
||||
this.doc_id3,
|
||||
this.deletedAt3,
|
||||
'three.tex',
|
||||
done
|
||||
)
|
||||
|
@ -364,9 +378,21 @@ describe('Delete via PATCH', function () {
|
|||
if (error) return done(error)
|
||||
|
||||
expect(deletedDocs).to.deep.equal([
|
||||
{ _id: this.doc_id3.toString(), name: 'three.tex' },
|
||||
{ _id: this.doc_id2.toString(), name: 'two.tex' },
|
||||
{ _id: this.doc_id.toString(), name: 'main.tex' },
|
||||
{
|
||||
_id: this.doc_id3.toString(),
|
||||
name: 'three.tex',
|
||||
deletedAt: this.deletedAt3.toISOString(),
|
||||
},
|
||||
{
|
||||
_id: this.doc_id2.toString(),
|
||||
name: 'two.tex',
|
||||
deletedAt: this.deletedAt2.toISOString(),
|
||||
},
|
||||
{
|
||||
_id: this.doc_id.toString(),
|
||||
name: 'main.tex',
|
||||
deletedAt: this.deletedAt.toISOString(),
|
||||
},
|
||||
])
|
||||
done()
|
||||
}
|
||||
|
@ -390,8 +416,16 @@ describe('Delete via PATCH', function () {
|
|||
if (error) return done(error)
|
||||
|
||||
expect(deletedDocs).to.deep.equal([
|
||||
{ _id: this.doc_id3.toString(), name: 'three.tex' },
|
||||
{ _id: this.doc_id2.toString(), name: 'two.tex' },
|
||||
{
|
||||
_id: this.doc_id3.toString(),
|
||||
name: 'three.tex',
|
||||
deletedAt: this.deletedAt3.toISOString(),
|
||||
},
|
||||
{
|
||||
_id: this.doc_id2.toString(),
|
||||
name: 'two.tex',
|
||||
deletedAt: this.deletedAt2.toISOString(),
|
||||
},
|
||||
// dropped main.tex
|
||||
])
|
||||
done()
|
||||
|
|
Loading…
Reference in a new issue