Commit 02c62d89 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '246739-use-gitlab-svg-icons-in-file_type_icon_class-helper' into 'master'

Use GitLab SVG icons in file_type_icon_class helper

See merge request gitlab-org/gitlab!44580
parents 22296e67 1769d3c9
...@@ -148,7 +148,7 @@ module BlobHelper ...@@ -148,7 +148,7 @@ module BlobHelper
# mode - File unix mode # mode - File unix mode
# mode - File name # mode - File name
def blob_icon(mode, name) def blob_icon(mode, name)
icon("#{file_type_icon_class('file', mode, name)} fw") sprite_icon(file_type_icon_class('file', mode, name))
end end
def blob_raw_url(**kwargs) def blob_raw_url(**kwargs)
......
...@@ -124,7 +124,7 @@ module IconsHelper ...@@ -124,7 +124,7 @@ module IconsHelper
def file_type_icon_class(type, mode, name) def file_type_icon_class(type, mode, name)
if type == 'folder' if type == 'folder'
icon_class = 'folder' icon_class = 'folder-o'
elsif type == 'archive' elsif type == 'archive'
icon_class = 'archive' icon_class = 'archive'
elsif mode == '120000' elsif mode == '120000'
...@@ -135,36 +135,36 @@ module IconsHelper ...@@ -135,36 +135,36 @@ module IconsHelper
case File.extname(name).downcase case File.extname(name).downcase
when '.pdf' when '.pdf'
icon_class = 'file-pdf-o' icon_class = 'document'
when '.jpg', '.jpeg', '.jif', '.jfif', when '.jpg', '.jpeg', '.jif', '.jfif',
'.jp2', '.jpx', '.j2k', '.j2c', '.jp2', '.jpx', '.j2k', '.j2c',
'.apng', '.png', '.gif', '.tif', '.tiff', '.apng', '.png', '.gif', '.tif', '.tiff',
'.svg', '.ico', '.bmp', '.webp' '.svg', '.ico', '.bmp', '.webp'
icon_class = 'file-image-o' icon_class = 'doc-image'
when '.zip', '.zipx', '.tar', '.gz', '.gzip', '.tgz', '.bz', '.bzip', when '.zip', '.zipx', '.tar', '.gz', '.gzip', '.tgz', '.bz', '.bzip',
'.bz2', '.bzip2', '.car', '.tbz', '.xz', 'txz', '.rar', '.7z', '.bz2', '.bzip2', '.car', '.tbz', '.xz', 'txz', '.rar', '.7z',
'.lz', '.lzma', '.tlz' '.lz', '.lzma', '.tlz'
icon_class = 'file-archive-o' icon_class = 'doc-compressed'
when '.mp3', '.wma', '.ogg', '.oga', '.wav', '.flac', '.aac', '.3ga', when '.mp3', '.wma', '.ogg', '.oga', '.wav', '.flac', '.aac', '.3ga',
'.ac3', '.midi', '.m4a', '.ape', '.mpa' '.ac3', '.midi', '.m4a', '.ape', '.mpa'
icon_class = 'file-audio-o' icon_class = 'volume-up'
when '.mp4', '.m4p', '.m4v', when '.mp4', '.m4p', '.m4v',
'.mpg', '.mp2', '.mpeg', '.mpe', '.mpv', '.mpg', '.mp2', '.mpeg', '.mpe', '.mpv',
'.mpg', '.mpeg', '.m2v', '.m2ts', '.mpg', '.mpeg', '.m2v', '.m2ts',
'.avi', '.mkv', '.flv', '.ogv', '.mov', '.avi', '.mkv', '.flv', '.ogv', '.mov',
'.3gp', '.3g2' '.3gp', '.3g2'
icon_class = 'file-video-o' icon_class = 'live-preview'
when '.doc', '.dot', '.docx', '.docm', '.dotx', '.dotm', '.docb', when '.doc', '.dot', '.docx', '.docm', '.dotx', '.dotm', '.docb',
'.odt', '.ott', '.uot', '.rtf' '.odt', '.ott', '.uot', '.rtf'
icon_class = 'file-word-o' icon_class = 'doc-text'
when '.xls', '.xlt', '.xlm', '.xlsx', '.xlsm', '.xltx', '.xltm', when '.xls', '.xlt', '.xlm', '.xlsx', '.xlsm', '.xltx', '.xltm',
'.xlsb', '.xla', '.xlam', '.xll', '.xlw', '.ots', '.ods', '.uos' '.xlsb', '.xla', '.xlam', '.xll', '.xlw', '.ots', '.ods', '.uos'
icon_class = 'file-excel-o' icon_class = 'document'
when '.ppt', '.pot', '.pps', '.pptx', '.pptm', '.potx', '.potm', when '.ppt', '.pot', '.pps', '.pptx', '.pptm', '.potx', '.potm',
'.ppam', '.ppsx', '.ppsm', '.sldx', '.sldm', '.odp', '.otp', '.uop' '.ppam', '.ppsx', '.ppsm', '.sldx', '.sldm', '.odp', '.otp', '.uop'
icon_class = 'file-powerpoint-o' icon_class = 'doc-chart'
else else
icon_class = 'file-text-o' icon_class = 'doc-text'
end end
end end
......
...@@ -31,7 +31,7 @@ module TreeHelper ...@@ -31,7 +31,7 @@ module TreeHelper
# mode - File unix mode # mode - File unix mode
# name - File name # name - File name
def tree_icon(type, mode, name) def tree_icon(type, mode, name)
icon([file_type_icon_class(type, mode, name), 'fw']) sprite_icon(file_type_icon_class(type, mode, name))
end end
# Using Rails `*_path` methods can be slow, especially when generating # Using Rails `*_path` methods can be slow, especially when generating
......
---
title: Use GitLab SVG icons in file_type_icon_class helper
merge_request: 44580
author:
type: changed
...@@ -156,7 +156,7 @@ RSpec.describe Projects::MergeRequests::ConflictsController do ...@@ -156,7 +156,7 @@ RSpec.describe Projects::MergeRequests::ConflictsController do
expect(json_response).to include('old_path' => path, expect(json_response).to include('old_path' => path,
'new_path' => path, 'new_path' => path,
'blob_icon' => 'file-text-o', 'blob_icon' => 'doc-text',
'blob_path' => a_string_ending_with(path), 'blob_path' => a_string_ending_with(path),
'content' => content) 'content' => content)
end end
......
...@@ -114,128 +114,128 @@ RSpec.describe IconsHelper do ...@@ -114,128 +114,128 @@ RSpec.describe IconsHelper do
end end
describe 'file_type_icon_class' do describe 'file_type_icon_class' do
it 'returns folder class' do it 'returns folder-o class' do
expect(file_type_icon_class('folder', 0, 'folder_name')).to eq 'folder' expect(file_type_icon_class('folder', 0, 'folder_name')).to eq 'folder-o'
end end
it 'returns share class' do it 'returns share class' do
expect(file_type_icon_class('file', '120000', 'link')).to eq 'share' expect(file_type_icon_class('file', '120000', 'link')).to eq 'share'
end end
it 'returns file-pdf-o class with .pdf' do it 'returns document class with .pdf' do
expect(file_type_icon_class('file', 0, 'filename.pdf')).to eq 'file-pdf-o' expect(file_type_icon_class('file', 0, 'filename.pdf')).to eq 'document'
end end
it 'returns file-image-o class with .jpg' do it 'returns doc-image class with .jpg' do
expect(file_type_icon_class('file', 0, 'filename.jpg')).to eq 'file-image-o' expect(file_type_icon_class('file', 0, 'filename.jpg')).to eq 'doc-image'
end end
it 'returns file-image-o class with .JPG' do it 'returns doc-image class with .JPG' do
expect(file_type_icon_class('file', 0, 'filename.JPG')).to eq 'file-image-o' expect(file_type_icon_class('file', 0, 'filename.JPG')).to eq 'doc-image'
end end
it 'returns file-image-o class with .png' do it 'returns doc-image class with .png' do
expect(file_type_icon_class('file', 0, 'filename.png')).to eq 'file-image-o' expect(file_type_icon_class('file', 0, 'filename.png')).to eq 'doc-image'
end end
it 'returns file-image-o class with .apng' do it 'returns doc-image class with .apng' do
expect(file_type_icon_class('file', 0, 'filename.apng')).to eq 'file-image-o' expect(file_type_icon_class('file', 0, 'filename.apng')).to eq 'doc-image'
end end
it 'returns file-image-o class with .webp' do it 'returns doc-image class with .webp' do
expect(file_type_icon_class('file', 0, 'filename.webp')).to eq 'file-image-o' expect(file_type_icon_class('file', 0, 'filename.webp')).to eq 'doc-image'
end end
it 'returns file-archive-o class with .tar' do it 'returns doc-compressed class with .tar' do
expect(file_type_icon_class('file', 0, 'filename.tar')).to eq 'file-archive-o' expect(file_type_icon_class('file', 0, 'filename.tar')).to eq 'doc-compressed'
end end
it 'returns file-archive-o class with .TAR' do it 'returns doc-compressed class with .TAR' do
expect(file_type_icon_class('file', 0, 'filename.TAR')).to eq 'file-archive-o' expect(file_type_icon_class('file', 0, 'filename.TAR')).to eq 'doc-compressed'
end end
it 'returns file-archive-o class with .tar.gz' do it 'returns doc-compressed class with .tar.gz' do
expect(file_type_icon_class('file', 0, 'filename.tar.gz')).to eq 'file-archive-o' expect(file_type_icon_class('file', 0, 'filename.tar.gz')).to eq 'doc-compressed'
end end
it 'returns file-audio-o class with .mp3' do it 'returns volume-up class with .mp3' do
expect(file_type_icon_class('file', 0, 'filename.mp3')).to eq 'file-audio-o' expect(file_type_icon_class('file', 0, 'filename.mp3')).to eq 'volume-up'
end end
it 'returns file-audio-o class with .MP3' do it 'returns volume-up class with .MP3' do
expect(file_type_icon_class('file', 0, 'filename.MP3')).to eq 'file-audio-o' expect(file_type_icon_class('file', 0, 'filename.MP3')).to eq 'volume-up'
end end
it 'returns file-audio-o class with .m4a' do it 'returns volume-up class with .m4a' do
expect(file_type_icon_class('file', 0, 'filename.m4a')).to eq 'file-audio-o' expect(file_type_icon_class('file', 0, 'filename.m4a')).to eq 'volume-up'
end end
it 'returns file-audio-o class with .wav' do it 'returns volume-up class with .wav' do
expect(file_type_icon_class('file', 0, 'filename.wav')).to eq 'file-audio-o' expect(file_type_icon_class('file', 0, 'filename.wav')).to eq 'volume-up'
end end
it 'returns file-video-o class with .avi' do it 'returns live-preview class with .avi' do
expect(file_type_icon_class('file', 0, 'filename.avi')).to eq 'file-video-o' expect(file_type_icon_class('file', 0, 'filename.avi')).to eq 'live-preview'
end end
it 'returns file-video-o class with .AVI' do it 'returns live-preview class with .AVI' do
expect(file_type_icon_class('file', 0, 'filename.AVI')).to eq 'file-video-o' expect(file_type_icon_class('file', 0, 'filename.AVI')).to eq 'live-preview'
end end
it 'returns file-video-o class with .mp4' do it 'returns live-preview class with .mp4' do
expect(file_type_icon_class('file', 0, 'filename.mp4')).to eq 'file-video-o' expect(file_type_icon_class('file', 0, 'filename.mp4')).to eq 'live-preview'
end end
it 'returns file-word-o class with .odt' do it 'returns doc-text class with .odt' do
expect(file_type_icon_class('file', 0, 'filename.odt')).to eq 'file-word-o' expect(file_type_icon_class('file', 0, 'filename.odt')).to eq 'doc-text'
end end
it 'returns file-word-o class with .doc' do it 'returns doc-text class with .doc' do
expect(file_type_icon_class('file', 0, 'filename.doc')).to eq 'file-word-o' expect(file_type_icon_class('file', 0, 'filename.doc')).to eq 'doc-text'
end end
it 'returns file-word-o class with .DOC' do it 'returns doc-text class with .DOC' do
expect(file_type_icon_class('file', 0, 'filename.DOC')).to eq 'file-word-o' expect(file_type_icon_class('file', 0, 'filename.DOC')).to eq 'doc-text'
end end
it 'returns file-word-o class with .docx' do it 'returns doc-text class with .docx' do
expect(file_type_icon_class('file', 0, 'filename.docx')).to eq 'file-word-o' expect(file_type_icon_class('file', 0, 'filename.docx')).to eq 'doc-text'
end end
it 'returns file-excel-o class with .xls' do it 'returns document class with .xls' do
expect(file_type_icon_class('file', 0, 'filename.xls')).to eq 'file-excel-o' expect(file_type_icon_class('file', 0, 'filename.xls')).to eq 'document'
end end
it 'returns file-excel-o class with .XLS' do it 'returns document class with .XLS' do
expect(file_type_icon_class('file', 0, 'filename.XLS')).to eq 'file-excel-o' expect(file_type_icon_class('file', 0, 'filename.XLS')).to eq 'document'
end end
it 'returns file-excel-o class with .xlsx' do it 'returns document class with .xlsx' do
expect(file_type_icon_class('file', 0, 'filename.xlsx')).to eq 'file-excel-o' expect(file_type_icon_class('file', 0, 'filename.xlsx')).to eq 'document'
end end
it 'returns file-excel-o class with .odp' do it 'returns doc-chart class with .odp' do
expect(file_type_icon_class('file', 0, 'filename.odp')).to eq 'file-powerpoint-o' expect(file_type_icon_class('file', 0, 'filename.odp')).to eq 'doc-chart'
end end
it 'returns file-excel-o class with .ppt' do it 'returns doc-chart class with .ppt' do
expect(file_type_icon_class('file', 0, 'filename.ppt')).to eq 'file-powerpoint-o' expect(file_type_icon_class('file', 0, 'filename.ppt')).to eq 'doc-chart'
end end
it 'returns file-excel-o class with .PPT' do it 'returns doc-chart class with .PPT' do
expect(file_type_icon_class('file', 0, 'filename.PPT')).to eq 'file-powerpoint-o' expect(file_type_icon_class('file', 0, 'filename.PPT')).to eq 'doc-chart'
end end
it 'returns file-excel-o class with .pptx' do it 'returns doc-chart class with .pptx' do
expect(file_type_icon_class('file', 0, 'filename.pptx')).to eq 'file-powerpoint-o' expect(file_type_icon_class('file', 0, 'filename.pptx')).to eq 'doc-chart'
end end
it 'returns file-text-o class with .unknow' do it 'returns doc-text class with .unknow' do
expect(file_type_icon_class('file', 0, 'filename.unknow')).to eq 'file-text-o' expect(file_type_icon_class('file', 0, 'filename.unknow')).to eq 'doc-text'
end end
it 'returns file-text-o class with no extension' do it 'returns doc-text class with no extension' do
expect(file_type_icon_class('file', 0, 'CHANGELOG')).to eq 'file-text-o' expect(file_type_icon_class('file', 0, 'CHANGELOG')).to eq 'doc-text'
end end
end end
......
...@@ -262,7 +262,7 @@ RSpec.describe Gitlab::Conflict::File do ...@@ -262,7 +262,7 @@ RSpec.describe Gitlab::Conflict::File do
end end
it 'includes the blob icon for the file' do it 'includes the blob icon for the file' do
expect(conflict_file.as_json[:blob_icon]).to eq('file-text-o') expect(conflict_file.as_json[:blob_icon]).to eq('doc-text')
end end
context 'with the full_content option passed' do context 'with the full_content option passed' do
......
...@@ -22,7 +22,7 @@ RSpec.describe BlobEntity do ...@@ -22,7 +22,7 @@ RSpec.describe BlobEntity do
name: blob.name, name: blob.name,
mode: "100644", mode: "100644",
readable_text: true, readable_text: true,
icon: "file-text-o", icon: "doc-text",
url: "/#{project.full_path}/-/blob/master/bar/branch-test.txt" url: "/#{project.full_path}/-/blob/master/bar/branch-test.txt"
}) })
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment