diff --git a/capsule-prototype/index.html b/capsule-prototype/index.html index eb41085d8407578af0a8dd9c7f4c025a7da5bc58..970c40a6e842dba94ffe84bbd4762822f6586152 100644 --- a/capsule-prototype/index.html +++ b/capsule-prototype/index.html @@ -41,7 +41,6 @@ <script language="javascript" type='text/javascript' src='../shared/js/iannix.js'></script> <script language="javascript" type='text/javascript' src='../shared/js/online-script.js'></script> - <script type="module" src="../shared/php/rekallApp.js.php"></script> <script language="javascript" type='text/javascript' src="../shared/js/libs/video-js/video.min.js"></script> <link rel="stylesheet" type="text/css" href="../shared/js/libs/video-js/video-js.min.css" /> @@ -84,7 +83,7 @@ <input class="popupFormButton" id="popupFormButtonUpload" type="submit" value="Upload" name="submit"> </div> </div> --> - <a class="displayMode" id="watermarkBox" href="javascript:window.app.rekall.Rekall('openUrl', window.app.urls.memberHome)" title="Open in MemoRekall" target="_parent"><img id="watermark" src="../shared/css/images/watermark.png" /></a> + <a class="displayMode" id="watermarkBox" href="javascript:window.app.rekall.Rekall('openUrl', 'home')" title="Open in MemoRekall" target="_parent"><img id="watermark" src="../shared/css/images/watermark.png" /></a> <!--<a class="displayMode" id="openFullScreenBox" href="http://www.memorekall.fr" alt="Open in MemoRekall" target="_blank"><img id="openFullScreen" src="../shared/css/images/expand.png" /></a>--> <div class="displayMode" id="projectInfoBtn" title="Project informations">i</div> <div id="popupAlertSpace"> @@ -205,7 +204,7 @@ <div id='left_menu' class='flex-col editmode'> <div class='top'> - <a class="left_menu_item dropable" href="javascript:window.app.rekall.Rekall('openUrl', window.app.urls.memberHome)"> + <a class="left_menu_item dropable" href="javascript:window.app.rekall.Rekall('openUrl', 'home')"> <i class="fas fa-home fa-3x left_menu_item_icn"></i> <p>Go back to my capsules</p> </a> diff --git a/capsule-prototype/js/online-rekall/RekallApplication.js b/capsule-prototype/js/online-rekall/RekallApplication.js index e8097663b7d4946f56da8b48cfed0241fcf37062..135f3733138a2d544be99be304c398d5e55a09a7 100644 --- a/capsule-prototype/js/online-rekall/RekallApplication.js +++ b/capsule-prototype/js/online-rekall/RekallApplication.js @@ -6,12 +6,24 @@ 'init', 'setPlaybackRate', 'videoPlayer', - 'rekall' + 'rekall', + 'getUrl' ]; let localOptions = {}; const OPTIONS = { + getUrl: function (){ + if (arguments && localOptions.links && localOptions.links[arguments[0]]) { + return localOptions.links[arguments[0]]; + } + return ''; + }, + init: function (opts) { + if (opts) { + $.extend(localOptions, opts); + } + }, openUrl: function () { if (!arguments) return; @@ -24,10 +36,8 @@ pubSub: function () { return localOptions.PubSub; }, - init: function (opts) { - if (opts) { - $.extend(localOptions, opts); - } + rekall: function () { + return localOptions.Rekall; }, setPlaybackRate: function () { if (arguments.length > 0 && 'number' === typeof arguments[0] && 0 < arguments[0] && arguments[0] < 10) { @@ -40,9 +50,6 @@ } return localOptions._videoPlayer; - }, - rekall: function () { - return localOptions.Rekall; } }; @@ -60,5 +67,5 @@ } } } - app.rekall = new RekallApplication() + app.rekall = new RekallApplication(); })(window.app = window.app || {}) \ No newline at end of file diff --git a/capsule-prototype/js/online-script.js b/capsule-prototype/js/online-script.js index 5a1a1ac2dbdaf3627c543e3169454a607ed7a3cb..8f53cf8fa0bc0660838410e9cefe4471bdcc590f 100644 --- a/capsule-prototype/js/online-script.js +++ b/capsule-prototype/js/online-script.js @@ -19,7 +19,6 @@ $(document).ready(function() { }); window.app.rekall.Rekall().allowProjectDeletion(window.app.Settings.Project.ProjectDeletionEnabled); - rekall.allowProjectDeletion(window.app.Settings.Project.ProjectDeletionEnabled) Utils.actionPrefix = "php/"; Utils.actionSuffix = ".php?r="; @@ -41,8 +40,6 @@ $(document).ready(function() { rekall_common = infos; if(getParameterByName("w") != "") rekall_common.owner.canEdit = false; -// -//rekall_common.owner.canEdit = true; if(rekall_common.owner.canEdit) { //Mode preview or not @@ -310,8 +307,7 @@ function setEditionControls() { $("#left_menu_item_preview").click(function(event){ event.stopPropagation(); - window.open(window.app.urls.memberHome + 'capsule/preview/' + window.location.pathname.replace('/legacy/', '').slice(0, -1), '_blank'); - /*window.open("?w=1", "Preview Rekall", "menubar=no, status=no, scrollbars=no, menubar=no, width=1150, height=560"); */ + window.open(window.app.rekall.Rekall('getUrl', 'projectPreview'), '_blank'); }); $("#popupSettingsBtnDownloadXml").click(function(event){ @@ -558,7 +554,7 @@ function setEditionControls() { setMetaFromDom(keyDoc, "Rekall->Highlight", "true"); var tmpColor = $("#popupNom").css("color"); $(this).attr("isHighlight", "true").addClass("selected"); - $("#popupEdit").addClass("highlightPopup"); + $("#popupEdit").addClass("highlightPopup"); } }); @@ -1086,7 +1082,7 @@ function removeProject() { data: {"remove": 1}, success: function(retour) { rouletteEnd(); - window.app.rekall.Rekall('openUrl', window.app.urls.memberHome); + window.app.rekall.Rekall('openUrl', 'home'); }, error: function() { openAlert("Server error. Try again."); diff --git a/src/Controller/CapsuleController.php b/src/Controller/CapsuleController.php index 894664f804cd3b9089b06a219d4b0a0b0e886f9c..cb9eecf490e83eb68ec4947e64c2177561f075e6 100755 --- a/src/Controller/CapsuleController.php +++ b/src/Controller/CapsuleController.php @@ -20,6 +20,7 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Uid\Uuid; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -132,7 +133,7 @@ class CapsuleController extends AbstractController } #[Route('/{_locale<%app.supported_locales%>}/capsule/preview/{path}', name:'preview_capsule')] - public function preview(string $path): Response + public function preview(string $path, UrlGeneratorInterface $urlGenerator): Response { $file_path = '../legacy/' . $path; if (!file_exists($file_path)) { @@ -143,12 +144,15 @@ class CapsuleController extends AbstractController return $this->render( 'project/project_view.html.twig', - [ 'url' => $url ] + [ + 'url' => $url, + 'linkHome' => $urlGenerator->generate('home', [], UrlGeneratorInterface::ABSOLUTE_URL) + ] ); } #[Route('/{_locale<%app.supported_locales%>}/capsule/edit/{path}', name:'edit_capsule')] - public function edit(string $path): Response + public function edit(string $path, UrlGeneratorInterface $urlGenerator): Response { $current_user = $this->getUser(); @@ -175,8 +179,21 @@ class CapsuleController extends AbstractController $url = $this->getParameter('app.legacy_external_prefix') . '/' . $capsule->getEditionLink(); return $this->render( - 'project/project_view.html.twig', - [ 'url' => $url ] + 'project/edit.html.twig', + [ + 'url' => $url, + 'linkHome' => $urlGenerator->generate( + 'home', + [], + UrlGeneratorInterface::ABSOLUTE_URL + ) + , + 'linkPreview' => $urlGenerator->generate( + 'preview_capsule', + [ 'path' => $capsule->getLinkPath() ], + UrlGeneratorInterface::ABSOLUTE_URL + ) + ] ); } diff --git a/src/Controller/CapsuleGroupController.php b/src/Controller/CapsuleGroupController.php index fb61dd0269b16d823db01ed85b162c451efc9647..f69a6fd1c4c657f73acb468b00ac1b53f2e48460 100755 --- a/src/Controller/CapsuleGroupController.php +++ b/src/Controller/CapsuleGroupController.php @@ -12,10 +12,12 @@ use App\Form\SelectCapsuleGroupsFormType; use App\Repository\CapsuleRepository; use App\Repository\GroupRepository; use Doctrine\ORM\EntityManagerInterface; +use Exception; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Component\Routing\Annotation\Route; @@ -41,7 +43,7 @@ class CapsuleGroupController extends AbstractController $groups = $current_user->getGroups()->toArray(); return $this->render('capsule/groups/user_groups.html.twig', [ - 'groups' => $groups + 'groups' => $groups, ]); } @@ -77,10 +79,13 @@ class CapsuleGroupController extends AbstractController } return $this->renderForm('capsule/groups/create.html.twig', [ - 'createCapsuleGroupsForm' => $form + 'createCapsuleGroupsForm' => $form, ]); } + /** + * @throws Exception The group doesn't exist + */ #[Route('/{_locale<%app.supported_locales%>}/my_groups/{group_id}/delete', name:'delete_group')] public function deleteGroup(int $group_id, Request $request): Response { @@ -91,7 +96,7 @@ class CapsuleGroupController extends AbstractController $group = $this->group_repository->findOneBy(['id' => $group_id]); if (! $group instanceof Group) { - throw new \Exception('Group not found'); + throw new Exception('Group not found'); } $form = $this->createForm(DeleteGroupFormType::class); @@ -125,10 +130,13 @@ class CapsuleGroupController extends AbstractController return $this->renderForm('capsule/groups/delete.html.twig', [ 'deleteGroupForm' => $form, - 'group_name' => $group->getName() + 'group_name' => $group->getName(), ]); } + /** + * @throws Exception the capsule doesn't exist + */ #[Route('/{_locale<%app.supported_locales%>}/capsule/{capsule_id}/groups/edit', name:'edit_capsule_groups')] public function edit(int $capsule_id, Request $request): Response { @@ -141,7 +149,7 @@ class CapsuleGroupController extends AbstractController $capsule = $this->capsule_repository->findOneBy(['id' => $capsule_id]); if (! $capsule instanceof Capsule) { - throw new \Exception("Capsule does not exist"); + throw new Exception("Capsule does not exist"); } $capsule_groups_by_author = $current_user->getGroupsByCapsule($capsule); @@ -174,7 +182,7 @@ class CapsuleGroupController extends AbstractController ); return $this->redirectToRoute('edit_capsule_groups', [ - 'capsule_id' => $capsule_id + 'capsule_id' => $capsule_id, ]); } @@ -186,6 +194,9 @@ class CapsuleGroupController extends AbstractController ]); } + /** + * @throws Exception the capsule is not found or the group is not found + */ #[Route('/{_locale<%app.supported_locales%>}/capsule/{capsule_id}/groups/{group_id}/remove', name:'remove_group')] public function remove( int $capsule_id, @@ -194,12 +205,12 @@ class CapsuleGroupController extends AbstractController ): Response { $capsule = $this->capsule_repository->findOneBy(['id' => $capsule_id]); if (! $capsule instanceof Capsule) { - throw new \Exception('Capsule not found'); + throw new Exception('Capsule not found'); } $group = $this->group_repository->findOneBy(['id' => $group_id]); if (! $group instanceof Group) { - throw new \Exception('Group not found'); + throw new Exception('Group not found'); } $current_user = $this->getUser(); @@ -238,7 +249,7 @@ class CapsuleGroupController extends AbstractController return $this->renderForm('capsule/groups/remove.html.twig', [ 'removeGroupForm' => $form, 'group_name' => $group->getName(), - 'capsule_id' => $capsule_id + 'capsule_id' => $capsule_id, ]); } @@ -254,7 +265,7 @@ class CapsuleGroupController extends AbstractController $group_db = $this->group_repository->findOneBy(['id' => $group_data->getId()]); if (! $group_db instanceof Group) { - throw new \Exception('Group not found'); + throw new Exception('Group not found'); } $groups[] = $group_db; diff --git a/templates/capsule/delete.html.twig b/templates/capsule/delete.html.twig index 67d6f794bedbd58b3d1ccb9481b72b1dfcbaf9a8..df950587951bc3b379a5ab556f5ec4a638d24fe5 100644 --- a/templates/capsule/delete.html.twig +++ b/templates/capsule/delete.html.twig @@ -23,7 +23,7 @@ {{ form_start(deleteCapsuleForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} {{ form_row(deleteCapsuleForm.delete, {'row_attr': {'class' : 'm-auto mb-2 me-3'}}) }} - <a href="/"> + <a href="{{ path('home') }}"> {{ form_row(deleteCapsuleForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }} </a> {{ form_end(deleteCapsuleForm) }} diff --git a/templates/capsule/editors/list_editors.html.twig b/templates/capsule/editors/list_editors.html.twig index 355ec3640f684795957c9ef547e04b113dc1dd02..d6d82fe7347f2680e1d30f135ca998bed63ee1e4 100644 --- a/templates/capsule/editors/list_editors.html.twig +++ b/templates/capsule/editors/list_editors.html.twig @@ -48,7 +48,7 @@ {{ editor.getFirstName() }} {{ editor.getLastName() }} {% if editor is not same as capsule.getCreationAuthor() %} - - <a href="{{ path('remove_editor', {'_locale': current_user.getLocale(), 'capsule_id' : capsule.getId(), 'editor_id': editor.getId()}) }}" + <a href="{{ path('remove_editor', { 'capsule_id' : capsule.getId(), 'editor_id': editor.getId()}) }}" class="remove-link"> {{ 'editors.remove.editor.link'|trans }} </a> @@ -63,8 +63,7 @@ {% for pending_editor in pending_editors %} <li class="text-secondary list-unstyled p-1"> {{ pending_editor.getEmail() }} - <a href="{{ path('remove_pending_editor', {'_locale': current_user.getLocale(), 'capsule_id' : capsule.getId(), 'pending_editor_invitation_id': pending_editor.getId()}) }}" - class="remove-link"> + <a href="{{ path('remove_editor', { 'capsule_id': capsule.getId(), 'editor_id': pending_editor.getId() }) }}" class="remove-link"> {{ 'editors.remove.pending_editor.link'|trans }} </a> </li> diff --git a/templates/capsule/editors/remove_editor.html.twig b/templates/capsule/editors/remove_editor.html.twig index ddfd703f8eebfc2dde4012ad8d5bffafd9b9b4e5..b8f32bf160065233e687d346887eddcd8c04b8fd 100644 --- a/templates/capsule/editors/remove_editor.html.twig +++ b/templates/capsule/editors/remove_editor.html.twig @@ -23,7 +23,7 @@ {{ form_start(removeEditorForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} {{ form_row(removeEditorForm.remove, {'row_attr': {'class' : 'm-auto mb-2 me-3'}}) }} - <a href="/capsule/{{ capsule_id }}/editors"> + <a href="{{ path('edit_capsule_editors', { 'capsule_id': capsule_id }) }}"> {{ form_row(removeEditorForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }} </a> {{ form_end(removeEditorForm) }} diff --git a/templates/capsule/editors/remove_pending_editor.html.twig b/templates/capsule/editors/remove_pending_editor.html.twig index bd96a9193560995c33445dad36946b2de7114512..d1156702541071fed53588e1e63e0cc5238196cb 100644 --- a/templates/capsule/editors/remove_pending_editor.html.twig +++ b/templates/capsule/editors/remove_pending_editor.html.twig @@ -23,7 +23,7 @@ {{ form_start(removeEditorForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} {{ form_row(removeEditorForm.remove, {'row_attr': {'class' : 'm-auto mb-2 me-3'}}) }} - <a href="/capsule/{{ capsule_id }}/editors"> + <a href="{{ path('edit_capsule_editors', { 'capsule_id': capsule_id }) }}"> {{ form_row(removeEditorForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }} </a> {{ form_end(removeEditorForm) }} diff --git a/templates/capsule/groups/capsule_groups.html.twig b/templates/capsule/groups/capsule_groups.html.twig index ebc4298a2881f46a8cca38f2f1fe3f33d353f1c9..608582f983b54d40c33bd6de8b03d5a314626008 100644 --- a/templates/capsule/groups/capsule_groups.html.twig +++ b/templates/capsule/groups/capsule_groups.html.twig @@ -44,7 +44,7 @@ {{ group.getName() }} </span> - - <a href="/capsule/{{ capsule.getId() }}/groups/{{ group.getId() }}/remove" class="remove-link"> + <a href="{{ path('remove_group', { 'capsule_id': capsule.getId(), 'group_id':group.getId() }) }}" class="remove-link"> {{ 'groups.remove.link'|trans }} </a> </li> diff --git a/templates/capsule/groups/create.html.twig b/templates/capsule/groups/create.html.twig index aa0da53e162d2c444d521ab75e5ecf514f5f6bb9..9f4c16c43662b1a9dc39c7efbdebb576379969e8 100644 --- a/templates/capsule/groups/create.html.twig +++ b/templates/capsule/groups/create.html.twig @@ -23,7 +23,8 @@ <div class="d-flex flex-column flex-sm-row justify-content-center align-items-center align-items-sm-start"> {{ form_row(createCapsuleGroupsForm.validate, {'row_attr': {'class' : 'me-sm-3 mb-3'}}) }} - <a href="/my_groups"> + <a href="{{ path('edit_user_groups') }}"> + <a href="{{ path('edit_user_groups') }}"> {{ form_row(createCapsuleGroupsForm.go_back) }} </a> </div> diff --git a/templates/capsule/groups/delete.html.twig b/templates/capsule/groups/delete.html.twig index 80dcb3e8135c58a1ae22da7886572c75900a6334..a73829063d672f73a40908487225267aad751805 100644 --- a/templates/capsule/groups/delete.html.twig +++ b/templates/capsule/groups/delete.html.twig @@ -23,7 +23,7 @@ {{ form_start(deleteGroupForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} {{ form_row(deleteGroupForm.delete, {'row_attr': {'class' : 'm-auto mb-2 me-3'}}) }} - <a href="/my_groups"> + <a href="{{ path('edit_user_groups') }}"> {{ form_row(deleteGroupForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }} </a> {{ form_end(deleteGroupForm) }} diff --git a/templates/capsule/groups/remove.html.twig b/templates/capsule/groups/remove.html.twig index 9894b62642153b5b19f1e7aaec4e74452ca56f09..1e2df223c05565cd01f5bfd25a3822c5c1b883b0 100644 --- a/templates/capsule/groups/remove.html.twig +++ b/templates/capsule/groups/remove.html.twig @@ -23,7 +23,7 @@ {{ form_start(removeGroupForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} {{ form_row(removeGroupForm.remove, {'row_attr': {'class' : 'm-auto mb-2 me-3'}}) }} - <a href="/capsule/{{ capsule_id }}/editors"> + <a href="{{ path('edit_capsule_editors', { 'capsule_id': capsule_id }) }}"> {{ form_row(removeGroupForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }} </a> {{ form_end(removeGroupForm) }} diff --git a/templates/capsule/groups/user_groups.html.twig b/templates/capsule/groups/user_groups.html.twig index f5a410fe80a4b512c282e234dd08384add0ca3e0..f4dcc40e353595ce3f39f63e279290595c02adad 100644 --- a/templates/capsule/groups/user_groups.html.twig +++ b/templates/capsule/groups/user_groups.html.twig @@ -43,7 +43,7 @@ {{ group.getName() }} </span> - - <a href="/my_groups/{{ group.getId() }}/delete" class="remove-link"> + <a href="{{ path('delete_group', { 'group_id': group.getId() }) }}" class="remove-link"> {{ 'general.delete'|trans }} </a> </li> @@ -54,7 +54,7 @@ </div> <div class="d-flex align-items-center mt-3 mt-md-0"> - <a href="/my_groups/create" class="btn btn-primary"> + <a href="{{ path('create_group') }}" class="btn btn-primary"> {{ 'groups.create.title'|trans }} </a> </div> diff --git a/templates/capsule/index.html.twig b/templates/capsule/index.html.twig index f3d0c508324a3b236ad12158f2f0e7d4643bbc8a..242a6fcc6e0baad08c710becfdd4e2abad63be07 100644 --- a/templates/capsule/index.html.twig +++ b/templates/capsule/index.html.twig @@ -50,7 +50,7 @@ <div class="capsule-item pb-4 col-12 col-sm-11 col-md-10 col-xxl-8"> <div class="d-flex flex-column flex-md-row justify-content-center align-items-center mt-sm-4"> <div class="list-item"> - <a href="{{ path('preview_capsule', {'_locale': current_user.getLocale(), 'path': capsule.getLinkPath()}) }}" class="capsule-title"> + <a href="{{ path('preview_capsule', { 'path': capsule.getLinkPath() } ) }}" class="capsule-title"> {{ capsule.getName() }} </a> </div> @@ -73,7 +73,7 @@ <i class="fa-thin fa-gears"></i> <div class="list-item text-nowrap"> - <a href="{{ path('edit_capsule_editors', {'_locale': current_user.getLocale(), 'capsule_id': capsule.getId()}) }}" + <a href="{{ path('edit_capsule_editors', {'capsule_id': capsule.getId()}) }}" class="links text-decoration-none"> <i class="fas fa-cog m-2"></i> {{ 'capsule.edit_permissions.link'|trans }} @@ -81,7 +81,7 @@ </div> <div class="list-item text-nowrap"> - <a href="{{ path('edit_video_url', {'_locale': current_user.getLocale(), 'capsule_id': capsule.getId()}) }}" + <a href="{{ path('edit_video_url', {'capsule_id': capsule.getId()}) }}" class="links text-decoration-none"> <i class="fas fa-link m-2"></i> {{ 'capsule.edit.video_url.link'|trans }} @@ -90,7 +90,7 @@ <div class="list-item text-nowrap"> - <a href="{{ path('edit_capsule_groups', {'_locale': current_user.getLocale(), 'capsule_id' : capsule.getId()}) }}" + <a href="{{ path('edit_capsule_groups', {'capsule_id' : capsule.getId()}) }}" class="links text-decoration-none"> <i class="fas fa-layer-group m-2"></i> {{ 'groups.edit.title'|trans({'%capsule_name%': capsule.getName()}) }} @@ -98,7 +98,7 @@ </div> <div class="list-item text-nowrap"> - <a href="{{ path('duplicate_capsule', {'_locale': current_user.getLocale(), 'capsule_id' : capsule.getId()}) }}" + <a href="{{ path('duplicate_capsule', {'capsule_id' : capsule.getId()}) }}" class="links text-decoration-none"> <i class="far fa-clone m-2"></i> {{ 'capsule.duplicate.link'|trans }} @@ -107,7 +107,7 @@ {% if capsule.getCreationauthor() is same as current_user %} <div class="list-item text-nowrap"> - <a href="{{ path('delete_capsule', {'_locale': current_user.getLocale(), 'capsule_id' : capsule.getId()}) }}" + <a href="{{ path('delete_capsule', {'capsule_id' : capsule.getId()}) }}" class="links text-decoration-none"> <i class="fas fa-trash m-2"></i> {{ 'capsule.delete.link'|trans }} @@ -115,7 +115,7 @@ </div> {% endif %} - <a href="{{ path('edit_capsule', {'_locale': current_user.getLocale(), 'path' : capsule.getLinkPath()}) }}" + <a href="{{ path('edit_capsule', {'path' : capsule.getLinkPath()}) }}" class="list-item text-nowrap lh-md"> <button class="btn btn-primary btn-lg rounded-3 col-12"> {{ 'capsule.edit.link'|trans }} diff --git a/templates/project/edit.html.twig b/templates/project/edit.html.twig index 78caedf4f50d431d4a0ae38d2f4f9a287edc567a..2faddade7986fe6a7559ad5c224986b30ce78c62 100644 --- a/templates/project/edit.html.twig +++ b/templates/project/edit.html.twig @@ -11,3 +11,18 @@ </iframe> {% endblock %} + +{% block script %} + <script> + window.onload = function (){ + const iframe = document.getElementById('legacyContent').contentWindow; + iframe.app.rekall.Rekall('init', { + links: { + home: '{{ linkHome }}', + projectPreview: '{{ linkPreview }}' + } + } + ); + } + </script> +{% endblock %} \ No newline at end of file diff --git a/templates/project/project_view.html.twig b/templates/project/project_view.html.twig index 613f4be7e96e7eb37495b7e12ad926a94c51ec77..2a923da7148fc5e036e6e3b83bb446bf2523ae56 100644 --- a/templates/project/project_view.html.twig +++ b/templates/project/project_view.html.twig @@ -28,6 +28,7 @@ </div> <iframe src="{{ url }}" + id="legacyContent" style="width:100%;height:100%;top:0;left:0;position:absolute" frameborder="0" @@ -36,5 +37,20 @@ allowfullscreen> </iframe> + + {% block script %} + <script> + window.onload = function (){ + const iframe = document.getElementById('legacyContent').contentWindow; + iframe.app.rekall.Rekall('init', { + links: { + home: '{{ linkHome }}' + } + } + ); + } + </script> + {% endblock %} + </body> </html> diff --git a/tests/acceptance/BasePageTest.php b/tests/acceptance/BasePageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..efa274c70cd388a0e1bd82627cab43f380040a25 --- /dev/null +++ b/tests/acceptance/BasePageTest.php @@ -0,0 +1,73 @@ +<?php + +namespace App\Tests\acceptance; + +use App\Entity\User; +use Symfony\Bundle\FrameworkBundle\KernelBrowser; +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; + +abstract class BasePageTest extends WebTestCase +{ + protected KernelBrowser $client; + protected ?User $user; + + protected function givenUser(string $userName): BasePageTest + { + $object_manager = $this->client->getContainer() + ->get('doctrine') + ->getManager(); + $user_repository = $object_manager->getRepository(User::class); + $user = $user_repository + ->findOneBy(['email' => $userName ]); + + if (! $user instanceof User) { + throw new \Exception("User does not exist."); + } + + $this->user = $user; + + return $this; + } + + protected function onPage(string $uri): BasePageTest + { + $this->client->request('GET', $uri); + $this->assertResponseIsSuccessful(); + + return $this; + } + + protected function clickLink(string $linkText, ?string $errorMessageText): BasePageTest + { + $this->client->clickLink($linkText); + $this->assertResponseIsSuccessful($errorMessageText ?? ''); + + return $this; + } + + /** + * @throws \Exception the user is not initialized + */ + protected function logged(): BasePageTest + { + if (null === $this->user) { + throw new \Exception("User is not initialized."); + } + $this->client->loginUser($this->user); + + return $this; + } + + protected function setUp(): void + { + self::ensureKernelShutdown(); + + $this->client = static::createClient(); + } + + protected function tearDown(): void + { + parent::tearDown(); + self::ensureKernelShutdown(); + } +} diff --git a/tests/acceptance/CreateCapsuleGroupPageTest.php b/tests/acceptance/CreateCapsuleGroupPageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..195c2199dce98b45990dcba3855dd492d427b16d --- /dev/null +++ b/tests/acceptance/CreateCapsuleGroupPageTest.php @@ -0,0 +1,36 @@ +<?php + +namespace App\Tests\acceptance; + +class CreateCapsuleGroupPageTest extends BasePageTest +{ + public function testUserShouldGoBackToUserCapsuleGroupsOnCancel(): void + { + $this->clickLink('Go back to my groups', 'The user should access to its group list'); + } + + public function testUserShouldGoBackToUserCapsuleGroups(): void + { + $this->clickLink( + 'Go back to my groups', + 'The user should access to the user capsule group from create a capsule group page' + ); + } + + protected function setUp(): void + { + parent::setUp(); + $this->setInitialPage(); + } + + private function setInitialPage(): void + { + $this->givenUser('defaultUser@localhost.com') + ->logged() + ->onPage('en/my_groups') + ->clickLink( + 'Create a new group', + 'The use should be able to access to the capsule group creation page' + ); + } +} diff --git a/tests/acceptance/DeleteCapsuleGroupPageTest.php b/tests/acceptance/DeleteCapsuleGroupPageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0dd05da29496ac1f5bc291e6a9d3abb596c37c68 --- /dev/null +++ b/tests/acceptance/DeleteCapsuleGroupPageTest.php @@ -0,0 +1,33 @@ +<?php + +namespace App\Tests\acceptance; + +class DeleteCapsuleGroupPageTest extends BasePageTest +{ + public function testUserShouldAllowCancelGroupDeletion(): void + { + $this->clickLink( + 'Cancel', + 'The user should be able to delete one group from the user the capsule groups page' + ); + } + + public function testUserShouldBeRedirectedToTheCapsuleGroupListOnCancelGroupDeletion(): void + { + $this->clickLink('Cancel', 'The user should be able to cancel capsule group deletion'); + } + + protected function setUp(): void + { + parent::setUp(); + $this->setInitialPage(); + } + + private function setInitialPage(): void + { + $this->givenUser('defaultUser@localhost.com') + ->logged() + ->onPage('en/my_groups') + ->clickLink('Delete', 'The user should access to a capsule group deletion page'); + } +} diff --git a/tests/acceptance/IndexPageTest.php b/tests/acceptance/IndexPageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b7c3381f273a1d38f5ea8f55cfcb534a25e43a15 --- /dev/null +++ b/tests/acceptance/IndexPageTest.php @@ -0,0 +1,27 @@ +<?php + +namespace App\Tests\acceptance; + +class IndexPageTest extends BasePageTest +{ + public function testUserShoudAccessToCapsuleGroupList(): void + { + $this->clickLink( + 'My groups', + 'The user should access to its group list from index page' + ); + } + + protected function setUp(): void + { + parent::setUp(); + $this->setInitialPage(); + } + + private function setInitialPage(): void + { + $this->givenUser('defaultUser@localhost.com') + ->logged() + ->onPage('en'); + } +} diff --git a/tests/acceptance/UserCapsuleGroupsPageTest.php b/tests/acceptance/UserCapsuleGroupsPageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d56bfc283604752c3a1d05ad781104a86654aacd --- /dev/null +++ b/tests/acceptance/UserCapsuleGroupsPageTest.php @@ -0,0 +1,34 @@ +<?php + +namespace App\Tests\acceptance; + +class UserCapsuleGroupsPageTest extends BasePageTest +{ + public function testUserShouldAccessToCapsuleGroupCreationPage(): void + { + $this->client->clickLink('Create a new group'); + $this->assertResponseIsSuccessful('The user should access capsule group creation'); + } + + public function testUserShouldAccessDeleteGroupPageFromUserCapsuleGroupList(): void + { + $this->clickLink('Delete', 'The user should access to its capsule groups list'); + $this->assertResponseIsSuccessful( + 'The user should be able to delete one group from the user the capsule groups page' + ); + } + + protected function setUp(): void + { + parent::setUp(); + $this->setCapsuleGroupPage(); + } + + private function setCapsuleGroupPage(): void + { + $this->givenUser('defaultUser@localhost.com') + ->logged() + ->onPage('en/my_groups'); + $this->assertResponseIsSuccessful(); + } +} diff --git a/tests/functional/CapsuleGroupControllerTest.php b/tests/functional/CapsuleGroupControllerTest.php index 9ebea5b10547933bad422fac6aac4b5686b9933f..c66655ec89ab01f81d08ea03fd271efef29e7a7a 100644 --- a/tests/functional/CapsuleGroupControllerTest.php +++ b/tests/functional/CapsuleGroupControllerTest.php @@ -24,31 +24,6 @@ class CapsuleGroupControllerTest extends WebTestCase private Group $group_pop_own_by_user_1; private Group $group_rock_own_by_user_1; - protected function setUp(): void - { - self::ensureKernelShutdown(); - - $this->client = static::createClient(); - - $this->object_manager = $this->client->getContainer() - ->get('doctrine') - ->getManager(); - - $this->user_repository = $this->object_manager->getRepository(User::class); - $this->capsule_repository = $this->object_manager->getRepository(Capsule::class); - $this->group_repository = $this->object_manager->getRepository(Group::class); - - $this->setUsers(); - $this->setCapsuleGroupPop(); - $this->setCapsuleGroupRock(); - } - - protected function tearDown(): void - { - parent::tearDown(); - self::ensureKernelShutdown(); - } - public function testUserShouldNotBeAbleToCreateACapsuleGroupWithExistingGroupName(): void { $this->client->loginUser($this->user_1); @@ -85,6 +60,25 @@ class CapsuleGroupControllerTest extends WebTestCase $this->assertTrue($this->client->getResponse()->isRedirect()); } + protected function setUp(): void + { + self::ensureKernelShutdown(); + + $this->client = static::createClient(); + + $this->object_manager = $this->client->getContainer() + ->get('doctrine') + ->getManager(); + + $this->user_repository = $this->object_manager->getRepository(User::class); + $this->capsule_repository = $this->object_manager->getRepository(Capsule::class); + $this->group_repository = $this->object_manager->getRepository(Group::class); + + $this->setUsers(); + $this->setCapsuleGroupPop(); + $this->setCapsuleGroupRock(); + } + private function setUsers(): void { $verified_user_1 = $this->user_repository @@ -127,4 +121,10 @@ class CapsuleGroupControllerTest extends WebTestCase $this->group_rock_own_by_user_1 = $group_rock; } + + protected function tearDown(): void + { + parent::tearDown(); + self::ensureKernelShutdown(); + } }