Merge branch '50535-display-banner-to-notify-user-if-project-is-implicitly-opted-ado' into 'master'
Displays banner to notify users ADO is implicitly enabled Closes #50535 See merge request gitlab-org/gitlab-ce!21503
This commit is contained in:
commit
07c031338a
|
@ -61,6 +61,13 @@ export default class Project {
|
|||
.remove();
|
||||
return e.preventDefault();
|
||||
});
|
||||
$('.hide-auto-devops-implicitly-enabled-banner').on('click', function(e) {
|
||||
const projectId = $(this).data('project-id');
|
||||
const cookieKey = `hide_auto_devops_implicitly_enabled_banner_${projectId}`;
|
||||
Cookies.set(cookieKey, 'false');
|
||||
$(this).parents('.auto-devops-implicitly-enabled-banner').remove();
|
||||
return e.preventDefault();
|
||||
});
|
||||
Project.projectSelectDropdown();
|
||||
}
|
||||
|
||||
|
|
|
@ -203,6 +203,14 @@ module ProjectsHelper
|
|||
current_user.require_extra_setup_for_git_auth?
|
||||
end
|
||||
|
||||
def show_auto_devops_implicitly_enabled_banner?(project)
|
||||
cookie_key = "hide_auto_devops_implicitly_enabled_banner_#{project.id}"
|
||||
|
||||
project.has_auto_devops_implicitly_enabled? &&
|
||||
cookies[cookie_key.to_sym].blank? &&
|
||||
(project.owner == current_user || project.team.maintainer?(current_user))
|
||||
end
|
||||
|
||||
def link_to_set_password
|
||||
if current_user.require_password_creation_for_git?
|
||||
link_to s_('SetPasswordToCloneLink|set a password'), edit_profile_password_path
|
||||
|
|
|
@ -5,3 +5,4 @@
|
|||
- if current_user && can?(current_user, :download_code, project)
|
||||
= render 'shared/no_ssh'
|
||||
= render 'shared/no_password'
|
||||
= render 'shared/auto_devops_implicitly_enabled_banner', project: project
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
- if show_auto_devops_implicitly_enabled_banner?(project)
|
||||
.auto-devops-implicitly-enabled-banner.alert.alert-warning
|
||||
- more_information_link = link_to _('More information'), 'https://docs.gitlab.com/ee/topics/autodevops/', class: 'alert-link'
|
||||
- auto_devops_message = s_("AutoDevOps|The Auto DevOps pipeline has been enabled and will be used if no alternative CI configuration file is found. %{more_information_link}") % { more_information_link: more_information_link }
|
||||
= auto_devops_message.html_safe
|
||||
.alert-link-group
|
||||
= link_to _('Settings'), project_settings_ci_cd_path(project), class: 'alert-link'
|
||||
|
|
||||
= link_to _('Dismiss'), '#', class: 'hide-auto-devops-implicitly-enabled-banner alert-link', data: { project_id: project.id }
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Display banner on project page if AutoDevOps is implicitly enabled
|
||||
merge_request: 21503
|
||||
author:
|
||||
type: added
|
|
@ -739,6 +739,9 @@ msgstr ""
|
|||
msgid "AutoDevOps|Learn more in the %{link_to_documentation}"
|
||||
msgstr ""
|
||||
|
||||
msgid "AutoDevOps|The Auto DevOps pipeline has been enabled and will be used if no alternative CI configuration file is found. %{more_information_link}"
|
||||
msgstr ""
|
||||
|
||||
msgid "AutoDevOps|You can automatically build and test your application if you %{link_to_auto_devops_settings} for this project. You can automatically deploy it as well, if you %{link_to_add_kubernetes_cluster}."
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Project > Show > User interacts with auto devops implicitly enabled banner' do
|
||||
let(:project) { create(:project, :repository) }
|
||||
let(:user) { create(:user) }
|
||||
|
||||
before do
|
||||
project.add_user(user, role)
|
||||
sign_in(user)
|
||||
end
|
||||
|
||||
context 'when user does not have maintainer access' do
|
||||
let(:role) { :developer }
|
||||
|
||||
context 'when AutoDevOps is implicitly enabled' do
|
||||
it 'does not display AutoDevOps implicitly enabled banner' do
|
||||
expect(page).not_to have_css('.auto-devops-implicitly-enabled-banner')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user has mantainer access' do
|
||||
let(:role) { :maintainer }
|
||||
|
||||
context 'when AutoDevOps is implicitly enabled' do
|
||||
before do
|
||||
stub_application_setting(auto_devops_enabled: true)
|
||||
|
||||
visit project_path(project)
|
||||
end
|
||||
|
||||
it 'display AutoDevOps implicitly enabled banner' do
|
||||
expect(page).to have_css('.auto-devops-implicitly-enabled-banner')
|
||||
end
|
||||
|
||||
context 'when user dismisses the banner', :js do
|
||||
it 'does not display AutoDevOps implicitly enabled banner' do
|
||||
find('.hide-auto-devops-implicitly-enabled-banner').click
|
||||
wait_for_requests
|
||||
visit project_path(project)
|
||||
|
||||
expect(page).not_to have_css('.auto-devops-implicitly-enabled-banner')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when AutoDevOps is not implicitly enabled' do
|
||||
before do
|
||||
stub_application_setting(auto_devops_enabled: false)
|
||||
|
||||
visit project_path(project)
|
||||
end
|
||||
|
||||
it 'does not display AutoDevOps implicitly enabled banner' do
|
||||
expect(page).not_to have_css('.auto-devops-implicitly-enabled-banner')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue