From db7d0beda394896c79c1d224b37c3fdf991f8556 Mon Sep 17 00:00:00 2001 From: Jessica Lawshe Date: Mon, 26 Sep 2022 12:40:02 -0500 Subject: [PATCH] Merge pull request #9663 from overleaf/jel-archiving-trashed [web] Update view when archiving trashed project GitOrigin-RevId: c40fb036a0c6c2bd18c2245a24f41e3979efd707 --- .../action-buttons/archive-project-button.tsx | 7 ++++++- .../buttons/archive-projects-button.tsx | 7 ++++++- .../components/project-list-root.test.tsx | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/archive-project-button.tsx b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/archive-project-button.tsx index e2957a6733..b24c5f69c4 100644 --- a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/archive-project-button.tsx +++ b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/archive-project-button.tsx @@ -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 diff --git a/services/web/frontend/js/features/project-list/components/table/project-tools/buttons/archive-projects-button.tsx b/services/web/frontend/js/features/project-list/components/table/project-tools/buttons/archive-projects-button.tsx index c033a96bf3..c263eaea39 100644 --- a/services/web/frontend/js/features/project-list/components/table/project-tools/buttons/archive-projects-button.tsx +++ b/services/web/frontend/js/features/project-list/components/table/project-tools/buttons/archive-projects-button.tsx @@ -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]) diff --git a/services/web/test/frontend/features/project-list/components/project-list-root.test.tsx b/services/web/test/frontend/features/project-list/components/project-list-root.test.tsx index a9ca3c2742..09229664cc 100644 --- a/services/web/test/frontend/features/project-list/components/project-list-root.test.tsx +++ b/services/web/test/frontend/features/project-list/components/project-list-root.test.tsx @@ -223,6 +223,25 @@ describe('', 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('Archive') + fireEvent.click(untrashButton) + + const confirmButton = screen.getByText('Confirm') + fireEvent.click(confirmButton) + expect(confirmButton.disabled).to.be.true + + await fetchMock.flush(true) + expect(fetchMock.done()).to.be.true + + screen.getByText('No projects') + }) }) })