Commit 887c39e3 authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch...

Merge branch '273303-fy21q4-foundations-kr2-audit-and-update-buttons-on-projects-branchescontroller-index' into 'master'

Audit and update buttons on Projects::BranchesController#index"

See merge request gitlab-org/gitlab!61791
parents abff3eb9 b7a9bbd3
...@@ -62,17 +62,18 @@ export default { ...@@ -62,17 +62,18 @@ export default {
}; };
</script> </script>
<template> <template>
<div class="gl-display-flex gl-pr-4"> <div class="gl-display-flex">
<gl-search-box-by-click <gl-search-box-by-click
v-model="searchTerm" v-model="searchTerm"
:placeholder="$options.i18n.searchPlaceholder" :placeholder="$options.i18n.searchPlaceholder"
class="gl-pr-4" class="gl-mr-3"
data-testid="branch-search" data-testid="branch-search"
@submit="visitUrlFromOption(selectedKey)" @submit="visitUrlFromOption(selectedKey)"
/> />
<gl-dropdown <gl-dropdown
v-if="shouldShowDropdown" v-if="shouldShowDropdown"
:text="selectedSortMethodName" :text="selectedSortMethodName"
class="gl-mr-3"
data-testid="branches-dropdown" data-testid="branches-dropdown"
> >
<gl-dropdown-item <gl-dropdown-item
......
...@@ -135,7 +135,7 @@ ul.content-list { ...@@ -135,7 +135,7 @@ ul.content-list {
float: right; float: right;
> .control-text { > .control-text {
margin-right: $gl-padding-top; margin-right: $grid-size;
line-height: $list-text-height; line-height: $list-text-height;
&:last-child { &:last-child {
...@@ -148,8 +148,6 @@ ul.content-list { ...@@ -148,8 +148,6 @@ ul.content-list {
> .dropdown.inline { > .dropdown.inline {
margin-right: $grid-size; margin-right: $grid-size;
display: inline-block; display: inline-block;
margin-top: 3px;
margin-bottom: 4px;
&.btn-ldap-override { &.btn-ldap-override {
@include media-breakpoint-up(sm) { @include media-breakpoint-up(sm) {
......
...@@ -46,35 +46,37 @@ ...@@ -46,35 +46,37 @@
title: s_('Branches|Compare') do title: s_('Branches|Compare') do
= s_('Branches|Compare') = s_('Branches|Compare')
= render 'projects/buttons/download', project: @project, ref: branch.name, pipeline: @refs_pipelines[branch.name] = render 'projects/buttons/download', project: @project, ref: branch.name, pipeline: @refs_pipelines[branch.name], class: 'gl-vertical-align-top'
- if can?(current_user, :push_code, @project) - if can?(current_user, :push_code, @project)
- if branch.name == @project.repository.root_ref - if branch.name == @project.repository.root_ref
- delete_default_branch_tooltip = s_('Branches|The default branch cannot be deleted') - delete_default_branch_tooltip = s_('Branches|The default branch cannot be deleted')
%span.has-tooltip{ title: delete_default_branch_tooltip } %span.gl-display-inline-block.has-tooltip{ title: delete_default_branch_tooltip }
%button{ class: "gl-button btn btn-danger disabled", disabled: true, 'aria-label' => delete_default_branch_tooltip } %button{ class: 'gl-button btn btn-default btn-icon disabled', disabled: true, 'aria-label' => delete_default_branch_tooltip }
= sprite_icon("remove") = sprite_icon('remove', css_class: 'gl-button-icon gl-icon')
- elsif protected_branch?(@project, branch) - elsif protected_branch?(@project, branch)
- if can?(current_user, :push_to_delete_protected_branch, @project) - if can?(current_user, :push_to_delete_protected_branch, @project)
%button{ class: "gl-button btn btn-danger has-tooltip", - delete_protected_branch_tooltip = s_('Branches|Delete protected branch')
title: s_('Branches|Delete protected branch'), %button{ class: 'gl-button btn btn-default btn-icon has-tooltip',
data: { toggle: "modal", title: delete_protected_branch_tooltip,
target: "#modal-delete-branch", 'aria-label' => delete_protected_branch_tooltip,
data: { toggle: 'modal',
target: '#modal-delete-branch',
delete_path: project_branch_path(@project, branch.name), delete_path: project_branch_path(@project, branch.name),
branch_name: branch.name, branch_name: branch.name,
is_merged: ("true" if merged) } } is_merged: ('true' if merged) } }
= sprite_icon("remove") = sprite_icon('remove', css_class: 'gl-button-icon gl-icon')
- else - else
- delete_protected_branch_tooltip = s_('Branches|Only a project maintainer or owner can delete a protected branch') - delete_protected_branch_disabled_tooltip = s_('Branches|Only a project maintainer or owner can delete a protected branch')
%span.has-tooltip{ title: delete_protected_branch_tooltip } %span.has-tooltip{ title: delete_protected_branch_disabled_tooltip }
%button{ class: "gl-button btn btn-danger disabled", disabled: true, 'aria-label' => delete_protected_branch_tooltip } %button{ class: 'gl-button btn btn-default btn-icon disabled', disabled: true, 'aria-label' => delete_protected_branch_disabled_tooltip, data: { testid: 'remove-protected-branch' } }
= sprite_icon("remove") = sprite_icon('remove', css_class: 'gl-button-icon gl-icon')
- else - else
= link_to project_branch_path(@project, branch.name), = link_to project_branch_path(@project, branch.name),
class: "gl-button btn btn-danger js-remove-row qa-remove-btn js-ajax-loading-spinner has-tooltip", class: 'gl-button btn btn-default btn-icon js-remove-row qa-remove-btn js-ajax-loading-spinner has-tooltip',
title: s_('Branches|Delete branch'), title: s_('Branches|Delete branch'),
method: :delete, method: :delete,
data: { confirm: s_("Branches|Deleting the '%{branch_name}' branch cannot be undone. Are you sure?") % { branch_name: branch.name } }, data: { confirm: s_("Branches|Deleting the '%{branch_name}' branch cannot be undone. Are you sure?") % { branch_name: branch.name } },
remote: true, remote: true,
'aria-label' => s_('Branches|Delete branch') do 'aria-label' => s_('Branches|Delete branch') do
= sprite_icon("remove") = sprite_icon('remove', css_class: 'gl-button-icon gl-icon')
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
- if !project.empty_repo? && can?(current_user, :download_code, project) - if !project.empty_repo? && can?(current_user, :download_code, project)
- archive_prefix = "#{project.path}-#{ref.tr('/', '-')}" - archive_prefix = "#{project.path}-#{ref.tr('/', '-')}"
.project-action-button.dropdown.inline> .project-action-button.dropdown.gl-new-dropdown.inline>
%button.gl-button.btn.btn-default.has-tooltip{ title: s_('DownloadSource|Download'), 'data-toggle' => 'dropdown', 'aria-label' => s_('DownloadSource|Download'), 'data-display' => 'static', data: { qa_selector: 'download_source_code_button' } } %button.gl-button.btn.btn-default.dropdown-toggle.gl-dropdown-toggle.dropdown-icon-only.has-tooltip{ title: s_('DownloadSource|Download'), 'data-toggle' => 'dropdown', 'aria-label' => s_('DownloadSource|Download'), 'data-display' => 'static', data: { qa_selector: 'download_source_code_button' } }
= sprite_icon('download', css_class: 'gl-icon') = sprite_icon('download', css_class: 'gl-icon dropdown-icon')
%span.sr-only= _('Select Archive Format') %span.sr-only= _('Select Archive Format')
= sprite_icon('chevron-down', css_class: 'gl-icon') = sprite_icon('chevron-down', css_class: 'gl-icon dropdown-chevron')
.dropdown-menu.dropdown-menu-right{ role: 'menu' } .dropdown-menu.dropdown-menu-right{ role: 'menu' }
%section %section
%h5.m-0.dropdown-bold-header= _('Download source code') %h5.m-0.dropdown-bold-header= _('Download source code')
......
...@@ -21,7 +21,7 @@ RSpec.describe "User deletes branch", :js do ...@@ -21,7 +21,7 @@ RSpec.describe "User deletes branch", :js do
branch_search.native.send_keys(:enter) branch_search.native.send_keys(:enter)
page.within(".js-branch-improve\\/awesome") do page.within(".js-branch-improve\\/awesome") do
accept_alert { find(".btn-danger").click } accept_alert { click_link(title: 'Delete branch') }
end end
wait_for_requests wait_for_requests
......
...@@ -99,11 +99,13 @@ RSpec.describe 'Branches' do ...@@ -99,11 +99,13 @@ RSpec.describe 'Branches' do
end end
describe 'Delete unprotected branch on Overview' do describe 'Delete unprotected branch on Overview' do
it 'removes branch after confirmation', :js, quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/239019' do it 'removes branch after confirmation', :js do
visit project_branches_filtered_path(project, state: 'all') visit project_branches_filtered_path(project, state: 'all')
expect(all('.all-branches').last).to have_selector('li', count: 20) expect(all('.all-branches').last).to have_selector('li', count: 20)
accept_confirm { first('.js-branch-item .btn-danger').click } accept_confirm do
within('.js-branch-item', match: :first) { click_link(title: 'Delete branch') }
end
expect(all('.all-branches').last).to have_selector('li', count: 19) expect(all('.all-branches').last).to have_selector('li', count: 19)
end end
...@@ -172,7 +174,9 @@ RSpec.describe 'Branches' do ...@@ -172,7 +174,9 @@ RSpec.describe 'Branches' do
expect(page).to have_content('fix') expect(page).to have_content('fix')
expect(find('.all-branches')).to have_selector('li', count: 1) expect(find('.all-branches')).to have_selector('li', count: 1)
accept_confirm { find('.js-branch-fix .btn-danger').click } accept_confirm do
within('.js-branch-fix') { click_link(title: 'Delete branch') }
end
expect(page).not_to have_content('fix') expect(page).not_to have_content('fix')
expect(find('.all-branches')).to have_selector('li', count: 0) expect(find('.all-branches')).to have_selector('li', count: 0)
......
...@@ -333,7 +333,7 @@ RSpec.describe 'Environment' do ...@@ -333,7 +333,7 @@ RSpec.describe 'Environment' do
visit project_branches_filtered_path(project, state: 'all', search: 'feature') visit project_branches_filtered_path(project, state: 'all', search: 'feature')
remove_branch_with_hooks(project, user, 'feature') do remove_branch_with_hooks(project, user, 'feature') do
page.within('.js-branch-feature') { find('a.btn-danger').click } within('.js-branch-feature') { click_link(title: 'Delete branch') }
end end
visit_environment(environment) visit_environment(environment)
......
...@@ -21,13 +21,13 @@ RSpec.describe 'Protected Branches', :js do ...@@ -21,13 +21,13 @@ RSpec.describe 'Protected Branches', :js do
expect(ProtectedBranch.count).to eq(1) expect(ProtectedBranch.count).to eq(1)
end end
it 'does not allow developer to removes protected branch' do it 'does not allow developer to remove protected branch' do
visit project_branches_path(project) visit project_branches_path(project)
find('input[data-testid="branch-search"]').set('fix') find('input[data-testid="branch-search"]').set('fix')
find('input[data-testid="branch-search"]').native.send_keys(:enter) find('input[data-testid="branch-search"]').native.send_keys(:enter)
expect(page).to have_css('.btn-danger.disabled') expect(page).to have_selector('button[data-testid="remove-protected-branch"][disabled]')
end end
end end
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