From 68ecad1c0930e1f94c54ccf7ede68fd75f5db669 Mon Sep 17 00:00:00 2001 From: Camille Simiand <camille.simiand@tetras-libre.fr> Date: Mon, 24 Jan 2022 14:42:35 +0100 Subject: [PATCH] Fix flash message types --- src/Controller/CapsuleController.php | 10 ++++----- src/Controller/ProjectController.php | 6 +++--- templates/capsule/index.html.twig | 31 +--------------------------- translations/messages.en.yaml | 2 +- 4 files changed, 10 insertions(+), 39 deletions(-) diff --git a/src/Controller/CapsuleController.php b/src/Controller/CapsuleController.php index 26b28d3..b169c9f 100644 --- a/src/Controller/CapsuleController.php +++ b/src/Controller/CapsuleController.php @@ -159,7 +159,7 @@ class CapsuleController extends AbstractController if (! $do_capsule_belongs_to_user) { $this->addFlash( - 'capsule_deleted_error', + 'warning', $translator->trans( 'capsule.delete.error', [ @@ -176,7 +176,7 @@ class CapsuleController extends AbstractController $entityManager->flush(); $this->addFlash( - 'capsule_deleted_success', + 'success', $translator->trans( 'capsule.delete.success', [ @@ -222,9 +222,9 @@ class CapsuleController extends AbstractController if (! $capsule_repository->doCapsuleBelongsToUser($parent_capsule, $current_user)) { $this->addFlash( - 'capsule_deleted_error', + 'warning', $translator->trans( - 'capsule.delete.error', + 'capsule.duplicate.error', [ 'capsule_name' => $parent_capsule->getName() ] @@ -238,7 +238,7 @@ class CapsuleController extends AbstractController $parent_directory_exists = $file_system->exists('../legacy/' . $parent_directory_name); if (! $parent_directory_exists) { $this->addFlash( - 'project_does_not_exist', + 'warning', $translator->trans( 'project.not_exist', [ diff --git a/src/Controller/ProjectController.php b/src/Controller/ProjectController.php index e335abe..6fded99 100644 --- a/src/Controller/ProjectController.php +++ b/src/Controller/ProjectController.php @@ -51,7 +51,7 @@ class ProjectController extends AbstractController $this->createOrUpdatePasswordFile($capsule_directory, $capsule->getPassword()); $this->addFlash( - 'capsule_created_success', + 'success', $translator->trans( 'capsule.created_success', [ @@ -80,7 +80,7 @@ class ProjectController extends AbstractController if (file_exists($capsule_directory)) { $this->addFlash( - 'project_already_exists', + 'warning', $translator->trans( 'project.already_exists', [ @@ -97,7 +97,7 @@ class ProjectController extends AbstractController $this->createOrUpdatePasswordFile($capsule_directory, $capsule->getPassword()); $this->addFlash( - 'capsule_duplicated_success', + 'success', $translator->trans( 'capsule.duplicate.success', [ diff --git a/templates/capsule/index.html.twig b/templates/capsule/index.html.twig index acbe4ed..c18fa5a 100644 --- a/templates/capsule/index.html.twig +++ b/templates/capsule/index.html.twig @@ -29,41 +29,12 @@ </div> {% endfor %} - {% for flashSuccess in app.flashes('capsule_created_success') %} + {% for flashSuccess in app.flashes('success') %} <div class="text-center alert alert-success col-5 mx-auto my-5" role="alert"> {{ flashSuccess }} </div> {% endfor %} - {% for flashSuccess in app.flashes('capsule_deleted_success') %} - <div class="text-center alert alert-success col-5 mx-auto my-5" role="alert"> - {{ flashSuccess }} - </div> - {% endfor %} - - {% for flashSuccess in app.flashes('capsule_deleted_error') %} - <div class="text-center alert alert-warning col-5 mx-auto my-5" role="alert"> - {{ flashSuccess }} - </div> - {% endfor %} - - {% for flashWarning in app.flashes('project_does_not_exist') %} - <div class="text-center alert alert-warning col-5 mx-auto my-5" role="alert"> - {{ flashWarning }} - </div> - {% endfor %} - - {% for flashSuccess in app.flashes('capsule_duplicated_success') %} - <div class="text-center alert alert-success col-5 mx-auto my-5" role="alert"> - {{ flashSuccess }} - </div> - {% endfor %} - - {% for flashSuccess in app.flashes('capsule_duplicated_error') %} - <div class="text-center alert alert-warning> col-5 mx-auto my-5" role="alert"> - {{ flashSuccess }} - </div> - {% endfor %} </div> <div class="capsules-list d-flex flex-column m-6"> diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index eec934e..b6e3029 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -75,7 +75,7 @@ capsule: title_name: Duplicate capsule %capsule_name% new_name: Enter the name of the new capsule success: The capsule has been successfully duplicated into capsule_name. You can see it at the end of your list - error: You don't have the permission to delete this capsule + error: You don't have the permission to duplicate this capsule delete: link: Delete capsule button: Delete -- GitLab