Read about our upcoming Code of Conduct on this issue

Commit 9af361a7 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 32346bf6b560
......@@ -6,16 +6,14 @@ const handleOnDismiss = ({ currentTarget }) => {
dataset: { id },
} = currentTarget;
Cookies.set(`hide_broadcast_notification_message_${id}`, true);
Cookies.set(`hide_broadcast_message_${id}`, true);
const notification = document.querySelector(`.js-broadcast-notification-${id}`);
notification.parentNode.removeChild(notification);
};
export default () => {
const dismissButton = document.querySelector('.js-dismiss-current-broadcast-notification');
if (dismissButton) {
dismissButton.addEventListener('click', handleOnDismiss);
}
document
.querySelectorAll('.js-dismiss-current-broadcast-notification')
.forEach(dismissButton => dismissButton.addEventListener('click', handleOnDismiss));
};
......@@ -25,9 +25,11 @@ export default () => {
$broadcastMessageType.on('change', () => {
const $broadcastMessageColorFormGroup = $('.js-broadcast-message-background-color-form-group');
const $broadcastMessageDismissableFormGroup = $('.js-broadcast-message-dismissable-form-group');
const $broadcastNotificationMessagePreview = $('.js-broadcast-notification-message-preview');
$broadcastMessageColorFormGroup.toggleClass('hidden');
$broadcastMessageDismissableFormGroup.toggleClass('hidden');
$broadcastBannerMessagePreview.toggleClass('hidden');
$broadcastNotificationMessagePreview.toggleClass('hidden');
});
......
......@@ -17,6 +17,10 @@
@extend .broadcast-message;
@extend .alert-warning;
text-align: center;
.broadcast-message-dismiss {
color: inherit;
}
}
.broadcast-notification-message {
......@@ -36,6 +40,11 @@
&.preview {
position: static;
}
.broadcast-message-dismiss {
height: 100%;
color: $gray-800;
}
}
.toggle-colors {
......
......@@ -62,6 +62,7 @@ def broadcast_message_params
starts_at
target_path
broadcast_type
dismissable
))
end
end
......@@ -24,7 +24,6 @@ def index
respond_to do |format|
format.html do
@project_namespace = @project.namespace.becomes(Namespace)
# We need to show group milestones in the JSON response
# so that people can filter by and assign group milestones,
# but we don't need to show them on the project milestones page itself.
......@@ -47,8 +46,6 @@ def edit
end
def show
@project_namespace = @project.namespace.becomes(Namespace)
respond_to do |format|
format.html
end
......
......@@ -6,7 +6,7 @@ class GitHttpClientController < Repositories::ApplicationController
include KerberosSpnegoHelper
include Gitlab::Utils::StrongMemoize
attr_reader :authentication_result, :redirected_path
attr_reader :authentication_result, :redirected_path, :container
delegate :actor, :authentication_abilities, to: :authentication_result, allow_nil: true
delegate :type, to: :authentication_result, allow_nil: true, prefix: :auth_result
......@@ -81,7 +81,7 @@ def project
end
def parse_repo_path
@project, @repo_type, @redirected_path = Gitlab::RepoPath.parse("#{params[:namespace_id]}/#{params[:repository_id]}")
@container, @project, @repo_type, @redirected_path = Gitlab::RepoPath.parse("#{params[:namespace_id]}/#{params[:repository_id]}")
end
def render_missing_personal_access_token
......@@ -93,7 +93,7 @@ def render_missing_personal_access_token
def repository
strong_memoize(:repository) do
repo_type.repository_for(project)
repo_type.repository_for(container)
end
end
......@@ -117,7 +117,8 @@ def ci?
def http_download_allowed?
Gitlab::ProtocolAccess.allowed?('http') &&
download_request? &&
project && Guest.can?(:download_code, project)
container &&
Guest.can?(repo_type.guest_read_ability, container)
end
end
end
......
......@@ -84,10 +84,10 @@ def enqueue_fetch_statistics_update
end
def access
@access ||= access_klass.new(access_actor, project, 'http',
@access ||= access_klass.new(access_actor, container, 'http',
authentication_abilities: authentication_abilities,
namespace_path: params[:namespace_id],
project_path: project_path,
repository_path: repository_path,
redirected_path: redirected_path,
auth_result_type: auth_result_type)
end
......@@ -99,15 +99,18 @@ def access_actor
def access_check
access.check(git_command, Gitlab::GitAccess::ANY)
@project ||= access.project
if repo_type.project? && !container
@project = @container = access.project
end
end
def access_klass
@access_klass ||= repo_type.access_checker_class
end
def project_path
@project_path ||= params[:repository_id].sub(/\.git$/, '')
def repository_path
@repository_path ||= params[:repository_id].sub(/\.git$/, '')
end
def log_user_activity
......
......@@ -2,12 +2,14 @@
module BroadcastMessagesHelper
def current_broadcast_banner_messages
BroadcastMessage.current_banner_messages(request.path)
BroadcastMessage.current_banner_messages(request.path).select do |message|
cookies["hide_broadcast_message_#{message.id}"].blank?
end
end
def current_broadcast_notification_message
not_hidden_messages = BroadcastMessage.current_notification_messages(request.path).select do |message|
cookies["hide_broadcast_notification_message_#{message.id}"].blank?
cookies["hide_broadcast_message_#{message.id}"].blank?
end
not_hidden_messages.last
end
......
......@@ -151,18 +151,20 @@ def milestone_time_for(date, date_type)
end
def milestone_issues_tooltip_text(milestone)
issues = milestone.count_issues_by_state(current_user)
total = milestone.total_issues_count(current_user)
opened = milestone.opened_issues_count(current_user)
closed = milestone.closed_issues_count(current_user)
return _("Issues") if issues.empty?
return _("Issues") if total.zero?
content = []
if issues["opened"]
content << n_("1 open issue", "%{issues} open issues", issues["opened"]) % { issues: issues["opened"] }
if opened > 0
content << n_("1 open issue", "%{issues} open issues", opened) % { issues: opened }
end
if issues["closed"]
content << n_("1 closed issue", "%{issues} closed issues", issues["closed"]) % { issues: issues["closed"] }
if closed > 0
content << n_("1 closed issue", "%{issues} closed issues", closed) % { issues: closed }
end
content.join('<br />').html_safe
......
......@@ -2,13 +2,27 @@
module Milestoneish
def total_issues_count(user)
count_issues_by_state(user).values.sum
@total_issues_count ||=
if Feature.enabled?(:cached_milestone_issue_counters)
Milestones::IssuesCountService.new(self).count
else
count_issues_by_state(user).values.sum
end
end
def closed_issues_count(user)
closed_state_id = Issue.available_states[:closed]
@close_issues_count ||=
if Feature.enabled?(:cached_milestone_issue_counters)
Milestones::ClosedIssuesCountService.new(self).count
else
closed_state_id = Issue.available_states[:closed]
count_issues_by_state(user)[closed_state_id].to_i
end
end
count_issues_by_state(user)[closed_state_id].to_i
def opened_issues_count(user)
total_issues_count(user) - closed_issues_count(user)
end
def complete?(user)
......
......@@ -160,6 +160,10 @@ def self.link_reference_pattern
@link_reference_pattern ||= super("snippets", /(?<snippet>\d+)/)
end
def self.find_by_id_and_project(id:, project:)
Snippet.find_by(id: id, project: project)
end
def initialize(attributes = {})
# We can't use default_value_for because the database has a default
# value of 0 for visibility_level. If someone attempts to create a
......
......@@ -34,6 +34,18 @@ def execute_hooks(issue, action = 'open', old_associations: {})
def update_project_counter_caches?(issue)
super || issue.confidential_changed?
end
def delete_milestone_closed_issue_counter_cache(milestone)
return unless milestone
Milestones::ClosedIssuesCountService.new(milestone).delete_cache
end
def delete_milestone_total_issue_counter_cache(milestone)
return unless milestone
Milestones::IssuesCountService.new(milestone).delete_cache
end
end
end
......
......@@ -38,6 +38,8 @@ def close_issue(issue, closed_via: nil, notifications: true, system_note: true)
issue.update_project_counter_caches
store_first_mentioned_in_commit_at(issue, closed_via) if closed_via.is_a?(MergeRequest)
delete_milestone_closed_issue_counter_cache(issue.milestone)
end
issue
......
......@@ -29,6 +29,7 @@ def after_create(issuable)
todo_service.new_issue(issuable, current_user)
user_agent_detail_service.create
resolve_discussions_with_issue(issuable)
delete_milestone_total_issue_counter_cache(issuable.milestone)
super
end
......
......@@ -12,6 +12,7 @@ def execute(issue)
execute_hooks(issue, 'reopen')
invalidate_cache_counts(issue, users: issue.assignees)
issue.update_project_counter_caches
delete_milestone_closed_issue_counter_cache(issue.milestone)
end
issue
......
......@@ -115,10 +115,26 @@ def create_merge_request_from_quick_action
end
def handle_milestone_change(issue)
return if skip_milestone_email
return unless issue.previous_changes.include?('milestone_id')
invalidate_milestone_issue_counters(issue)
send_milestone_change_notification(issue)
end
def invalidate_milestone_issue_counters(issue)
issue.previous_changes['milestone_id'].each do |milestone_id|
next unless milestone_id
milestone = Milestone.find_by_id(milestone_id)
delete_milestone_closed_issue_counter_cache(milestone)
delete_milestone_total_issue_counter_cache(milestone)
end
end
def send_milestone_change_notification(issue)
return if skip_milestone_email
if issue.milestone.nil?
notification_service.async.removed_milestone_issue(issue, current_user)
else
......
......@@ -5,6 +5,10 @@
module Metrics
module Dashboard
class BaseEmbedService < ::Metrics::Dashboard::BaseService
def self.embedded?(embed_param)
ActiveModel::Type::Boolean.new.cast(embed_param)
end
def cache_key
"dynamic_metrics_dashboard_#{identifiers}"
end
......
......@@ -18,7 +18,7 @@ class << self
# custom metrics from the DB.
def valid_params?(params)
[
params[:embedded],
embedded?(params[:embedded]),
valid_dashboard?(params[:dashboard_path]),
valid_group_title?(params[:group]),
params[:title].present?,
......
......@@ -22,7 +22,7 @@ class DefaultEmbedService < ::Metrics::Dashboard::BaseEmbedService
class << self
def valid_params?(params)
params[:embedded].present?
embedded?(params[:embedded])
end
end
......
......@@ -22,7 +22,7 @@ class << self
# for additional info on defining custom dashboards.
def valid_params?(params)
[
params[:embedded],
embedded?(params[:embedded]),
params[:group].present?,
params[:title].present?,
params[:y_label]
......
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