|
|
|
@ -91,6 +91,27 @@ module RepositoriesHelper |
|
|
|
|
render_changes_tree(tree[:s]) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# Mapping from internal action to (folder|file)-icon type |
|
|
|
|
def change_action_mapping |
|
|
|
|
{ |
|
|
|
|
'A' => :add, |
|
|
|
|
'B' => :remove |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# This calculates whether a folder was added, deleted or modified. It is based on the assumption that |
|
|
|
|
# a folder was added/deleted when all content was added/deleted since the folder changes were not tracked. |
|
|
|
|
def calculate_folder_action(tree) |
|
|
|
|
seen = Set.new |
|
|
|
|
tree.each do |_, entry| |
|
|
|
|
if folderStyle = change_action_mapping[entry[:c].try(:action)] |
|
|
|
|
seen << folderStyle |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
seen.size == 1 ? seen.first : :open |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def render_changes_tree(tree) |
|
|
|
|
return '' if tree.nil? |
|
|
|
|
|
|
|
|
@ -108,7 +129,8 @@ module RepositoriesHelper |
|
|
|
|
project_id: @project, |
|
|
|
|
path: path_param, |
|
|
|
|
rev: @changeset.identifier) |
|
|
|
|
output << "<li class='#{style} icon icon-folder-open'>#{text}</li>" |
|
|
|
|
|
|
|
|
|
output << "<li class='#{style} icon icon-folder-#{calculate_folder_action(s)}'>#{text}</li>" |
|
|
|
|
output << render_changes_tree(s) |
|
|
|
|
elsif c = tree[file][:c] |
|
|
|
|
style << " change-#{c.action}" |
|
|
|
|