Skip to content
代码片段 群组 项目
提交 00b86bac 编辑于 作者: Annabel Dunstone Gray's avatar Annabel Dunstone Gray 提交者: Max Woolf
浏览文件

Migrate link_to buttons to Pajamas buttons in commits_helper.rb

Changelog: changed
上级 11864804
No related branches found
No related tags found
无相关合并请求
...@@ -111,7 +111,7 @@ def link_to_browse_code(project, commit) ...@@ -111,7 +111,7 @@ def link_to_browse_code(project, commit)
tooltip = _("Browse Directory") tooltip = _("Browse Directory")
end end
link_to url, class: "btn gl-button btn-default btn-icon has-tooltip", title: tooltip, data: { container: "body" } do render Pajamas::ButtonComponent.new(href: url, button_options: { title: tooltip, class: 'has-tooltip btn-icon', data: { container: 'body' } }) do
sprite_icon('folder-open') sprite_icon('folder-open')
end end
end end
...@@ -188,12 +188,11 @@ def diff_mode_swap_button(mode, file_hash) ...@@ -188,12 +188,11 @@ def diff_mode_swap_button(mode, file_hash)
entity = mode == 'raw' ? 'rawButton' : 'renderedButton' entity = mode == 'raw' ? 'rawButton' : 'renderedButton'
title = "Display #{mode} diff" title = "Display #{mode} diff"
link_to( render Pajamas::ButtonComponent.new(
"##{mode}-diff-#{file_hash}", href: "##{mode}-diff-#{file_hash}",
class: "btn gl-button btn-default btn-file-option has-tooltip btn-show-#{mode}-diff", button_options: { title: title,
title: title, class: "btn-file-option has-tooltip btn-show-#{mode}-diff",
data: { file_hash: file_hash, diff_toggle_entity: entity } data: { file_hash: file_hash, diff_toggle_entity: entity } }) do
) do
sprite_icon(icon) sprite_icon(icon)
end end
end end
...@@ -242,7 +241,7 @@ def view_file_button(commit_sha, diff_new_path, project, replaced: false) ...@@ -242,7 +241,7 @@ def view_file_button(commit_sha, diff_new_path, project, replaced: false)
path = project_blob_path(project, tree_join(commit_sha, diff_new_path)) path = project_blob_path(project, tree_join(commit_sha, diff_new_path))
title = replaced ? _('View replaced file @ ') : _('View file @ ') title = replaced ? _('View replaced file @ ') : _('View file @ ')
link_to(path, class: 'btn gl-button btn-default gl-ml-3') do render Pajamas::ButtonComponent.new(href: path, button_options: { class: 'gl-ml-3' }) do
raw(title) + content_tag(:span, truncate_sha(commit_sha), class: 'commit-sha') raw(title) + content_tag(:span, truncate_sha(commit_sha), class: 'commit-sha')
end end
end end
...@@ -253,7 +252,7 @@ def view_on_environment_button(commit_sha, diff_new_path, environment) ...@@ -253,7 +252,7 @@ def view_on_environment_button(commit_sha, diff_new_path, environment)
external_url = environment.external_url_for(diff_new_path, commit_sha) external_url = environment.external_url_for(diff_new_path, commit_sha)
return unless external_url return unless external_url
link_to(external_url, class: 'btn gl-button btn-default btn-file-option has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: "View on #{environment.formatted_external_url}", data: { container: 'body' }) do render Pajamas::ButtonComponent.new(href: external_url, target: '_blank', button_options: { rel: 'noopener noreferrer', title: "View on #{environment.formatted_external_url}", data: { container: 'body' } }) do
sprite_icon('external-link') sprite_icon('external-link')
end end
end end
......
...@@ -91,22 +91,22 @@ ...@@ -91,22 +91,22 @@
let(:node) { Nokogiri::HTML.parse(helper.diff_mode_swap_button(keyword, 'abc')).at_css('a') } let(:node) { Nokogiri::HTML.parse(helper.diff_mode_swap_button(keyword, 'abc')).at_css('a') }
context 'for rendered' do context 'for rendered' do
it 'renders the correct select-rendered button' do it 'renders the correct select-rendered button', :aggregate_failures do
expect(node[:title]).to eq('Display rendered diff') expect(node[:title]).to eq('Display rendered diff')
expect(node['data-file-hash']).to eq('abc') expect(node['data-file-hash']).to eq('abc')
expect(node['data-diff-toggle-entity']).to eq('renderedButton') expect(node['data-diff-toggle-entity']).to eq('renderedButton')
expect(node.xpath("//a/svg")[0]["data-testid"]).to eq('doc-text-icon') expect(node.xpath("//a/span/svg")[0]["data-testid"]).to eq('doc-text-icon')
end end
end end
context 'for raw' do context 'for raw' do
let(:keyword) { 'raw' } let(:keyword) { 'raw' }
it 'renders the correct select-raw button' do it 'renders the correct select-raw button', :aggregate_failures do
expect(node[:title]).to eq('Display raw diff') expect(node[:title]).to eq('Display raw diff')
expect(node['data-file-hash']).to eq('abc') expect(node['data-file-hash']).to eq('abc')
expect(node['data-diff-toggle-entity']).to eq('rawButton') expect(node['data-diff-toggle-entity']).to eq('rawButton')
expect(node.xpath("//a/svg")[0]["data-testid"]).to eq('doc-code-icon') expect(node.xpath("//a/span/svg")[0]["data-testid"]).to eq('doc-code-icon')
end end
end end
end end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册