mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #9663 from overleaf/jel-archiving-trashed
[web] Update view when archiving trashed project GitOrigin-RevId: c40fb036a0c6c2bd18c2245a24f41e3979efd707
This commit is contained in:
parent
341ee52c3f
commit
db7d0beda3
3 changed files with 31 additions and 2 deletions
|
@ -35,7 +35,12 @@ function ArchiveProjectButton({
|
|||
|
||||
const handleArchiveProject = useCallback(async () => {
|
||||
await archiveProject(project.id)
|
||||
updateProjectViewData({ ...project, archived: true, selected: false })
|
||||
updateProjectViewData({
|
||||
...project,
|
||||
archived: true,
|
||||
selected: false,
|
||||
trashed: false,
|
||||
})
|
||||
}, [project, updateProjectViewData])
|
||||
|
||||
if (project.archived) return null
|
||||
|
|
|
@ -28,7 +28,12 @@ function ArchiveProjectsButton() {
|
|||
const handleArchiveProjects = useCallback(async () => {
|
||||
for (const project of selectedProjects) {
|
||||
await archiveProject(project.id)
|
||||
updateProjectViewData({ ...project, archived: true, selected: false })
|
||||
updateProjectViewData({
|
||||
...project,
|
||||
archived: true,
|
||||
selected: false,
|
||||
trashed: false,
|
||||
})
|
||||
}
|
||||
}, [selectedProjects, updateProjectViewData])
|
||||
|
||||
|
|
|
@ -223,6 +223,25 @@ describe('<ProjectListRoot />', function () {
|
|||
|
||||
expect(screen.queryByText('No projects')).to.be.null
|
||||
})
|
||||
|
||||
it('removes project from view when archiving', async function () {
|
||||
fetchMock.post(`express:/project/:id/archive`, {
|
||||
status: 200,
|
||||
})
|
||||
|
||||
const untrashButton =
|
||||
within(actionsToolbar).getByLabelText<HTMLInputElement>('Archive')
|
||||
fireEvent.click(untrashButton)
|
||||
|
||||
const confirmButton = screen.getByText<HTMLInputElement>('Confirm')
|
||||
fireEvent.click(confirmButton)
|
||||
expect(confirmButton.disabled).to.be.true
|
||||
|
||||
await fetchMock.flush(true)
|
||||
expect(fetchMock.done()).to.be.true
|
||||
|
||||
screen.getByText('No projects')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue