Browse Source

Fixes #5310 - Icons are not up to date.

Co-authored-by: Mantas Masalskis <mm@zammad.com>


(cherry picked from commit 006fc5c81811e33300525fa8700fb4d336e63feb)

dcafe124 Fixes #5310 - Icons are not up to date.
ed71ab6c wip
25e3a13f remove code
5c7263f4 change more
c0e7eea7 change url
03aa0b62 readd comment
3091b536 add application helper
1a9d50ee remove obsolete code
ed400287 add icons url to kb
c8ec305e improve icons url selector
7fe6f14f queryElement -> documentElement
94bbe9c9 (un)check is now a single action
443bc214 fix html utils test
5f9a82f4 remove util var
5150f2a2 Revert "(un)check is now a single action"
1d0be7c1 fix icon
085b2e0c changing to @Icon in some strange copy-pastas
3bf91cc7 one more capypaste cleaned up
9bb0b36c fix urls
5a7f9798 add request cache for icons url

Co-authored-by: Rolf Schmidt <rolf.schmidt@zammad.com>
Rolf Schmidt 5 months ago
parent
commit
13e4f810d5

+ 1 - 1
app/assets/javascripts/app/controllers/_ui_element/object_manager_attribute.coffee

@@ -964,7 +964,7 @@ class App.UiElement.object_manager_attribute extends App.UiElement.ApplicationUi
 
                 link = App.Utils.replaceTags(params.data_option?.linktemplate, objects)
 
-                resultLinkIcon = $('<svg class="icon icon-external"><use xlink:href="assets/images/icons.svg#icon-external" /></svg>')
+                resultLinkIcon = $(App.Utils.icon('external'))
                 resultLinkAnchor = $('<a />')
                   .addClass('settings-list-control')
                   .attr('href', link)

+ 1 - 1
app/assets/javascripts/app/lib/app_post/utils.coffee

@@ -1187,7 +1187,7 @@ class App.Utils
     # search: <svg class="icon icon-([^\s]+)\s([^"]*).*<\/svg>
     # replace: <%- @Icon('$1', '$2') %>
     #
-    path = if window.svgPolyfill then '' else 'assets/images/icons.svg'
+    path = if window.svgPolyfill then '' else App.Config.get('icons_url')
     "<svg class=\"icon icon-#{name} #{className}\"><use xlink:href=\"#{path}#icon-#{name}\" /></svg>"
 
   @fontIcon: (name, font, className = '') ->

+ 2 - 2
app/assets/javascripts/app/views/knowledge_base/public_menu_form_item_row.jst.eco

@@ -7,8 +7,8 @@
   <td class="settings-list-control-cell settings-list-checkbox-cell">
     <label class="inline-label checkbox-replacement js-new-tab">
       <input type="checkbox" value="1" data-name="new_tab" <% if @item?.new_tab: %>checked<% end %>>
-      <svg class="icon icon-checkbox icon-unchecked"><use xlink:href="assets/images/icons.svg#icon-checkbox"></use></svg>
-      <svg class="icon icon-checkbox-checked icon-checked"><use xlink:href="assets/images/icons.svg#icon-checkbox-checked"></use></svg>
+      <%- @Icon('checkbox', 'icon-unchecked') %>
+      <%- @Icon('checkbox-checked', 'icon-checked') %>
       <span class="label-text"><%- @T('New tab') %></span>
     </label>
 

+ 1 - 3
app/assets/javascripts/app/views/ticket_zoom.jst.eco

@@ -2,9 +2,7 @@
   <div class="scrollPageHeader tabsSidebar-sidebarSpacer" style="<%- if @dir is 'rtl' then 'left' else 'right' %>: <%- @scrollbarWidth %>px">
     <small class="ticket-number-copy-header">
       <%- @C('ticket_hook') %><span class="ticket-number"><%- @ticket.number %></span>
-      <svg class="icon icon-clipboard ticketNumberCopy-icon u-clickable">
-        <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="assets/images/icons.svg#icon-clipboard"></use>
-      </svg>
+      <%- @Icon('clipboard', 'ticketNumberCopy-icon u-clickable') %>
     </small>
     <div class="js-ticketTitleContainer ticket-title"></div>
     <div class="js-highlighterContainer highlighter"></div>

+ 2 - 2
app/assets/javascripts/knowledge_base_public/language.js

@@ -9,7 +9,7 @@
     }
 
     this.kbPath = function() {
-      var html = document.querySelector('html')
+      var html = document.documentElement
       return html.dataset.basePath.replace(encodeURIComponent('{locale}'), targetLanguage)
     }
 
@@ -49,7 +49,7 @@
 
   function LanguageDetector() { }
 
-  LanguageDetector.html = function() { return document.querySelector('html') }
+  LanguageDetector.html = function() { return document.documentElement }
 
   LanguageDetector.document_languages = function() {
     return this.html().dataset.availableLocales.split(',')

+ 3 - 3
app/assets/javascripts/knowledge_base_public/search.js

@@ -19,8 +19,8 @@
 
   KnowledgeBaseSearch.lookupAction = function(query) {
     var params = {
-      knowledge_base_id: document.querySelector('html').dataset.id,
-      locale: document.querySelector('html').lang,
+      knowledge_base_id: document.documentElement.dataset.id,
+      locale: document.documentElement.lang,
       query: query,
       flavor: 'public'
     }
@@ -106,7 +106,7 @@
     this.generateIcon = function(iconName, type) {
       switch(type) {
         case 'KnowledgeBase::Category::Translation':
-          iconset = document.querySelector('html').dataset.iconset
+          iconset = document.documentElement.dataset.iconset
           return Zammad.Util.generateIcon(iconName, iconset)
         default:
           return Zammad.Util.generateIcon(iconName)

+ 1 - 1
app/assets/javascripts/knowledge_base_public/util.js

@@ -3,7 +3,7 @@
 
   Util.generateIcon = function(iconName, iconset) {
     if(!iconset) {
-      return '<svg class="icon icon-' + iconName + '"><use xlink:href="/assets/images/icons.svg#icon-' + iconName + '"></use></svg>'
+      return '<svg class="icon icon-' + iconName + '"><use xlink:href="/' + document.documentElement.dataset.iconsUrl + '#icon-' + iconName + '"></use></svg>'
     }
 
     return '<i data-font="' + iconset + '">&#x' + iconName + '</i>'

+ 1 - 0
app/controllers/application_controller.rb

@@ -15,4 +15,5 @@ class ApplicationController < ActionController::Base
   include ApplicationController::LogsHttpAccess
   include ApplicationController::Authorizes
   include ApplicationController::Klass
+  include ApplicationHelper
 end

+ 1 - 0
app/controllers/sessions_controller.rb

@@ -326,6 +326,7 @@ class SessionsController < ApplicationController
     end
 
     config['core_workflow_config'] = CoreWorkflow.config
+    config['icons_url']            = icons_url
 
     config
   end

+ 9 - 0
app/helpers/application_helper.rb

@@ -0,0 +1,9 @@
+# Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
+
+module ApplicationHelper
+  def icons_url
+    Auth::RequestCache.fetch_value('icons_url') do
+      "assets/images/icons.svg?#{Rails.public_path.join('assets/images/icons.svg').mtime.to_i}"
+    end
+  end
+end

Some files were not shown because too many files changed in this diff