Skip to content

[5.2] Improve UX for template buttons - replace PR #43592 #3252

@jgerman-bot

Description

@jgerman-bot

New language relevant PR in upstream repo: joomla/joomla-cms#43975 Here are the upstream changes:

Click to expand the diff!
diff --git a/administrator/components/com_templates/src/View/Template/HtmlView.php b/administrator/components/com_templates/src/View/Template/HtmlView.php
index 330972012e8f2..63298e6630fa7 100644
--- a/administrator/components/com_templates/src/View/Template/HtmlView.php
+++ b/administrator/components/com_templates/src/View/Template/HtmlView.php
@@ -236,39 +236,9 @@ protected function addToolbar()
 
         // User is global SuperUser
         $isSuperUser  = $user->authorise('core.admin');
-        $explodeArray = explode('.', $this->fileName);
-        $ext          = end($explodeArray);
 
         ToolbarHelper::title(Text::sprintf('COM_TEMPLATES_MANAGER_VIEW_TEMPLATE', ucfirst($this->template->name)), 'icon-code thememanager');
 
-        // Only show file edit buttons for global SuperUser
-        if ($isSuperUser) {
-            // Add an Apply and save button
-            if ($this->type === 'file') {
-                $toolbar->apply('template.apply');
-                $toolbar->save('template.save');
-            } elseif ($this->type === 'image') {
-                // Add a Crop and Resize button
-                $toolbar->standardButton('crop', 'COM_TEMPLATES_BUTTON_CROP', 'template.cropImage')
-                    ->listCheck(false)
-                    ->icon('icon-crop');
-                ToolbarHelper::modal('resizeModal', 'icon-expand', 'COM_TEMPLATES_BUTTON_RESIZE');
-            } elseif ($this->type === 'archive') {
-                // Add an extract button
-                $toolbar->standardButton('extract', 'COM_TEMPLATES_BUTTON_EXTRACT_ARCHIVE', 'template.extractArchive')
-                    ->listCheck(false)
-                    ->icon('icon-chevron-down');
-            } elseif ($this->type === 'home') {
-                // Add a copy/child template button
-                if (isset($this->template->xmldata->inheritable) && (string) $this->template->xmldata->inheritable === '1') {
-                    ToolbarHelper::modal('childModal', 'icon-copy', 'COM_TEMPLATES_BUTTON_TEMPLATE_CHILD');
-                } elseif (empty($this->template->xmldata->parent) && empty($this->template->xmldata->namespace)) {
-                    // We can't copy parent templates nor namespaced templates
-                    ToolbarHelper::modal('copyModal', 'icon-copy', 'COM_TEMPLATES_BUTTON_COPY_TEMPLATE');
-                }
-            }
-        }
-
         // Add a Template preview button
         if ($this->type === 'home') {
             $client = (int) $this->preview->client_id === 1 ? 'administrator/' : '';
@@ -278,6 +248,44 @@ protected function addToolbar()
                 ->attributes(['target' => '_new']);
         }
 
+        // Only show file edit buttons for global SuperUser
+        if ($isSuperUser) {
+            switch ($this->type) {
+                case 'file':
+                    $toolbar->apply('template.apply');
+                    $toolbar->save('template.save');
+                    $toolbar->cancel('template.close', 'COM_TEMPLATES_BUTTON_CLOSE_FILE');
+                    break;
+
+                case 'image':
+                    // Add a Crop and Resize button
+                    $toolbar->standardButton('crop', 'COM_TEMPLATES_BUTTON_CROP', 'template.cropImage')
+                        ->listCheck(false)
+                        ->icon('icon-crop');
+                    ToolbarHelper::modal('resizeModal', 'icon-expand', 'COM_TEMPLATES_BUTTON_RESIZE');
+                    $toolbar->cancel('template.close', 'COM_TEMPLATES_BUTTON_CLOSE_FILE');
+                    break;
+
+                case 'archive':
+                    // Add an extract button
+                    $toolbar->standardButton('extract', 'COM_TEMPLATES_BUTTON_EXTRACT_ARCHIVE', 'template.extractArchive')
+                        ->listCheck(false)
+                        ->icon('icon-chevron-down');
+                    break;
+
+                case 'home':
+                    // Add a copy/child template button
+                    if (isset($this->template->xmldata->inheritable) && (string) $this->template->xmldata->inheritable === '1') {
+                        ToolbarHelper::modal('childModal', 'icon-copy', 'COM_TEMPLATES_BUTTON_TEMPLATE_CHILD');
+                    } elseif (empty($this->template->xmldata->parent) && empty($this->template->xmldata->namespace)) {
+                        // We can't copy parent templates nor namespaced templates
+                        ToolbarHelper::modal('copyModal', 'icon-copy', 'COM_TEMPLATES_BUTTON_COPY_TEMPLATE');
+                    }
+
+                    break;
+            }
+        }
+
         // Only show file manage buttons for global SuperUser
         if ($isSuperUser) {
             if ($this->type === 'home') {
@@ -291,7 +299,7 @@ protected function addToolbar()
                 ToolbarHelper::modal('renameModal', 'icon-sync', 'COM_TEMPLATES_BUTTON_RENAME_FILE');
 
                 // Add a Delete file Button
-                ToolbarHelper::modal('deleteModal', 'icon-times', 'COM_TEMPLATES_BUTTON_DELETE_FILE', 'btn-danger');
+                ToolbarHelper::modal('deleteModal', 'icon-trash', 'COM_TEMPLATES_BUTTON_DELETE_FILE', 'btn-danger');
             }
         }
 
@@ -320,10 +328,8 @@ protected function addToolbar()
                 ->listCheck(true);
         }
 
-        if ($this->type === 'home') {
+        if (!\in_array($this->type, ['image', 'file'])) {
             $toolbar->cancel('template.cancel');
-        } else {
-            $toolbar->cancel('template.close', 'COM_TEMPLATES_BUTTON_CLOSE_FILE');
         }
 
         $toolbar->divider();
diff --git a/administrator/language/en-GB/com_templates.ini b/administrator/language/en-GB/com_templates.ini
index 8113e34f3106c..f6317ff857ebc 100644
--- a/administrator/language/en-GB/com_templates.ini
+++ b/administrator/language/en-GB/com_templates.ini
@@ -9,7 +9,7 @@ COM_TEMPLATES_ASSIGNED_1="Assigned to one menu item."
 COM_TEMPLATES_ASSIGNED_MORE="Assigned to %d menu items."
 COM_TEMPLATES_BUTTON_CHECK="Check Overrides"
 COM_TEMPLATES_BUTTON_CHECK_LIST_ENTRY="Mark Checked"
-COM_TEMPLATES_BUTTON_CLOSE_FILE="Close File"
+COM_TEMPLATES_BUTTON_CLOSE_FILE="Close"
 COM_TEMPLATES_BUTTON_COPY_FILE="Copy File"
 COM_TEMPLATES_BUTTON_COPY_TEMPLATE="Copy Template"
 COM_TEMPLATES_BUTTON_CREATE="Create"

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions