diff --git a/src/Controller/App/Revision/ResetRevisionVisibilityController.php b/src/Controller/App/Revision/ResetRevisionVisibilityController.php new file mode 100644 index 000000000..faacd6b7e --- /dev/null +++ b/src/Controller/App/Revision/ResetRevisionVisibilityController.php @@ -0,0 +1,42 @@ +}/revision-visibility/reset', name: self::class, methods: 'POST')] + #[IsGranted(Roles::ROLE_USER)] + public function __invoke(#[MapEntity] CodeReview $review): RedirectResponse + { + $revisions = $this->revisionService->getRevisions($review); + $visibilities = $this->visibilityService->getRevisionVisibilities($review, $revisions, $this->getUser()); + + // set all visible + foreach ($visibilities as $visibility) { + $visibility->setVisible(true); + } + $this->visibilityRepository->saveAll($visibilities, true); + + return $this->refererRedirect(ReviewController::class, ['review' => $review]); + } +} diff --git a/templates/app/review/review.sidebar.html.twig b/templates/app/review/review.sidebar.html.twig index eb9d6176d..b28107de2 100644 --- a/templates/app/review/review.sidebar.html.twig +++ b/templates/app/review/review.sidebar.html.twig @@ -21,6 +21,16 @@ {% endif %} + {% if reviewModel.visibleRevisionCount != reviewModel.revisions|length %} + + {% endif %} diff --git a/tests/Unit/Controller/App/Revision/ResetRevisionVisibilityControllerTest.php b/tests/Unit/Controller/App/Revision/ResetRevisionVisibilityControllerTest.php new file mode 100644 index 000000000..413f57b06 --- /dev/null +++ b/tests/Unit/Controller/App/Revision/ResetRevisionVisibilityControllerTest.php @@ -0,0 +1,58 @@ +visibilityService = $this->createMock(RevisionVisibilityService::class); + $this->visibilityRepository = $this->createMock(RevisionVisibilityRepository::class); + $this->revisionService = $this->createMock(CodeReviewRevisionService::class); + parent::setUp(); + } + + public function testInvoke(): void + { + $review = new CodeReview(); + $revision = new Revision(); + $visibility = (new RevisionVisibility())->setVisible(false); + $user = new User(); + + $this->expectGetUser($user); + $this->revisionService->expects(self::once())->method('getRevisions')->with($review)->willReturn([$revision]); + $this->visibilityService->expects(self::once())->method('getRevisionVisibilities') + ->with($review, [$revision], $user) + ->willReturn([$visibility]); + $this->visibilityRepository->expects(self::once())->method('saveAll')->with([$visibility], true); + $this->expectRefererRedirect(ReviewController::class, ['review' => $review]); + + ($this->controller)($review); + static::assertTrue($visibility->isVisible()); + } + + public function getController(): AbstractController + { + return new ResetRevisionVisibilityController($this->visibilityService, $this->visibilityRepository, $this->revisionService); + } +} diff --git a/translations/messages+intl-icu.en.php b/translations/messages+intl-icu.en.php index 2fb0ae68c..7f08127ab 100644 --- a/translations/messages+intl-icu.en.php +++ b/translations/messages+intl-icu.en.php @@ -138,6 +138,7 @@ 'ignore.space.at.eol' => 'Ignore space at end-of-line', 'ignore.space.change' => 'Ignore space changes', 'ignore.whitespaces' => 'Ignore whitespaces', + 'ignore.whitespaces.and.empty.lines' => 'Ignore whitespaces and empty lines', 'in.review' => 'In review', 'inactive' => 'Inactive', 'include.commits' => 'Include commits', @@ -164,6 +165,7 @@ 'login.not.successful' => 'The log in was not successful', 'login.unable.to.validate.login.attempt' => 'Unable to validate the login attempt. Please retry', 'logout' => 'Logout', + 'logs' => 'Logs', 'mail.comment.resolved.subject' => '[Resolved discussion] {reviewId}: {reviewTitle}', 'mail.comment.was.resolved.on' => 'Comment was resolved by {userName} on', 'mail.configure.settings' => 'Configure notification settings.', @@ -176,6 +178,7 @@ 'mail.unsubscribe.footer' => 'If you don\'t want to receive these emails from {app_name} in the future, please unsubscribe.', 'mail.updated.comment.subject' => '[Updated discussion] {reviewId}: {reviewTitle}', 'main.branch' => 'Main branch', + 'mark.all.as.read' => 'Mark all as read', 'merged' => 'merged', 'name' => 'Name', 'never' => 'Never', @@ -281,6 +284,7 @@ 'settings' => 'Settings', 'settings.save.successfully' => 'Settings successfully saved', 'show' => 'show', + 'show.all.revisions' => 'Show all revisions', 'sign.in' => 'Sign in', 'sign.up' => 'Sign up', 'subject' => 'Subject', @@ -346,7 +350,4 @@ 'webhooks' => 'Webhooks', 'yes' => 'Yes', 'you' => 'You', - 'logs' => 'Logs', - 'mark.all.as.read' => 'Mark all as read', - 'ignore.whitespaces.and.empty.lines' => 'Ignore whitespaces and empty lines', ];