Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

feat: Back to conversations links #75

Merged
merged 5 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions module/Olcs/src/Controller/ConversationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public function addAction(): ViewModel

$view = new ViewModel();
$view->setVariable('form', $form);
$view->setVariable('backUrl', $this->url()->fromRoute('conversations'));
$view->setTemplate('messages-new');

return $view;
Expand Down Expand Up @@ -200,6 +201,7 @@ public function viewAction()
'canReply' => $canReply,
'openReply' => false,
'canUploadFiles' => $canUploadFiles,
'backUrl' => $this->url()->fromRoute('conversations'),
],
);
$view->setTemplate('messages-view');
Expand Down
8 changes: 8 additions & 0 deletions module/Olcs/view/messages-new.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ echo $this->partial(
->setPartial('partials/tabs-nav');
?>

<div class="govuk-footer__heading">
<a href="<?php echo $this->backUrl; ?>" class="govuk-back-link">
<?php echo $this->translate('Back to conversations'); ?>
</a>
</div>

<h2><?php echo $this->translate('Start a new conversation'); ?></h2>

<div>
<?php
echo $this->formErrors($this->form);
Expand Down
6 changes: 6 additions & 0 deletions module/Olcs/view/messages-view.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ echo $this->partial(
->setPartial('partials/tabs-nav');
?>

<div class="govuk-footer__heading">
<a href="<?php echo $this->backUrl; ?>" class="govuk-back-link">
<?php echo $this->translate('Back to conversations'); ?>
</a>
</div>

<?php if ($this->canReply): ?>
<details class="govuk-details" data-module="govuk-details" <?php if ($this->openReply): ?>open<?php endif; ?>>
<summary class="govuk-details__summary" aria-controls="details-content-operating-centre">
Expand Down
11 changes: 11 additions & 0 deletions test/Olcs/src/Controller/ConversationsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Laminas\Http\Response as HttpResponse;
use Laminas\Mvc\Controller\Plugin\Params;
use Dvsa\Olcs\Transfer\Command\Messaging\Message\Create as CreateMessageCommand;
use Laminas\Mvc\Controller\Plugin\Url;
use Laminas\Navigation\Navigation;
use Laminas\View\Model\ViewModel;
use Mockery as m;
Expand Down Expand Up @@ -129,14 +130,24 @@ public function testViewAction(): void
],
);

$mockUrl = m::mock(Url::class);
$mockUrl->shouldReceive('fromRoute')
->once()
->with('conversations');

$this->sut->shouldReceive('params')
->andReturn($this->mockParams);
$this->sut->shouldReceive('plugin')
->with('handleQuery')
->once()
->andReturn($mockHandleQuery);
$this->sut->shouldReceive('plugin')
->with('currentUser')
->andReturn($mockUser);
$this->sut->shouldReceive('plugin')
->with('url')
->once()
->andReturn($mockUrl);

$table = '<table/>';

Expand Down
Loading