Show dedicated icons for previewable Microsoft Office attachments (#8959).

git-svn-id: https://svn.redmine.org/redmine/trunk@24587 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2026-04-16 11:46:09 +00:00
parent 906fc2dadf
commit 24733d885f
4 changed files with 48 additions and 0 deletions

View File

@@ -221,6 +221,32 @@
<path d="M11 16m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"/>
<path d="M12 16l0 -5l2 1"/>
</symbol>
<symbol viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" id="icon--file-type-docx">
<path d="M14 3v4a1 1 0 0 0 1 1h4"/>
<path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"/>
<path d="M2 15v6h1a2 2 0 0 0 2 -2v-2a2 2 0 0 0 -2 -2h-1z"/>
<path d="M17 16.5a1.5 1.5 0 0 0 -3 0v3a1.5 1.5 0 0 0 3 0"/>
<path d="M9.5 15a1.5 1.5 0 0 1 1.5 1.5v3a1.5 1.5 0 0 1 -3 0v-3a1.5 1.5 0 0 1 1.5 -1.5z"/>
<path d="M19.5 15l3 6"/>
<path d="M19.5 21l3 -6"/>
</symbol>
<symbol viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" id="icon--file-type-ppt">
<path d="M14 3v4a1 1 0 0 0 1 1h4"/>
<path d="M14 3v4a1 1 0 0 0 1 1h4"/>
<path d="M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"/>
<path d="M11 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"/>
<path d="M16.5 15h3"/>
<path d="M18 15v6"/>
<path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"/>
</symbol>
<symbol viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" id="icon--file-type-xls">
<path d="M14 3v4a1 1 0 0 0 1 1h4"/>
<path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"/>
<path d="M4 15l4 6"/>
<path d="M4 21l4 -6"/>
<path d="M17 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"/>
<path d="M11 15v6h3"/>
</symbol>
<symbol viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" id="icon--folder">
<path d="M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2"/>
</symbol>

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -139,6 +139,16 @@ module IconsHelper
when 'text'
%w(markdown plain x-textile).include?(subtype) ? 'text-plain' : nil
when 'video' then 'movie'
else
# MIME type mapping
{
# Microsoft Office Open XML documents
# Do not add legacy Office formats (.doc, .xls, .ppt) here because
# Redmine does not provide attachment preview for these formats.
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'file-type-ppt',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'file-type-xls',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'file-type-docx'
}[mime.to_s]
end
end
icon_name || 'file'

View File

@@ -250,3 +250,9 @@
svg: movie
- name: file-music
svg: file-music
- name: file-type-docx
svg: file-type-docx
- name: file-type-xls
svg: file-type-xls
- name: file-type-ppt
svg: file-type-ppt

View File

@@ -225,6 +225,12 @@ class IconsHelperTest < Redmine::HelperTest
assert_equal 'application-pdf', icon_for_mime_type('application/pdf')
assert_equal 'text-plain', icon_for_mime_type('text/markdown')
assert_equal 'text-plain', icon_for_mime_type('text/plain')
assert_equal 'file-type-docx',
icon_for_mime_type('application/vnd.openxmlformats-officedocument.wordprocessingml.document')
assert_equal 'file-type-xls',
icon_for_mime_type('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
assert_equal 'file-type-ppt',
icon_for_mime_type('application/vnd.openxmlformats-officedocument.presentationml.presentation')
end
def test_icon_for_mime_type_should_return_icon_for_top_level_types