From 2f07992e5508b34b91f194eebfac80c51e80e90a Mon Sep 17 00:00:00 2001
From: Yassine Doghri <yassine@doghri.fr>
Date: Tue, 6 Oct 2020 17:20:23 +0000
Subject: [PATCH] feat: display legal disclaimer and warning on podcast import
 page

updated podcast import translations

closes #34
---
 app/Helpers/form_helper.php        | 12 ++++++++++--
 app/Language/en/PodcastImport.php  | 15 +++++----------
 app/Views/_assets/icons/alert.svg  |  6 ++++++
 app/Views/_assets/icons/scales.svg |  6 ++++++
 app/Views/admin/podcast/import.php | 16 +++++++++++-----
 5 files changed, 38 insertions(+), 17 deletions(-)
 create mode 100644 app/Views/_assets/icons/alert.svg
 create mode 100644 app/Views/_assets/icons/scales.svg

diff --git a/app/Helpers/form_helper.php b/app/Helpers/form_helper.php
index 5be15eecfa..8e193cfbe2 100644
--- a/app/Helpers/form_helper.php
+++ b/app/Helpers/form_helper.php
@@ -21,8 +21,14 @@ if (!function_exists('form_section')) {
     function form_section(
         string $title = '',
         string $subtitle = '',
-        array $attributes = []
+        array $attributes = [],
+        string $customSubtitleClass = ''
     ): string {
+        $subtitleClass = 'text-sm text-gray-600';
+        if ($customSubtitleClass !== '') {
+            $subtitleClass = $customSubtitleClass;
+        }
+
         $section =
             '<div class="flex flex-wrap w-full gap-6 mb-8"' .
             stringify_attributes($attributes) .
@@ -31,7 +37,9 @@ if (!function_exists('form_section')) {
         $info =
             '<div class="w-full max-w-xs"><h2 class="text-lg font-semibold">' .
             $title .
-            '</h2><p class="text-sm text-gray-600">' .
+            '</h2><p class="' .
+            $subtitleClass .
+            '">' .
             $subtitle .
             '</p></div>';
 
diff --git a/app/Language/en/PodcastImport.php b/app/Language/en/PodcastImport.php
index 3bb3a912c2..ddd762b25e 100644
--- a/app/Language/en/PodcastImport.php
+++ b/app/Language/en/PodcastImport.php
@@ -7,19 +7,14 @@
  */
 
 return [
-    'legal_dislaimer_title' => 'Legal Disclaimer',
-    'legal_dislaimer_content' =>
-        'Make sure you own the rights for this podcast before importing it.<br/>Copying and broadcasting a podcast without the proper rights is piracy and is liable to prosecution.',
-    'warning_title' => 'Warning',
-    'warning_content' =>
-        'This procedure may take a long time.<br/>The current version does not show any progress while it runs. You will not see anything updated until it is done.<br/>In case of timeout error, increase max_execution_time value.',
+    'warning' =>
+        'This procedure may take a long time.<br/>As the current version does not show any progress while it runs, you will not see anything updated until it is done.<br/>In case of timeout error, increase `max_execution_time` value.',
     'old_podcast_section_title' => 'The podcast to import',
-    'old_podcast_section_subtitle' => '',
+    'old_podcast_section_subtitle' =>
+        'Make sure you own the rights for this podcast before importing it. Copying and broadcasting a podcast without the proper rights is piracy and is liable to prosecution.',
     'imported_feed_url' => 'Feed URL',
-    'imported_feed_url_hint' =>
-        'The feed must be in `.xml` format. Make sure you are legally allowed to copy the podcast.',
+    'imported_feed_url_hint' => 'The feed must be in `.xml` format.',
     'new_podcast_section_title' => 'The new podcast',
-    'new_podcast_section_subtitle' => '',
     'name' => 'Name',
     'name_hint' => 'Used for generating the podcast URL.',
     'advanced_params_section_title' => 'Advanced parameters',
diff --git a/app/Views/_assets/icons/alert.svg b/app/Views/_assets/icons/alert.svg
new file mode 100644
index 0000000000..02da88f90b
--- /dev/null
+++ b/app/Views/_assets/icons/alert.svg
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
+    <g>
+        <path fill="none" d="M0 0h24v24H0z"/>
+        <path fill-rule="nonzero" d="M12.866 3l9.526 16.5a1 1 0 0 1-.866 1.5H2.474a1 1 0 0 1-.866-1.5L11.134 3a1 1 0 0 1 1.732 0zm-8.66 16h15.588L12 5.5 4.206 19zM11 16h2v2h-2v-2zm0-7h2v5h-2V9z"/>
+    </g>
+</svg>
diff --git a/app/Views/_assets/icons/scales.svg b/app/Views/_assets/icons/scales.svg
new file mode 100644
index 0000000000..2592d2ca59
--- /dev/null
+++ b/app/Views/_assets/icons/scales.svg
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
+    <g>
+        <path fill="none" d="M0 0H24V24H0z"/>
+        <path d="M13 2v1.278l5 1.668 3.632-1.21.633 1.896-3.032 1.011 3.096 8.512C21.237 16.292 19.7 17 18 17c-1.701 0-3.237-.708-4.329-1.845l3.094-8.512L13 5.387V19H17v2H7v-2h4V5.387L7.232 6.643l3.096 8.512C9.237 16.292 7.7 17 6 17c-1.701 0-3.237-.708-4.329-1.845l3.094-8.512-3.03-1.01.633-1.898L6 4.945l5-1.667V2h2zm5 7.103l-1.958 5.386c.587.331 1.257.511 1.958.511.7 0 1.37-.18 1.958-.51L18 9.102zm-12 0l-1.958 5.386C4.629 14.82 5.299 15 6 15c.7 0 1.37-.18 1.958-.51L6 9.102z"/>
+    </g>
+</svg>
diff --git a/app/Views/admin/podcast/import.php b/app/Views/admin/podcast/import.php
index 6ec7ac586c..4d4f1f1386 100644
--- a/app/Views/admin/podcast/import.php
+++ b/app/Views/admin/podcast/import.php
@@ -16,9 +16,13 @@
 ]) ?>
 <?= csrf_field() ?>
 
+
 <?= form_section(
     lang('PodcastImport.old_podcast_section_title'),
-    lang('PodcastImport.old_podcast_section_subtitle')
+    icon('scales', 'mr-2 text-lg flex-shrink-0') .
+        lang('PodcastImport.old_podcast_section_subtitle'),
+    [],
+    'inline-flex text-xs p-2 text-teal-800 font-semibold bg-teal-100 border border-teal-300 rounded'
 ) ?>
 
 <?= form_label(
@@ -40,10 +44,7 @@
 <?= form_section_close() ?>
 
 
-<?= form_section(
-    lang('PodcastImport.new_podcast_section_title'),
-    lang('PodcastImport.new_podcast_section_subtitle')
-) ?>
+<?= form_section(lang('PodcastImport.new_podcast_section_title'), '') ?>
 
 <?= form_label(
     lang('PodcastImport.name'),
@@ -206,6 +207,11 @@
 
 <?= form_section_close() ?>
 
+<div class="inline-flex w-full p-2 mb-4 text-sm font-semibold text-yellow-800 bg-orange-100 border border-orange-300 rounded" role="alert">
+  <?= icon('alert', 'mr-2 text-lg flex-shrink-0') .
+      lang('PodcastImport.warning') ?>
+</div>
+
 <?= button(
     lang('PodcastImport.submit'),
     null,
-- 
GitLab